aboutsummaryrefslogtreecommitdiffstats
path: root/src/k8splugin/api/instancehandler.go
diff options
context:
space:
mode:
authorKiran Kamineni <kiran.k.kamineni@intel.com>2019-09-18 12:09:06 -0700
committerKiran Kamineni <kiran.k.kamineni@intel.com>2019-10-15 10:02:40 -0700
commit1c851d8bcbf526be6d7295b9e01a597be65cc692 (patch)
treef378b269d3bab5cd344c668bf9b65d50d4b040f5 /src/k8splugin/api/instancehandler.go
parente492a72a094cd4a54f96e47521578d0938d85d87 (diff)
Add a status getter api endpoint
Add a status endpoint to get status of instances. Status information will be added to the database asynchronously. Issue-ID: MULTICLOUD-675 Change-Id: Ia7d79a6f18f01bf24f2690caf74a48c2a082bd73 Signed-off-by: Kiran Kamineni <kiran.k.kamineni@intel.com>
Diffstat (limited to 'src/k8splugin/api/instancehandler.go')
-rw-r--r--src/k8splugin/api/instancehandler.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/k8splugin/api/instancehandler.go b/src/k8splugin/api/instancehandler.go
index acbeb53f..ab98e4be 100644
--- a/src/k8splugin/api/instancehandler.go
+++ b/src/k8splugin/api/instancehandler.go
@@ -106,6 +106,26 @@ func (i instanceHandler) getHandler(w http.ResponseWriter, r *http.Request) {
}
}
+// statusHandler retrieves status about an instance via the ID
+func (i instanceHandler) statusHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ id := vars["instID"]
+
+ resp, err := i.client.Status(id)
+ 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(resp)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+}
+
// listHandler retrieves information about an instance via the ID
func (i instanceHandler) listHandler(w http.ResponseWriter, r *http.Request) {