NextZen-UserService/codegen/user_service/user_service_api.go
2024-02-21 11:45:10 +07:00

291 lines
10 KiB
Go

// Package codegen provides primitives to interact with the openapi HTTP API.
//
// Code generated by github.com/deepmap/oapi-codegen version v1.12.4 DO NOT EDIT.
package codegen
import (
"bytes"
"compress/gzip"
"encoding/base64"
"fmt"
"net/http"
"net/url"
"path"
"strings"
"time"
"github.com/deepmap/oapi-codegen/pkg/runtime"
openapi_types "github.com/deepmap/oapi-codegen/pkg/types"
"github.com/getkin/kin-openapi/openapi3"
"github.com/labstack/echo/v4"
)
const (
Access_tokenScopes = "access_token.Scopes"
)
// BaseResponse defines model for BaseResponse.
type BaseResponse struct {
// Message Error message
Message *string `json:"message,omitempty"`
}
// Event defines model for Event.
type Event struct {
// EventUuid UUID of the event
EventUuid *openapi_types.UUID `json:"event_uuid,omitempty"`
// Name event name
Name string `json:"name"`
// Properties event properties
Properties []Property `json:"properties"`
// SourceID associated source id
SourceID string `json:"sourceID"`
// Timestamp timestamp this event took place
Timestamp *time.Time `json:"timestamp,omitempty"`
}
// Property defines model for Property.
type Property struct {
// Name Name of the property
Name *string `json:"name,omitempty"`
// Value Value of the property
Value *string `json:"value,omitempty"`
}
// EventUuid defines model for event_uuid.
type EventUuid = openapi_types.UUID
// Serial defines model for serial.
type Serial = string
// BadResponse defines model for BadResponse.
type BadResponse = BaseResponse
// DeleteEventOK defines model for DeleteEventOK.
type DeleteEventOK = Event
// OKResponse defines model for OKResponse.
type OKResponse = BaseResponse
// ResponseNotFound defines model for ResponseNotFound.
type ResponseNotFound = BaseResponse
// GetEventsParams defines parameters for GetEvents.
type GetEventsParams struct {
// Form Form of the events to get
Form *time.Time `form:"form,omitempty" json:"form,omitempty"`
}
// ServerInterface represents all server handlers.
type ServerInterface interface {
// Delete an event
// (DELETE /event/local_storage/{serial})
DeleteEventBySerial(ctx echo.Context, serial Serial) error
// Delete an event
// (DELETE /event/{event_uuid})
DeleteEvent(ctx echo.Context, eventUuid EventUuid) error
// Get all events
// (GET /events)
GetEvents(ctx echo.Context, params GetEventsParams) error
}
// ServerInterfaceWrapper converts echo contexts to parameters.
type ServerInterfaceWrapper struct {
Handler ServerInterface
}
// DeleteEventBySerial converts echo context to params.
func (w *ServerInterfaceWrapper) DeleteEventBySerial(ctx echo.Context) error {
var err error
// ------------- Path parameter "serial" -------------
var serial Serial
err = runtime.BindStyledParameterWithLocation("simple", false, "serial", runtime.ParamLocationPath, ctx.Param("serial"), &serial)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter serial: %s", err))
}
ctx.Set(Access_tokenScopes, []string{""})
// Invoke the callback with all the unmarshalled arguments
err = w.Handler.DeleteEventBySerial(ctx, serial)
return err
}
// DeleteEvent converts echo context to params.
func (w *ServerInterfaceWrapper) DeleteEvent(ctx echo.Context) error {
var err error
// ------------- Path parameter "event_uuid" -------------
var eventUuid EventUuid
err = runtime.BindStyledParameterWithLocation("simple", false, "event_uuid", runtime.ParamLocationPath, ctx.Param("event_uuid"), &eventUuid)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter event_uuid: %s", err))
}
ctx.Set(Access_tokenScopes, []string{""})
// Invoke the callback with all the unmarshalled arguments
err = w.Handler.DeleteEvent(ctx, eventUuid)
return err
}
// GetEvents converts echo context to params.
func (w *ServerInterfaceWrapper) GetEvents(ctx echo.Context) error {
var err error
ctx.Set(Access_tokenScopes, []string{""})
// Parameter object where we will unmarshal all parameters from the context
var params GetEventsParams
// ------------- Optional query parameter "form" -------------
err = runtime.BindQueryParameter("form", true, false, "form", ctx.QueryParams(), &params.Form)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter form: %s", err))
}
// Invoke the callback with all the unmarshalled arguments
err = w.Handler.GetEvents(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.DELETE(baseURL+"/event/local_storage/:serial", wrapper.DeleteEventBySerial)
router.DELETE(baseURL+"/event/:event_uuid", wrapper.DeleteEvent)
router.GET(baseURL+"/events", wrapper.GetEvents)
}
// Base64 encoded, gzipped, json marshaled Swagger object
var swaggerSpec = []string{
"H4sIAAAAAAAC/9xYbW/bNhD+KwS3DxsgWbKjpImAfmiatggCJMXSbsDiwDiLZ5uNRKokldY1/N8HUrQt",
"WzLidtkGrAjQULw33j13fJgFzWRRSoHCaJouaAkKCjSo3AofUZhRVXFmVwx1pnhpuBQ0pR8/Xl4QOSFm",
"hsTJESPJFA0NKLf7JZgZDaiAAmnatBRQhZ8rrpDR1KgKA6qzGRbgHH6FosytQn9whMnxyYsQT8/GYX/A",
"jkJIjk/CZHBycnycJHEcxzSgE6kKMDSl3rSZl1ZbG8XFlC6XAdWoOOTt+G/d99UJcplBTrSRCqbYfQRv",
"6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IdoKh0Dd9H",
"O9mpLFFAyWlKj3px78hOBDAz1z2RmzmRG2IjP8SiRc2El3U7WArXboyaTxIQ67vdNrLrr0u23ne04Xx+",
"u2LWzdfHXfe43ohEnpDbCb9FpwdxvG/Yr+WiBuFcBjSJ+x18qaYV0qwvNJrEydOmW5RyGdDjQ2JqvgPc",
"OKuKAtS8M50GpjZJNTmh91bcF2uxYV3PVaLvLk2D+P1YebbfI/+vCrks2Jdy6zzv0BDIc+LFdivyDs2b",
"1c5OPbbtvJWq2OLWeudx/rlCNd/cf5ZG0O6H7CAe9MPY/nyI49T9/Hko8dhT+YNfdwfxNv/G3CVte96c",
"eoOUv1nwVq1a9W4QElejbSpyd2/zY2d3dw33z+9K5TSl0eMgcleD6zDvvLtBFOaOoa7RpHf+MEOX98u/",
"AgAA//8z3sRjChIAAA==",
}
// 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
}
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
}