diff options
author | Kiran Kamineni <kiran.k.kamineni@intel.com> | 2019-07-18 14:49:25 -0700 |
---|---|---|
committer | Kiran Kamineni <kiran.k.kamineni@intel.com> | 2019-07-18 17:14:18 -0700 |
commit | 412d02f7bd53a9e810be2c17d1c391c9bc6dda13 (patch) | |
tree | 78e56002bd30c7273ae1bb14d9589601a5e74e3b /src/k8splugin/api/profilehandler.go | |
parent | d605586c571f5bc059486d3b41a9709b5d9c10e3 (diff) |
Add list api for profiles
Add a list api for profiles for a specific
definition and version.
GET /v1/rb/definition/name/version/profile
will list all the profiles.
Issue-ID: MULTICLOUD-730
Change-Id: If1b8e6910c276a0f7139ab13340721c6ec8a49e8
Signed-off-by: Kiran Kamineni <kiran.k.kamineni@intel.com>
Diffstat (limited to 'src/k8splugin/api/profilehandler.go')
-rw-r--r-- | src/k8splugin/api/profilehandler.go | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/k8splugin/api/profilehandler.go b/src/k8splugin/api/profilehandler.go index adb9249b..68ab77a4 100644 --- a/src/k8splugin/api/profilehandler.go +++ b/src/k8splugin/api/profilehandler.go @@ -20,9 +20,10 @@ import ( "encoding/json" "io" "io/ioutil" - "github.com/onap/multicloud-k8s/src/k8splugin/internal/rb" "net/http" + "github.com/onap/multicloud-k8s/src/k8splugin/internal/rb" + "github.com/gorilla/mux" ) @@ -119,6 +120,28 @@ func (h rbProfileHandler) getHandler(w http.ResponseWriter, r *http.Request) { } } +// getHandler handles GET operations on a particular ids +// Returns a rb.Definition +func (h rbProfileHandler) listHandler(w http.ResponseWriter, r *http.Request) { + vars := mux.Vars(r) + rbName := vars["rbname"] + rbVersion := vars["rbversion"] + + ret, err := h.client.List(rbName, rbVersion) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + err = json.NewEncoder(w).Encode(ret) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } +} + // deleteHandler handles DELETE operations on a particular bundle definition id func (h rbProfileHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) |