api

package
v0.0.0-...-e171d11 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: MIT Imports: 28 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) CreateSample

func (c *Client) CreateSample(ctx context.Context, request *CreateSampleRequestSchema) (CreateSampleRes, error)

CreateSample invokes createSample operation.

Create a new sample item.

POST /samples

func (*Client) DeleteSample

func (c *Client) DeleteSample(ctx context.Context, params DeleteSampleParams) (DeleteSampleRes, error)

DeleteSample invokes deleteSample operation.

Delete a specific sample item.

DELETE /samples/{id}

func (*Client) Health

func (c *Client) Health(ctx context.Context) (HealthRes, error)

Health invokes health operation.

Health.

GET /health

func (*Client) ListSample

func (c *Client) ListSample(ctx context.Context) (ListSampleRes, error)

ListSample invokes listSample operation.

Get all sample items.

GET /samples

func (*Client) ReadSample

func (c *Client) ReadSample(ctx context.Context, params ReadSampleParams) (ReadSampleRes, error)

ReadSample invokes readSample operation.

Read a specific sample item.

GET /samples/{id}

func (*Client) UpdateSample

func (c *Client) UpdateSample(ctx context.Context, request *UpdateSampleRequestSchema, params UpdateSampleParams) (UpdateSampleRes, error)

UpdateSample invokes updateSample operation.

Update a specific sample item.

PUT /samples/{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 CreateSampleRequestSchema

type CreateSampleRequestSchema struct {
	// Message.
	Message string `json:"message"`
}

Ref: #/components/schemas/CreateSampleRequestSchema

func (*CreateSampleRequestSchema) Decode

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

Decode decodes CreateSampleRequestSchema from json.

func (*CreateSampleRequestSchema) Encode

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

Encode implements json.Marshaler.

func (*CreateSampleRequestSchema) GetMessage

func (s *CreateSampleRequestSchema) GetMessage() string

GetMessage returns the value of Message.

func (*CreateSampleRequestSchema) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*CreateSampleRequestSchema) SetMessage

func (s *CreateSampleRequestSchema) SetMessage(val string)

SetMessage sets the value of Message.

func (*CreateSampleRequestSchema) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type CreateSampleRes

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

type CreateSampleResponseSchema

type CreateSampleResponseSchema struct {
	Sample Sample `json:"sample"`
}

Ref: #/components/schemas/CreateSampleResponseSchema

func (*CreateSampleResponseSchema) Decode

Decode decodes CreateSampleResponseSchema from json.

func (*CreateSampleResponseSchema) Encode

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

Encode implements json.Marshaler.

func (*CreateSampleResponseSchema) GetSample

func (s *CreateSampleResponseSchema) GetSample() Sample

GetSample returns the value of Sample.

func (*CreateSampleResponseSchema) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*CreateSampleResponseSchema) SetSample

func (s *CreateSampleResponseSchema) SetSample(val Sample)

SetSample sets the value of Sample.

func (*CreateSampleResponseSchema) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type DeleteSampleNoContent

type DeleteSampleNoContent struct{}

DeleteSampleNoContent is response for DeleteSample operation.

type DeleteSampleParams

type DeleteSampleParams struct {
	ID uuid.UUID
}

DeleteSampleParams is parameters of deleteSample operation.

type DeleteSampleRes

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

type ErrorHandler

type ErrorHandler = ogenerrors.ErrorHandler

ErrorHandler is error handler.

type ErrorResponseSchema

type ErrorResponseSchema struct {
	Message string `json:"message"`
}

Ref: #/components/schemas/ErrorResponseSchema

func (*ErrorResponseSchema) Decode

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

Decode decodes ErrorResponseSchema from json.

func (*ErrorResponseSchema) Encode

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

Encode implements json.Marshaler.

func (*ErrorResponseSchema) GetMessage

func (s *ErrorResponseSchema) GetMessage() string

GetMessage returns the value of Message.

func (*ErrorResponseSchema) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*ErrorResponseSchema) SetMessage

func (s *ErrorResponseSchema) SetMessage(val string)

SetMessage sets the value of Message.

func (*ErrorResponseSchema) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type Handler

