summaryrefslogtreecommitdiffstats
path: root/src/k8splugin/api/defhandler.go
diff options
context:
space:
mode:
authorKiran Kamineni <kiran.k.kamineni@intel.com>2019-03-15 15:18:12 -0700
committerKiran Kamineni <kiran.k.kamineni@intel.com>2019-03-26 19:19:53 -0700
commitb2b175eae0f4e8b5b0cb9ccbeeca1e98065feeb5 (patch)
treee5a984dd156016b3b615acfd0b903f61e07655ea /src/k8splugin/api/defhandler.go
parent1ab1af62578c1c2bf7b3b2e56827fe408cabdbb3 (diff)
Update definition and profile to latest spec
Bringing all the definition and profile code upto the latest spec. Integrated the end to end instance code changes that were made. P9: Added updated plugin.sh with updated uri paths based on spec Issue-ID: MULTICLOUD-291 Change-Id: Id6e3c6bc2cd02cfb7005e203ccf03e0793b97e95 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.go30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/k8splugin/api/defhandler.go b/src/k8splugin/api/defhandler.go
index f72247ab..93bbba15 100644
--- a/src/k8splugin/api/defhandler.go
+++ b/src/k8splugin/api/defhandler.go
@@ -54,6 +54,12 @@ func (h rbDefinitionHandler) createHandler(w http.ResponseWriter, r *http.Reques
return
}
+ // Version is required.
+ if v.Version == "" {
+ http.Error(w, "Missing version in POST request", http.StatusBadRequest)
+ return
+ }
+
ret, err := h.client.Create(v)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
@@ -72,7 +78,8 @@ func (h rbDefinitionHandler) createHandler(w http.ResponseWriter, r *http.Reques
// uploadHandler handles upload of the bundle tar file into the database
func (h rbDefinitionHandler) uploadHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
- uuid := vars["rbdID"]
+ name := vars["rbname"]
+ version := vars["rbversion"]
inpBytes, err := ioutil.ReadAll(r.Body)
if err != nil {
@@ -85,7 +92,7 @@ func (h rbDefinitionHandler) uploadHandler(w http.ResponseWriter, r *http.Reques
return
}
- err = h.client.Upload(uuid, inpBytes)
+ err = h.client.Upload(name, version, inpBytes)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -94,10 +101,13 @@ func (h rbDefinitionHandler) uploadHandler(w http.ResponseWriter, r *http.Reques
w.WriteHeader(http.StatusOK)
}
-// listHandler handles GET (list) operations on the endpoint
+// listVersionsHandler handles GET (list) operations on the endpoint
// Returns a list of rb.Definitions
-func (h rbDefinitionHandler) listHandler(w http.ResponseWriter, r *http.Request) {
- ret, err := h.client.List()
+func (h rbDefinitionHandler) listVersionsHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ name := vars["rbname"]
+
+ ret, err := h.client.List(name)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -116,9 +126,10 @@ func (h rbDefinitionHandler) listHandler(w http.ResponseWriter, r *http.Request)
// Returns a rb.Definition
func (h rbDefinitionHandler) getHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
- id := vars["rbdID"]
+ name := vars["rbname"]
+ version := vars["rbversion"]
- ret, err := h.client.Get(id)
+ ret, err := h.client.Get(name, version)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -136,9 +147,10 @@ func (h rbDefinitionHandler) getHandler(w http.ResponseWriter, r *http.Request)
// deleteHandler handles DELETE operations on a particular bundle definition id
func (h rbDefinitionHandler) deleteHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
- id := vars["rbdID"]
+ name := vars["rbname"]
+ version := vars["rbversion"]
- err := h.client.Delete(id)
+ err := h.client.Delete(name, version)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return