ogen

package
v0.0.37 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 7, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

Code generated by ogen, DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithServerURL

func WithServerURL(ctx context.Context, u *url.URL) context.Context

WithServerURL sets context key to override server URL.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client implements OAS client.

func NewClient

func NewClient(serverURL string, opts ...ClientOption) (*Client, error)

NewClient initializes new Client defined by OAS.

func (*Client) ListDefaultModel

func (c *Client) ListDefaultModel(ctx context.Context, params ListDefaultModelParams) (ListDefaultModelRes, error)

ListDefaultModel invokes listDefaultModel operation.

List for DefaultModels.

GET /defaultmodel

func (*Client) ReadDefaultModel

func (c *Client) ReadDefaultModel(ctx context.Context, params ReadDefaultModelParams) (ReadDefaultModelRes, error)

ReadDefaultModel invokes readDefaultModel operation.

Finds the DefaultModel with the requested ID and returns it.

GET /defaultmodel/{id}

type ClientOption

type ClientOption interface {
	// contains filtered or unexported methods
}

ClientOption is client config option.

func WithClient

func WithClient(client ht.Client) ClientOption

WithClient specifies http client to use.

type DefaultModel

type DefaultModel struct {
	ID   uuid.UUID `json:"id"`
	Name string    `json:"name"`
}

Ref: #/components/schemas/DefaultModel

func NewDefaultModel

func NewDefaultModel(e service.DefaultModel) *DefaultModel

func NewDefaultModelList

func NewDefaultModelList(es []service.DefaultModel) []DefaultModel

func (*DefaultModel) Decode

func (s *DefaultModel) Decode(d *jx.Decoder) error

Decode decodes DefaultModel from json.

func (*DefaultModel) Encode

func (s *DefaultModel) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*DefaultModel) GetID

func (s *DefaultModel) GetID() uuid.UUID

GetID returns the value of ID.

func (*DefaultModel) GetName

func (s *DefaultModel) GetName() string

GetName returns the value of Name.

func (*DefaultModel) MarshalJSON

func (s *DefaultModel) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*DefaultModel) SetID

func (s *DefaultModel) SetID(val uuid.UUID)

SetID sets the value of ID.

func (*DefaultModel) SetName

func (s *DefaultModel) SetName(val string)

SetName sets the value of Name.

func (*DefaultModel) UnmarshalJSON

func (s *DefaultModel) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type DefaultModelList

type DefaultModelList []DefaultModel

func (*DefaultModelList) Decode

func (s *DefaultModelList) Decode(d *jx.Decoder) error

Decode decodes DefaultModelList from json.

func (DefaultModelList) Encode

func (s DefaultModelList) Encode(e *jx.Encoder)

Encode encodes DefaultModelList as json.

func (DefaultModelList) MarshalJSON

func (s DefaultModelList) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*DefaultModelList) UnmarshalJSON

func (s *DefaultModelList) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (DefaultModelList) Validate

func (s DefaultModelList) Validate() error

type DefaultModelListHeaders

type DefaultModelListHeaders struct {
	ContentRange int
	Response     DefaultModelList
}

DefaultModelListHeaders wraps DefaultModelList with response headers.

func (*DefaultModelListHeaders) GetContentRange

func (s *DefaultModelListHeaders) GetContentRange() int

GetContentRange returns the value of ContentRange.

func (*DefaultModelListHeaders) GetResponse

func (s *DefaultModelListHeaders) GetResponse() DefaultModelList

GetResponse returns the value of Response.

func (*DefaultModelListHeaders) SetContentRange

func (s *DefaultModelListHeaders) SetContentRange(val int)

SetContentRange sets the value of ContentRange.

func (*DefaultModelListHeaders) SetResponse

func (s *DefaultModelListHeaders) SetResponse(val DefaultModelList)

SetResponse sets the value of Response.

func (*DefaultModelListHeaders) Validate

func (s *DefaultModelListHeaders) Validate() error

type ErrorHandler

type ErrorHandler = ogenerrors.ErrorHandler