type Handler interface {
	// CreateSample implements createSample operation.
	//
	// Create a new sample item.
	//
	// POST /samples
	CreateSample(ctx context.Context, req *CreateSampleRequestSchema) (CreateSampleRes, error)
	// DeleteSample implements deleteSample operation.
	//
	// Delete a specific sample item.
	//
	// DELETE /samples/{id}
	DeleteSample(ctx context.Context, params DeleteSampleParams) (DeleteSampleRes, error)
	// Health implements health operation.
	//
	// Health.
	//
	// GET /health
	Health(ctx context.Context) (HealthRes, error)
	// ListSample implements listSample operation.
	//
	// Get all sample items.
	//
	// GET /samples
	ListSample(ctx context.Context) (ListSampleRes, error)
	// ReadSample implements readSample operation.
	//
	// Read a specific sample item.
	//
	// GET /samples/{id}
	ReadSample(ctx context.Context, params ReadSampleParams) (ReadSampleRes, error)
	// UpdateSample implements updateSample operation.
	//
	// Update a specific sample item.
	//
	// PUT /samples/{id}
	UpdateSample(ctx context.Context, req *UpdateSampleRequestSchema, params UpdateSampleParams) (UpdateSampleRes, error)
}

Handler handles operations described by OpenAPI v3 specification.

type HealthRes

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

type HealthResponseSchema

type HealthResponseSchema struct {
	// Message.
	Message string `json:"message"`
}

Ref: #/components/schemas/HealthResponseSchema

func (*HealthResponseSchema) Decode

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

Decode decodes HealthResponseSchema from json.

func (*HealthResponseSchema) Encode

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

Encode implements json.Marshaler.

func (*HealthResponseSchema) GetMessage

func (s *HealthResponseSchema) GetMessage() string

GetMessage returns the value of Message.

func (*HealthResponseSchema) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*HealthResponseSchema) SetMessage

func (s *HealthResponseSchema) SetMessage(val string)

SetMessage sets the value of Message.

func (*HealthResponseSchema) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type Invoker

type Invoker interface {
	// CreateSample invokes createSample operation.
	//
	// Create a new sample item.
	//
	// POST /samples
	CreateSample(ctx context.Context, request *CreateSampleRequestSchema) (CreateSampleRes, error)
	// DeleteSample invokes deleteSample operation.
	//
	// Delete a specific sample item.
	//
	// DELETE /samples/{id}
	DeleteSample(ctx context.Context, params DeleteSampleParams) (DeleteSampleRes, error)
	// Health invokes health operation.
	//
	// Health.
	//
	// GET /health
	Health(ctx context.Context) (HealthRes, error)
	// ListSample invokes listSample operation.
	//
	// Get all sample items.
	//
	// GET /samples
	ListSample(ctx context.Context) (ListSampleRes, error)
	// ReadSample invokes readSample operation.
	//
	// Read a specific sample item.
	//
	// GET /samples/{id}
	ReadSample(ctx context.Context, params ReadSampleParams) (ReadSampleRes, error)
	// UpdateSample invokes updateSample operation.
	//
	// Update a specific sample item.
	//
	// PUT /samples/{id}
	UpdateSample(ctx context.Context, request *UpdateSampleRequestSchema, params UpdateSampleParams) (UpdateSampleRes, error)
}

Invoker invokes operations described by OpenAPI v3 specification.

type ListSampleRes

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

type ListSampleResponseSchema

type ListSampleResponseSchema struct {
	Samples []Sample `json:"samples"`
}

Ref: #/components/schemas/ListSampleResponseSchema

func (*ListSampleResponseSchema) Decode

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

Decode decodes ListSampleResponseSchema from json.

func (*ListSampleResponseSchema) Encode

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

Encode implements json.Marshaler.

func (*ListSampleResponseSchema) GetSamples

func (s *ListSampleResponseSchema) GetSamples() []Sample

GetSamples returns the value of Samples.

func (*ListSampleResponseSchema) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*ListSampleResponseSchema) SetSamples

func (s *ListSampleResponseSchema) SetSamples(val []Sample)

SetSamples sets the value of Samples.

func (*ListSampleResponseSchema) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*ListSampleResponseSchema) Validate

func (s *ListSampleResponseSchema) Validate() error

type Middleware

type Middleware = middleware.Middleware

Middleware is middleware type.

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 ReadSampleParams

type ReadSampleParams struct {
	ID uuid.UUID
}

ReadSampleParams is parameters of readSample operation.

type ReadSampleRes

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

type ReadSampleResponseSchema

type ReadSampleResponseSchema struct {
	Sample Sample `json:"sample"`
}

Ref: #/components/schemas/ReadSampleResponseSchema

func (*ReadSampleResponseSchema) Decode

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

Decode decodes ReadSampleResponseSchema from json.

func (*ReadSampleResponseSchema) Encode

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

Encode implements json.Marshaler.

func (*ReadSampleResponseSchema) GetSample

func (s *ReadSampleResponseSchema) GetSample() Sample

