From 91fe5c50c2d882a5c831dd473d8db765b2dd8699 Mon Sep 17 00:00:00 2001 From: Lukasz Rajewski Date: Mon, 2 Aug 2021 22:15:35 +0200 Subject: Config List handler added to Config API Config List handler added to Config API Issue-ID: MULTICLOUD-1332 Signed-off-by: Lukasz Rajewski Change-Id: I63355dd6b05e70398cfc89744efa332926286c40 --- src/k8splugin/api/confighandler.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/k8splugin/api/confighandler.go') 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) -- cgit 1.2.3-korg