Policy status notification handling - initial rollup
[ric-plt/a1.git] / pkg / restapi / operations / a1_api.go
index c8a14b1..a526e99 100644 (file)
@@ -39,8 +39,8 @@ import (
        "github.com/go-openapi/strfmt"
        "github.com/go-openapi/swag"
 
-       "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/restapi/operations/a1_e_i_data_delivery"
-       "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/restapi/operations/a1_mediator"
+       "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/restapi/operations/a1_e_i_data_delivery"
+       "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/restapi/operations/a1_mediator"
 )
 
 // NewA1API creates a new A1 instance
@@ -55,6 +55,7 @@ func NewA1API(spec *loads.Document) *A1API {
                PreServerShutdown:   func() {},
                ServerShutdown:      func() {},
                spec:                spec,
+               useSwaggerUI:        false,
                ServeError:          errors.ServeError,
                BasicAuthenticator:  security.BasicAuth,
                APIKeyAuthenticator: security.APIKeyAuth,
@@ -111,13 +112,16 @@ type A1API struct {
        defaultConsumes string
        defaultProduces string
        Middleware      func(middleware.Builder) http.Handler
+       useSwaggerUI    bool
 
        // BasicAuthenticator generates a runtime.Authenticator from the supplied basic auth function.
        // It has a default implementation in the security package, however you can replace it for your particular usage.
        BasicAuthenticator func(security.UserPassAuthentication) runtime.Authenticator
+
        // APIKeyAuthenticator generates a runtime.Authenticator from the supplied token auth function.
        // It has a default implementation in the security package, however you can replace it for your particular usage.
        APIKeyAuthenticator func(string, string, security.TokenAuthentication) runtime.Authenticator
+
        // BearerAuthenticator generates a runtime.Authenticator from the supplied bearer token auth function.
        // It has a default implementation in the security package, however you can replace it for your particular usage.
        BearerAuthenticator func(string, security.ScopedTokenAuthentication) runtime.Authenticator
@@ -152,6 +156,7 @@ type A1API struct {
        A1MediatorA1ControllerGetPolicyInstanceStatusHandler a1_mediator.A1ControllerGetPolicyInstanceStatusHandler
        // A1MediatorA1ControllerGetPolicyTypeHandler sets the operation handler for the a1 controller get policy type operation
        A1MediatorA1ControllerGetPolicyTypeHandler a1_mediator.A1ControllerGetPolicyTypeHandler
+
        // ServeError is called when an error is received, there is a default handler
        // but you can set your own with this
        ServeError func(http.ResponseWriter, *http.Request, error)
@@ -171,6 +176,16 @@ type A1API struct {
        Logger func(string, ...interface{})
 }
 
+// UseRedoc for documentation at /docs
+func (o *A1API) UseRedoc() {
+       o.useSwaggerUI = false
+}
+
+// UseSwaggerUI for documentation at /docs
+func (o *A1API) UseSwaggerUI() {
+       o.useSwaggerUI = true
+}
+
 // SetDefaultProduces sets the default produces media type
 func (o *A1API) SetDefaultProduces(mediaType string) {
        o.defaultProduces = mediaType
@@ -393,6 +408,9 @@ func (o *A1API) Serve(builder middleware.Builder) http.Handler {
        if o.Middleware != nil {
                return o.Middleware(builder)
        }
+       if o.useSwaggerUI {
+               return o.context.APIHandlerSwaggerUI(builder)
+       }
        return o.context.APIHandler(builder)
 }