2 ==================================================================================
3 Copyright (c) 2021 Samsung
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
9 http://www.apache.org/licenses/LICENSE-2.0
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.
17 This source code is part of the near-RT RIC (RAN Intelligent Controller)
18 platform project (RICP).
19 ==================================================================================
21 // Code generated by go-swagger; DO NOT EDIT.
25 // This file was generated by the swagger tool.
26 // Editing this file might prove futile when you re-run the swagger generate command
33 "github.com/go-openapi/errors"
34 "github.com/go-openapi/loads"
35 "github.com/go-openapi/runtime"
36 "github.com/go-openapi/runtime/middleware"
37 "github.com/go-openapi/runtime/security"
38 "github.com/go-openapi/spec"
39 "github.com/go-openapi/strfmt"
40 "github.com/go-openapi/swag"
42 "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/restapi/operations/a1_e_i_data_delivery"
43 "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/restapi/operations/a1_mediator"
46 // NewA1API creates a new A1 instance
47 func NewA1API(spec *loads.Document) *A1API {
49 handlers: make(map[string]map[string]http.Handler),
50 formats: strfmt.Default,
51 defaultConsumes: "application/json",
52 defaultProduces: "application/json",
53 customConsumers: make(map[string]runtime.Consumer),
54 customProducers: make(map[string]runtime.Producer),
55 PreServerShutdown: func() {},
56 ServerShutdown: func() {},
58 ServeError: errors.ServeError,
59 BasicAuthenticator: security.BasicAuth,
60 APIKeyAuthenticator: security.APIKeyAuth,
61 BearerAuthenticator: security.BearerAuth,
63 JSONConsumer: runtime.JSONConsumer(),
65 JSONProducer: runtime.JSONProducer(),
67 A1MediatorA1ControllerCreateOrReplacePolicyInstanceHandler: a1_mediator.A1ControllerCreateOrReplacePolicyInstanceHandlerFunc(func(params a1_mediator.A1ControllerCreateOrReplacePolicyInstanceParams) middleware.Responder {
68 return middleware.NotImplemented("operation a1_mediator.A1ControllerCreateOrReplacePolicyInstance has not yet been implemented")
70 A1MediatorA1ControllerCreatePolicyTypeHandler: a1_mediator.A1ControllerCreatePolicyTypeHandlerFunc(func(params a1_mediator.A1ControllerCreatePolicyTypeParams) middleware.Responder {
71 return middleware.NotImplemented("operation a1_mediator.A1ControllerCreatePolicyType has not yet been implemented")
73 A1eiDataDeliveryA1ControllerDataDeliveryHandler: a1_e_i_data_delivery.A1ControllerDataDeliveryHandlerFunc(func(params a1_e_i_data_delivery.A1ControllerDataDeliveryParams) middleware.Responder {
74 return middleware.NotImplemented("operation a1_e_i_data_delivery.A1ControllerDataDelivery has not yet been implemented")
76 A1MediatorA1ControllerDeletePolicyInstanceHandler: a1_mediator.A1ControllerDeletePolicyInstanceHandlerFunc(func(params a1_mediator.A1ControllerDeletePolicyInstanceParams) middleware.Responder {
77 return middleware.NotImplemented("operation a1_mediator.A1ControllerDeletePolicyInstance has not yet been implemented")
79 A1MediatorA1ControllerDeletePolicyTypeHandler: a1_mediator.A1ControllerDeletePolicyTypeHandlerFunc(func(params a1_mediator.A1ControllerDeletePolicyTypeParams) middleware.Responder {
80 return middleware.NotImplemented("operation a1_mediator.A1ControllerDeletePolicyType has not yet been implemented")
82 A1MediatorA1ControllerGetAllInstancesForTypeHandler: a1_mediator.A1ControllerGetAllInstancesForTypeHandlerFunc(func(params a1_mediator.A1ControllerGetAllInstancesForTypeParams) middleware.Responder {
83 return middleware.NotImplemented("operation a1_mediator.A1ControllerGetAllInstancesForType has not yet been implemented")
85 A1MediatorA1ControllerGetAllPolicyTypesHandler: a1_mediator.A1ControllerGetAllPolicyTypesHandlerFunc(func(params a1_mediator.A1ControllerGetAllPolicyTypesParams) middleware.Responder {
86 return middleware.NotImplemented("operation a1_mediator.A1ControllerGetAllPolicyTypes has not yet been implemented")
88 A1MediatorA1ControllerGetHealthcheckHandler: a1_mediator.A1ControllerGetHealthcheckHandlerFunc(func(params a1_mediator.A1ControllerGetHealthcheckParams) middleware.Responder {
89 return middleware.NotImplemented("operation a1_mediator.A1ControllerGetHealthcheck has not yet been implemented")
91 A1MediatorA1ControllerGetPolicyInstanceHandler: a1_mediator.A1ControllerGetPolicyInstanceHandlerFunc(func(params a1_mediator.A1ControllerGetPolicyInstanceParams) middleware.Responder {
92 return middleware.NotImplemented("operation a1_mediator.A1ControllerGetPolicyInstance has not yet been implemented")
94 A1MediatorA1ControllerGetPolicyInstanceStatusHandler: a1_mediator.A1ControllerGetPolicyInstanceStatusHandlerFunc(func(params a1_mediator.A1ControllerGetPolicyInstanceStatusParams) middleware.Responder {
95 return middleware.NotImplemented("operation a1_mediator.A1ControllerGetPolicyInstanceStatus has not yet been implemented")
97 A1MediatorA1ControllerGetPolicyTypeHandler: a1_mediator.A1ControllerGetPolicyTypeHandlerFunc(func(params a1_mediator.A1ControllerGetPolicyTypeParams) middleware.Responder {
98 return middleware.NotImplemented("operation a1_mediator.A1ControllerGetPolicyType has not yet been implemented")
103 /*A1API the a1 API */
106 context *middleware.Context
107 handlers map[string]map[string]http.Handler
108 formats strfmt.Registry
109 customConsumers map[string]runtime.Consumer
110 customProducers map[string]runtime.Producer
111 defaultConsumes string
112 defaultProduces string
113 Middleware func(middleware.Builder) http.Handler
115 // BasicAuthenticator generates a runtime.Authenticator from the supplied basic auth function.
116 // It has a default implementation in the security package, however you can replace it for your particular usage.
117 BasicAuthenticator func(security.UserPassAuthentication) runtime.Authenticator
118 // APIKeyAuthenticator generates a runtime.Authenticator from the supplied token auth function.
119 // It has a default implementation in the security package, however you can replace it for your particular usage.
120 APIKeyAuthenticator func(string, string, security.TokenAuthentication) runtime.Authenticator
121 // BearerAuthenticator generates a runtime.Authenticator from the supplied bearer token auth function.
122 // It has a default implementation in the security package, however you can replace it for your particular usage.
123 BearerAuthenticator func(string, security.ScopedTokenAuthentication) runtime.Authenticator
125 // JSONConsumer registers a consumer for the following mime types:
126 // - application/json
127 JSONConsumer runtime.Consumer
129 // JSONProducer registers a producer for the following mime types:
130 // - application/json
131 JSONProducer runtime.Producer
133 // A1MediatorA1ControllerCreateOrReplacePolicyInstanceHandler sets the operation handler for the a1 controller create or replace policy instance operation
134 A1MediatorA1ControllerCreateOrReplacePolicyInstanceHandler a1_mediator.A1ControllerCreateOrReplacePolicyInstanceHandler
135 // A1MediatorA1ControllerCreatePolicyTypeHandler sets the operation handler for the a1 controller create policy type operation
136 A1MediatorA1ControllerCreatePolicyTypeHandler a1_mediator.A1ControllerCreatePolicyTypeHandler
137 // A1eiDataDeliveryA1ControllerDataDeliveryHandler sets the operation handler for the a1 controller data delivery operation
138 A1eiDataDeliveryA1ControllerDataDeliveryHandler a1_e_i_data_delivery.A1ControllerDataDeliveryHandler
139 // A1MediatorA1ControllerDeletePolicyInstanceHandler sets the operation handler for the a1 controller delete policy instance operation
140 A1MediatorA1ControllerDeletePolicyInstanceHandler a1_mediator.A1ControllerDeletePolicyInstanceHandler
141 // A1MediatorA1ControllerDeletePolicyTypeHandler sets the operation handler for the a1 controller delete policy type operation
142 A1MediatorA1ControllerDeletePolicyTypeHandler a1_mediator.A1ControllerDeletePolicyTypeHandler
143 // A1MediatorA1ControllerGetAllInstancesForTypeHandler sets the operation handler for the a1 controller get all instances for type operation
144 A1MediatorA1ControllerGetAllInstancesForTypeHandler a1_mediator.A1ControllerGetAllInstancesForTypeHandler
145 // A1MediatorA1ControllerGetAllPolicyTypesHandler sets the operation handler for the a1 controller get all policy types operation
146 A1MediatorA1ControllerGetAllPolicyTypesHandler a1_mediator.A1ControllerGetAllPolicyTypesHandler
147 // A1MediatorA1ControllerGetHealthcheckHandler sets the operation handler for the a1 controller get healthcheck operation
148 A1MediatorA1ControllerGetHealthcheckHandler a1_mediator.A1ControllerGetHealthcheckHandler
149 // A1MediatorA1ControllerGetPolicyInstanceHandler sets the operation handler for the a1 controller get policy instance operation
150 A1MediatorA1ControllerGetPolicyInstanceHandler a1_mediator.A1ControllerGetPolicyInstanceHandler
151 // A1MediatorA1ControllerGetPolicyInstanceStatusHandler sets the operation handler for the a1 controller get policy instance status operation
152 A1MediatorA1ControllerGetPolicyInstanceStatusHandler a1_mediator.A1ControllerGetPolicyInstanceStatusHandler
153 // A1MediatorA1ControllerGetPolicyTypeHandler sets the operation handler for the a1 controller get policy type operation
154 A1MediatorA1ControllerGetPolicyTypeHandler a1_mediator.A1ControllerGetPolicyTypeHandler
155 // ServeError is called when an error is received, there is a default handler
156 // but you can set your own with this
157 ServeError func(http.ResponseWriter, *http.Request, error)
159 // PreServerShutdown is called before the HTTP(S) server is shutdown
160 // This allows for custom functions to get executed before the HTTP(S) server stops accepting traffic
161 PreServerShutdown func()
163 // ServerShutdown is called when the HTTP(S) server is shut down and done
164 // handling all active connections and does not accept connections any more
165 ServerShutdown func()
167 // Custom command line argument groups with their descriptions
168 CommandLineOptionsGroups []swag.CommandLineOptionsGroup
170 // User defined logger function.
171 Logger func(string, ...interface{})
174 // SetDefaultProduces sets the default produces media type
175 func (o *A1API) SetDefaultProduces(mediaType string) {
176 o.defaultProduces = mediaType
179 // SetDefaultConsumes returns the default consumes media type
180 func (o *A1API) SetDefaultConsumes(mediaType string) {
181 o.defaultConsumes = mediaType
184 // SetSpec sets a spec that will be served for the clients.
185 func (o *A1API) SetSpec(spec *loads.Document) {
189 // DefaultProduces returns the default produces media type
190 func (o *A1API) DefaultProduces() string {
191 return o.defaultProduces
194 // DefaultConsumes returns the default consumes media type
195 func (o *A1API) DefaultConsumes() string {
196 return o.defaultConsumes
199 // Formats returns the registered string formats
200 func (o *A1API) Formats() strfmt.Registry {
204 // RegisterFormat registers a custom format validator
205 func (o *A1API) RegisterFormat(name string, format strfmt.Format, validator strfmt.Validator) {
206 o.formats.Add(name, format, validator)
209 // Validate validates the registrations in the A1API
210 func (o *A1API) Validate() error {
211 var unregistered []string
213 if o.JSONConsumer == nil {
214 unregistered = append(unregistered, "JSONConsumer")
217 if o.JSONProducer == nil {
218 unregistered = append(unregistered, "JSONProducer")
221 if o.A1MediatorA1ControllerCreateOrReplacePolicyInstanceHandler == nil {
222 unregistered = append(unregistered, "a1_mediator.A1ControllerCreateOrReplacePolicyInstanceHandler")
224 if o.A1MediatorA1ControllerCreatePolicyTypeHandler == nil {
225 unregistered = append(unregistered, "a1_mediator.A1ControllerCreatePolicyTypeHandler")
227 if o.A1eiDataDeliveryA1ControllerDataDeliveryHandler == nil {
228 unregistered = append(unregistered, "a1_e_i_data_delivery.A1ControllerDataDeliveryHandler")
230 if o.A1MediatorA1ControllerDeletePolicyInstanceHandler == nil {
231 unregistered = append(unregistered, "a1_mediator.A1ControllerDeletePolicyInstanceHandler")
233 if o.A1MediatorA1ControllerDeletePolicyTypeHandler == nil {
234 unregistered = append(unregistered, "a1_mediator.A1ControllerDeletePolicyTypeHandler")
236 if o.A1MediatorA1ControllerGetAllInstancesForTypeHandler == nil {
237 unregistered = append(unregistered, "a1_mediator.A1ControllerGetAllInstancesForTypeHandler")
239 if o.A1MediatorA1ControllerGetAllPolicyTypesHandler == nil {
240 unregistered = append(unregistered, "a1_mediator.A1ControllerGetAllPolicyTypesHandler")
242 if o.A1MediatorA1ControllerGetHealthcheckHandler == nil {
243 unregistered = append(unregistered, "a1_mediator.A1ControllerGetHealthcheckHandler")
245 if o.A1MediatorA1ControllerGetPolicyInstanceHandler == nil {
246 unregistered = append(unregistered, "a1_mediator.A1ControllerGetPolicyInstanceHandler")
248 if o.A1MediatorA1ControllerGetPolicyInstanceStatusHandler == nil {
249 unregistered = append(unregistered, "a1_mediator.A1ControllerGetPolicyInstanceStatusHandler")
251 if o.A1MediatorA1ControllerGetPolicyTypeHandler == nil {
252 unregistered = append(unregistered, "a1_mediator.A1ControllerGetPolicyTypeHandler")
255 if len(unregistered) > 0 {
256 return fmt.Errorf("missing registration: %s", strings.Join(unregistered, ", "))
262 // ServeErrorFor gets a error handler for a given operation id
263 func (o *A1API) ServeErrorFor(operationID string) func(http.ResponseWriter, *http.Request, error) {
267 // AuthenticatorsFor gets the authenticators for the specified security schemes
268 func (o *A1API) AuthenticatorsFor(schemes map[string]spec.SecurityScheme) map[string]runtime.Authenticator {
272 // Authorizer returns the registered authorizer
273 func (o *A1API) Authorizer() runtime.Authorizer {
277 // ConsumersFor gets the consumers for the specified media types.
278 // MIME type parameters are ignored here.
279 func (o *A1API) ConsumersFor(mediaTypes []string) map[string]runtime.Consumer {
280 result := make(map[string]runtime.Consumer, len(mediaTypes))
281 for _, mt := range mediaTypes {
283 case "application/json":
284 result["application/json"] = o.JSONConsumer
287 if c, ok := o.customConsumers[mt]; ok {
294 // ProducersFor gets the producers for the specified media types.
295 // MIME type parameters are ignored here.
296 func (o *A1API) ProducersFor(mediaTypes []string) map[string]runtime.Producer {
297 result := make(map[string]runtime.Producer, len(mediaTypes))
298 for _, mt := range mediaTypes {
300 case "application/json":
301 result["application/json"] = o.JSONProducer
304 if p, ok := o.customProducers[mt]; ok {
311 // HandlerFor gets a http.Handler for the provided operation method and path
312 func (o *A1API) HandlerFor(method, path string) (http.Handler, bool) {
313 if o.handlers == nil {
316 um := strings.ToUpper(method)
317 if _, ok := o.handlers[um]; !ok {
323 h, ok := o.handlers[um][path]
327 // Context returns the middleware context for the a1 API
328 func (o *A1API) Context() *middleware.Context {
329 if o.context == nil {
330 o.context = middleware.NewRoutableContext(o.spec, o, nil)
336 func (o *A1API) initHandlerCache() {
337 o.Context() // don't care about the result, just that the initialization happened
338 if o.handlers == nil {
339 o.handlers = make(map[string]map[string]http.Handler)
342 if o.handlers["PUT"] == nil {
343 o.handlers["PUT"] = make(map[string]http.Handler)
345 o.handlers["PUT"]["/a1-p/policytypes/{policy_type_id}/policies/{policy_instance_id}"] = a1_mediator.NewA1ControllerCreateOrReplacePolicyInstance(o.context, o.A1MediatorA1ControllerCreateOrReplacePolicyInstanceHandler)
346 if o.handlers["PUT"] == nil {
347 o.handlers["PUT"] = make(map[string]http.Handler)
349 o.handlers["PUT"]["/a1-p/policytypes/{policy_type_id}"] = a1_mediator.NewA1ControllerCreatePolicyType(o.context, o.A1MediatorA1ControllerCreatePolicyTypeHandler)
350 if o.handlers["POST"] == nil {
351 o.handlers["POST"] = make(map[string]http.Handler)
353 o.handlers["POST"]["/data-delivery"] = a1_e_i_data_delivery.NewA1ControllerDataDelivery(o.context, o.A1eiDataDeliveryA1ControllerDataDeliveryHandler)
354 if o.handlers["DELETE"] == nil {
355 o.handlers["DELETE"] = make(map[string]http.Handler)
357 o.handlers["DELETE"]["/a1-p/policytypes/{policy_type_id}/policies/{policy_instance_id}"] = a1_mediator.NewA1ControllerDeletePolicyInstance(o.context, o.A1MediatorA1ControllerDeletePolicyInstanceHandler)
358 if o.handlers["DELETE"] == nil {
359 o.handlers["DELETE"] = make(map[string]http.Handler)
361 o.handlers["DELETE"]["/a1-p/policytypes/{policy_type_id}"] = a1_mediator.NewA1ControllerDeletePolicyType(o.context, o.A1MediatorA1ControllerDeletePolicyTypeHandler)
362 if o.handlers["GET"] == nil {
363 o.handlers["GET"] = make(map[string]http.Handler)
365 o.handlers["GET"]["/a1-p/policytypes/{policy_type_id}/policies"] = a1_mediator.NewA1ControllerGetAllInstancesForType(o.context, o.A1MediatorA1ControllerGetAllInstancesForTypeHandler)
366 if o.handlers["GET"] == nil {
367 o.handlers["GET"] = make(map[string]http.Handler)
369 o.handlers["GET"]["/a1-p/policytypes"] = a1_mediator.NewA1ControllerGetAllPolicyTypes(o.context, o.A1MediatorA1ControllerGetAllPolicyTypesHandler)
370 if o.handlers["GET"] == nil {
371 o.handlers["GET"] = make(map[string]http.Handler)
373 o.handlers["GET"]["/a1-p/healthcheck"] = a1_mediator.NewA1ControllerGetHealthcheck(o.context, o.A1MediatorA1ControllerGetHealthcheckHandler)
374 if o.handlers["GET"] == nil {
375 o.handlers["GET"] = make(map[string]http.Handler)
377 o.handlers["GET"]["/a1-p/policytypes/{policy_type_id}/policies/{policy_instance_id}"] = a1_mediator.NewA1ControllerGetPolicyInstance(o.context, o.A1MediatorA1ControllerGetPolicyInstanceHandler)
378 if o.handlers["GET"] == nil {
379 o.handlers["GET"] = make(map[string]http.Handler)
381 o.handlers["GET"]["/a1-p/policytypes/{policy_type_id}/policies/{policy_instance_id}/status"] = a1_mediator.NewA1ControllerGetPolicyInstanceStatus(o.context, o.A1MediatorA1ControllerGetPolicyInstanceStatusHandler)
382 if o.handlers["GET"] == nil {
383 o.handlers["GET"] = make(map[string]http.Handler)
385 o.handlers["GET"]["/a1-p/policytypes/{policy_type_id}"] = a1_mediator.NewA1ControllerGetPolicyType(o.context, o.A1MediatorA1ControllerGetPolicyTypeHandler)
388 // Serve creates a http handler to serve the API over HTTP
389 // can be used directly in http.ListenAndServe(":8000", api.Serve(nil))
390 func (o *A1API) Serve(builder middleware.Builder) http.Handler {
393 if o.Middleware != nil {
394 return o.Middleware(builder)
396 return o.context.APIHandler(builder)
399 // Init allows you to just initialize the handler cache, you can then recompose the middleware as you see fit
400 func (o *A1API) Init() {
401 if len(o.handlers) == 0 {
406 // RegisterConsumer allows you to add (or override) a consumer for a media type.
407 func (o *A1API) RegisterConsumer(mediaType string, consumer runtime.Consumer) {
408 o.customConsumers[mediaType] = consumer
411 // RegisterProducer allows you to add (or override) a producer for a media type.
412 func (o *A1API) RegisterProducer(mediaType string, producer runtime.Producer) {
413 o.customProducers[mediaType] = producer
416 // AddMiddlewareFor adds a http middleware to existing handler
417 func (o *A1API) AddMiddlewareFor(method, path string, builder middleware.Builder) {
418 um := strings.ToUpper(method)
423 if h, ok := o.handlers[um][path]; ok {
424 o.handlers[method][path] = builder(h)