api

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Code generated by ogen, DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Batch

type Batch struct {
	// Keys list.
	Keys []string `json:"keys"`
	// Cursor used for pagination.
	Cursor int64 `json:"cursor"`
}

Ref: #/components/schemas/batch

func (*Batch) Decode

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

Decode decodes Batch from json.

func (*Batch) Encode

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

Encode implements json.Marshaler.

func (*Batch) GetCursor

func (s *Batch) GetCursor() int64

GetCursor returns the value of Cursor.

func (*Batch) GetKeys

func (s *Batch) GetKeys() []string

GetKeys returns the value of Keys.

func (*Batch) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*Batch) SetCursor

func (s *Batch) SetCursor(val int64)

SetCursor sets the value of Cursor.

func (*Batch) SetKeys

func (s *Batch) SetKeys(val []string)

SetKeys sets the value of Keys.

func (*Batch) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*Batch) Validate

func (s *Batch) Validate() error

type DeleteNamespaceNoContent

type DeleteNamespaceNoContent struct{}

DeleteNamespaceNoContent is response for DeleteNamespace operation.

type DeleteNamespaceParams

type DeleteNamespaceParams struct {
	// Key-Value namespace.
	Namespace string
}

DeleteNamespaceParams is parameters of deleteNamespace operation.

type DeleteNoContent

type DeleteNoContent struct{}

DeleteNoContent is response for Delete operation.

type DeleteParams

type DeleteParams struct {
	// Key-Value namespace.
	Namespace string
	// Key name.
	Key string
}

DeleteParams is parameters of delete operation.

type ErrorHandler

type ErrorHandler = ogenerrors.ErrorHandler

ErrorHandler is error handler.

type GetNotFound

type GetNotFound struct{}

GetNotFound is response for Get operation.

type GetOK

type GetOK struct {
	Data io.Reader
}

func (GetOK) Read

func (s GetOK) Read(p []byte) (n int, err error)

Read reads data from the Data reader.

Kept to satisfy the io.Reader interface.

type GetOKHeaders

type GetOKHeaders struct {
	XContentType string
	XTTL         OptFloat64
	Response     GetOK
}

GetOKHeaders wraps GetOK with response headers.

func (*GetOKHeaders) GetResponse

func (s *GetOKHeaders) GetResponse() GetOK

GetResponse returns the value of Response.

func (*GetOKHeaders) GetXContentType

func (s *GetOKHeaders) GetXContentType() string

GetXContentType returns the value of XContentType.

func (*GetOKHeaders) GetXTTL

func (s *GetOKHeaders) GetXTTL() OptFloat64

GetXTTL returns the value of XTTL.

func (*GetOKHeaders) SetResponse

func (s *GetOKHeaders) SetResponse(val GetOK)

SetResponse sets the value of Response.

func (*GetOKHeaders) SetXContentType

func (s *GetOKHeaders) SetXContentType(val string)

SetXContentType sets the value of XContentType.

func (*GetOKHeaders) SetXTTL

func (s *GetOKHeaders) SetXTTL(val OptFloat64)

SetXTTL sets the value of XTTL.

func (*GetOKHeaders) Validate

func (s *GetOKHeaders) Validate() error

type GetParams

type GetParams struct {
	// Key-Value namespace.
	Namespace string
	// Key name.
	Key string
}

GetParams is parameters of get operation.

type GetRes

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

type Handler

type Handler interface {
	// Delete implements delete operation.
	//
	// Delete key. Does nothing if key not exists.
	//
	// DELETE /{namespace}/{key}
	Delete(ctx context.Context, params DeleteParams) error
	// DeleteNamespace implements deleteNamespace operation.
	//
	// Delete namespace and all keys.
	//
	// DELETE /{namespace}
	DeleteNamespace(ctx context.Context, params DeleteNamespaceParams) error
	// Get implements get operation.
	//
	// Get value by key.
	//
	// GET /{namespace}/{key}
	Get(ctx context.Context, params GetParams) (GetRes, error)
	// Keys implements keys operation.
	//
	// List keys in namespace page by page. Iteration may not be consistent if there are updates between
	// pages.
	// At the end of page, operation will return empty list.
	// Iteration order is non-deterministic, but generally tends to be from oldest key to newest key.
	//
	// GET /{namespace}
	Keys(ctx context.Context, params KeysParams) (*Batch, error)
	// Set implements set operation.
	//
	// Create or replace value in namespace.
	//
	// POST /{namespace}/{key}
	Set(ctx context.Context, req *SetReqWithContentType, params SetParams) error
}

Handler handles operations described by OpenAPI v3 specification.

type HeaderAuth

type HeaderAuth struct {
	APIKey string
}

func (*HeaderAuth) GetAPIKey

func (s *HeaderAuth) GetAPIKey() string

GetAPIKey returns the value of APIKey.

func (*HeaderAuth) SetAPIKey

