mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-19 07:07:42 +01:00
19f3ebd353
This patch provides a command-line tool for managing Harbor resources like users, projects, images, etc.
42 lines
997 B
Python
42 lines
997 B
Python
"""
|
|
Base utilities to build API operation managers and objects on top of.
|
|
"""
|
|
|
|
|
|
class Manager(object):
|
|
"""Manager for API service.
|
|
|
|
Managers interact with a particular type of API (projects, users,
|
|
reposiries,etc.) and provide CRUD operations for them.
|
|
"""
|
|
|
|
def __init__(self, api):
|
|
self.api = api
|
|
|
|
@property
|
|
def client(self):
|
|
return self.api.client
|
|
|
|
@property
|
|
def api_version(self):
|
|
return self.api.api_version
|
|
|
|
def _list(self, url, body=None):
|
|
if body:
|
|
data = self.api.client.post(url, body=body)
|
|
else:
|
|
data = self.api.client.get(url)
|
|
return data
|
|
|
|
def _get(self, url):
|
|
return self.api.client.get(url)
|
|
|
|
def _create(self, url, body=None, **kwargs):
|
|
return self.api.client.post(url, body=body)
|
|
|
|
def _delete(self, url):
|
|
return self.api.client.delete(url)
|
|
|
|
def _update(self, url, body, **kwargs):
|
|
return self.api.client.put(url, body=body)
|