| // Package auditingapi provides primitives to interact with the openapi HTTP API. |
| // |
| // Code generated by github.com/deepmap/oapi-codegen version v1.10.1 DO NOT EDIT. |
| package auditingapi |
| |
| import ( |
| "bytes" |
| "compress/gzip" |
| "encoding/base64" |
| "encoding/json" |
| "fmt" |
| "net/http" |
| "net/url" |
| "path" |
| "strings" |
| |
| "github.com/deepmap/oapi-codegen/pkg/runtime" |
| "github.com/getkin/kin-openapi/openapi3" |
| "github.com/labstack/echo/v4" |
| externalRef0 "oransc.org/nonrtric/sme/internal/common29122" |
| externalRef1 "oransc.org/nonrtric/sme/internal/common29571" |
| externalRef2 "oransc.org/nonrtric/sme/internal/publishserviceapi" |
| ) |
| |
| // ServerInterface represents all server handlers. |
| type ServerInterface interface { |
| |
| // (GET /apiInvocationLogs) |
| GetApiInvocationLogs(ctx echo.Context, params GetApiInvocationLogsParams) error |
| } |
| |
| // ServerInterfaceWrapper converts echo contexts to parameters. |
| type ServerInterfaceWrapper struct { |
| Handler ServerInterface |
| } |
| |
| // GetApiInvocationLogs converts echo context to params. |
| func (w *ServerInterfaceWrapper) GetApiInvocationLogs(ctx echo.Context) error { |
| var err error |
| |
| // Parameter object where we will unmarshal all parameters from the context |
| var params GetApiInvocationLogsParams |
| // ------------- Optional query parameter "aef-id" ------------- |
| |
| err = runtime.BindQueryParameter("form", true, false, "aef-id", ctx.QueryParams(), ¶ms.AefId) |
| if err != nil { |
| return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter aef-id: %s", err)) |
| } |
| |
| // ------------- Optional query parameter "api-invoker-id" ------------- |
| |
| err = runtime.BindQueryParameter("form", true, false, "api-invoker-id", ctx.QueryParams(), ¶ms.ApiInvokerId) |
| if err != nil { |
| return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter api-invoker-id: %s", err)) |
| } |
| |
| // ------------- Optional query parameter "time-range-start" ------------- |
| |
| err = runtime.BindQueryParameter("form", true, false, "time-range-start", ctx.QueryParams(), ¶ms.TimeRangeStart) |
| if err != nil { |
| return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter time-range-start: %s", err)) |
| } |
| |
| // ------------- Optional query parameter "time-range-end" ------------- |
| |
| err = runtime.BindQueryParameter("form", true, false, "time-range-end", ctx.QueryParams(), ¶ms.TimeRangeEnd) |
| if err != nil { |
| return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter time-range-end: %s", err)) |
| } |
| |
| // ------------- Optional query parameter "api-id" ------------- |
| |
| err = runtime.BindQueryParameter("form", true, false, "api-id", ctx.QueryParams(), ¶ms.ApiId) |
| if err != nil { |
| return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter api-id: %s", err)) |
| } |
| |
| // ------------- Optional query parameter "api-name" ------------- |
| |
| err = runtime.BindQueryParameter("form", true, false, "api-name", ctx.QueryParams(), ¶ms.ApiName) |
| if err != nil { |
| return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter api-name: %s", err)) |
| } |
| |
| // ------------- Optional query parameter "api-version" ------------- |
| |
| err = runtime.BindQueryParameter("form", true, false, "api-version", ctx.QueryParams(), ¶ms.ApiVersion) |
| if err != nil { |
| return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter api-version: %s", err)) |
| } |
| |
| // ------------- Optional query parameter "protocol" ------------- |
| |
| err = runtime.BindQueryParameter("form", true, false, "protocol", ctx.QueryParams(), ¶ms.Protocol) |
| if err != nil { |
| return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter protocol: %s", err)) |
| } |
| |
| // ------------- Optional query parameter "operation" ------------- |
| |
| err = runtime.BindQueryParameter("form", true, false, "operation", ctx.QueryParams(), ¶ms.Operation) |
| if err != nil { |
| return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter operation: %s", err)) |
| } |
| |
| // ------------- Optional query parameter "result" ------------- |
| |
| err = runtime.BindQueryParameter("form", true, false, "result", ctx.QueryParams(), ¶ms.Result) |
| if err != nil { |
| return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter result: %s", err)) |
| } |
| |
| // ------------- Optional query parameter "resource-name" ------------- |
| |
| err = runtime.BindQueryParameter("form", true, false, "resource-name", ctx.QueryParams(), ¶ms.ResourceName) |
| if err != nil { |
| return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter resource-name: %s", err)) |
| } |
| |
| // ------------- Optional query parameter "src-interface" ------------- |
| |
| if paramValue := ctx.QueryParam("src-interface"); paramValue != "" { |
| |
| var value externalRef2.InterfaceDescription |
| err = json.Unmarshal([]byte(paramValue), &value) |
| if err != nil { |
| return echo.NewHTTPError(http.StatusBadRequest, "Error unmarshaling parameter 'src-interface' as JSON") |
| } |
| params.SrcInterface = &value |
| |
| } |
| |
| // ------------- Optional query parameter "dest-interface" ------------- |
| |
| if paramValue := ctx.QueryParam("dest-interface"); paramValue != "" { |
| |
| var value externalRef2.InterfaceDescription |
| err = json.Unmarshal([]byte(paramValue), &value) |
| if err != nil { |
| return echo.NewHTTPError(http.StatusBadRequest, "Error unmarshaling parameter 'dest-interface' as JSON") |
| } |
| params.DestInterface = &value |
| |
| } |
| |
| // ------------- Optional query parameter "supported-features" ------------- |
| |
| err = runtime.BindQueryParameter("form", true, false, "supported-features", ctx.QueryParams(), ¶ms.SupportedFeatures) |
| if err != nil { |
| return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter supported-features: %s", err)) |
| } |
| |
| // Invoke the callback with all the unmarshalled arguments |
| err = w.Handler.GetApiInvocationLogs(ctx, params) |
| return err |
| } |
| |
| // This is a simple interface which specifies echo.Route addition functions which |
| // are present on both echo.Echo and echo.Group, since we want to allow using |
| // either of them for path registration |
| type EchoRouter interface { |
| CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route |
| DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route |
| GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route |
| HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route |
| OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route |
| PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route |
| POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route |
| PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route |
| TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route |
| } |
| |
| // RegisterHandlers adds each server route to the EchoRouter. |
| func RegisterHandlers(router EchoRouter, si ServerInterface) { |
| RegisterHandlersWithBaseURL(router, si, "") |
| } |
| |
| // Registers handlers, and prepends BaseURL to the paths, so that the paths |
| // can be served under a prefix. |
| func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) { |
| |
| wrapper := ServerInterfaceWrapper{ |
| Handler: si, |
| } |
| |
| router.GET(baseURL+"/apiInvocationLogs", wrapper.GetApiInvocationLogs) |
| |
| } |
| |
| // Base64 encoded, gzipped, json marshaled Swagger object |
| var swaggerSpec = []string{ |
| |
| "H4sIAAAAAAAC/9RXzXLbNhB+lR20h3aGIkXaimPdVDvJaCaTqJaaS5PxwOSSREMCKABKcT18oL5Gn6yz", |
| "oKgotmVHlnvoRT/k7rff7gcsFjcsVbVWEqWzbHzTBgy/ODSSV+cqpScsQ5saoZ1Qko3Z0ZvZDBZzSE7D", |
| "JEngQ3wSxuEQzlRdKwmT2RReG17jSpnPkCsD3v6dMq68Uo3MyMKygDWmYmNWOqfHUbRarcKjQutQmSLK", |
| "nY7mGlMbcZOWYolRcnpp0Qi0URc0Ym3AhMzVXXYUn6LyJhNOyCL8KP/5G5JhEgcdk/em4FL8xcmeVzDj", |
| "xkk0Fn6aXEx/CWCymM4DODubTwJ4tZhPA1jMz/3XYkI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OCWJ0gKijTtTRAYqMOkUyzDkdiU+F6f3b1m9Jf/1bX3y6Oy1NgxdKuTaia1a0jOnux43gV1XX", |
| "Udbvuwvcmoy/CdtxFOEXXusKw1TV7PaGXzvunCVPwtGtWTJJkpCYfmr/DQAA//8fy/fu5w8AAA==", |
| } |
| |
| // GetSwagger returns the content of the embedded swagger specification file |
| // or error if failed to decode |
| func decodeSpec() ([]byte, error) { |
| zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, "")) |
| if err != nil { |
| return nil, fmt.Errorf("error base64 decoding spec: %s", err) |
| } |
| zr, err := gzip.NewReader(bytes.NewReader(zipped)) |
| if err != nil { |
| return nil, fmt.Errorf("error decompressing spec: %s", err) |
| } |
| var buf bytes.Buffer |
| _, err = buf.ReadFrom(zr) |
| if err != nil { |
| return nil, fmt.Errorf("error decompressing spec: %s", err) |
| } |
| |
| return buf.Bytes(), nil |
| } |
| |
| var rawSpec = decodeSpecCached() |
| |
| // a naive cached of a decoded swagger spec |
| func decodeSpecCached() func() ([]byte, error) { |
| data, err := decodeSpec() |
| return func() ([]byte, error) { |
| return data, err |
| } |
| } |
| |
| // Constructs a synthetic filesystem for resolving external references when loading openapi specifications. |
| func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) { |
| var res = make(map[string]func() ([]byte, error)) |
| if len(pathToFile) > 0 { |
| res[pathToFile] = rawSpec |
| } |
| |
| pathPrefix := path.Dir(pathToFile) |
| |
| for rawPath, rawFunc := range externalRef0.PathToRawSpec(path.Join(pathPrefix, "TS29122_CommonData.yaml")) { |
| if _, ok := res[rawPath]; ok { |
| // it is not possible to compare functions in golang, so always overwrite the old value |
| } |
| res[rawPath] = rawFunc |
| } |
| for rawPath, rawFunc := range externalRef2.PathToRawSpec(path.Join(pathPrefix, "TS29222_CAPIF_Publish_Service_API.yaml")) { |
| if _, ok := res[rawPath]; ok { |
| // it is not possible to compare functions in golang, so always overwrite the old value |
| } |
| res[rawPath] = rawFunc |
| } |
| for rawPath, rawFunc := range externalRef1.PathToRawSpec(path.Join(pathPrefix, "TS29571_CommonData.yaml")) { |
| if _, ok := res[rawPath]; ok { |
| // it is not possible to compare functions in golang, so always overwrite the old value |
| } |
| res[rawPath] = rawFunc |
| } |
| return res |
| } |
| |
| // GetSwagger returns the Swagger specification corresponding to the generated code |
| // in this file. The external references of Swagger specification are resolved. |
| // The logic of resolving external references is tightly connected to "import-mapping" feature. |
| // Externally referenced files must be embedded in the corresponding golang packages. |
| // Urls can be supported but this task was out of the scope. |
| func GetSwagger() (swagger *openapi3.T, err error) { |
| var resolvePath = PathToRawSpec("") |
| |
| loader := openapi3.NewLoader() |
| loader.IsExternalRefsAllowed = true |
| loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) { |
| var pathToFile = url.String() |
| pathToFile = path.Clean(pathToFile) |
| getSpec, ok := resolvePath[pathToFile] |
| if !ok { |
| err1 := fmt.Errorf("path not found: %s", pathToFile) |
| return nil, err1 |
| } |
| return getSpec() |
| } |
| var specData []byte |
| specData, err = rawSpec() |
| if err != nil { |
| return |
| } |
| swagger, err = loader.LoadFromData(specData) |
| if err != nil { |
| return |
| } |
| return |
| } |