G release step 1 of 2
[ric-plt/e2mgr.git] / tools / RoutingManagerSimulator / go / routers.go
1 //
2 // Copyright 2019 AT&T Intellectual Property
3 // Copyright 2019 Nokia
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //      http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16
17 //  This source code is part of the near-RT RIC (RAN Intelligent Controller)
18 //  platform project (RICP).
19
20 /*
21  * Routing Manager
22  *
23  * This is the Swagger/OpenAPI 2.0 definition of Routing Manager's Northbound API.
24  *
25  * API version: 0.4.0
26  * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
27  */
28
29 package swagger
30
31 import (
32         "fmt"
33         "net/http"
34         "strings"
35
36         "github.com/gorilla/mux"
37 )
38
39 type Route struct {
40         Name        string
41         Method      string
42         Pattern     string
43         HandlerFunc http.HandlerFunc
44 }
45
46 type Routes []Route
47
48 func NewRouter() *mux.Router {
49         router := mux.NewRouter().StrictSlash(true)
50         for _, route := range routes {
51                 var handler http.Handler
52                 handler = route.HandlerFunc
53                 handler = Logger(handler, route.Name)
54
55                 router.
56                         Methods(route.Method).
57                         Path(route.Pattern).
58                         Name(route.Name).
59                         Handler(handler)
60         }
61
62         return router
63 }
64
65 func Index(w http.ResponseWriter, r *http.Request) {
66         fmt.Fprintf(w, "Hello World!")
67 }
68
69 var routes = Routes{
70         Route{
71                 "Index",
72                 "GET",
73                 "/ric/v1/",
74                 Index,
75         },
76
77         Route{
78                 "AssociateRanToE2tHandle",
79                 strings.ToUpper("Post"),
80                 "/ric/v1/handles/associate-ran-to-e2t",
81                 AssociateRanToE2tHandle,
82         },
83
84         Route{
85                 "CreateNewE2tHandle",
86                 strings.ToUpper("Post"),
87                 "/ric/v1/handles/e2t",
88                 CreateNewE2tHandle,
89         },
90
91         Route{
92                 "DeleteE2tHandle",
93                 strings.ToUpper("Delete"),
94                 "/ric/v1/handles/e2t",
95                 DeleteE2tHandle,
96         },
97
98         Route{
99                 "DeleteXappSubscriptionHandle",
100                 strings.ToUpper("Delete"),
101                 "/ric/v1/handles/xapp-subscription-handle",
102                 DeleteXappSubscriptionHandle,
103         },
104
105         Route{
106                 "DissociateRan",
107                 strings.ToUpper("Post"),
108                 "/ric/v1/handles/dissociate-ran",
109                 DissociateRan,
110         },
111
112         Route{
113                 "GetHandles",
114                 strings.ToUpper("Get"),
115                 "/ric/v1/handles",
116                 GetHandles,
117         },
118
119         Route{
120                 "ProvideXappHandle",
121                 strings.ToUpper("Post"),
122                 "/ric/v1/handles/xapp-handle",
123                 ProvideXappHandle,
124         },
125
126         Route{
127                 "ProvideXappSubscriptionHandle",
128                 strings.ToUpper("Post"),
129                 "/ric/v1/handles/xapp-subscription-handle",
130                 ProvideXappSubscriptionHandle,
131         },
132
133         Route{
134                 "UpdateXappSubscriptionHandle",
135                 strings.ToUpper("Put"),
136                 "/ric/v1/handles/xapp-subscription-handle/{subscription_id}",
137                 UpdateXappSubscriptionHandle,
138         },
139
140         Route{
141                 "GetHealth",
142                 strings.ToUpper("Get"),
143                 "/ric/v1/health",
144                 GetHealth,
145         },
146 }