[Kimchi-devel] [PATCH 4/7] Repository Management - Add API Support

Adam King rak at linux.vnet.ibm.com
Tue Mar 25 18:18:09 UTC 2014


From: Hongliang Wang <hlwang at linux.vnet.ibm.com>

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
+        });
+    }
 };
-- 
1.8.1.4




More information about the Kimchi-devel mailing list