[Kimchi-devel] [PATCH 2/5 V2] Host's repositories management: Update REST API
Aline Manera
alinefm at linux.vnet.ibm.com
Thu Feb 13 17:49:40 UTC 2014
On 02/13/2014 04:01 AM, Paulo Vital wrote:
> 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 at linux.vnet.ibm.com>
> ---
> src/kimchi/API.json | 59 ++++++++++++++++++++++++++++++++++++++++++++++
> src/kimchi/control/host.py | 21 +++++++++++++++++
> 2 files changed, 80 insertions(+)
>
> diff --git a/src/kimchi/API.json b/src/kimchi/API.json
> index 08c77c5..d1c8e95 100644
> --- a/src/kimchi/API.json
> +++ b/src/kimchi/API.json
> @@ -359,6 +359,65 @@
> "graphics": { "$ref": "#/kimchitype/graphics" }
> },
> "additionalProperties": false
> + },
> + "repository_create": {
> + "type": "object",
> + "properties": {
> + "repo_id": {
> + "description": "Unique repository name for each repository, one word.",
> + "type": "string"
> + },
> + "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",
> + "required": true
> + },
> + "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"
> + },
> + "gpgkey": {
> + "description": "URL pointing to the ASCII-armored GPG key file for the repository.",
> + "type": "string"
> + }
> + }
> + },
> + "repository_update": {
> + "type": "object",
> + "properties": {
> + "repo_id": {
> + "description": "Unique repository name for each repository, one word.",
> + "type": "string"
> + },
> + "repo_name": {
> + "description": "Human-readable string describing the repository.",
> + "type": "string"
> + },
> + "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"
> + },
> + "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"
> + },
> + "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.",
> + "type": "string"
> + }
> + }
> }
You need to add the "error" parameter for each schema above.
So UI can shown also translated and custom messages to the error from
jsonschema validation
> }
> }
> diff --git a/src/kimchi/control/host.py b/src/kimchi/control/host.py
> index 053c822..12c998e 100644
> --- a/src/kimchi/control/host.py
> +++ b/src/kimchi/control/host.py
> @@ -36,6 +36,7 @@ class Host(Resource):
> self.shutdown = self.generate_action_handler('shutdown')
> self.stats = HostStats(self.model)
> self.partitions = Partitions(self.model)
> + self.repositories = Repositories(self.model)
>
> @property
> def data(self):
> @@ -61,3 +62,23 @@ class Partition(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", "enabled", "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
More information about the Kimchi-devel
mailing list