func (s *HeaderAuth) SetAPIKey(val string)

SetAPIKey sets the value of APIKey.

type KeysParams

type KeysParams struct {
	// Key-Value namespace.
	Namespace string
	// Cursor of the previous page, should be passed in from the previous request or absent for new
	// request.
	Cursor OptInt64
}

KeysParams is parameters of keys operation.

type Middleware

type Middleware = middleware.Middleware

Middleware is middleware type.

type OptFloat64

type OptFloat64 struct {
	Value float64
	Set   bool
}

OptFloat64 is optional float64.

func NewOptFloat64

func NewOptFloat64(v float64) OptFloat64

NewOptFloat64 returns new OptFloat64 with value set to v.

func (OptFloat64) Get

func (o OptFloat64) Get() (v float64, ok bool)

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

func (OptFloat64) IsSet

func (o OptFloat64) IsSet() bool

IsSet returns true if OptFloat64 was set.

func (OptFloat64) Or

func (o OptFloat64) Or(d float64) float64

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

func (*OptFloat64) Reset

func (o *OptFloat64) Reset()

Reset unsets value.

func (*OptFloat64) SetTo

func (o *OptFloat64) SetTo(v float64)

SetTo sets value to v.

type OptInt64

type OptInt64 struct {
	Value int64
	Set   bool
}

OptInt64 is optional int64.

func NewOptInt64

func NewOptInt64(v int64) OptInt64

NewOptInt64 returns new OptInt64 with value set to v.

func (OptInt64) Get

func (o OptInt64) Get() (v int64, ok bool)

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

func (OptInt64) IsSet

func (o OptInt64) IsSet() bool

IsSet returns true if OptInt64 was set.

func (OptInt64) Or

func (o OptInt64) Or(d int64) int64

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

func (*OptInt64) Reset

func (o *OptInt64) Reset()

Reset unsets value.

func (*OptInt64) SetTo

func (o *OptInt64) SetTo(v int64)

SetTo sets value to v.

type Option

type Option interface {
	ServerOption
}

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 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.

type SecurityHandler

type SecurityHandler interface {
	// HandleHeaderAuth handles HeaderAuth security.
	HandleHeaderAuth(ctx context.Context, operationName string, t HeaderAuth) (context.Context, error)
}

SecurityHandler is handler for security parameters.

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, sec SecurityHandler, 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 SetNoContent

type SetNoContent struct{}

SetNoContent is response for Set operation.

type SetParams

type SetParams struct {
	// Key-Value namespace.
	Namespace string
	// Key name.
	Key string
	// Time-to-live for the key in seconds (floating).
	TTL OptFloat64
}

SetParams is parameters of set operation.

type SetReq

type SetReq struct {
	Data io.Reader
}

func (SetReq) Read

func (s SetReq) Read(p []byte) (n int, err error)

Read reads data from the Data reader.

Kept to satisfy the io.Reader interface.

type SetReqWithContentType

type SetReqWithContentType struct {
	ContentType string
	Content     SetReq
}

SetReqWithContentType wraps SetReq with Content-Type.

func (*SetReqWithContentType) GetContent

func (s *SetReqWithContentType) GetContent() SetReq

GetContent returns the value of Content.

func (*SetReqWithContentType) GetContentType

func (s *SetReqWithContentType) GetContentType() string

GetContentType returns the value of ContentType.

func (*SetReqWithContentType) SetContent

func (s *SetReqWithContentType) SetContent(val SetReq)

SetContent sets the value of Content.

func (*SetReqWithContentType) SetContentType

func (s *SetReqWithContentType) SetContentType(val string)

SetContentType sets the value of ContentType.

type UnimplementedHandler

type UnimplementedHandler struct{}

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

func (UnimplementedHandler) Delete

Delete implements delete operation.

Delete key. Does nothing if key not exists.

DELETE /{namespace}/{key}

func (UnimplementedHandler) DeleteNamespace

func (UnimplementedHandler) DeleteNamespace(ctx context.Context, params DeleteNamespaceParams) error

DeleteNamespace implements deleteNamespace operation.

Delete namespace and all keys.

DELETE /{namespace}

func (UnimplementedHandler) Get

func (UnimplementedHandler) Get(ctx context.Context, params GetParams) (r GetRes, _ error)

Get implements get operation.

Get value by key.

GET /{namespace}/{key}

func (UnimplementedHandler) Keys

func (UnimplementedHandler) Keys(ctx context.Context, params KeysParams) (r *Batch, _ error)

Keys implements keys operation.

List keys in namespace page by page. Iteration may not be consistent if there are updates between pages. At the end of page, operation will return empty list. Iteration order is non-deterministic, but generally tends to be from oldest key to newest key.

GET /{namespace}

func (UnimplementedHandler) Set

Set implements set operation.

Create or replace value in namespace.

POST /{namespace}/{key}

Jump to

Keyboard shortcuts

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