NONRTRIC-946: Add support for Kong routes
[nonrtric/plt/sme.git] / servicemanager / internal / publishserviceapi / publishserviceapi-server.gen.go
1 // Package publishserviceapi 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 publishserviceapi
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/servicemanager/internal/common"
20         externalRef1 "oransc.org/nonrtric/servicemanager/internal/common29122"
21         externalRef2 "oransc.org/nonrtric/servicemanager/internal/common29571"
22 )
23
24 // ServerInterface represents all server handlers.
25 type ServerInterface interface {
26
27         // (GET /{apfId}/service-apis)
28         GetApfIdServiceApis(ctx echo.Context, apfId string) error
29
30         // (POST /{apfId}/service-apis)
31         PostApfIdServiceApis(ctx echo.Context, apfId string) error
32
33         // (DELETE /{apfId}/service-apis/{serviceApiId})
34         DeleteApfIdServiceApisServiceApiId(ctx echo.Context, apfId string, serviceApiId string) error
35
36         // (GET /{apfId}/service-apis/{serviceApiId})
37         GetApfIdServiceApisServiceApiId(ctx echo.Context, apfId string, serviceApiId string) error
38
39         // (PATCH /{apfId}/service-apis/{serviceApiId})
40         ModifyIndAPFPubAPI(ctx echo.Context, apfId string, serviceApiId string) error
41
42         // (PUT /{apfId}/service-apis/{serviceApiId})
43         PutApfIdServiceApisServiceApiId(ctx echo.Context, apfId string, serviceApiId string) error
44 }
45
46 // ServerInterfaceWrapper converts echo contexts to parameters.
47 type ServerInterfaceWrapper struct {
48         Handler ServerInterface
49 }
50
51 // GetApfIdServiceApis converts echo context to params.
52 func (w *ServerInterfaceWrapper) GetApfIdServiceApis(ctx echo.Context) error {
53         var err error
54         // ------------- Path parameter "apfId" -------------
55         var apfId string
56
57         err = runtime.BindStyledParameterWithLocation("simple", false, "apfId", runtime.ParamLocationPath, ctx.Param("apfId"), &apfId)
58         if err != nil {
59                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter apfId: %s", err))
60         }
61
62         // Invoke the callback with all the unmarshalled arguments
63         err = w.Handler.GetApfIdServiceApis(ctx, apfId)
64         return err
65 }
66
67 // PostApfIdServiceApis converts echo context to params.
68 func (w *ServerInterfaceWrapper) PostApfIdServiceApis(ctx echo.Context) error {
69         var err error
70         // ------------- Path parameter "apfId" -------------
71         var apfId string
72
73         err = runtime.BindStyledParameterWithLocation("simple", false, "apfId", runtime.ParamLocationPath, ctx.Param("apfId"), &apfId)
74         if err != nil {
75                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter apfId: %s", err))
76         }
77
78         // Invoke the callback with all the unmarshalled arguments
79         err = w.Handler.PostApfIdServiceApis(ctx, apfId)
80         return err
81 }
82
83 // DeleteApfIdServiceApisServiceApiId converts echo context to params.
84 func (w *ServerInterfaceWrapper) DeleteApfIdServiceApisServiceApiId(ctx echo.Context) error {
85         var err error
86         // ------------- Path parameter "apfId" -------------
87         var apfId string
88
89         err = runtime.BindStyledParameterWithLocation("simple", false, "apfId", runtime.ParamLocationPath, ctx.Param("apfId"), &apfId)
90         if err != nil {
91                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter apfId: %s", err))
92         }
93
94         // ------------- Path parameter "serviceApiId" -------------
95         var serviceApiId string
96
97         err = runtime.BindStyledParameterWithLocation("simple", false, "serviceApiId", runtime.ParamLocationPath, ctx.Param("serviceApiId"), &serviceApiId)
98         if err != nil {
99                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter serviceApiId: %s", err))
100         }
101
102         // Invoke the callback with all the unmarshalled arguments
103         err = w.Handler.DeleteApfIdServiceApisServiceApiId(ctx, apfId, serviceApiId)
104         return err
105 }
106
107 // GetApfIdServiceApisServiceApiId converts echo context to params.
108 func (w *ServerInterfaceWrapper) GetApfIdServiceApisServiceApiId(ctx echo.Context) error {
109         var err error
110         // ------------- Path parameter "apfId" -------------
111         var apfId string
112
113         err = runtime.BindStyledParameterWithLocation("simple", false, "apfId", runtime.ParamLocationPath, ctx.Param("apfId"), &apfId)
114         if err != nil {
115                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter apfId: %s", err))
116         }
117
118         // ------------- Path parameter "serviceApiId" -------------
119         var serviceApiId string
120
121         err = runtime.BindStyledParameterWithLocation("simple", false, "serviceApiId", runtime.ParamLocationPath, ctx.Param("serviceApiId"), &serviceApiId)
122         if err != nil {
123                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter serviceApiId: %s", err))
124         }
125
126         // Invoke the callback with all the unmarshalled arguments
127         err = w.Handler.GetApfIdServiceApisServiceApiId(ctx, apfId, serviceApiId)
128         return err
129 }
130
131 // ModifyIndAPFPubAPI converts echo context to params.
132 func (w *ServerInterfaceWrapper) ModifyIndAPFPubAPI(ctx echo.Context) error {
133         var err error
134         // ------------- Path parameter "apfId" -------------
135         var apfId string
136
137         err = runtime.BindStyledParameterWithLocation("simple", false, "apfId", runtime.ParamLocationPath, ctx.Param("apfId"), &apfId)
138         if err != nil {
139                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter apfId: %s", err))
140         }
141
142         // ------------- Path parameter "serviceApiId" -------------
143         var serviceApiId string
144
145         err = runtime.BindStyledParameterWithLocation("simple", false, "serviceApiId", runtime.ParamLocationPath, ctx.Param("serviceApiId"), &serviceApiId)
146         if err != nil {
147                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter serviceApiId: %s", err))
148         }
149
150         // Invoke the callback with all the unmarshalled arguments
151         err = w.Handler.ModifyIndAPFPubAPI(ctx, apfId, serviceApiId)
152         return err
153 }
154
155 // PutApfIdServiceApisServiceApiId converts echo context to params.
156 func (w *ServerInterfaceWrapper) PutApfIdServiceApisServiceApiId(ctx echo.Context) error {
157         var err error
158         // ------------- Path parameter "apfId" -------------
159         var apfId string
160
161         err = runtime.BindStyledParameterWithLocation("simple", false, "apfId", runtime.ParamLocationPath, ctx.Param("apfId"), &apfId)
162         if err != nil {
163                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter apfId: %s", err))
164         }
165
166         // ------------- Path parameter "serviceApiId" -------------
167         var serviceApiId string
168
169         err = runtime.BindStyledParameterWithLocation("simple", false, "serviceApiId", runtime.ParamLocationPath, ctx.Param("serviceApiId"), &serviceApiId)
170         if err != nil {
171                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter serviceApiId: %s", err))
172         }
173
174         // Invoke the callback with all the unmarshalled arguments
175         err = w.Handler.PutApfIdServiceApisServiceApiId(ctx, apfId, serviceApiId)
176         return err
177 }
178
179 // This is a simple interface which specifies echo.Route addition functions which
180 // are present on both echo.Echo and echo.Group, since we want to allow using
181 // either of them for path registration
182 type EchoRouter interface {
183         CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
184         DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
185         GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
186         HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
187         OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
188         PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
189         POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
190         PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
191         TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
192 }
193
194 // RegisterHandlers adds each server route to the EchoRouter.
195 func RegisterHandlers(router EchoRouter, si ServerInterface) {
196         RegisterHandlersWithBaseURL(router, si, "")
197 }
198
199 // Registers handlers, and prepends BaseURL to the paths, so that the paths
200 // can be served under a prefix.
201 func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) {
202
203         wrapper := ServerInterfaceWrapper{
204                 Handler: si,
205         }
206
207         router.GET(baseURL+"/:apfId/service-apis", wrapper.GetApfIdServiceApis)
208         router.POST(baseURL+"/:apfId/service-apis", wrapper.PostApfIdServiceApis)
209         router.DELETE(baseURL+"/:apfId/service-apis/:serviceApiId", wrapper.DeleteApfIdServiceApisServiceApiId)
210         router.GET(baseURL+"/:apfId/service-apis/:serviceApiId", wrapper.GetApfIdServiceApisServiceApiId)
211         router.PATCH(baseURL+"/:apfId/service-apis/:serviceApiId", wrapper.ModifyIndAPFPubAPI)
212         router.PUT(baseURL+"/:apfId/service-apis/:serviceApiId", wrapper.PutApfIdServiceApisServiceApiId)
213
214 }
215
216 // Base64 encoded, gzipped, json marshaled Swagger object
217 var swaggerSpec = []string{
218
219         "H4sIAAAAAAAC/+xa/27bOPJ/FULfL3ANTpVjp2m3/s91nKy23UQXOQscNkVAS2OLW5nUkZRTX+EHute4",
220         "JzuQlGRZZmIl7nZ/+Z/ENsnhzHDmMz/IL07E5hmjQKVw+l8cESUwx/rjAKYfWIQlYVR9jUFEnGTmqzNO",
221         "AKXFKCJ0yvjcfH4B3sxDEVmQCOE45iCEiy6CEEWM8ZhQLEG4KMYSowioBI78syN0nwAHJBNAg9E5yjhb",
222         "kJjQmf5FAF+QCNAg8BERZleIvVvquE7GWQZcEtAc610HcczVl//nMHX6zpDN54yeYYm9JZ6n/9dZy9sp",
223         "hO0My3UghLNynTjy422R/RioJFMCQrNVF+G57MtlBk7fEZITOlM7z4ANOOAn8n8BbMZxlpBIL16tKsps",
224         "8gtEUlEewDTgbEpS2JbsGjIOQpGsy6Dmaim9LUVjmD6qIY7Y1JAKfASfMyaUNqY5jfRMi+B409gK4a3S",
225         "1u1SHRaW+Fyb366FZ+uZah2bY0Iv8dyikDM9hiRD9wmJEi3GBFJGZwJJZuOfKDuY4gjO1oSERUPlNBSD",
226         "xCQVjusQCXOxi3ffQl/tOyfUN+u7FVeYc7xUgxlnkkUs3UU8KOetXEdAlHMilz+CTFhsESEsJqC5mYFE",
227         "nmWMS4jRZFnaT1uxwo3ddgq0AC7silUnVIy23funYvrjm65ch8O/csIhdvo/F5Zf4+SjxdeUz+aUGBsd",
228         "69EmvwETgkxSQAuc5iAQ5tC/pS/R9egfN6NwfHc9CoOry3DURwppozpBhSKFe6mdkWIPhHzJQWSMClBk",
229         "wpt34fDafze6u7wa++f/bEFG5BPF4AReUibJdKkBCmg+V2I32XJcp7lFTRNrtxjmQrL5VQb8gTjSgJ7a",
230         "oGIOo0gTQKyksI1FSqhSx48d9/ahrFxHkb/K7CBApFKRAImwQF/WM1cow1yWuru59pGQPI9kzgFNGbcw",
231         "je6JTFguEQfBch4BwkKwiJhBLFAMU0IhRoSiKMW5AHTq9bxXao+TiyBA4xD13nrdXu+BsLHB+Faohs+y",
232         "qVjFeZNLG+Fq0AYEld9/Px4HFRwoFZTQX8rroSuaLhHOspREWJn9fQJUTysxSsm+jlGI0FgdFQhN3Ijd",
233         "yqvXtvYkv66saMMmbM59thFv2nn1D+HVZR/9gBc41LPRlSaHLpnUvG74mppsdSZrDHiqR1F1MH8TqApY",
234         "2x5FssWrRhY1Dntvu73eXZtsxC+Xq7CYLV7vR+p1SUrZ2jPJBGrp14ltldpcRCSS+JOyYIggBhoBYgvg",
235         "RdLXIGRyQuPiazN3C29ROJNBRKYkqh1Me6N/Uhi1ZYePIPRDNn0xGveN51+MxoWc6vfgKiwH1Mf6yE01",
236         "cLPx+2A8/L4cUZ9rY2ejD6PxqBg0X6rRms9cjMaO66j91L8b/VdRclzHLLI6VFDLj9oJrdi46951C4aK",
237         "LAB1vW412muM9TYYLQk4rvnYszOWT1IiEogHGQmwTHZ6eVYu0LCbYZnomEMMxgo8BzQcBH5ZmwBHJv21",
238         "hNNo6ttcY4BSInTUGw7PEakyfVErfhqlDk454Hi5Zs6r2/OW0E802esituwuZ2qB6IF65o+QQ5QpA8T6",
239         "aBGuZxO/TQZR1+xfK3tQyYNhzn7upXEiqoYtqsk5sa1KsSQLYxAWHeuYU7MnnJGwCBthPp2SzyAeM6y9",
240         "zaSRM22owK2nUEo6W+7UiFOtYTcI3/dRIzijLnpxo/sK4w/hyyB8f2QENEWMFrEU6eREiaQJvfe3CfVK",
241         "QsF7vw2Rq8HN+PttMifoxfhDaJzzapDLBEn2CehuirXwEITvVeh67zuuo7exhofQ4Owg8PfJBDfgGota",
242         "DCnr+ODc2vopvMwWJGqdo1pT0C3aKIRGaR4X/TPdFioCVtEMKZqHpVMfPcFxa+2tXZ6LM2JrXumgtW5g",
243         "YSHIjK6VYcJnxBRAF30sJFkj+NY06qEwwWmKKJNoopNEdRKoiMjr9Kio3tGUs3nl8AXFetOs3MzCR7nV",
244         "49uY5sB6n0cEeogFTOMNyirxezJhQhfsE3D0IiYiUgnzUv189EBcwhmxI6wipcDVgom7AuyTcPABplT4",
245         "OgcsRaMkOX3TbVWSVOFPEck56L6zzr22RbUpdG2p3tcM5zZaWT6ppaGP9hGbaauuuUqsGmIJM8aX1uRP",
246         "JJiDiu0+nbKd5U59coExmsiWUr/a4TTbgIVZ2oOcBZ0DLKMWaTzmeA5SZdWSVdCgRuYsVmEeb9Tx5428",
247         "v0qYLHcjDdz+FUD14BK/O5ew1U3WmZaLijKDvk9AJlVbo5Yx0LjDtn+OCpFQhKmKSFqKuAwAVQ1pK0aF",
248         "9U4PZ0RZ4eKMzS0Zx4dHCa5vcLbK09qVpWRrRhspx1OKVNcholKurbck1U63juQ53Dq1GkUmWH4D9dZl",
249         "9tCVOtR7IkBHTs3YFKcCbp2NSDxhLAVMtwCwLqoNBMvLlTbFedkpqfO3jV8ZeZCmIjLHvzBeI6Vjvskn",
250         "F90jmxObavzhCnXYqMDFo218r22m2rwS2WVU8DkjBiGe0fk8wxLGZA71ilU8XK7aLvMCv7VoVUvmaVdq",
251         "65PdtqSV1oAETnF6xiIL77V8rdfroZ+6b7zX3jEy2tH2da6C6j3jn3R3Qc+/ZFwmE5ZTHTiFLllTp+8k",
252         "Umai3+nc3997J7Ms8xifdaYy66g6W3QwjxKygE7v7Z0ATkB0zK4dcwVsYHrbNtW2tXy65s/CQ+iW/vc/",
253         "qHfc67mGtys+w5T8W1sHTlGAuaQqI3gxuPbfuWgw9kMXDYfhwEWjcei7aBye6X/jgfozPNI0B2mKOJkl",
254         "UihzBb6o3hwQqeDJhNC7Ij7dFUnLnQl45U1q3+l6Pa9b9HIozohSuHfsHSv/xDLR59H5grOpH686hWAv",
255         "cUb0wAykzdYkJ7AApEqWjfxFKEOr3E2FfecC5EDRLnMqRVjtXKZJTv/nLw5RZBU3juvofkvf0Qw5dTtT",
256         "qOsWz1ssyL76qB1ElzKa997xsekMUglUGgTS/SfFW+cXYXBoTa9ln95WuK+2HKSZrjhnql4hVfKXpnUj",
257         "eiGObMW7tYbz1G4nx2+eiCeVajpqrSbx3R4kvlMkXhkNP4uEWqtJdPcg0TUkTvYgcWJIvNqDxCtD4vUe",
258         "JF5rEr23zyfRe6tInO5xIqfmRE73UOepUWcMU5yn8tlkyvXajTImbPe0xjEQRhTuyxC3iTwBE98UenSp",
259         "947FyyehzjPAZjP8Kt5WW9DX/RZMNNPjdZJba6jlUQRCTPM0XeonLLXOeMRB34ZU2Zgou2AcZM6L9o6a",
260         "eeuUD8ZuHdO5SgDHwE1ANJ+15A+/dxwyKk1FsckEhft0ucWKi3AU6eeOszI1X7efdI/qmjG56lSC6pDZ",
261         "WXStobTzRVQ26McrzXR761odoHYTart7CNI1gnT3EKRrBOme7kHi9AD4dsBfuU4bFzL+nYK01Ok3NKui",
262         "g72zvxUrzjSpZrQIazu2ihxic0F7F3d/tRz4lf3lN6ExWZA4x6ldRWiOZZQ0XkAPAuLHiAhkNB8fUtHf",
263         "Jz4eYMWSR+4oZdsihaWe/TPAxPG3zxc3K+IaIAlrIrmjKr6lBzA61MV/pbrYfh/5I4vJdIkwRfCZCKl8",
264         "pCWymZU+jQfBeZBPTB/xjwJmbYrvOfAZvNR6+/tXwDRzIdyqGv8N0HWs3wvVEdbyvtPcSTerdExj/Tax",
265         "uObBdQJ5Fus6uUGoWa+XF98TFi8LaLamopcMDY1aPPR8jg956KFOP9Tp3zQAuY7EMxUT9DuDInHbes/i",
266         "fNRPLSyJ943GkfZpd5D/WdLu31Wb+DdP++vwXsWWJrTvCB0H9D+g/wH9v22XtngEV6KteXvxyLWI4zoL",
267         "zAmepNVjIDXTuHXBVvV2Az7jeZaCF7G504SPYqH9CfAb77TxALjX63mK4Y+r/wUAAP//h5XpSShDAAA=",
268 }
269
270 // GetSwagger returns the content of the embedded swagger specification file
271 // or error if failed to decode
272 func decodeSpec() ([]byte, error) {
273         zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, ""))
274         if err != nil {
275                 return nil, fmt.Errorf("error base64 decoding spec: %s", err)
276         }
277         zr, err := gzip.NewReader(bytes.NewReader(zipped))
278         if err != nil {
279                 return nil, fmt.Errorf("error decompressing spec: %s", err)
280         }
281         var buf bytes.Buffer
282         _, err = buf.ReadFrom(zr)
283         if err != nil {
284                 return nil, fmt.Errorf("error decompressing spec: %s", err)
285         }
286
287         return buf.Bytes(), nil
288 }
289
290 var rawSpec = decodeSpecCached()
291
292 // a naive cached of a decoded swagger spec
293 func decodeSpecCached() func() ([]byte, error) {
294         data, err := decodeSpec()
295         return func() ([]byte, error) {
296                 return data, err
297         }
298 }
299
300 // Constructs a synthetic filesystem for resolving external references when loading openapi specifications.
301 func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) {
302         var res = make(map[string]func() ([]byte, error))
303         if len(pathToFile) > 0 {
304                 res[pathToFile] = rawSpec
305         }
306
307         pathPrefix := path.Dir(pathToFile)
308
309         for rawPath, rawFunc := range externalRef0.PathToRawSpec(path.Join(pathPrefix, "CommonData.yaml")) {
310                 if _, ok := res[rawPath]; ok {
311                         // it is not possible to compare functions in golang, so always overwrite the old value
312                 }
313                 res[rawPath] = rawFunc
314         }
315         for rawPath, rawFunc := range externalRef1.PathToRawSpec(path.Join(pathPrefix, "TS29122_CommonData.yaml")) {
316                 if _, ok := res[rawPath]; ok {
317                         // it is not possible to compare functions in golang, so always overwrite the old value
318                 }
319                 res[rawPath] = rawFunc
320         }
321         for rawPath, rawFunc := range externalRef2.PathToRawSpec(path.Join(pathPrefix, "TS29571_CommonData.yaml")) {
322                 if _, ok := res[rawPath]; ok {
323                         // it is not possible to compare functions in golang, so always overwrite the old value
324                 }
325                 res[rawPath] = rawFunc
326         }
327         return res
328 }
329
330 // GetSwagger returns the Swagger specification corresponding to the generated code
331 // in this file. The external references of Swagger specification are resolved.
332 // The logic of resolving external references is tightly connected to "import-mapping" feature.
333 // Externally referenced files must be embedded in the corresponding golang packages.
334 // Urls can be supported but this task was out of the scope.
335 func GetSwagger() (swagger *openapi3.T, err error) {
336         var resolvePath = PathToRawSpec("")
337
338         loader := openapi3.NewLoader()
339         loader.IsExternalRefsAllowed = true
340         loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) {
341                 var pathToFile = url.String()
342                 pathToFile = path.Clean(pathToFile)
343                 getSpec, ok := resolvePath[pathToFile]
344                 if !ok {
345                         err1 := fmt.Errorf("path not found: %s", pathToFile)
346                         return nil, err1
347                 }
348                 return getSpec()
349         }
350         var specData []byte
351         specData, err = rawSpec()
352         if err != nil {
353                 return
354         }
355         swagger, err = loader.LoadFromData(specData)
356         if err != nil {
357                 return
358         }
359         return
360 }