
Define Repositories collection and Repository resource according to API.md Update API.json Activate auth support to new collection Signed-off-by: Paulo Vital <pvital@linux.vnet.ibm.com> --- src/kimchi/API.json | 76 ++++++++++++++++++++++++++++++++++++++++++++++ src/kimchi/control/host.py | 21 +++++++++++++ 2 files changed, 97 insertions(+) diff --git a/src/kimchi/API.json b/src/kimchi/API.json index c36244c..68037fc 100644 --- a/src/kimchi/API.json +++ b/src/kimchi/API.json @@ -478,6 +478,82 @@ }, "additionalProperties": false, "error": "KCHAPI0001E" + }, + "repository_create": { + "type": "object", + "properties": { + "repo_id": { + "description": "Unique repository name for each repository, one word.", + "type": "string", + "error": "KCHREPOS0001E" + }, + "baseurl": { + "description": "URL to the directory where the repodata directory of a repository is located. Can be an http://, ftp:// or file:// URL.", + "type": "string", + "pattern": "^((file):|(http)[s]?:|(ftp)[s]?:)?$", + "required": true, + "error": "KCHREPOS0002E" + }, + "is_mirror": { + "description": "Set the given URI of baseurl as a mirror list", + "type": "boolean" + }, + "url_args": { + "description": "Arguments to be passed to baseurl, like the list of APT repositories provided by the same baseurl.", + "type": "string", + "error": "KCHREPOS0003E" + }, + "gpgkey": { + "description": "URL pointing to the ASCII-armored GPG key file for the repository.", + "pattern": "^((file):|(http)[s]?:|(ftp)[s]?:)?$", + "type": "string", + "error": "KCHREPOS0004E" + } + }, + "additionalProperties": false, + "error": "KCHAPI0001E" + }, + "repository_update": { + "type": "object", + "properties": { + "repo_id": { + "description": "Unique repository name for each repository, one word.", + "type": "string", + "error": "KCHREPOS0001E" + }, + "repo_name": { + "description": "Human-readable string describing the repository.", + "type": "string", + "error": "KCHREPOS0005E" + }, + "baseurl": { + "description": "URL to the directory where the repodata directory of a repository is located. Can be an http://, ftp:// or file:// URL.", + "type": "string", + "pattern": "^((file):|(http)[s]?:|(ftp)[s]?:)?$", + "error": "KCHREPOS0002E" + }, + "is_mirror": { + "description": "Set the given URI of baseurl as a mirror list", + "type": "boolean" + }, + "url_args": { + "description": "Arguments to be passed to baseurl, like the list of APT repositories provided by the same baseurl.", + "type": "string", + "error": "KCHREPOS0003E" + }, + "gpgcheck": { + "description": "Indicates if a GPG signature check on the packages gotten from repository should be performed.", + "type": "boolean" + }, + "gpgkey": { + "description": "URL pointing to the ASCII-armored GPG key file for the repository.", + "pattern": "^((file):|(http)[s]?:|(ftp)[s]?:)?$", + "type": "string", + "error": "KCHREPOS0004E" + } + }, + "additionalProperties": false, + "error": "KCHAPI0001E" } } } diff --git a/src/kimchi/control/host.py b/src/kimchi/control/host.py index a705f59..a2a92a5 100644 --- a/src/kimchi/control/host.py +++ b/src/kimchi/control/host.py @@ -42,6 +42,7 @@ class Host(Resource): self.partitions = Partitions(self.model) self.devices = Devices(self.model) self.packagesupdate = PackagesUpdate(self.model) + self.repositories = Repositories(self.model) @property def data(self): @@ -106,3 +107,23 @@ class PackageUpdate(Resource): @property def data(self): return self.info + + +class Repositories(Collection): + def __init__(self, model): + super(Repositories, self).__init__(model) + self.resource = Repository + + +class Repository(Resource): + def __init__(self, model, id): + super(Repository, self).__init__(model, id) + self.update_params = ["repo_id", "repo_name", "baseurl", "mirrors", + "url_args", "gpgcheck", "gpgkey"] + self.uri_fmt = "/host/repositories/%s" + self.enable = self.generate_action_handler('enable') + self.disable = self.generate_action_handler('disable') + + @property + def data(self): + return self.info -- 1.8.3.1