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() {},
59 ServeError: errors.ServeError,
60 BasicAuthenticator: security.BasicAuth,
61 APIKeyAuthenticator: security.APIKeyAuth,
62 BearerAuthenticator: security.BearerAuth,
64 JSONConsumer: runtime.JSONConsumer(),
66 JSONProducer: runtime.JSONProducer(),
68 A1MediatorA1ControllerCreateOrReplacePolicyInstanceHandler: a1_mediator.A1ControllerCreateOrReplacePolicyInstanceHandlerFunc(func(params a1_mediator.A1ControllerCreateOrReplacePolicyInstanceParams) middleware.Responder {
69 return middleware.NotImplemented("operation a1_mediator.A1ControllerCreateOrReplacePolicyInstance has not yet been implemented")
71 A1MediatorA1ControllerCreatePolicyTypeHandler: a1_mediator.A1ControllerCreatePolicyTypeHandlerFunc(func(params a1_mediator.A1ControllerCreatePolicyTypeParams) middleware.Responder {
72 return middleware.NotImplemented("operation a1_mediator.A1ControllerCreatePolicyType has not yet been implemented")
74 A1eiDataDeliveryA1ControllerDataDeliveryHandler: a1_e_i_data_delivery.A1ControllerDataDeliveryHandlerFunc(func(params a1_e_i_data_delivery.A1ControllerDataDeliveryParams) middleware.Responder {
75 return middleware.NotImplemented("operation a1_e_i_data_delivery.A1ControllerDataDelivery has not yet been implemented")
77 A1MediatorA1ControllerDeletePolicyInstanceHandler: a1_mediator.A1ControllerDeletePolicyInstanceHandlerFunc(func(params a1_mediator.A1ControllerDeletePolicyInstanceParams) middleware.Responder {
78 return middleware.NotImplemented("operation a1_mediator.A1ControllerDeletePolicyInstance has not yet been implemented")
80 A1MediatorA1ControllerDeletePolicyTypeHandler: a1_mediator.A1ControllerDeletePolicyTypeHandlerFunc(func(params a1_mediator.A1ControllerDeletePolicyTypeParams) middleware.Responder {
81 return middleware.NotImplemented("operation a1_mediator.A1ControllerDeletePolicyType has not yet been implemented")
83 A1MediatorA1ControllerGetAllInstancesForTypeHandler: a1_mediator.A1ControllerGetAllInstancesForTypeHandlerFunc(func(params a1_mediator.A1ControllerGetAllInstancesForTypeParams) middleware.Responder {
84 return middleware.NotImplemented("operation a1_mediator.A1ControllerGetAllInstancesForType has not yet been implemented")
86 A1MediatorA1ControllerGetAllPolicyTypesHandler: a1_mediator.A1ControllerGetAllPolicyTypesHandlerFunc(func(params a1_mediator.A1ControllerGetAllPolicyTypesParams) middleware.Responder {
87 return middleware.NotImplemented("operation a1_mediator.A1ControllerGetAllPolicyTypes has not yet been implemented")
89 A1MediatorA1ControllerGetHealthcheckHandler: a1_mediator.A1ControllerGetHealthcheckHandlerFunc(func(params a1_mediator.A1ControllerGetHealthcheckParams) middleware.Responder {
90 return middleware.NotImplemented("operation a1_mediator.A1ControllerGetHealthcheck has not yet been implemented")
92 A1MediatorA1ControllerGetPolicyInstanceHandler: a1_mediator.A1ControllerGetPolicyInstanceHandlerFunc(func(params a1_mediator.A1ControllerGetPolicyInstanceParams) middleware.Responder {
93 return middleware.NotImplemented("operation a1_mediator.A1ControllerGetPolicyInstance has not yet been implemented")
95 A1MediatorA1ControllerGetPolicyInstanceStatusHandler: a1_mediator.A1ControllerGetPolicyInstanceStatusHandlerFunc(func(params a1_mediator.A1ControllerGetPolicyInstanceStatusParams) middleware.Responder {
96 return middleware.NotImplemented("operation a1_mediator.A1ControllerGetPolicyInstanceStatus has not yet been implemented")
98 A1MediatorA1ControllerGetPolicyTypeHandler: a1_mediator.A1ControllerGetPolicyTypeHandlerFunc(func(params a1_mediator.A1ControllerGetPolicyTypeParams) middleware.Responder {
99 return middleware.NotImplemented("operation a1_mediator.A1ControllerGetPolicyType has not yet been implemented")
104 /*A1API the a1 API */
107 context *middleware.Context
108 handlers map[string]map[string]http.Handler
109 formats strfmt.Registry
110 customConsumers map[string]runtime.Consumer
111 customProducers map[string]runtime.Producer
112 defaultConsumes string
113 defaultProduces string
114 Middleware func(middleware.Builder) http.Handler
117 // BasicAuthenticator generates a runtime.Authenticator from the supplied basic auth function.
118 // It has a default implementation in the security package, however you can replace it for your particular usage.
119 BasicAuthenticator func(security.UserPassAuthentication) runtime.Authenticator
121 // APIKeyAuthenticator generates a runtime.Authenticator from the supplied token auth function.
122 // It has a default implementation in the security package, however you can replace it for your particular usage.
123 APIKeyAuthenticator func(string, string, security.TokenAuthentication) runtime.Authenticator
125 // BearerAuthenticator generates a runtime.Authenticator from the supplied bearer token auth function.
126 // It has a default implementation in the security package, however you can replace it for your particular usage.
127 BearerAuthenticator func(string, security.ScopedTokenAuthentication) runtime.Authenticator
129 // JSONConsumer registers a consumer for the following mime types:
130 // - application/json
131 JSONConsumer runtime.Consumer
133 // JSONProducer registers a producer for the following mime types:
134 // - application/json
135 JSONProducer runtime.Producer
137 // A1MediatorA1ControllerCreateOrReplacePolicyInstanceHandler sets the operation handler for the a1 controller create or replace policy instance operation
138 A1MediatorA1ControllerCreateOrReplacePolicyInstanceHandler a1_mediator.A1ControllerCreateOrReplacePolicyInstanceHandler
139 // A1MediatorA1ControllerCreatePolicyTypeHandler sets the operation handler for the a1 controller create policy type operation
140 A1MediatorA1ControllerCreatePolicyTypeHandler a1_mediator.A1ControllerCreatePolicyTypeHandler
141 // A1eiDataDeliveryA1ControllerDataDeliveryHandler sets the operation handler for the a1 controller data delivery operation
142 A1eiDataDeliveryA1ControllerDataDeliveryHandler a1_e_i_data_delivery.A1ControllerDataDeliveryHandler
143 // A1MediatorA1ControllerDeletePolicyInstanceHandler sets the operation handler for the a1 controller delete policy instance operation
144 A1MediatorA1ControllerDeletePolicyInstanceHandler a1_mediator.A1ControllerDeletePolicyInstanceHandler
145 // A1MediatorA1ControllerDeletePolicyTypeHandler sets the operation handler for the a1 controller delete policy type operation
146 A1MediatorA1ControllerDeletePolicyTypeHandler a1_mediator.A1ControllerDeletePolicyTypeHandler
147 // A1MediatorA1ControllerGetAllInstancesForTypeHandler sets the operation handler for the a1 controller get all instances for type operation
148 A1MediatorA1ControllerGetAllInstancesForTypeHandler a1_mediator.A1ControllerGetAllInstancesForTypeHandler
149 // A1MediatorA1ControllerGetAllPolicyTypesHandler sets the operation handler for the a1 controller get all policy types operation
150 A1MediatorA1ControllerGetAllPolicyTypesHandler a1_mediator.A1ControllerGetAllPolicyTypesHandler
151 // A1MediatorA1ControllerGetHealthcheckHandler sets the operation handler for the a1 controller get healthcheck operation
152 A1MediatorA1ControllerGetHealthcheckHandler a1_mediator.A1ControllerGetHealthcheckHandler
153 // A1MediatorA1ControllerGetPolicyInstanceHandler sets the operation handler for the a1 controller get policy instance operation
154 A1MediatorA1ControllerGetPolicyInstanceHandler a1_mediator.A1ControllerGetPolicyInstanceHandler
155 // A1MediatorA1ControllerGetPolicyInstanceStatusHandler sets the operation handler for the a1 controller get policy instance status operation
156 A1MediatorA1ControllerGetPolicyInstanceStatusHandler a1_mediator.A1ControllerGetPolicyInstanceStatusHandler
157 // A1MediatorA1ControllerGetPolicyTypeHandler sets the operation handler for the a1 controller get policy type operation
158 A1MediatorA1ControllerGetPolicyTypeHandler a1_mediator.A1ControllerGetPolicyTypeHandler
160 // ServeError is called when an error is received, there is a default handler
161 // but you can set your own with this
162 ServeError func(http.ResponseWriter, *http.Request, error)
164 // PreServerShutdown is called before the HTTP(S) server is shutdown
165 // This allows for custom functions to get executed before the HTTP(S) server stops accepting traffic
166 PreServerShutdown func()
168 // ServerShutdown is called when the HTTP(S) server is shut down and done
169 // handling all active connections and does not accept connections any more
170 ServerShutdown func()
172 // Custom command line argument groups with their descriptions
173 CommandLineOptionsGroups []swag.CommandLineOptionsGroup
175 // User defined logger function.
176 Logger func(string, ...interface{})
179 // UseRedoc for documentation at /docs
180 func (o *A1API) UseRedoc() {
181 o.useSwaggerUI = false
184 // UseSwaggerUI for documentation at /docs
185 func (o *A1API) UseSwaggerUI() {
186 o.useSwaggerUI = true
189 // SetDefaultProduces sets the default produces media type
190 func (o *A1API) SetDefaultProduces(mediaType string) {
191 o.defaultProduces = mediaType
194 // SetDefaultConsumes returns the default consumes media type
195 func (o *A1API) SetDefaultConsumes(mediaType string) {
196 o.defaultConsumes = mediaType
199 // SetSpec sets a spec that will be served for the clients.
200 func (o *A1API) SetSpec(spec *loads.Document) {
204 // DefaultProduces returns the default produces media type
205 func (o *A1API) DefaultProduces() string {
206 return o.defaultProduces
209 // DefaultConsumes returns the default consumes media type
210 func (o *A1API) DefaultConsumes() string {
211 return o.defaultConsumes
214 // Formats returns the registered string formats
215 func (o *A1API) Formats() strfmt.Registry {
219 // RegisterFormat registers a custom format validator
220 func (o *A1API) RegisterFormat(name string, format strfmt.Format, validator strfmt.Validator) {
221 o.formats.Add(name, format, validator)
224 // Validate validates the registrations in the A1API
225 func (o *A1API) Validate() error {
226 var unregistered []string
228 if o.JSONConsumer == nil {
229 unregistered = append(unregistered, "JSONConsumer")
232 if o.JSONProducer == nil {
233 unregistered = append(unregistered, "JSONProducer")
236 if o.A1MediatorA1ControllerCreateOrReplacePolicyInstanceHandler == nil {
237 unregistered = append(unregistered, "a1_mediator.A1ControllerCreateOrReplacePolicyInstanceHandler")
239 if o.A1MediatorA1ControllerCreatePolicyTypeHandler == nil {
240 unregistered = append(unregistered, "a1_mediator.A1ControllerCreatePolicyTypeHandler")
242 if o.A1eiDataDeliveryA1ControllerDataDeliveryHandler == nil {
243 unregistered = append(unregistered, "a1_e_i_data_delivery.A1ControllerDataDeliveryHandler")
245 if o.A1MediatorA1ControllerDeletePolicyInstanceHandler == nil {
246 unregistered = append(unregistered, "a1_mediator.A1ControllerDeletePolicyInstanceHandler")
248 if o.A1MediatorA1ControllerDeletePolicyTypeHandler == nil {
249 unregistered = append(unregistered, "a1_mediator.A1ControllerDeletePolicyTypeHandler")
251 if o.A1MediatorA1ControllerGetAllInstancesForTypeHandler == nil {
252 unregistered = append(unregistered, "a1_mediator.A1ControllerGetAllInstancesForTypeHandler")
254 if o.A1MediatorA1ControllerGetAllPolicyTypesHandler == nil {
255 unregistered = append(unregistered, "a1_mediator.A1ControllerGetAllPolicyTypesHandler")
257 if o.A1MediatorA1ControllerGetHealthcheckHandler == nil {
258 unregistered = append(unregistered, "a1_mediator.A1ControllerGetHealthcheckHandler")
260 if o.A1MediatorA1ControllerGetPolicyInstanceHandler == nil {
261 unregistered = append(unregistered, "a1_mediator.A1ControllerGetPolicyInstanceHandler")
263 if o.A1MediatorA1ControllerGetPolicyInstanceStatusHandler == nil {
264 unregistered = append(unregistered, "a1_mediator.A1ControllerGetPolicyInstanceStatusHandler")
266 if o.A1MediatorA1ControllerGetPolicyTypeHandler == nil {
267 unregistered = append(unregistered, "a1_mediator.A1ControllerGetPolicyTypeHandler")
270 if len(unregistered) > 0 {
271 return fmt.Errorf("missing registration: %s", strings.Join(unregistered, ", "))
277 // ServeErrorFor gets a error handler for a given operation id
278 func (o *A1API) ServeErrorFor(operationID string) func(http.ResponseWriter, *http.Request, error) {
282 // AuthenticatorsFor gets the authenticators for the specified security schemes
283 func (o *A1API) AuthenticatorsFor(schemes map[string]spec.SecurityScheme) map[string]runtime.Authenticator {
287 // Authorizer returns the registered authorizer
288 func (o *A1API) Authorizer() runtime.Authorizer {
292 // ConsumersFor gets the consumers for the specified media types.
293 // MIME type parameters are ignored here.
294 func (o *A1API) ConsumersFor(mediaTypes []string) map[string]runtime.Consumer {
295 result := make(map[string]runtime.Consumer, len(mediaTypes))
296 for _, mt := range mediaTypes {
298 case "application/json":
299 result["application/json"] = o.JSONConsumer
302 if c, ok := o.customConsumers[mt]; ok {
309 // ProducersFor gets the producers for the specified media types.
310 // MIME type parameters are ignored here.
311 func (o *A1API) ProducersFor(mediaTypes []string) map[string]runtime.Producer {
312 result := make(map[string]runtime.Producer, len(mediaTypes))
313 for _, mt := range mediaTypes {
315 case "application/json":
316 result["application/json"] = o.JSONProducer
319 if p, ok := o.customProducers[mt]; ok {
326 // HandlerFor gets a http.Handler for the provided operation method and path
327 func (o *A1API) HandlerFor(method, path string) (http.Handler, bool) {
328 if o.handlers == nil {
331 um := strings.ToUpper(method)
332 if _, ok := o.handlers[um]; !ok {
338 h, ok := o.handlers[um][path]
342 // Context returns the middleware context for the a1 API
343 func (o *A1API) Context() *middleware.Context {
344 if o.context == nil {
345 o.context = middleware.NewRoutableContext(o.spec, o, nil)
351 func (o *A1API) initHandlerCache() {
352 o.Context() // don't care about the result, just that the initialization happened
353 if o.handlers == nil {
354 o.handlers = make(map[string]map[string]http.Handler)
357 if o.handlers["PUT"] == nil {
358 o.handlers["PUT"] = make(map[string]http.Handler)
360 o.handlers["PUT"]["/a1-p/policytypes/{policy_type_id}/policies/{policy_instance_id}"] = a1_mediator.NewA1ControllerCreateOrReplacePolicyInstance(o.context, o.A1MediatorA1ControllerCreateOrReplacePolicyInstanceHandler)
361 if o.handlers["PUT"] == nil {
362 o.handlers["PUT"] = make(map[string]http.Handler)
364 o.handlers["PUT"]["/a1-p/policytypes/{policy_type_id}"] = a1_mediator.NewA1ControllerCreatePolicyType(o.context, o.A1MediatorA1ControllerCreatePolicyTypeHandler)
365 if o.handlers["POST"] == nil {
366 o.handlers["POST"] = make(map[string]http.Handler)
368 o.handlers["POST"]["/data-delivery"] = a1_e_i_data_delivery.NewA1ControllerDataDelivery(o.context, o.A1eiDataDeliveryA1ControllerDataDeliveryHandler)
369 if o.handlers["DELETE"] == nil {
370 o.handlers["DELETE"] = make(map[string]http.Handler)
372 o.handlers["DELETE"]["/a1-p/policytypes/{policy_type_id}/policies/{policy_instance_id}"] = a1_mediator.NewA1ControllerDeletePolicyInstance(o.context, o.A1MediatorA1ControllerDeletePolicyInstanceHandler)
373 if o.handlers["DELETE"] == nil {
374 o.handlers["DELETE"] = make(map[string]http.Handler)
376 o.handlers["DELETE"]["/a1-p/policytypes/{policy_type_id}"] = a1_mediator.NewA1ControllerDeletePolicyType(o.context, o.A1MediatorA1ControllerDeletePolicyTypeHandler)
377 if o.handlers["GET"] == nil {
378 o.handlers["GET"] = make(map[string]http.Handler)
380 o.handlers["GET"]["/a1-p/policytypes/{policy_type_id}/policies"] = a1_mediator.NewA1ControllerGetAllInstancesForType(o.context, o.A1MediatorA1ControllerGetAllInstancesForTypeHandler)
381 if o.handlers["GET"] == nil {
382 o.handlers["GET"] = make(map[string]http.Handler)
384 o.handlers["GET"]["/a1-p/policytypes"] = a1_mediator.NewA1ControllerGetAllPolicyTypes(o.context, o.A1MediatorA1ControllerGetAllPolicyTypesHandler)
385 if o.handlers["GET"] == nil {
386 o.handlers["GET"] = make(map[string]http.Handler)
388 o.handlers["GET"]["/a1-p/healthcheck"] = a1_mediator.NewA1ControllerGetHealthcheck(o.context, o.A1MediatorA1ControllerGetHealthcheckHandler)
389 if o.handlers["GET"] == nil {
390 o.handlers["GET"] = make(map[string]http.Handler)
392 o.handlers["GET"]["/a1-p/policytypes/{policy_type_id}/policies/{policy_instance_id}"] = a1_mediator.NewA1ControllerGetPolicyInstance(o.context, o.A1MediatorA1ControllerGetPolicyInstanceHandler)
393 if o.handlers["GET"] == nil {
394 o.handlers["GET"] = make(map[string]http.Handler)
396 o.handlers["GET"]["/a1-p/policytypes/{policy_type_id}/policies/{policy_instance_id}/status"] = a1_mediator.NewA1ControllerGetPolicyInstanceStatus(o.context, o.A1MediatorA1ControllerGetPolicyInstanceStatusHandler)
397 if o.handlers["GET"] == nil {
398 o.handlers["GET"] = make(map[string]http.Handler)
400 o.handlers["GET"]["/a1-p/policytypes/{policy_type_id}"] = a1_mediator.NewA1ControllerGetPolicyType(o.context, o.A1MediatorA1ControllerGetPolicyTypeHandler)
403 // Serve creates a http handler to serve the API over HTTP
404 // can be used directly in http.ListenAndServe(":8000", api.Serve(nil))
405 func (o *A1API) Serve(builder middleware.Builder) http.Handler {
408 if o.Middleware != nil {
409 return o.Middleware(builder)
412 return o.context.APIHandlerSwaggerUI(builder)
414 return o.context.APIHandler(builder)
417 // Init allows you to just initialize the handler cache, you can then recompose the middleware as you see fit
418 func (o *A1API) Init() {
419 if len(o.handlers) == 0 {
424 // RegisterConsumer allows you to add (or override) a consumer for a media type.
425 func (o *A1API) RegisterConsumer(mediaType string, consumer runtime.Consumer) {
426 o.customConsumers[mediaType] = consumer
429 // RegisterProducer allows you to add (or override) a producer for a media type.
430 func (o *A1API) RegisterProducer(mediaType string, producer runtime.Producer) {
431 o.customProducers[mediaType] = producer
434 // AddMiddlewareFor adds a http middleware to existing handler
435 func (o *A1API) AddMiddlewareFor(method, path string, builder middleware.Builder) {
436 um := strings.ToUpper(method)
441 if h, ok := o.handlers[um][path]; ok {
442 o.handlers[method][path] = builder(h)