summaryrefslogtreecommitdiffstats
path: root/src/orchestrator/api
diff options
context:
space:
mode:
authorRajamohan Raj <rajamohan.raj@intel.com>2020-07-17 02:11:13 +0000
committerRajamohan Raj <rajamohan.raj@intel.com>2020-07-17 02:17:49 +0000
commit09ade2b51d5e3d4da5921115a993bec97a905e1b (patch)
tree68879bcda8b583c2afdf6831c09af8a40a6c5a41 /src/orchestrator/api
parent46feb5b7bb5ed0348261637be34bd368155b55b7 (diff)
Add API to query all composite apps under a project
In this patch implemented a new route to query all compApps under a project. Issue-ID: MULTICLOUD-1127 Signed-off-by: Rajamohan Raj <rajamohan.raj@intel.com> Change-Id: I5d5d4861539edd2ca0eccff16d94b75439e14db7
Diffstat (limited to 'src/orchestrator/api')
-rw-r--r--src/orchestrator/api/api.go1
-rw-r--r--src/orchestrator/api/composite_app_handler.go26
2 files changed, 27 insertions, 0 deletions
diff --git a/src/orchestrator/api/api.go b/src/orchestrator/api/api.go
index 9194419c..5f1665ac 100644
--- a/src/orchestrator/api/api.go
+++ b/src/orchestrator/api/api.go
@@ -69,6 +69,7 @@ func NewRouter(projectClient moduleLib.ProjectManager,
}
router.HandleFunc("/projects/{project-name}/composite-apps", compAppHandler.createHandler).Methods("POST")
router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{version}", compAppHandler.getHandler).Methods("GET")
+ router.HandleFunc("/projects/{project-name}/composite-apps", compAppHandler.getAllCompositeAppsHandler).Methods("GET")
router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{version}", compAppHandler.deleteHandler).Methods("DELETE")
if appClient == nil {
diff --git a/src/orchestrator/api/composite_app_handler.go b/src/orchestrator/api/composite_app_handler.go
index b54c488e..ab052f00 100644
--- a/src/orchestrator/api/composite_app_handler.go
+++ b/src/orchestrator/api/composite_app_handler.go
@@ -95,6 +95,32 @@ func (h compositeAppHandler) getHandler(w http.ResponseWriter, r *http.Request)
}
}
+// getAllCompositeAppsHandler handles the GetAllComppositeApps, returns a list of compositeApps under a project
+func (h compositeAppHandler) getAllCompositeAppsHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ pName := vars["project-name"]
+
+ var caList []moduleLib.CompositeApp
+
+ cApps, err := h.client.GetAllCompositeApps(pName)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusNotFound)
+ return
+ }
+
+ for _, cApp := range cApps {
+ caList = append(caList, moduleLib.CompositeApp{Metadata: cApp.Metadata, Spec: cApp.Spec})
+ }
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusOK)
+ err = json.NewEncoder(w).Encode(caList)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusNotFound)
+ return
+ }
+ return
+}
+
// deleteHandler handles DELETE operations on a particular CompositeApp Name
func (h compositeAppHandler) deleteHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)