[Kimchi-devel] [PATCH 2/4] [UI] Add API Support for Repositories Management

Hongliang Wang hlwang at linux.vnet.ibm.com
Tue Mar 4 10:33:06 UTC 2014


Add APIs.

Signed-off-by: Hongliang Wang <hlwang at linux.vnet.ibm.com>
---
 ui/js/src/kimchi.api.js | 61 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
index fdd9cfc..df110c1 100644
--- a/ui/js/src/kimchi.api.js
+++ b/ui/js/src/kimchi.api.js
@@ -727,5 +727,66 @@ var kimchi = {
             success : suc,
             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
+        });
+    },
+
+    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
+        });
     }
 };
-- 
1.8.1.4




More information about the Kimchi-devel mailing list