2 Copyright 2018 Intel Corporation.
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 http://www.apache.org/licenses/LICENSE-2.0
7 Unless required by applicable law or agreed to in writing, software
8 distributed under the License is distributed on an "AS IS" BASIS,
9 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 See the License for the specific language governing permissions and
11 limitations under the License.
17 "k8splugin/internal/rb"
19 "github.com/gorilla/mux"
22 // NewRouter creates a router instance that serves the VNFInstance web methods
23 func NewRouter(kubeconfig string, defClient rb.DefinitionManager,
24 profileClient rb.ProfileManager) *mux.Router {
25 router := mux.NewRouter()
27 vnfInstanceHandler := router.PathPrefix("/v1/vnf_instances").Subrouter()
28 vnfInstanceHandler.HandleFunc("/", CreateHandler).Methods("POST").Name("VNFCreation")
29 vnfInstanceHandler.HandleFunc("/{cloudRegionID}/{namespace}", ListHandler).Methods("GET")
30 vnfInstanceHandler.HandleFunc("/{cloudRegionID}/{namespace}/{externalVNFID}", DeleteHandler).Methods("DELETE")
31 vnfInstanceHandler.HandleFunc("/{cloudRegionID}/{namespace}/{externalVNFID}", GetHandler).Methods("GET")
33 //rbd is resource bundle definition
35 defClient = rb.NewDefinitionClient()
37 defHandler := rbDefinitionHandler{client: defClient}
38 resRouter := router.PathPrefix("/v1/rb").Subrouter()
39 resRouter.HandleFunc("/definition", defHandler.createHandler).Methods("POST")
40 resRouter.HandleFunc("/definition/{rbdID}/content", defHandler.uploadHandler).Methods("POST")
41 resRouter.HandleFunc("/definition", defHandler.listHandler).Methods("GET")
42 resRouter.HandleFunc("/definition/{rbdID}", defHandler.getHandler).Methods("GET")
43 resRouter.HandleFunc("/definition/{rbdID}", defHandler.deleteHandler).Methods("DELETE")
45 //rbp is resource bundle profile
46 if profileClient == nil {
47 profileClient = rb.NewProfileClient()
49 profileHandler := rbProfileHandler{client: profileClient}
50 resRouter.HandleFunc("/profile", profileHandler.createHandler).Methods("POST")
51 resRouter.HandleFunc("/profile/{rbpID}/content", profileHandler.uploadHandler).Methods("POST")
52 resRouter.HandleFunc("/profile/help", profileHandler.helpHandler).Methods("GET")
53 resRouter.HandleFunc("/profile", profileHandler.listHandler).Methods("GET")
54 resRouter.HandleFunc("/profile/{rbpID}", profileHandler.getHandler).Methods("GET")
55 resRouter.HandleFunc("/profile/{rbpID}", profileHandler.deleteHandler).Methods("DELETE")
57 // (TODO): Fix update method
58 // vnfInstanceHandler.HandleFunc("/{vnfInstanceId}", UpdateHandler).Methods("PUT")