diff options
Diffstat (limited to 'src/ncm/api/clusterhandler.go')
-rw-r--r-- | src/ncm/api/clusterhandler.go | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/ncm/api/clusterhandler.go b/src/ncm/api/clusterhandler.go index cb147a8a..78453aa8 100644 --- a/src/ncm/api/clusterhandler.go +++ b/src/ncm/api/clusterhandler.go @@ -194,6 +194,23 @@ func (h clusterHandler) getClusterHandler(w http.ResponseWriter, r *http.Request provider := vars["provider-name"] name := vars["name"] + label := r.URL.Query().Get("label") + if len(label) != 0 { + ret, err := h.client.GetClustersWithLabel(provider, label) + 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 + } + return + } + // handle the get all clusters case - return a list of only the json parts if len(name) == 0 { var retList []moduleLib.Cluster @@ -307,6 +324,36 @@ func (h clusterHandler) deleteClusterHandler(w http.ResponseWriter, r *http.Requ w.WriteHeader(http.StatusNoContent) } +// apply network intents associated with the cluster +func (h clusterHandler) applyClusterHandler(w http.ResponseWriter, r *http.Request) { + vars := mux.Vars(r) + provider := vars["provider-name"] + name := vars["name"] + + err := h.client.ApplyNetworkIntents(provider, name) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + w.WriteHeader(http.StatusNoContent) +} + +// terminate network intents associated with the cluster +func (h clusterHandler) terminateClusterHandler(w http.ResponseWriter, r *http.Request) { + vars := mux.Vars(r) + provider := vars["provider-name"] + name := vars["name"] + + err := h.client.TerminateNetworkIntents(provider, name) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + w.WriteHeader(http.StatusNoContent) +} + // Create handles creation of the ClusterLabel entry in the database func (h clusterHandler) createClusterLabelHandler(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) |