ErrorHandler is error handler.

type ErrorItem

type ErrorItem struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

func (*ErrorItem) Decode

func (s *ErrorItem) Decode(d *jx.Decoder) error

Decode decodes ErrorItem from json.

func (*ErrorItem) Encode

func (s *ErrorItem) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*ErrorItem) GetCode

func (s *ErrorItem) GetCode() int

GetCode returns the value of Code.

func (*ErrorItem) GetMessage

func (s *ErrorItem) GetMessage() string

GetMessage returns the value of Message.

func (*ErrorItem) MarshalJSON

func (s *ErrorItem) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*ErrorItem) SetCode

func (s *ErrorItem) SetCode(val int)

SetCode sets the value of Code.

func (*ErrorItem) SetMessage

func (s *ErrorItem) SetMessage(val string)

SetMessage sets the value of Message.

func (*ErrorItem) UnmarshalJSON

func (s *ErrorItem) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type ErrorStatusCode

type ErrorStatusCode struct {
	StatusCode int
	Response   []ErrorItem
}

ErrorStatusCode wraps []ErrorItem with StatusCode.

func (*ErrorStatusCode) Error

func (s *ErrorStatusCode) Error() string

func (*ErrorStatusCode) GetResponse

func (s *ErrorStatusCode) GetResponse() []ErrorItem

GetResponse returns the value of Response.

func (*ErrorStatusCode) GetStatusCode

func (s *ErrorStatusCode) GetStatusCode() int

GetStatusCode returns the value of StatusCode.

func (*ErrorStatusCode) SetResponse

func (s *ErrorStatusCode) SetResponse(val []ErrorItem)

SetResponse sets the value of Response.

func (*ErrorStatusCode) SetStatusCode

func (s *ErrorStatusCode) SetStatusCode(val int)

SetStatusCode sets the value of StatusCode.

func (*ErrorStatusCode) Validate

func (s *ErrorStatusCode) Validate() error

type Handler

type Handler interface {
	// ListDefaultModel implements listDefaultModel operation.
	//
	// List for DefaultModels.
	//
	// GET /defaultmodel
	ListDefaultModel(ctx context.Context, params ListDefaultModelParams) (ListDefaultModelRes, error)
	// ReadDefaultModel implements readDefaultModel operation.
	//
	// Finds the DefaultModel with the requested ID and returns it.
	//
	// GET /defaultmodel/{id}
	ReadDefaultModel(ctx context.Context, params ReadDefaultModelParams) (ReadDefaultModelRes, error)
	// NewError creates *ErrorStatusCode from error returned by handler.
	//
	// Used for common default response.
	NewError(ctx context.Context, err error) *ErrorStatusCode
}

Handler handles operations described by OpenAPI v3 specification.

type HandlerImpl

type HandlerImpl struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(
	client *gen.Client,
	srvc *service.Service, logger *zap.Logger,
) *HandlerImpl

func (*HandlerImpl) CreateDefaultModel

func (h *HandlerImpl) CreateDefaultModel(ctx context.Context, req *CreateDefaultModel) (CreateDefaultModelRes, error)

func (*HandlerImpl) DeleteDefaultModel

func (h *HandlerImpl) DeleteDefaultModel(ctx context.Context, params DeleteDefaultModelParams) (DeleteDefaultModelRes, error)

DeleteDefaultModel handles DELETE /defaultmodel/{id} requests.

func (*HandlerImpl) ListDefaultModel

func (h *HandlerImpl) ListDefaultModel(ctx context.Context, params ListDefaultModelParams) (ListDefaultModelRes, error)

func (*HandlerImpl) NewError

func (h *HandlerImpl) NewError(ctx context.Context, err error) *ErrorStatusCode

func (*HandlerImpl) ReadDefaultModel

func (h *HandlerImpl) ReadDefaultModel(ctx context.Context, params ReadDefaultModelParams) (ReadDefaultModelRes, error)

func (*HandlerImpl) UpdateDefaultModel

