Move capifcore code to separate folder
[nonrtric/plt/sme.git] / capifcore / internal / auditingapi / auditingapi-server.gen.go
1 // Package auditingapi 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 auditingapi
5
6 import (
7         "bytes"
8         "compress/gzip"
9         "encoding/base64"
10         "encoding/json"
11         "fmt"
12         "net/http"
13         "net/url"
14         "path"
15         "strings"
16
17         "github.com/deepmap/oapi-codegen/pkg/runtime"
18         "github.com/getkin/kin-openapi/openapi3"
19         "github.com/labstack/echo/v4"
20         externalRef0 "oransc.org/nonrtric/capifcore/internal/common29122"
21         externalRef1 "oransc.org/nonrtric/capifcore/internal/common29571"
22         externalRef2 "oransc.org/nonrtric/capifcore/internal/publishserviceapi"
23 )
24
25 // ServerInterface represents all server handlers.
26 type ServerInterface interface {
27
28         // (GET /apiInvocationLogs)
29         GetApiInvocationLogs(ctx echo.Context, params GetApiInvocationLogsParams) error
30 }
31
32 // ServerInterfaceWrapper converts echo contexts to parameters.
33 type ServerInterfaceWrapper struct {
34         Handler ServerInterface
35 }
36
37 // GetApiInvocationLogs converts echo context to params.
38 func (w *ServerInterfaceWrapper) GetApiInvocationLogs(ctx echo.Context) error {
39         var err error
40
41         // Parameter object where we will unmarshal all parameters from the context
42         var params GetApiInvocationLogsParams
43         // ------------- Optional query parameter "aef-id" -------------
44
45         err = runtime.BindQueryParameter("form", true, false, "aef-id", ctx.QueryParams(), &params.AefId)
46         if err != nil {
47                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter aef-id: %s", err))
48         }
49
50         // ------------- Optional query parameter "api-invoker-id" -------------
51
52         err = runtime.BindQueryParameter("form", true, false, "api-invoker-id", ctx.QueryParams(), &params.ApiInvokerId)
53         if err != nil {
54                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter api-invoker-id: %s", err))
55         }
56
57         // ------------- Optional query parameter "time-range-start" -------------
58
59         err = runtime.BindQueryParameter("form", true, false, "time-range-start", ctx.QueryParams(), &params.TimeRangeStart)
60         if err != nil {
61                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter time-range-start: %s", err))
62         }
63
64         // ------------- Optional query parameter "time-range-end" -------------
65
66         err = runtime.BindQueryParameter("form", true, false, "time-range-end", ctx.QueryParams(), &params.TimeRangeEnd)
67         if err != nil {
68                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter time-range-end: %s", err))
69         }
70
71         // ------------- Optional query parameter "api-id" -------------
72
73         err = runtime.BindQueryParameter("form", true, false, "api-id", ctx.QueryParams(), &params.ApiId)
74         if err != nil {
75                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter api-id: %s", err))
76         }
77
78         // ------------- Optional query parameter "api-name" -------------
79
80         err = runtime.BindQueryParameter("form", true, false, "api-name", ctx.QueryParams(), &params.ApiName)
81         if err != nil {
82                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter api-name: %s", err))
83         }
84
85         // ------------- Optional query parameter "api-version" -------------
86
87         err = runtime.BindQueryParameter("form", true, false, "api-version", ctx.QueryParams(), &params.ApiVersion)
88         if err != nil {
89                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter api-version: %s", err))
90         }
91
92         // ------------- Optional query parameter "protocol" -------------
93
94         err = runtime.BindQueryParameter("form", true, false, "protocol", ctx.QueryParams(), &params.Protocol)
95         if err != nil {
96                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter protocol: %s", err))
97         }
98
99         // ------------- Optional query parameter "operation" -------------
100
101         err = runtime.BindQueryParameter("form", true, false, "operation", ctx.QueryParams(), &params.Operation)
102         if err != nil {
103                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter operation: %s", err))
104         }
105
106         // ------------- Optional query parameter "result" -------------
107
108         err = runtime.BindQueryParameter("form", true, false, "result", ctx.QueryParams(), &params.Result)
109         if err != nil {
110                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter result: %s", err))
111         }
112
113         // ------------- Optional query parameter "resource-name" -------------
114
115         err = runtime.BindQueryParameter("form", true, false, "resource-name", ctx.QueryParams(), &params.ResourceName)
116         if err != nil {
117                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter resource-name: %s", err))
118         }
119
120         // ------------- Optional query parameter "src-interface" -------------
121
122         if paramValue := ctx.QueryParam("src-interface"); paramValue != "" {
123
124                 var value externalRef2.InterfaceDescription
125                 err = json.Unmarshal([]byte(paramValue), &value)
126                 if err != nil {
127                         return echo.NewHTTPError(http.StatusBadRequest, "Error unmarshaling parameter 'src-interface' as JSON")
128                 }
129                 params.SrcInterface = &value
130
131         }
132
133         // ------------- Optional query parameter "dest-interface" -------------
134
135         if paramValue := ctx.QueryParam("dest-interface"); paramValue != "" {
136
137                 var value externalRef2.InterfaceDescription
138                 err = json.Unmarshal([]byte(paramValue), &value)
139                 if err != nil {
140                         return echo.NewHTTPError(http.StatusBadRequest, "Error unmarshaling parameter 'dest-interface' as JSON")
141                 }
142                 params.DestInterface = &value
143
144         }
145
146         // ------------- Optional query parameter "supported-features" -------------
147
148         err = runtime.BindQueryParameter("form", true, false, "supported-features", ctx.QueryParams(), &params.SupportedFeatures)
149         if err != nil {
150                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter supported-features: %s", err))
151         }
152
153         // Invoke the callback with all the unmarshalled arguments
154         err = w.Handler.GetApiInvocationLogs(ctx, params)
155         return err
156 }
157
158 // This is a simple interface which specifies echo.Route addition functions which
159 // are present on both echo.Echo and echo.Group, since we want to allow using
160 // either of them for path registration
161 type EchoRouter interface {
162         CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
163         DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
164         GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
165         HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
166         OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
167         PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
168         POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
169         PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
170         TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
171 }
172
173 // RegisterHandlers adds each server route to the EchoRouter.
174 func RegisterHandlers(router EchoRouter, si ServerInterface) {
175         RegisterHandlersWithBaseURL(router, si, "")
176 }
177
178 // Registers handlers, and prepends BaseURL to the paths, so that the paths
179 // can be served under a prefix.
180 func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) {
181
182         wrapper := ServerInterfaceWrapper{
183                 Handler: si,
184         }
185
186         router.GET(baseURL+"/apiInvocationLogs", wrapper.GetApiInvocationLogs)
187
188 }
189
190 // Base64 encoded, gzipped, json marshaled Swagger object
191 var swaggerSpec = []string{
192
193         "H4sIAAAAAAAC/9RXzXLbNhB+lR20h3aGIkXaimPdVDvJaCaTqJaaS5PxwOSSREMCKABKcT18oL5Gn6yz",
194         "oKgotmVHlnvoRT/k7rff7gcsFjcsVbVWEqWzbHzTBgy/ODSSV+cqpScsQ5saoZ1Qko3Z0ZvZDBZzSE7D",
195         "JEngQ3wSxuEQzlRdKwmT2RReG17jSpnPkCsD3v6dMq68Uo3MyMKygDWmYmNWOqfHUbRarcKjQutQmSLK",
196         "nY7mGlMbcZOWYolRcnpp0Qi0URc0Ym3AhMzVXXYUn6LyJhNOyCL8KP/5G5JhEgcdk/em4FL8xcmeVzDj",
197         "xkk0Fn6aXEx/CWCymM4DODubTwJ4tZhPA1jMz/3XYkIfZz+HH+WkqsCIonQWDFo0S8zCj5IFzAlXIRuz",
198         "s8ls+vpysuZwOZlNWcCWaGxHMg6TcDjglS55GFMuSqPkWlB1w2E4ZAHT3JW++BHXYiqXKvWM36rCPy3Q",
199         "3c391wbNNXCZgUFnBC4RiJxI0csiNihQqcKCdcpgBkqCKxE8ZUiVQcgbmZJZyDwz432mGRuzN+gmd+gQ",
200         "WVLcobFs/PttVnNnhCxAZCidyK/pN8UjRvhFK0sPtiMKcvqTUmEBk7ymenLMByJjAbNpiTWn1N21pjfW",
201         "o7O2DfaIS5X4jAZWpUjL9b/Mv92q104uWgzWAE/gxI0DJ2oElfuAW6L4x4bLAneFJouBtxhYQvom+I8G",
202         "czZmi3lyGifJZbcfz7nj4TWvqx+ir7s86pxsdM4dLkSN91F9JbNnIYoy+y9pPqpy9qCOe+pHsOQegHAg",
203         "LFh0wC3ccC3e8Rpb0KTvumK/XUzBOtOkrjFIZhnmQmIGQoJtrtKKNxbhODwmh62uOhrGD3H2P/di/aFr",
204         "PD0vSqJb+Stuv6dKfePaK+jMKKdSVT0WQK/tdi2ShBaJb6ez5qoStrycd3uUuuruNdOHv4/a+76ngSu5",
205         "265C3wwf2P6bhvjMhDek7mN8gbapHCgDqnG6cXc35S66xnvuJx0t5T6C1ZiKXKR00KnGpPiYnr3dd63T",
206         "VEmH0h9lXOtKdLlEf1jicfOs9Z1KhybnKZ5v5dq2bXAr+Y0dbD3f3jrr3r8rf2vSgegx2P87yZ0iZ2jd",
207         "rSy/DbBQkIvKoQFhDFa45NLREtJKWqSpqeKOjlwFjbSN1srQ3xw59Uq7q7S94WDL8N7yjU7i7zpZ5j3i",
208         "6x6wbT8FbEOUYJPhkL4OU/GtKor1JHj5dXx6TMytMes+Ffuu0MnmiwWb9gS8UrKAlXAl5OjSErMHpkHI",
209         "qE40ih4NT/Y8pjfVisjXQ7w8AOIlQRx3RX8SBPl6iPgAiLiDODoA4qiDOD4A4riDeHEAxAsPER/AIu5Y",
210         "JKdPh0hOCWJ0gKijTtTRAYqMOkUyzDkdiU+F6f3b1m9Jf/1bX3y6Oy1NgxdKuTaia1a0jOnux43gV1XX",
211         "Udbvuwvcmoy/CdtxFOEXXusKw1TV7PaGXzvunCVPwtGtWTJJkpCYfmr/DQAA//8fy/fu5w8AAA==",
212 }
213
214 // GetSwagger returns the content of the embedded swagger specification file
215 // or error if failed to decode
216 func decodeSpec() ([]byte, error) {
217         zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, ""))
218         if err != nil {
219                 return nil, fmt.Errorf("error base64 decoding spec: %s", err)
220         }
221         zr, err := gzip.NewReader(bytes.NewReader(zipped))
222         if err != nil {
223                 return nil, fmt.Errorf("error decompressing spec: %s", err)
224         }
225         var buf bytes.Buffer
226         _, err = buf.ReadFrom(zr)
227         if err != nil {
228                 return nil, fmt.Errorf("error decompressing spec: %s", err)
229         }
230
231         return buf.Bytes(), nil
232 }
233
234 var rawSpec = decodeSpecCached()
235
236 // a naive cached of a decoded swagger spec
237 func decodeSpecCached() func() ([]byte, error) {
238         data, err := decodeSpec()
239         return func() ([]byte, error) {
240                 return data, err
241         }
242 }
243
244 // Constructs a synthetic filesystem for resolving external references when loading openapi specifications.
245 func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) {
246         var res = make(map[string]func() ([]byte, error))
247         if len(pathToFile) > 0 {
248                 res[pathToFile] = rawSpec
249         }
250
251         pathPrefix := path.Dir(pathToFile)
252
253         for rawPath, rawFunc := range externalRef0.PathToRawSpec(path.Join(pathPrefix, "TS29122_CommonData.yaml")) {
254                 if _, ok := res[rawPath]; ok {
255                         // it is not possible to compare functions in golang, so always overwrite the old value
256                 }
257                 res[rawPath] = rawFunc
258         }
259         for rawPath, rawFunc := range externalRef2.PathToRawSpec(path.Join(pathPrefix, "TS29222_CAPIF_Publish_Service_API.yaml")) {
260                 if _, ok := res[rawPath]; ok {
261                         // it is not possible to compare functions in golang, so always overwrite the old value
262                 }
263                 res[rawPath] = rawFunc
264         }
265         for rawPath, rawFunc := range externalRef1.PathToRawSpec(path.Join(pathPrefix, "TS29571_CommonData.yaml")) {
266                 if _, ok := res[rawPath]; ok {
267                         // it is not possible to compare functions in golang, so always overwrite the old value
268                 }
269                 res[rawPath] = rawFunc
270         }
271         return res
272 }
273
274 // GetSwagger returns the Swagger specification corresponding to the generated code
275 // in this file. The external references of Swagger specification are resolved.
276 // The logic of resolving external references is tightly connected to "import-mapping" feature.
277 // Externally referenced files must be embedded in the corresponding golang packages.
278 // Urls can be supported but this task was out of the scope.
279 func GetSwagger() (swagger *openapi3.T, err error) {
280         var resolvePath = PathToRawSpec("")
281
282         loader := openapi3.NewLoader()
283         loader.IsExternalRefsAllowed = true
284         loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) {
285                 var pathToFile = url.String()
286                 pathToFile = path.Clean(pathToFile)
287                 getSpec, ok := resolvePath[pathToFile]
288                 if !ok {
289                         err1 := fmt.Errorf("path not found: %s", pathToFile)
290                         return nil, err1
291                 }
292                 return getSpec()
293         }
294         var specData []byte
295         specData, err = rawSpec()
296         if err != nil {
297                 return
298         }
299         swagger, err = loader.LoadFromData(specData)
300         if err != nil {
301                 return
302         }
303         return
304 }