[Kimchi-devel] [PATCH v3 2/5] [UI] Repository Management - Add API Support

Adam King rak at linux.vnet.ibm.com
Thu Mar 13 19:36:22 UTC 2014


Reviewed-by: Adam King <rak at linux.vnet.ibm.com>

On 03/13/2014 05:18 AM, Hongliang Wang wrote:
> Add API calling in kimchi.api.js.
>
> Signed-off-by: Hongliang Wang <hlwang at linux.vnet.ibm.com>
> ---
>   ui/js/src/kimchi.api.js | 76 ++++++++++++++++++++++++++++++++++++++++++++++++-
>   1 file changed, 75 insertions(+), 1 deletion(-)
>
> diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
> index 4310435..9ceed0b 100644
> --- a/ui/js/src/kimchi.api.js
> +++ b/ui/js/src/kimchi.api.js
> @@ -856,5 +856,79 @@ var kimchi = {
>               success : onResponse,
>               error : err
>           });
> -     }
> +    },
> +
> +    createRepository : function(settings, suc, err) {
> +        kimchi.requestJSON({
> +            url : "host/repositories",
> +            type : "POST",
> +            contentType : "application/json",
> +            data : JSON.stringify(settings),
> +            dataType : "json",
> +            success: suc,
> +            error: err
> +        });
> +    },
> +
> +    retrieveRepository : function(repository, suc, err) {
> +        var reposID = encodeURIComponent(repository);
> +        kimchi.requestJSON({
> +            url : kimchi.url + "host/repositories/" + reposID,
> +            type : 'GET',
> +            contentType : 'application/json',
> +            dataType : 'json',
> +            success : suc,
> +            error : err
> +        });
> +    },
> +
> +    updateRepository : function(name, settings, suc, err) {
> +        var reposID = encodeURIComponent(name);
> +        $.ajax({
> +            url : kimchi.url + "host/repositories/" + reposID,
> +            type : 'PUT',
> +            contentType : 'application/json',
> +            data : JSON.stringify(settings),
> +            dataType : 'json',
> +            success : suc,
> +            error : err
> +        });
> +    },
> +
> +    enableRepository : function(name, enable, suc, err) {
> +        var reposID = encodeURIComponent(name);
> +        $.ajax({
> +            url : kimchi.url + "host/repositories/" + reposID +
> +                '/' + (enable === true ? 'enable' : 'disable'),
> +            type : 'POST',
> +            contentType : 'application/json',
> +            dataType : 'json',
> +            success : suc,
> +            error : err
> +        });
> +    },
> +
> +    deleteRepository : function(repository, suc, err) {
> +        var reposID = encodeURIComponent(repository);
> +        kimchi.requestJSON({
> +            url : kimchi.url + 'host/repositories/' + reposID,
> +            type : 'DELETE',
> +            contentType : 'application/json',
> +            dataType : 'json',
> +            success : suc,
> +            error : err
> +        });
> +    },
> +
> +    listRepositories : function(suc, err) {
> +        kimchi.requestJSON({
> +            url : kimchi.url + 'host/repositories',
> +            type : 'GET',
> +            contentType : 'application/json',
> +            dataType : 'json',
> +            resend: true,
> +            success : suc,
> +            error : err
> +        });
> +    }
>   };


-- 
Adam King <rak at linux.vnet.ibm.com>
IBM CSI




More information about the Kimchi-devel mailing list