func (h *HandlerImpl) UpdateDefaultModel(ctx context.Context, req *UpdateDefaultModel, params UpdateDefaultModelParams) (UpdateDefaultModelRes, error)

type Invoker

type Invoker interface {
	// ListDefaultModel invokes listDefaultModel operation.
	//
	// List for DefaultModels.
	//
	// GET /defaultmodel
	ListDefaultModel(ctx context.Context, params ListDefaultModelParams) (ListDefaultModelRes, error)
	// ReadDefaultModel invokes readDefaultModel operation.
	//
	// Finds the DefaultModel with the requested ID and returns it.
	//
	// GET /defaultmodel/{id}
	ReadDefaultModel(ctx context.Context, params ReadDefaultModelParams) (ReadDefaultModelRes, error)
}

Invoker invokes operations described by OpenAPI v3 specification.

type ListDefaultModelBadRequestApplicationJSON

type ListDefaultModelBadRequestApplicationJSON []R400Item

func (*ListDefaultModelBadRequestApplicationJSON) Decode

Decode decodes ListDefaultModelBadRequestApplicationJSON from json.

func (ListDefaultModelBadRequestApplicationJSON) Encode

Encode encodes ListDefaultModelBadRequestApplicationJSON as json.

func (ListDefaultModelBadRequestApplicationJSON) MarshalJSON

MarshalJSON implements stdjson.Marshaler.

func (*ListDefaultModelBadRequestApplicationJSON) UnmarshalJSON

func (s *ListDefaultModelBadRequestApplicationJSON) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (ListDefaultModelBadRequestApplicationJSON) Validate

type ListDefaultModelConflictApplicationJSON

type ListDefaultModelConflictApplicationJSON []R409Item

func (*ListDefaultModelConflictApplicationJSON) Decode

Decode decodes ListDefaultModelConflictApplicationJSON from json.

func (ListDefaultModelConflictApplicationJSON) Encode

Encode encodes ListDefaultModelConflictApplicationJSON as json.

func (ListDefaultModelConflictApplicationJSON) MarshalJSON

func (s ListDefaultModelConflictApplicationJSON) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*ListDefaultModelConflictApplicationJSON) UnmarshalJSON

func (s *ListDefaultModelConflictApplicationJSON) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (ListDefaultModelConflictApplicationJSON) Validate

type ListDefaultModelInternalServerErrorApplicationJSON

type ListDefaultModelInternalServerErrorApplicationJSON []R500Item

func (*ListDefaultModelInternalServerErrorApplicationJSON) Decode

Decode decodes ListDefaultModelInternalServerErrorApplicationJSON from json.

func (ListDefaultModelInternalServerErrorApplicationJSON) Encode

Encode encodes ListDefaultModelInternalServerErrorApplicationJSON as json.

func (ListDefaultModelInternalServerErrorApplicationJSON) MarshalJSON

MarshalJSON implements stdjson.Marshaler.

func (*ListDefaultModelInternalServerErrorApplicationJSON) UnmarshalJSON

UnmarshalJSON implements stdjson.Unmarshaler.

func (ListDefaultModelInternalServerErrorApplicationJSON) Validate

type ListDefaultModelNotFoundApplicationJSON

type ListDefaultModelNotFoundApplicationJSON []R404Item

func (*ListDefaultModelNotFoundApplicationJSON) Decode

Decode decodes ListDefaultModelNotFoundApplicationJSON from json.

func (ListDefaultModelNotFoundApplicationJSON) Encode

Encode encodes ListDefaultModelNotFoundApplicationJSON as json.

func (ListDefaultModelNotFoundApplicationJSON) MarshalJSON

func (s ListDefaultModelNotFoundApplicationJSON) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*ListDefaultModelNotFoundApplicationJSON) UnmarshalJSON

func (s *ListDefaultModelNotFoundApplicationJSON) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (ListDefaultModelNotFoundApplicationJSON) Validate

type ListDefaultModelParams

type ListDefaultModelParams struct {
	// What page to render.
	Page OptInt
	// Item count to render per page.
	ItemsPerPage OptInt
}

