summaryrefslogtreecommitdiffstats
path: root/src/orchestrator/api/projecthandler.go
diff options
context:
space:
mode:
authorRajamohan Raj <rajamohan.raj@intel.com>2020-07-16 23:12:57 +0000
committerRajamohan Raj <rajamohan.raj@intel.com>2020-07-16 23:15:29 +0000
commit7e1ac3352cac761fe4e6052a6770d8bd77cdf046 (patch)
tree38911f1e25c51a2e021f61437ab5a62037545d20 /src/orchestrator/api/projecthandler.go
parentad02ea4b31bc3a8e32c72f4a2905bfe94194ae33 (diff)
Implement GetAll projects handler
In this patch implement the route: /v2/projects. Issue-ID: MULTICLOUD-1126 Signed-off-by: Rajamohan Raj <rajamohan.raj@intel.com> Change-Id: Ia38aa560a74c26b8528d6bd579038c1b80b4d3c9
Diffstat (limited to 'src/orchestrator/api/projecthandler.go')
-rw-r--r--src/orchestrator/api/projecthandler.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/orchestrator/api/projecthandler.go b/src/orchestrator/api/projecthandler.go
index 1e78c676..09b24096 100644
--- a/src/orchestrator/api/projecthandler.go
+++ b/src/orchestrator/api/projecthandler.go
@@ -75,6 +75,31 @@ func (h projectHandler) getHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
name := vars["project-name"]
+ // handle for get all projects
+ if len(name) == 0 {
+ var pList []moduleLib.Project
+
+ projects, err := h.client.GetAllProjects()
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ for _, p := range projects {
+ pList = append(pList, moduleLib.Project{MetaData: p.MetaData})
+ }
+
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusOK)
+ err = json.NewEncoder(w).Encode(pList)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ return
+
+ }
+
ret, err := h.client.GetProject(name)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)