Add generated code
[nonrtric/plt/sme.git] / capifcore / internal / aefsecurityapi / aefsecurityapi-server.gen.go
1 // Package aefsecurityapi provides primitives to interact with the openapi HTTP API.
2 //
3 // Code generated by github.com/deepmap/oapi-codegen version v1.10.1 DO NOT EDIT.
4 package aefsecurityapi
5
6 import (
7         "bytes"
8         "compress/gzip"
9         "encoding/base64"
10         "fmt"
11         "net/url"
12         "path"
13         "strings"
14
15         "github.com/getkin/kin-openapi/openapi3"
16         "github.com/labstack/echo/v4"
17         externalRef0 "oransc.org/nonrtric/capifcore/internal/common29571"
18 )
19
20 // ServerInterface represents all server handlers.
21 type ServerInterface interface {
22         // Check authentication.
23         // (POST /check-authentication)
24         PostCheckAuthentication(ctx echo.Context) error
25         // Revoke authorization.
26         // (POST /revoke-authorization)
27         PostRevokeAuthorization(ctx echo.Context) error
28 }
29
30 // ServerInterfaceWrapper converts echo contexts to parameters.
31 type ServerInterfaceWrapper struct {
32         Handler ServerInterface
33 }
34
35 // PostCheckAuthentication converts echo context to params.
36 func (w *ServerInterfaceWrapper) PostCheckAuthentication(ctx echo.Context) error {
37         var err error
38
39         // Invoke the callback with all the unmarshalled arguments
40         err = w.Handler.PostCheckAuthentication(ctx)
41         return err
42 }
43
44 // PostRevokeAuthorization converts echo context to params.
45 func (w *ServerInterfaceWrapper) PostRevokeAuthorization(ctx echo.Context) error {
46         var err error
47
48         // Invoke the callback with all the unmarshalled arguments
49         err = w.Handler.PostRevokeAuthorization(ctx)
50         return err
51 }
52
53 // This is a simple interface which specifies echo.Route addition functions which
54 // are present on both echo.Echo and echo.Group, since we want to allow using
55 // either of them for path registration
56 type EchoRouter interface {
57         CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
58         DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
59         GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
60         HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
61         OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
62         PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
63         POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
64         PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
65         TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
66 }
67
68 // RegisterHandlers adds each server route to the EchoRouter.
69 func RegisterHandlers(router EchoRouter, si ServerInterface) {
70         RegisterHandlersWithBaseURL(router, si, "")
71 }
72
73 // Registers handlers, and prepends BaseURL to the paths, so that the paths
74 // can be served under a prefix.
75 func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) {
76
77         wrapper := ServerInterfaceWrapper{
78                 Handler: si,
79         }
80
81         router.POST(baseURL+"/check-authentication", wrapper.PostCheckAuthentication)
82         router.POST(baseURL+"/revoke-authorization", wrapper.PostRevokeAuthorization)
83
84 }
85
86 // Base64 encoded, gzipped, json marshaled Swagger object
87 var swaggerSpec = []string{
88
89         "H4sIAAAAAAAC/+xY3W7iOBR+Fcu7F7tSSEgo6pC7DG1XuZlFgPZmOkImOSGeJrbHdmDYigfa19gnW9lO",
90         "2UKhqhpNpZF6U6L4nM/n5/Pnk97jjNeCM2Ba4fgeq6yEmtjHcQnZXdLoEpimGdGUsyl8Mys5qExSYd7g",
91         "GE9BSFAGAJEDa5QZBCThWwNKo5xo4mMPC8kFSE3B7kIETdma34FM86fYySRF1C2j9AoRpeiKQY6WW6RL",
92         "QONkkt6gjEtARcMyu6nmdumx56akFSDOektOZE7Z6tjChKW3AnCMlZaUrfDOw6oRgksN+Q0Q3UgX7q8S",
93         "Chzj+SwaDS/DxZjXNWdXJrMtqatfgv+rGbSlDGZPcHY7D5uqUAk5jj8f1uDUxl/24fHlV8i0Ce9Ue5R4",
94         "TXuU4EzBmf68XRVelvYUTKFM3lzSv1/Myr0xkrDm2cPjc8yUdqeUFfwo5SiKFpZ5ixlkjaR6u0gm6TOp",
95         "t1afuKZFW/y3JdijVLwOdX4Bvc7U+SeimPGB7xokI9UVz9TTlAd/TCZoPkPRyI+iCP0VXvqh30cuRCsr",
96         "N5LUsOHyDhVcImv/iUtdLnnDcmOhsIcbWeEYl1qLOAg2m40/WAnhc7kKCi2CmYBMBURmJV1DEI0WCiQF",
97         "FbhNA9Mi2lLzqWSaXZPrG6Ra5qGaMLKCGpj2b9m//6CoH4WeC+xPuSKsbRqp0IRIzUAq9FsyTT96KJmn",
98         "Mw+Nx7PEQ9fzWeqh+ezK/swT82f8u3/LkqpCkq5KrUyvQa4h92+ZEVWqK1Pc5PrwsGAPr0EqF3HoR36/",
99         "RypREj80iXEBjAhqSu33/b4hDNGl7URgRat3qGRmQXClza8hln1prhM84UqfEErsaAFKf+T51rhlnGlg",
100         "2t1Iomrtgq/KoTuKPeLlSQKeuTF3hzTUsgH7wh0Km1bU7//QKJRwURxSZV7CXgM3RCHVZBkoVTSVb9ow",
101         "6F8encTQKN8zJ3GfU2B8LcSHDhAfDMSFK82rIIyvhQg7QIQOYtABYuAgLjpAXFiIsEMioUsk7JBI6BIJ",
102         "hx0ghhYiGr0eIhoZiGEHXgwdL4Ydmjp0Tc2hIE2lXw3z4L+z80BdE7nFsZvtjsY139oE7irvHdy1z+vf",
103         "iZv8B+nfmdnsjfXvzOTyrn/v+veufz+H/rkjfPhB4bsTbKdLqXD8+b6doO+JoFPO9S4gUPQeRt5gHZoh",
104         "k0hKltX+Xw3Gzo3Mbdh2/lZxEMB3UosK/IzX+FgnWkdEFMqhoAxyRBlSzTKrSKMAXfpDxAt0+F1g4/2y",
105         "+y8AAP//CPXtp2ERAAA=",
106 }
107
108 // GetSwagger returns the content of the embedded swagger specification file
109 // or error if failed to decode
110 func decodeSpec() ([]byte, error) {
111         zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, ""))
112         if err != nil {
113                 return nil, fmt.Errorf("error base64 decoding spec: %s", err)
114         }
115         zr, err := gzip.NewReader(bytes.NewReader(zipped))
116         if err != nil {
117                 return nil, fmt.Errorf("error decompressing spec: %s", err)
118         }
119         var buf bytes.Buffer
120         _, err = buf.ReadFrom(zr)
121         if err != nil {
122                 return nil, fmt.Errorf("error decompressing spec: %s", err)
123         }
124
125         return buf.Bytes(), nil
126 }
127
128 var rawSpec = decodeSpecCached()
129
130 // a naive cached of a decoded swagger spec
131 func decodeSpecCached() func() ([]byte, error) {
132         data, err := decodeSpec()
133         return func() ([]byte, error) {
134                 return data, err
135         }
136 }
137
138 // Constructs a synthetic filesystem for resolving external references when loading openapi specifications.
139 func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) {
140         var res = make(map[string]func() ([]byte, error))
141         if len(pathToFile) > 0 {
142                 res[pathToFile] = rawSpec
143         }
144
145         pathPrefix := path.Dir(pathToFile)
146
147         for rawPath, rawFunc := range externalRef0.PathToRawSpec(path.Join(pathPrefix, "TS29571_CommonData.yaml")) {
148                 if _, ok := res[rawPath]; ok {
149                         // it is not possible to compare functions in golang, so always overwrite the old value
150                 }
151                 res[rawPath] = rawFunc
152         }
153         return res
154 }
155
156 // GetSwagger returns the Swagger specification corresponding to the generated code
157 // in this file. The external references of Swagger specification are resolved.
158 // The logic of resolving external references is tightly connected to "import-mapping" feature.
159 // Externally referenced files must be embedded in the corresponding golang packages.
160 // Urls can be supported but this task was out of the scope.
161 func GetSwagger() (swagger *openapi3.T, err error) {
162         var resolvePath = PathToRawSpec("")
163
164         loader := openapi3.NewLoader()
165         loader.IsExternalRefsAllowed = true
166         loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) {
167                 var pathToFile = url.String()
168                 pathToFile = path.Clean(pathToFile)
169                 getSpec, ok := resolvePath[pathToFile]
170                 if !ok {
171                         err1 := fmt.Errorf("path not found: %s", pathToFile)
172                         return nil, err1
173                 }
174                 return getSpec()
175         }
176         var specData []byte
177         specData, err = rawSpec()
178         if err != nil {
179                 return
180         }
181         swagger, err = loader.LoadFromData(specData)
182         if err != nil {
183                 return
184         }
185         return
186 }