ListDefaultModelParams is parameters of listDefaultModel operation.

type ListDefaultModelRes

type ListDefaultModelRes interface {
	// contains filtered or unexported methods
}

type Middleware

type Middleware = middleware.Middleware

Middleware is middleware type.

type OptInt

type OptInt struct {
	Value int
	Set   bool
}

OptInt is optional int.

func NewOptInt

func NewOptInt(v int) OptInt

NewOptInt returns new OptInt with value set to v.

func (OptInt) Get

func (o OptInt) Get() (v int, ok bool)

Get returns value and boolean that denotes whether value was set.

func (OptInt) IsSet

func (o OptInt) IsSet() bool

IsSet returns true if OptInt was set.

func (OptInt) Or

func (o OptInt) Or(d int) int

Or returns value if set, or given parameter if does not.

func (*OptInt) Reset

func (o *OptInt) Reset()

Reset unsets value.

func (*OptInt) SetTo

func (o *OptInt) SetTo(v int)

SetTo sets value to v.

type Option

type Option interface {
	ServerOption
	ClientOption
}

Option is config option.

func WithMeterProvider

func WithMeterProvider(provider metric.MeterProvider) Option

WithMeterProvider specifies a meter provider to use for creating a meter.

If none is specified, the otel.GetMeterProvider() is used.

func WithTracerProvider

func WithTracerProvider(provider trace.TracerProvider) Option

WithTracerProvider specifies a tracer provider to use for creating a tracer.

If none is specified, the global provider is used.

type R400Item

type R400Item struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

func (*R400Item) Decode

func (s *R400Item) Decode(d *jx.Decoder) error

Decode decodes R400Item from json.

func (*R400Item) Encode

func (s *R400Item) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*R400Item) GetCode

func (s *R400Item) GetCode() int

GetCode returns the value of Code.

func (*R400Item) GetMessage

func (s *R400Item) GetMessage() string

GetMessage returns the value of Message.

func (*R400Item) MarshalJSON

func (s *R400Item) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*R400Item) SetCode

func (s *R400Item) SetCode(val int)

SetCode sets the value of Code.

func (*R400Item) SetMessage

func (s *R400Item) SetMessage(val string)

SetMessage sets the value of Message.

func (*R400Item) UnmarshalJSON

func (s *R400Item) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type R404Item

type R404Item struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

func (*R404Item) Decode

func (s *R404Item) Decode(d *jx.Decoder) error

Decode decodes R404Item from json.

func (*R404Item) Encode

func (s *R404Item) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*R404Item) GetCode

func (s *R404Item) GetCode() int

GetCode returns the value of Code.

func (*R404Item) GetMessage

func (s *R404Item) GetMessage() string

GetMessage returns the value of Message.

func (*R404Item) MarshalJSON

func (s *R404Item) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*R404Item) SetCode

func (s *R404Item) SetCode(val int)

SetCode sets the value of Code.

func (*R404Item) SetMessage

func (s *R404Item) SetMessage(val string)

SetMessage sets the value of Message.

func (*R404Item) UnmarshalJSON

func (s *R404Item) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type R409Item

type R409Item struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

func (*R409Item) Decode

func (s *R409Item) Decode(d *jx.Decoder) error

Decode decodes R409Item from json.

func (*R409Item) Encode

func (s *R409Item) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*R409Item) GetCode

func (s *R409Item) GetCode() int

GetCode returns the value of Code.

func (*R409Item) GetMessage

func (s *R409Item) GetMessage() string

GetMessage returns the value of Message.

func (*R409Item) MarshalJSON

func (s *R409Item) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*R409Item) SetCode

func (s *R409Item) SetCode(val int)

SetCode sets the value of Code.

func (*R409Item) SetMessage

func (s *R409Item) SetMessage(val string)

SetMessage sets the value of Message.

func (*R409Item) UnmarshalJSON

func (s *R409Item) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type R500Item

type R500Item struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

func (*R500Item) Decode

func (s *R500Item) Decode(d *jx.Decoder) error

