summaryrefslogtreecommitdiffstats
path: root/src/orchestrator/api/api.go
diff options
context:
space:
mode:
authorMarcus G K Williams <marcus.williams@intel.com>2020-02-14 13:29:37 -0800
committerMarcus G K Williams <marcus.williams@intel.com>2020-02-21 10:00:07 -0800
commit95e9ddd082cb2ccd28d9d33ea2f8607bd5c793f5 (patch)
tree3649bfda50603ad04af857440cb1653371e6dc7b /src/orchestrator/api/api.go
parentbea5027a7f59bffee2a6ed931e63c05a9fb1bdc7 (diff)
Add Controller Register API to Orchestrator
Add API allows Controllers to register themselves as gRPC servers consumed by the orchestrator. Issue-ID: MULTICLOUD-995 Signed-off-by: Marcus G K Williams <marcus.williams@intel.com> Change-Id: I75946a4af711bf2e9d65f354923db494da667e70
Diffstat (limited to 'src/orchestrator/api/api.go')
-rw-r--r--src/orchestrator/api/api.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/orchestrator/api/api.go b/src/orchestrator/api/api.go
index 1cb4299e..f0342433 100644
--- a/src/orchestrator/api/api.go
+++ b/src/orchestrator/api/api.go
@@ -22,7 +22,8 @@ import (
var moduleClient *moduleLib.Client
// NewRouter creates a router that registers the various urls that are supported
-func NewRouter(projectClient moduleLib.ProjectManager, compositeAppClient moduleLib.CompositeAppManager) *mux.Router {
+
+func NewRouter(projectClient moduleLib.ProjectManager, compositeAppClient moduleLib.CompositeAppManager, ControllerClient moduleLib.ControllerManager) *mux.Router {
router := mux.NewRouter().PathPrefix("/v2").Subrouter()
moduleClient = moduleLib.NewClient()
@@ -32,6 +33,12 @@ func NewRouter(projectClient moduleLib.ProjectManager, compositeAppClient module
projHandler := projectHandler{
client: projectClient,
}
+ if ControllerClient == nil {
+ ControllerClient = moduleClient.Controller
+ }
+ controlHandler := controllerHandler{
+ client: ControllerClient,
+ }
router.HandleFunc("/projects", projHandler.createHandler).Methods("POST")
router.HandleFunc("/projects/{project-name}", projHandler.getHandler).Methods("GET")
router.HandleFunc("/projects/{project-name}", projHandler.deleteHandler).Methods("DELETE")
@@ -47,5 +54,9 @@ func NewRouter(projectClient moduleLib.ProjectManager, compositeAppClient module
router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{version}", compAppHandler.getHandler).Methods("GET")
router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{version}", compAppHandler.deleteHandler).Methods("DELETE")
+ router.HandleFunc("/controllers", controlHandler.createHandler).Methods("POST")
+ router.HandleFunc("/controllers", controlHandler.createHandler).Methods("PUT")
+ router.HandleFunc("/controllers/{controller-name}", controlHandler.getHandler).Methods("GET")
+ router.HandleFunc("/controllers/{controller-name}", controlHandler.deleteHandler).Methods("DELETE")
return router
}