summaryrefslogtreecommitdiffstats
path: root/src/k8splugin/api
diff options
context:
space:
mode:
authorLukasz Rajewski <lukasz.rajewski@orange.com>2021-08-02 22:15:35 +0200
committerLukasz Rajewski <lukasz.rajewski@orange.com>2021-08-02 22:30:16 +0200
commit91fe5c50c2d882a5c831dd473d8db765b2dd8699 (patch)
treea2c42ea34ea265b7ef72c237ece1c19b231be8c4 /src/k8splugin/api
parente42203ee6c170eebb9466ee82baa97f83e88955c (diff)
Config List handler added to Config API
Config List handler added to Config API Issue-ID: MULTICLOUD-1332 Signed-off-by: Lukasz Rajewski <lukasz.rajewski@orange.com> Change-Id: I63355dd6b05e70398cfc89744efa332926286c40
Diffstat (limited to 'src/k8splugin/api')
-rw-r--r--src/k8splugin/api/api.go1
-rw-r--r--src/k8splugin/api/confighandler.go21
2 files changed, 22 insertions, 0 deletions
diff --git a/src/k8splugin/api/api.go b/src/k8splugin/api/api.go
index 4a196ae2..1c7c5eaf 100644
--- a/src/k8splugin/api/api.go
+++ b/src/k8splugin/api/api.go
@@ -116,6 +116,7 @@ func NewRouter(defClient rb.DefinitionManager,
}
configHandler := rbConfigHandler{client: configClient}
instRouter.HandleFunc("/instance/{instID}/config", configHandler.createHandler).Methods("POST")
+ instRouter.HandleFunc("/instance/{instID}/config", configHandler.listHandler).Methods("GET")
instRouter.HandleFunc("/instance/{instID}/config/{cfgname}", configHandler.getHandler).Methods("GET")
instRouter.HandleFunc("/instance/{instID}/config/{cfgname}", configHandler.updateHandler).Methods("PUT")
instRouter.HandleFunc("/instance/{instID}/config/{cfgname}", configHandler.deleteHandler).Methods("DELETE")
diff --git a/src/k8splugin/api/confighandler.go b/src/k8splugin/api/confighandler.go
index f4bb0862..4ce30799 100644
--- a/src/k8splugin/api/confighandler.go
+++ b/src/k8splugin/api/confighandler.go
@@ -94,6 +94,27 @@ func (h rbConfigHandler) getHandler(w http.ResponseWriter, r *http.Request) {
}
}
+// listHandler handles GET operations for all configs of instance
+// Returns a app.Definition
+func (h rbConfigHandler) listHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ instanceID := vars["instID"]
+
+ ret, err := h.client.List(instanceID)
+ 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 config
func (h rbConfigHandler) deleteHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)