Decode decodes R500Item from json.

func (*R500Item) Encode

func (s *R500Item) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*R500Item) GetCode

func (s *R500Item) GetCode() int

GetCode returns the value of Code.

func (*R500Item) GetMessage

func (s *R500Item) GetMessage() string

GetMessage returns the value of Message.

func (*R500Item) MarshalJSON

func (s *R500Item) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*R500Item) SetCode

func (s *R500Item) SetCode(val int)

SetCode sets the value of Code.

func (*R500Item) SetMessage

func (s *R500Item) SetMessage(val string)

SetMessage sets the value of Message.

func (*R500Item) UnmarshalJSON

func (s *R500Item) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type ReadDefaultModelParams

type ReadDefaultModelParams struct {
	// ID of the DefaultModel.
	ID uuid.UUID
}

ReadDefaultModelParams is parameters of readDefaultModel operation.

type ReadDefaultModelRes

type ReadDefaultModelRes interface {
	// contains filtered or unexported methods
}

type Route

type Route struct {
	// contains filtered or unexported fields
}

Route is route object.

func (Route) Args

func (r Route) Args() []string

Args returns parsed arguments.

func (Route) Name

func (r Route) Name() string

Name returns ogen operation name.

It is guaranteed to be unique and not empty.

func (Route) OperationID

func (r Route) OperationID() string

OperationID returns OpenAPI operationId.

func (Route) PathPattern

func (r Route) PathPattern() string

PathPattern returns OpenAPI path.

func (Route) Summary

func (r Route) Summary() string

Summary returns OpenAPI summary.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server implements http server based on OpenAPI v3 specification and calls Handler to handle requests.

func NewServer

func NewServer(h Handler, opts ...ServerOption) (*Server, error)

NewServer creates new Server.

func (*Server) FindPath

func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool)

FindPath finds Route for given method and URL.

func (*Server) FindRoute

func (s *Server) FindRoute(method, path string) (Route, bool)

FindRoute finds Route for given method and path.

Note: this method does not unescape path or handle reserved characters in path properly. Use FindPath instead.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves http request as defined by OpenAPI v3 specification, calling handler that matches the path or returning not found error.

type ServerOption

type ServerOption interface {
	// contains filtered or unexported methods
}

ServerOption is server config option.

func WithErrorHandler

func WithErrorHandler(h ErrorHandler) ServerOption

WithErrorHandler specifies error handler to use.

func WithMaxMultipartMemory

func WithMaxMultipartMemory(max int64) ServerOption

WithMaxMultipartMemory specifies limit of memory for storing file parts. File parts which can't be stored in memory will be stored on disk in temporary files.

func WithMethodNotAllowed

func WithMethodNotAllowed(methodNotAllowed func(w http.ResponseWriter, r *http.Request, allowed string)) ServerOption

WithMethodNotAllowed specifies Method Not Allowed handler to use.

func WithMiddleware

func WithMiddleware(m ...Middleware) ServerOption

WithMiddleware specifies middlewares to use.

func WithNotFound

func WithNotFound(notFound http.HandlerFunc) ServerOption

WithNotFound specifies Not Found handler to use.

func WithPathPrefix

func WithPathPrefix(prefix string) ServerOption

WithPathPrefix specifies server path prefix.

type UnimplementedHandler

type UnimplementedHandler struct{}

UnimplementedHandler is no-op Handler which returns http.ErrNotImplemented.

func (UnimplementedHandler) ListDefaultModel

ListDefaultModel implements listDefaultModel operation.

List for DefaultModels.

GET /defaultmodel

func (UnimplementedHandler) NewError

func (UnimplementedHandler) NewError(ctx context.Context, err error) (r *ErrorStatusCode)

NewError creates *ErrorStatusCode from error returned by handler.

Used for common default response.

func (UnimplementedHandler) ReadDefaultModel

ReadDefaultModel implements readDefaultModel operation.

Finds the DefaultModel with the requested ID and returns it.

GET /defaultmodel/{id}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL