summaryrefslogtreecommitdiffstats
path: root/src/k8splugin/api/defhandler.go
diff options
context:
space:
mode:
authorKiran Kamineni <kiran.k.kamineni@intel.com>2019-07-17 17:14:07 -0700
committerKiran Kamineni <kiran.k.kamineni@intel.com>2019-07-18 16:24:34 -0700
commitb8ecedd40b6be727233bf620a0aa5592f98161e7 (patch)
tree43d8525616b1a6ddd01ce23ad1bee090b8984264 /src/k8splugin/api/defhandler.go
parent045ce10b7c48136dee24761e23ea0156f6255521 (diff)
Add a listallhandler to definitions api
GET calls to the v1/rb/definition will return all definitions and their versions Issue-ID: MULTICLOUD-715 Change-Id: Ia0951ac83283830e475bf727e7d5ced7aab3add2 Signed-off-by: Kiran Kamineni <kiran.k.kamineni@intel.com>
Diffstat (limited to 'src/k8splugin/api/defhandler.go')
-rw-r--r--src/k8splugin/api/defhandler.go22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/k8splugin/api/defhandler.go b/src/k8splugin/api/defhandler.go
index c1110a97..480d4be5 100644
--- a/src/k8splugin/api/defhandler.go
+++ b/src/k8splugin/api/defhandler.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"
)
@@ -122,6 +123,25 @@ func (h rbDefinitionHandler) listVersionsHandler(w http.ResponseWriter, r *http.
}
}
+// listVersionsHandler handles GET (list) operations on the endpoint
+// Returns a list of rb.Definitions
+func (h rbDefinitionHandler) listAllHandler(w http.ResponseWriter, r *http.Request) {
+
+ ret, err := h.client.List("")
+ 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
+ }
+}
+
// getHandler handles GET operations on a particular ids
// Returns a rb.Definition
func (h rbDefinitionHandler) getHandler(w http.ResponseWriter, r *http.Request) {