Move capifcore code to separate folder
[nonrtric/plt/sme.git] / capifcore / internal / securityapi / securityapi-server.gen.go
1 // Package securityapi 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 securityapi
5
6 import (
7         "bytes"
8         "compress/gzip"
9         "encoding/base64"
10         "fmt"
11         "net/http"
12         "net/url"
13         "path"
14         "strings"
15
16         "github.com/deepmap/oapi-codegen/pkg/runtime"
17         "github.com/getkin/kin-openapi/openapi3"
18         "github.com/labstack/echo/v4"
19         externalRef0 "oransc.org/nonrtric/capifcore/internal/common29122"
20         externalRef1 "oransc.org/nonrtric/capifcore/internal/common29571"
21         externalRef2 "oransc.org/nonrtric/capifcore/internal/publishserviceapi"
22 )
23
24 // ServerInterface represents all server handlers.
25 type ServerInterface interface {
26
27         // (POST /securities/{securityId}/token)
28         PostSecuritiesSecurityIdToken(ctx echo.Context, securityId string) error
29
30         // (DELETE /trustedInvokers/{apiInvokerId})
31         DeleteTrustedInvokersApiInvokerId(ctx echo.Context, apiInvokerId string) error
32
33         // (GET /trustedInvokers/{apiInvokerId})
34         GetTrustedInvokersApiInvokerId(ctx echo.Context, apiInvokerId string, params GetTrustedInvokersApiInvokerIdParams) error
35
36         // (PUT /trustedInvokers/{apiInvokerId})
37         PutTrustedInvokersApiInvokerId(ctx echo.Context, apiInvokerId string) error
38
39         // (POST /trustedInvokers/{apiInvokerId}/delete)
40         PostTrustedInvokersApiInvokerIdDelete(ctx echo.Context, apiInvokerId string) error
41
42         // (POST /trustedInvokers/{apiInvokerId}/update)
43         PostTrustedInvokersApiInvokerIdUpdate(ctx echo.Context, apiInvokerId string) error
44 }
45
46 // ServerInterfaceWrapper converts echo contexts to parameters.
47 type ServerInterfaceWrapper struct {
48         Handler ServerInterface
49 }
50
51 // PostSecuritiesSecurityIdToken converts echo context to params.
52 func (w *ServerInterfaceWrapper) PostSecuritiesSecurityIdToken(ctx echo.Context) error {
53         var err error
54         // ------------- Path parameter "securityId" -------------
55         var securityId string
56
57         err = runtime.BindStyledParameterWithLocation("simple", false, "securityId", runtime.ParamLocationPath, ctx.Param("securityId"), &securityId)
58         if err != nil {
59                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter securityId: %s", err))
60         }
61
62         // Invoke the callback with all the unmarshalled arguments
63         err = w.Handler.PostSecuritiesSecurityIdToken(ctx, securityId)
64         return err
65 }
66
67 // DeleteTrustedInvokersApiInvokerId converts echo context to params.
68 func (w *ServerInterfaceWrapper) DeleteTrustedInvokersApiInvokerId(ctx echo.Context) error {
69         var err error
70         // ------------- Path parameter "apiInvokerId" -------------
71         var apiInvokerId string
72
73         err = runtime.BindStyledParameterWithLocation("simple", false, "apiInvokerId", runtime.ParamLocationPath, ctx.Param("apiInvokerId"), &apiInvokerId)
74         if err != nil {
75                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter apiInvokerId: %s", err))
76         }
77
78         // Invoke the callback with all the unmarshalled arguments
79         err = w.Handler.DeleteTrustedInvokersApiInvokerId(ctx, apiInvokerId)
80         return err
81 }
82
83 // GetTrustedInvokersApiInvokerId converts echo context to params.
84 func (w *ServerInterfaceWrapper) GetTrustedInvokersApiInvokerId(ctx echo.Context) error {
85         var err error
86         // ------------- Path parameter "apiInvokerId" -------------
87         var apiInvokerId string
88
89         err = runtime.BindStyledParameterWithLocation("simple", false, "apiInvokerId", runtime.ParamLocationPath, ctx.Param("apiInvokerId"), &apiInvokerId)
90         if err != nil {
91                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter apiInvokerId: %s", err))
92         }
93
94         // Parameter object where we will unmarshal all parameters from the context
95         var params GetTrustedInvokersApiInvokerIdParams
96         // ------------- Optional query parameter "authenticationInfo" -------------
97
98         err = runtime.BindQueryParameter("form", true, false, "authenticationInfo", ctx.QueryParams(), &params.AuthenticationInfo)
99         if err != nil {
100                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter authenticationInfo: %s", err))
101         }
102
103         // ------------- Optional query parameter "authorizationInfo" -------------
104
105         err = runtime.BindQueryParameter("form", true, false, "authorizationInfo", ctx.QueryParams(), &params.AuthorizationInfo)
106         if err != nil {
107                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter authorizationInfo: %s", err))
108         }
109
110         // Invoke the callback with all the unmarshalled arguments
111         err = w.Handler.GetTrustedInvokersApiInvokerId(ctx, apiInvokerId, params)
112         return err
113 }
114
115 // PutTrustedInvokersApiInvokerId converts echo context to params.
116 func (w *ServerInterfaceWrapper) PutTrustedInvokersApiInvokerId(ctx echo.Context) error {
117         var err error
118         // ------------- Path parameter "apiInvokerId" -------------
119         var apiInvokerId string
120
121         err = runtime.BindStyledParameterWithLocation("simple", false, "apiInvokerId", runtime.ParamLocationPath, ctx.Param("apiInvokerId"), &apiInvokerId)
122         if err != nil {
123                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter apiInvokerId: %s", err))
124         }
125
126         // Invoke the callback with all the unmarshalled arguments
127         err = w.Handler.PutTrustedInvokersApiInvokerId(ctx, apiInvokerId)
128         return err
129 }
130
131 // PostTrustedInvokersApiInvokerIdDelete converts echo context to params.
132 func (w *ServerInterfaceWrapper) PostTrustedInvokersApiInvokerIdDelete(ctx echo.Context) error {
133         var err error
134         // ------------- Path parameter "apiInvokerId" -------------
135         var apiInvokerId string
136
137         err = runtime.BindStyledParameterWithLocation("simple", false, "apiInvokerId", runtime.ParamLocationPath, ctx.Param("apiInvokerId"), &apiInvokerId)
138         if err != nil {
139                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter apiInvokerId: %s", err))
140         }
141
142         // Invoke the callback with all the unmarshalled arguments
143         err = w.Handler.PostTrustedInvokersApiInvokerIdDelete(ctx, apiInvokerId)
144         return err
145 }
146
147 // PostTrustedInvokersApiInvokerIdUpdate converts echo context to params.
148 func (w *ServerInterfaceWrapper) PostTrustedInvokersApiInvokerIdUpdate(ctx echo.Context) error {
149         var err error
150         // ------------- Path parameter "apiInvokerId" -------------
151         var apiInvokerId string
152
153         err = runtime.BindStyledParameterWithLocation("simple", false, "apiInvokerId", runtime.ParamLocationPath, ctx.Param("apiInvokerId"), &apiInvokerId)
154         if err != nil {
155                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter apiInvokerId: %s", err))
156         }
157
158         // Invoke the callback with all the unmarshalled arguments
159         err = w.Handler.PostTrustedInvokersApiInvokerIdUpdate(ctx, apiInvokerId)
160         return err
161 }
162
163 // This is a simple interface which specifies echo.Route addition functions which
164 // are present on both echo.Echo and echo.Group, since we want to allow using
165 // either of them for path registration
166 type EchoRouter interface {
167         CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
168         DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
169         GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
170         HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
171         OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
172         PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
173         POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
174         PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
175         TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
176 }
177
178 // RegisterHandlers adds each server route to the EchoRouter.
179 func RegisterHandlers(router EchoRouter, si ServerInterface) {
180         RegisterHandlersWithBaseURL(router, si, "")
181 }
182
183 // Registers handlers, and prepends BaseURL to the paths, so that the paths
184 // can be served under a prefix.
185 func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) {
186
187         wrapper := ServerInterfaceWrapper{
188                 Handler: si,
189         }
190
191         router.POST(baseURL+"/securities/:securityId/token", wrapper.PostSecuritiesSecurityIdToken)
192         router.DELETE(baseURL+"/trustedInvokers/:apiInvokerId", wrapper.DeleteTrustedInvokersApiInvokerId)
193         router.GET(baseURL+"/trustedInvokers/:apiInvokerId", wrapper.GetTrustedInvokersApiInvokerId)
194         router.PUT(baseURL+"/trustedInvokers/:apiInvokerId", wrapper.PutTrustedInvokersApiInvokerId)
195         router.POST(baseURL+"/trustedInvokers/:apiInvokerId/delete", wrapper.PostTrustedInvokersApiInvokerIdDelete)
196         router.POST(baseURL+"/trustedInvokers/:apiInvokerId/update", wrapper.PostTrustedInvokersApiInvokerIdUpdate)
197
198 }
199
200 // Base64 encoded, gzipped, json marshaled Swagger object
201 var swaggerSpec = []string{
202
203         "H4sIAAAAAAAC/+xa/W7jNhJ/FUI9oLuAItnepNv4P6/jXbhoEyNyugf0AoOWxjYbidSSlJ1c4Ae617gn",
204         "O5CUZH3ZTuKml94ZWGxsmTOcz98MR3y0fBbFjAKVwuo+WsJfQIT1x57vgxBjdgd0wLl6EoDwOYklYdTq",
205         "WtcQcxCKEGGKgHPGEaFILgBhTYqkokUcviUgpGPZVsxZDFwS0BtoEv2BJpHV/c0idIlDEkxSCsvOn/gh",
206         "AVp8MOdYf08oTuSCcfJPKKxKqEjimHEJ6cqJfIihQC58FoN1a1v6edcSkhM6t9a2EWpS0vRx26qEk4Zf",
207         "17alFCAcAqWU0XKzFZv+Dr5UTAoGvoZvOw28zaiI0BnjEVYUysDmi9W17k9Wq9WJ+nqS8BCozwIIah4w",
208         "BpuQoFHJ9FcBPgfZuKJg24IbUzqfQwBUEhyKRksbH+y1X8l/G4H3GVTEzzWoiBkVULVo2WCGZKJJ6vx/",
209         "+uqhPoti7EvkASc4VGGJeLatZorYDKmFgswpBOgn7+oSGRXQu4IC/RCTSLy3mkL0PiYcxIRoEf7GYWZ1",
210         "rbHXOW93OpM+iyJGL7DEzgOOwu/cTX67aXK7FwnXonjg73KEbWk9a/79BJgDb/BpxXMlY5WYlXRo8mQf",
211         "JwLqBh4xIcg0BLTEYQICYQ7oBF39Orj+efjLcDy58XpfBl00XgDisGR+bnDt7hQoSg97oyEidMnugCMi",
212         "UJAAkkz/wpbAQxIRiRKB55ARCOBL4hvCE3RzOfj7aNAfDy4m14Oed3X5B2yeULiPwZc6crBg1PmHMl9m",
213         "/Yq2lm3VhGhMNw/8hBP5MNzE994MIVQCn2EfUAASk1AhfZCawXBDEcgFC1SmMApXM6v722MpCHIWF4aD",
214         "dbu2yyswzIaBdbu+rSWb/qEm41CjyowAL9oR7mMmCJ2jWUJ9vbLBBjgmTRy1H3KujYSJXKjfjVOVCRu4",
215         "lNYgDiFWPizgyTbOeWBsZ7yJnSfyrdm9DBUdBRW90fDzZJRMQyIWE88E9qQ3Gm5HjuGG60bCtXIczLIA",
216         "+0VHhKjr4ZVjRiBFBZxDgKYPtYSYMV54lm6r4oxIiP4gdcoiK0UiQoeGfzs3KuYcP2ighLBC8SpSVGC0",
217         "ybZNmJmtuWQqjv39Ga5Q6g6CCjbRAnmW9g2FsDk3PR1/WTI9qM/ah4PPztZ8FE9J8QLsFkOgxnGn/9R2",
218         "JrqeI3shJrFIq3Yar9rZyGcccthp1NPPylkaLI1hYGperYgWZc4tlrFsjgNtqiwc9oJ8Bu25pUtZqvMQ",
219         "sL8oVb5NQqKvC6CIUD9MgsZEthFRbWqgQgrMjpu8T/dgs3zbLQwbLN3AuCq7ZGgKKBEQ5HDSrEUtvotZ",
220         "cAFCEprn0wsarhtOrNSvIOQYhNydpB5I3YbwBJQBiiEoWd77b7GLWiKABggjqZaVEhoLFMCMUF1A1D+R",
221         "TP1QxRL66PzgoHTnGQ4FIMYRi4hU1YbJBfAVEVCI7yljIWBqkHHTXCh1qhi9E/eKHYlJYRKpXqcJgbNj",
222         "3WfAMuFQrQNnH9tPcohX47O2rRVMBfPvtGv6jM7I/IXu/lpnVE3rksHsreFWz++1PgBI4BSHF8xvAM8P",
223         "X0YjNPZQ59zpdDro1/ZH59RpISO4jqXPHEewYvxOZ4Vef8m4XExZQgO1QgFMwkOray2kjEXXdVerlfNh",
224         "HscO43N3JmPXi8EXLub+gizB7ZxPBHACwjW7uqYFaexmRkO9rYncTcZiiucQAZUO+ve/UKfV6dhGtCs+",
225         "xzStTjhEI8wlBS7Qu9718JONeuOhZ6N+3+vZaDD2hjYaexf6z7in/uu/d1AvDBEn84UuegoBQHeskshQ",
226         "2dbU7CwcJ6bGLIELI3Hb6TitExzGC+x0lGIsBopjomzttJyWAg8sF9oVbqqQMsVj7uRg7eZHxpgJfZhW",
227         "aGOavsCcbKSXk+aZEYzTw1OMlc8kcKE77F3lElONiksSJDgsYoeef1hdLayKORzpKpXvZRVDVGGPnY6D",
228         "mg7ptzmcfWKBLjI+oxKo1g3HcZhGs9s8ichHTftAojIkWZcTSUmpH5jDu3ZBp9XaIc7vwgDu83cXsdm9",
229         "AtWJXjJLQmQWI70aXaczrLVtfWh9fCaQ5Pq4ilaz+PEAFj8qFqevY5YB501mGRTHgc2G0VSu5ImQEKQ9",
230         "jnAfiw3P2sBHCBLqKXOhn4/L9L1yu/R6aVPpy56ZOKVwPa2D5CVDfeMo9K4QYdoUhQEC3BNVK+aqiufk",
231         "799czL2IhaLVLNoHsGgbFh8OYPHBsDg9gMWpZtE5fzmLzrlicXaAOc+MOc8OsMWZsUUAM5yE8sVsMnqd",
232         "/3NoKIZfQP7l0tquiqGPMcK0098r6u8bDiy72vdsbFiYKRVmPg0zxCd271rrbwnwh4La9flWg7J5w/+K",
233         "2m4GEa+qbHnktlPX21fsL6pn9YZKOi6eaxuGf0XbpKGLplgdeZmpvtlxccZZtH1c6hyrxpusGq0fDmDx",
234         "g2bRPkCK9rF2ba1dcaIZ+TgMp9i/2zc3esxehE9Z8PCdu2XlunhGfNoJ67mQ0zAmftKxak+fKjZ9alG3",
235         "Yzv6NoGlfYAibaNI+wBF2kaR9tkBLM6O2NSMTTqdKwOmRP41j8qvgYB7my6fA5aA8Kbz0jvfSz26xLSi",
236         "9D7kbP+ZshfmBUYNPetcAA60bx+tn9m29w4KyzGhplu/uR5mvSWFVfiQcUMcBEu4DzbCvs94oN+UmUsT",
237         "QvLElwmHLnrEMblmTK5dH8dkdpJZ0l229w19nhMj6/8pXH8joHx4w3jE9VfB9b0DU3czLd3+omFHITBD",
238         "1f+zcrCtIa6+NldCP+02l6oSvdFQX5x4QVtdgPD0ksbxeH7soo9d9JtD2yQO8AFoe2PIj813SV9jlfKF",
239         "nqz9fgfO3EEcTijMmSS1denVwvdPAd7Wf6krN0FzhPQjpB8h/U8fjNiWvv+TAq255LTjqGrZ1hJzgqdh",
240         "eu/VrDQtWypWfkkK7nEUh+D4LLKq+Z8SVi7gFW/fnSl0L1/ecpTMt+v/BAAA///ckgllpTUAAA==",
241 }
242
243 // GetSwagger returns the content of the embedded swagger specification file
244 // or error if failed to decode
245 func decodeSpec() ([]byte, error) {
246         zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, ""))
247         if err != nil {
248                 return nil, fmt.Errorf("error base64 decoding spec: %s", err)
249         }
250         zr, err := gzip.NewReader(bytes.NewReader(zipped))
251         if err != nil {
252                 return nil, fmt.Errorf("error decompressing spec: %s", err)
253         }
254         var buf bytes.Buffer
255         _, err = buf.ReadFrom(zr)
256         if err != nil {
257                 return nil, fmt.Errorf("error decompressing spec: %s", err)
258         }
259
260         return buf.Bytes(), nil
261 }
262
263 var rawSpec = decodeSpecCached()
264
265 // a naive cached of a decoded swagger spec
266 func decodeSpecCached() func() ([]byte, error) {
267         data, err := decodeSpec()
268         return func() ([]byte, error) {
269                 return data, err
270         }
271 }
272
273 // Constructs a synthetic filesystem for resolving external references when loading openapi specifications.
274 func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) {
275         var res = make(map[string]func() ([]byte, error))
276         if len(pathToFile) > 0 {
277                 res[pathToFile] = rawSpec
278         }
279
280         pathPrefix := path.Dir(pathToFile)
281
282         for rawPath, rawFunc := range externalRef0.PathToRawSpec(path.Join(pathPrefix, "TS29122_CommonData.yaml")) {
283                 if _, ok := res[rawPath]; ok {
284                         // it is not possible to compare functions in golang, so always overwrite the old value
285                 }
286                 res[rawPath] = rawFunc
287         }
288         for rawPath, rawFunc := range externalRef2.PathToRawSpec(path.Join(pathPrefix, "TS29222_CAPIF_Publish_Service_API.yaml")) {
289                 if _, ok := res[rawPath]; ok {
290                         // it is not possible to compare functions in golang, so always overwrite the old value
291                 }
292                 res[rawPath] = rawFunc
293         }
294         for rawPath, rawFunc := range externalRef1.PathToRawSpec(path.Join(pathPrefix, "TS29571_CommonData.yaml")) {
295                 if _, ok := res[rawPath]; ok {
296                         // it is not possible to compare functions in golang, so always overwrite the old value
297                 }
298                 res[rawPath] = rawFunc
299         }
300         return res
301 }
302
303 // GetSwagger returns the Swagger specification corresponding to the generated code
304 // in this file. The external references of Swagger specification are resolved.
305 // The logic of resolving external references is tightly connected to "import-mapping" feature.
306 // Externally referenced files must be embedded in the corresponding golang packages.
307 // Urls can be supported but this task was out of the scope.
308 func GetSwagger() (swagger *openapi3.T, err error) {
309         var resolvePath = PathToRawSpec("")
310
311         loader := openapi3.NewLoader()
312         loader.IsExternalRefsAllowed = true
313         loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) {
314                 var pathToFile = url.String()
315                 pathToFile = path.Clean(pathToFile)
316                 getSpec, ok := resolvePath[pathToFile]
317                 if !ok {
318                         err1 := fmt.Errorf("path not found: %s", pathToFile)
319                         return nil, err1
320                 }
321                 return getSpec()
322         }
323         var specData []byte
324         specData, err = rawSpec()
325         if err != nil {
326                 return
327         }
328         swagger, err = loader.LoadFromData(specData)
329         if err != nil {
330                 return
331         }
332         return
333 }