diff options
Diffstat (limited to 'src/orchestrator/api')
-rw-r--r-- | src/orchestrator/api/api.go | 1 | ||||
-rw-r--r-- | src/orchestrator/api/app_profilehandler.go | 4 | ||||
-rw-r--r-- | src/orchestrator/api/apphandler.go | 28 |
3 files changed, 29 insertions, 4 deletions
diff --git a/src/orchestrator/api/api.go b/src/orchestrator/api/api.go index 70b40d96..a261319c 100644 --- a/src/orchestrator/api/api.go +++ b/src/orchestrator/api/api.go @@ -84,6 +84,7 @@ func NewRouter(projectClient moduleLib.ProjectManager, router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{version}/apps", appHandler.createAppHandler).Methods("POST") router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{version}/apps/{app-name}", appHandler.getAppHandler).Methods("GET") + router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{version}/apps", appHandler.getAppHandler).Methods("GET") router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{version}/apps/{app-name}", appHandler.deleteAppHandler).Methods("DELETE") if compositeProfileClient == nil { diff --git a/src/orchestrator/api/app_profilehandler.go b/src/orchestrator/api/app_profilehandler.go index 16423483..ef7833de 100644 --- a/src/orchestrator/api/app_profilehandler.go +++ b/src/orchestrator/api/app_profilehandler.go @@ -27,8 +27,8 @@ import ( "net/http" "net/textproto" + "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/validation" moduleLib "github.com/onap/multicloud-k8s/src/orchestrator/pkg/module" - "github.com/onap/multicloud-k8s/src/orchestrator/utils" "github.com/gorilla/mux" pkgerrors "github.com/pkg/errors" @@ -89,7 +89,7 @@ func (h appProfileHandler) createAppProfileHandler(w http.ResponseWriter, r *htt return } - err = utils.IsTarGz(bytes.NewBuffer(content)) + err = validation.IsTarGz(bytes.NewBuffer(content)) if err != nil { http.Error(w, "Error in file format", http.StatusUnprocessableEntity) return diff --git a/src/orchestrator/api/apphandler.go b/src/orchestrator/api/apphandler.go index 3cd2dbc8..2c81431c 100644 --- a/src/orchestrator/api/apphandler.go +++ b/src/orchestrator/api/apphandler.go @@ -27,8 +27,8 @@ import ( "net/http" "net/textproto" + "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/validation" moduleLib "github.com/onap/multicloud-k8s/src/orchestrator/pkg/module" - "github.com/onap/multicloud-k8s/src/orchestrator/utils" "github.com/gorilla/mux" ) @@ -92,7 +92,7 @@ func (h appHandler) createAppHandler(w http.ResponseWriter, r *http.Request) { return } - err = utils.IsTarGz(bytes.NewBuffer(content)) + err = validation.IsTarGz(bytes.NewBuffer(content)) if err != nil { http.Error(w, "Error in file format", http.StatusUnprocessableEntity) return @@ -129,6 +129,30 @@ func (h appHandler) getAppHandler(w http.ResponseWriter, r *http.Request) { compositeAppVersion := vars["version"] name := vars["app-name"] + // handle the get all apps case - return a list of only the json parts + if len(name) == 0 { + var retList []moduleLib.App + + ret, err := h.client.GetApps(projectName, compositeAppName, compositeAppVersion) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + for _, app := range ret { + retList = append(retList, moduleLib.App{Metadata: app.Metadata}) + } + + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + err = json.NewEncoder(w).Encode(retList) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + return + } + accepted, _, err := mime.ParseMediaType(r.Header.Get("Accept")) if err != nil { http.Error(w, err.Error(), http.StatusNotAcceptable) |