Initial code for the a1 implementation for go
[ric-plt/a1.git] / a1-go / pkg / restapi / configure_a1.go
1 /*
2 ==================================================================================
3   Copyright (c) 2021 Samsung
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 // This file is safe to edit. Once it exists it will not be overwritten
22
23 package restapi
24
25 import (
26         "crypto/tls"
27         "net/http"
28
29         "github.com/go-openapi/errors"
30         "github.com/go-openapi/runtime"
31         "github.com/go-openapi/runtime/middleware"
32
33         "subh.com/a1-go/pkg/restapi/operations"
34         "subh.com/a1-go/pkg/restapi/operations/a1_e_i_data_delivery"
35         "subh.com/a1-go/pkg/restapi/operations/a1_mediator"
36 )
37
38 //go:generate swagger generate server --target ../../pkg --name A1 --spec ../../api/swagger.yaml --exclude-main
39
40 func configureFlags(api *operations.A1API) {
41         // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... }
42 }
43
44 func configureAPI(api *operations.A1API) http.Handler {
45         // configure the api here
46         api.ServeError = errors.ServeError
47
48         // Set your custom logger if needed. Default one is log.Printf
49         // Expected interface func(string, ...interface{})
50         //
51         // Example:
52         // api.Logger = log.Printf
53
54         api.JSONConsumer = runtime.JSONConsumer()
55
56         api.JSONProducer = runtime.JSONProducer()
57
58         if api.A1MediatorA1ControllerCreateOrReplacePolicyInstanceHandler == nil {
59                 api.A1MediatorA1ControllerCreateOrReplacePolicyInstanceHandler = a1_mediator.A1ControllerCreateOrReplacePolicyInstanceHandlerFunc(func(params a1_mediator.A1ControllerCreateOrReplacePolicyInstanceParams) middleware.Responder {
60                         return middleware.NotImplemented("operation a1_mediator.A1ControllerCreateOrReplacePolicyInstance has not yet been implemented")
61                 })
62         }
63         if api.A1MediatorA1ControllerCreatePolicyTypeHandler == nil {
64                 api.A1MediatorA1ControllerCreatePolicyTypeHandler = a1_mediator.A1ControllerCreatePolicyTypeHandlerFunc(func(params a1_mediator.A1ControllerCreatePolicyTypeParams) middleware.Responder {
65                         return middleware.NotImplemented("operation a1_mediator.A1ControllerCreatePolicyType has not yet been implemented")
66                 })
67         }
68         if api.A1eiDataDeliveryA1ControllerDataDeliveryHandler == nil {
69                 api.A1eiDataDeliveryA1ControllerDataDeliveryHandler = a1_e_i_data_delivery.A1ControllerDataDeliveryHandlerFunc(func(params a1_e_i_data_delivery.A1ControllerDataDeliveryParams) middleware.Responder {
70                         return middleware.NotImplemented("operation a1_e_i_data_delivery.A1ControllerDataDelivery has not yet been implemented")
71                 })
72         }
73         if api.A1MediatorA1ControllerDeletePolicyInstanceHandler == nil {
74                 api.A1MediatorA1ControllerDeletePolicyInstanceHandler = a1_mediator.A1ControllerDeletePolicyInstanceHandlerFunc(func(params a1_mediator.A1ControllerDeletePolicyInstanceParams) middleware.Responder {
75                         return middleware.NotImplemented("operation a1_mediator.A1ControllerDeletePolicyInstance has not yet been implemented")
76                 })
77         }
78         if api.A1MediatorA1ControllerDeletePolicyTypeHandler == nil {
79                 api.A1MediatorA1ControllerDeletePolicyTypeHandler = a1_mediator.A1ControllerDeletePolicyTypeHandlerFunc(func(params a1_mediator.A1ControllerDeletePolicyTypeParams) middleware.Responder {
80                         return middleware.NotImplemented("operation a1_mediator.A1ControllerDeletePolicyType has not yet been implemented")
81                 })
82         }
83         if api.A1MediatorA1ControllerGetAllInstancesForTypeHandler == nil {
84                 api.A1MediatorA1ControllerGetAllInstancesForTypeHandler = a1_mediator.A1ControllerGetAllInstancesForTypeHandlerFunc(func(params a1_mediator.A1ControllerGetAllInstancesForTypeParams) middleware.Responder {
85                         return middleware.NotImplemented("operation a1_mediator.A1ControllerGetAllInstancesForType has not yet been implemented")
86                 })
87         }
88         if api.A1MediatorA1ControllerGetAllPolicyTypesHandler == nil {
89                 api.A1MediatorA1ControllerGetAllPolicyTypesHandler = a1_mediator.A1ControllerGetAllPolicyTypesHandlerFunc(func(params a1_mediator.A1ControllerGetAllPolicyTypesParams) middleware.Responder {
90                         return middleware.NotImplemented("operation a1_mediator.A1ControllerGetAllPolicyTypes has not yet been implemented")
91                 })
92         }
93         if api.A1MediatorA1ControllerGetHealthcheckHandler == nil {
94                 api.A1MediatorA1ControllerGetHealthcheckHandler = a1_mediator.A1ControllerGetHealthcheckHandlerFunc(func(params a1_mediator.A1ControllerGetHealthcheckParams) middleware.Responder {
95                         return middleware.NotImplemented("operation a1_mediator.A1ControllerGetHealthcheck has not yet been implemented")
96                 })
97         }
98         if api.A1MediatorA1ControllerGetPolicyInstanceHandler == nil {
99                 api.A1MediatorA1ControllerGetPolicyInstanceHandler = a1_mediator.A1ControllerGetPolicyInstanceHandlerFunc(func(params a1_mediator.A1ControllerGetPolicyInstanceParams) middleware.Responder {
100                         return middleware.NotImplemented("operation a1_mediator.A1ControllerGetPolicyInstance has not yet been implemented")
101                 })
102         }
103         if api.A1MediatorA1ControllerGetPolicyInstanceStatusHandler == nil {
104                 api.A1MediatorA1ControllerGetPolicyInstanceStatusHandler = a1_mediator.A1ControllerGetPolicyInstanceStatusHandlerFunc(func(params a1_mediator.A1ControllerGetPolicyInstanceStatusParams) middleware.Responder {
105                         return middleware.NotImplemented("operation a1_mediator.A1ControllerGetPolicyInstanceStatus has not yet been implemented")
106                 })
107         }
108         if api.A1MediatorA1ControllerGetPolicyTypeHandler == nil {
109                 api.A1MediatorA1ControllerGetPolicyTypeHandler = a1_mediator.A1ControllerGetPolicyTypeHandlerFunc(func(params a1_mediator.A1ControllerGetPolicyTypeParams) middleware.Responder {
110                         return middleware.NotImplemented("operation a1_mediator.A1ControllerGetPolicyType has not yet been implemented")
111                 })
112         }
113
114         api.PreServerShutdown = func() {}
115
116         api.ServerShutdown = func() {}
117
118         return setupGlobalMiddleware(api.Serve(setupMiddlewares))
119 }
120
121 // The TLS configuration before HTTPS server starts.
122 func configureTLS(tlsConfig *tls.Config) {
123         // Make all necessary changes to the TLS configuration here.
124 }
125
126 // As soon as server is initialized but not run yet, this function will be called.
127 // If you need to modify a config, store server instance to stop it individually later, this is the place.
128 // This function can be called multiple times, depending on the number of serving schemes.
129 // scheme value will be set accordingly: "http", "https" or "unix"
130 func configureServer(s *http.Server, scheme, addr string) {
131 }
132
133 // The middleware configuration is for the handler executors. These do not apply to the swagger.json document.
134 // The middleware executes after routing but before authentication, binding and validation
135 func setupMiddlewares(handler http.Handler) http.Handler {
136         return handler
137 }
138
139 // The middleware configuration happens before anything, this middleware also applies to serving the swagger.json document.
140 // So this is a good place to plug in a panic handling middleware, logging and metrics
141 func setupGlobalMiddleware(handler http.Handler) http.Handler {
142         return handler
143 }