diff options
author | Konrad Bańka <k.banka@samsung.com> | 2021-02-23 20:35:59 +0100 |
---|---|---|
committer | Konrad Bańka <k.banka@samsung.com> | 2021-02-23 22:53:33 +0100 |
commit | f026b794a6be909731470af5398b03af375e7b78 (patch) | |
tree | c75bd6d3cb0d55ceb9df3bbfec5fb623fcabe3a2 /src/k8splugin/api | |
parent | 33ec73cffb875eb8cc1fbad8d33f1385621250ba (diff) |
Move Day2 Config Values API to new endpoint
Issue-ID: MULTICLOUD-1280
Signed-off-by: Konrad Bańka <k.banka@samsung.com>
Change-Id: Ibeb0920b4ce083f4294b83c887fc7c793a2c3df5
Diffstat (limited to 'src/k8splugin/api')
-rw-r--r-- | src/k8splugin/api/api.go | 13 | ||||
-rw-r--r-- | src/k8splugin/api/confighandler.go | 37 |
2 files changed, 20 insertions, 30 deletions
diff --git a/src/k8splugin/api/api.go b/src/k8splugin/api/api.go index c836fc65..cb094683 100644 --- a/src/k8splugin/api/api.go +++ b/src/k8splugin/api/api.go @@ -1,5 +1,6 @@ /* Copyright 2018 Intel Corporation. +Copyright © 2021 Samsung Electronics Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -107,12 +108,12 @@ func NewRouter(defClient rb.DefinitionManager, configClient = app.NewConfigClient() } configHandler := rbConfigHandler{client: configClient} - resRouter.HandleFunc("/definition/{rbname}/{rbversion}/profile/{prname}/config", configHandler.createHandler).Methods("POST") - resRouter.HandleFunc("/definition/{rbname}/{rbversion}/profile/{prname}/config/{cfgname}", configHandler.getHandler).Methods("GET") - resRouter.HandleFunc("/definition/{rbname}/{rbversion}/profile/{prname}/config/{cfgname}", configHandler.updateHandler).Methods("PUT") - resRouter.HandleFunc("/definition/{rbname}/{rbversion}/profile/{prname}/config/{cfgname}", configHandler.deleteHandler).Methods("DELETE") - resRouter.HandleFunc("/definition/{rbname}/{rbversion}/profile/{prname}/config/rollback", configHandler.rollbackHandler).Methods("POST") - resRouter.HandleFunc("/definition/{rbname}/{rbversion}/profile/{prname}/config/tagit", configHandler.tagitHandler).Methods("POST") + instRouter.HandleFunc("/instance/{instID}/config", configHandler.createHandler).Methods("POST") + 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") + instRouter.HandleFunc("/instance/{instID}/config/rollback", configHandler.rollbackHandler).Methods("POST") + instRouter.HandleFunc("/instance/{instID}/config/tagit", configHandler.tagitHandler).Methods("POST") // Add healthcheck path instRouter.HandleFunc("/healthcheck", healthCheckHandler).Methods("GET") diff --git a/src/k8splugin/api/confighandler.go b/src/k8splugin/api/confighandler.go index c9af2893..f4bb0862 100644 --- a/src/k8splugin/api/confighandler.go +++ b/src/k8splugin/api/confighandler.go @@ -1,5 +1,6 @@ /* * Copyright 2018 Intel Corporation, Inc + * Copyright © 2021 Samsung Electronics * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,9 +38,7 @@ type rbConfigHandler struct { func (h rbConfigHandler) createHandler(w http.ResponseWriter, r *http.Request) { var p app.Config vars := mux.Vars(r) - rbName := vars["rbname"] - rbVersion := vars["rbversion"] - prName := vars["prname"] + instanceID := vars["instID"] if r.Body == nil { http.Error(w, "Empty body", http.StatusBadRequest) @@ -58,7 +57,7 @@ func (h rbConfigHandler) createHandler(w http.ResponseWriter, r *http.Request) { return } - ret, err := h.client.Create(rbName, rbVersion, prName, p) + ret, err := h.client.Create(instanceID, p) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return @@ -77,12 +76,10 @@ func (h rbConfigHandler) createHandler(w http.ResponseWriter, r *http.Request) { // Returns a app.Definition func (h rbConfigHandler) getHandler(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) - rbName := vars["rbname"] - rbVersion := vars["rbversion"] - prName := vars["prname"] + instanceID := vars["instID"] cfgName := vars["cfgname"] - ret, err := h.client.Get(rbName, rbVersion, prName, cfgName) + ret, err := h.client.Get(instanceID, cfgName) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return @@ -100,12 +97,10 @@ func (h rbConfigHandler) getHandler(w http.ResponseWriter, r *http.Request) { // deleteHandler handles DELETE operations on a config func (h rbConfigHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) - rbName := vars["rbname"] - rbVersion := vars["rbversion"] - prName := vars["prname"] + instanceID := vars["instID"] cfgName := vars["cfgname"] - ret, err := h.client.Delete(rbName, rbVersion, prName, cfgName) + ret, err := h.client.Delete(instanceID, cfgName) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return @@ -124,9 +119,7 @@ func (h rbConfigHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { // UpdateHandler handles Update operations on a particular configuration func (h rbConfigHandler) updateHandler(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) - rbName := vars["rbname"] - rbVersion := vars["rbversion"] - prName := vars["prname"] + instanceID := vars["instID"] cfgName := vars["cfgname"] var p app.Config @@ -142,7 +135,7 @@ func (h rbConfigHandler) updateHandler(w http.ResponseWriter, r *http.Request) { return } - ret, err := h.client.Update(rbName, rbVersion, prName, cfgName, p) + ret, err := h.client.Update(instanceID, cfgName, p) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return @@ -160,9 +153,7 @@ func (h rbConfigHandler) updateHandler(w http.ResponseWriter, r *http.Request) { // rollbackHandler handles Rollback operations to a specific version func (h rbConfigHandler) rollbackHandler(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) - rbName := vars["rbname"] - rbVersion := vars["rbversion"] - prName := vars["prname"] + instanceID := vars["instID"] if r.Body == nil { http.Error(w, "Empty body", http.StatusBadRequest) @@ -175,7 +166,7 @@ func (h rbConfigHandler) rollbackHandler(w http.ResponseWriter, r *http.Request) http.Error(w, err.Error(), http.StatusUnprocessableEntity) return } - err = h.client.Rollback(rbName, rbVersion, prName, p) + err = h.client.Rollback(instanceID, p) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return @@ -186,9 +177,7 @@ func (h rbConfigHandler) rollbackHandler(w http.ResponseWriter, r *http.Request) // tagitHandler handles TAGIT operation func (h rbConfigHandler) tagitHandler(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) - rbName := vars["rbname"] - rbVersion := vars["rbversion"] - prName := vars["prname"] + instanceID := vars["instID"] if r.Body == nil { http.Error(w, "Empty body", http.StatusBadRequest) @@ -202,7 +191,7 @@ func (h rbConfigHandler) tagitHandler(w http.ResponseWriter, r *http.Request) { return } - err = h.client.Tagit(rbName, rbVersion, prName, p) + err = h.client.Tagit(instanceID, p) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return |