GetSample returns the value of Sample.

func (*ReadSampleResponseSchema) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*ReadSampleResponseSchema) SetSample

func (s *ReadSampleResponseSchema) SetSample(val Sample)

SetSample sets the value of Sample.

func (*ReadSampleResponseSchema) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

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 Sample

type Sample struct {
	// The ID of the sample item.
	ID uuid.UUID `json:"id"`
	// Message.
	Message string `json:"message"`
	// The date and time when the sample item was created.
	CreatedAt time.Time `json:"created_at"`
	// The date and time when the sample item was updated.
	UpdatedAt time.Time `json:"updated_at"`
}

Ref: #/components/schemas/Sample

func (*Sample) Decode

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

Decode decodes Sample from json.

func (*Sample) Encode

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

Encode implements json.Marshaler.

func (*Sample) GetCreatedAt

func (s *Sample) GetCreatedAt() time.Time

GetCreatedAt returns the value of CreatedAt.

func (*Sample) GetID

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

GetID returns the value of ID.

func (*Sample) GetMessage

func (s *Sample) GetMessage() string

GetMessage returns the value of Message.

func (*Sample) GetUpdatedAt

func (s *Sample) GetUpdatedAt() time.Time

GetUpdatedAt returns the value of UpdatedAt.

func (*Sample) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*Sample) SetCreatedAt

func (s *Sample) SetCreatedAt(val time.Time)

SetCreatedAt sets the value of CreatedAt.

func (*Sample) SetID

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

SetID sets the value of ID.

func (*Sample) SetMessage

func (s *Sample) SetMessage(val string)

SetMessage sets the value of Message.

func (*Sample) SetUpdatedAt

func (s *Sample) SetUpdatedAt(val time.Time)

SetUpdatedAt sets the value of UpdatedAt.

func (*Sample) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

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) CreateSample

CreateSample implements createSample operation.

Create a new sample item.

POST /samples

func (UnimplementedHandler) DeleteSample

DeleteSample implements deleteSample operation.

Delete a specific sample item.

DELETE /samples/{id}

func (UnimplementedHandler) Health

func (UnimplementedHandler) Health(ctx context.Context) (r HealthRes, _ error)

Health implements health operation.

Health.

GET /health

func (UnimplementedHandler) ListSample

func (UnimplementedHandler) ListSample(ctx context.Context) (r ListSampleRes, _ error)

ListSample implements listSample operation.

Get all sample items.

GET /samples

func (UnimplementedHandler) ReadSample

ReadSample implements readSample operation.

Read a specific sample item.

GET /samples/{id}

func (UnimplementedHandler) UpdateSample

UpdateSample implements updateSample operation.

Update a specific sample item.

PUT /samples/{id}

type UpdateSampleParams

type UpdateSampleParams struct {
	ID uuid.UUID
}

UpdateSampleParams is parameters of updateSample operation.

type UpdateSampleRequestSchema

type UpdateSampleRequestSchema struct {
	// Message.
	Message string `json:"message"`
}

Ref: #/components/schemas/UpdateSampleRequestSchema

func (*UpdateSampleRequestSchema) Decode

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

Decode decodes UpdateSampleRequestSchema from json.

func (*UpdateSampleRequestSchema) Encode

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

Encode implements json.Marshaler.

func (*UpdateSampleRequestSchema) GetMessage

func (s *UpdateSampleRequestSchema) GetMessage() string

GetMessage returns the value of Message.

func (*UpdateSampleRequestSchema) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*UpdateSampleRequestSchema) SetMessage

func (s *UpdateSampleRequestSchema) SetMessage(val string)

SetMessage sets the value of Message.

func (*UpdateSampleRequestSchema) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type UpdateSampleRes

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

type UpdateSampleResponseSchema

type UpdateSampleResponseSchema struct {
	Sample Sample `json:"sample"`
}

Ref: #/components/schemas/UpdateSampleResponseSchema

func (*UpdateSampleResponseSchema) Decode

Decode decodes UpdateSampleResponseSchema from json.

func (*UpdateSampleResponseSchema) Encode

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

Encode implements json.Marshaler.

func (*UpdateSampleResponseSchema) GetSample

func (s *UpdateSampleResponseSchema) GetSample() Sample

GetSample returns the value of Sample.

func (*UpdateSampleResponseSchema) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*UpdateSampleResponseSchema) SetSample

func (s *UpdateSampleResponseSchema) SetSample(val Sample)

SetSample sets the value of Sample.

func (*UpdateSampleResponseSchema) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

Jump to

Keyboard shortcuts

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