api

package
v0.0.0-...-ab1f78f Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: Apache-2.0 Imports: 27 Imported by: 1

Documentation

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 AddItemOK

type AddItemOK struct{}

AddItemOK is response for AddItem operation.

type AddItemRequest

type AddItemRequest struct {
	Identifier string   `json:"identifier"`
	SetSpecs   []string `json:"set_specs"`
}

Ref: #/components/schemas/AddItemRequest

func (*AddItemRequest) Decode

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

Decode decodes AddItemRequest from json.

func (*AddItemRequest) Encode

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

Encode implements json.Marshaler.

func (*AddItemRequest) GetIdentifier

func (s *AddItemRequest) GetIdentifier() string

GetIdentifier returns the value of Identifier.

func (*AddItemRequest) GetSetSpecs

func (s *AddItemRequest) GetSetSpecs() []string

GetSetSpecs returns the value of SetSpecs.

func (*AddItemRequest) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*AddItemRequest) SetIdentifier

func (s *AddItemRequest) SetIdentifier(val string)

SetIdentifier sets the value of Identifier.

func (*AddItemRequest) SetSetSpecs

func (s *AddItemRequest) SetSetSpecs(val []string)

SetSetSpecs sets the value of SetSpecs.

func (*AddItemRequest) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*AddItemRequest) Validate

func (s *AddItemRequest) Validate() error

type AddMetadataFormatOK

type AddMetadataFormatOK struct{}

AddMetadataFormatOK is response for AddMetadataFormat operation.

type AddMetadataFormatRequest

type AddMetadataFormatRequest struct {
	MetadataPrefix    string `json:"metadata_prefix"`
	Schema            string `json:"schema"`
	MetadataNamespace string `json:"metadata_namespace"`
}

Ref: #/components/schemas/AddMetadataFormatRequest

func (*AddMetadataFormatRequest) Decode

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

Decode decodes AddMetadataFormatRequest from json.

func (*AddMetadataFormatRequest) Encode

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

Encode implements json.Marshaler.

func (*AddMetadataFormatRequest) GetMetadataNamespace

func (s *AddMetadataFormatRequest) GetMetadataNamespace() string

GetMetadataNamespace returns the value of MetadataNamespace.

func (*AddMetadataFormatRequest) GetMetadataPrefix

func (s *AddMetadataFormatRequest) GetMetadataPrefix() string

GetMetadataPrefix returns the value of MetadataPrefix.

func (*AddMetadataFormatRequest) GetSchema

func (s *AddMetadataFormatRequest) GetSchema() string

GetSchema returns the value of Schema.

func (*AddMetadataFormatRequest) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*AddMetadataFormatRequest) SetMetadataNamespace

func (s *AddMetadataFormatRequest) SetMetadataNamespace(val string)

SetMetadataNamespace sets the value of MetadataNamespace.

func (*AddMetadataFormatRequest) SetMetadataPrefix

func (s *AddMetadataFormatRequest) SetMetadataPrefix(val string)

SetMetadataPrefix sets the value of MetadataPrefix.

func (*AddMetadataFormatRequest) SetSchema

func (s *AddMetadataFormatRequest) SetSchema(val string)

SetSchema sets the value of Schema.

func (*AddMetadataFormatRequest) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*AddMetadataFormatRequest) Validate

func (s *AddMetadataFormatRequest) Validate() error

type AddRecordOK

type AddRecordOK struct{}

AddRecordOK is response for AddRecord operation.

type AddRecordRequest

type AddRecordRequest struct {
	Identifier     string `json:"identifier"`
	MetadataPrefix string `json:"metadata_prefix"`
	Content        string `json:"content"`
}

Ref: #/components/schemas/AddRecordRequest

func (*AddRecordRequest) Decode

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

Decode decodes AddRecordRequest from json.

func (*AddRecordRequest) Encode

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

Encode implements json.Marshaler.

func (*AddRecordRequest) GetContent

func (s *AddRecordRequest) GetContent() string

GetContent returns the value of Content.

func (*AddRecordRequest) GetIdentifier

func (s *AddRecordRequest) GetIdentifier() string

GetIdentifier returns the value of Identifier.

func (*AddRecordRequest) GetMetadataPrefix

func (s *AddRecordRequest) GetMetadataPrefix() string

GetMetadataPrefix returns the value of MetadataPrefix.

func (*AddRecordRequest) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*AddRecordRequest) SetContent

func (s *AddRecordRequest) SetContent(val string)

SetContent sets the value of Content.

func (*AddRecordRequest) SetIdentifier

func (s *AddRecordRequest) SetIdentifier(val string)

SetIdentifier sets the value of Identifier.

func (*AddRecordRequest) SetMetadataPrefix

func (s *AddRecordRequest) SetMetadataPrefix(val string)

SetMetadataPrefix sets the value of MetadataPrefix.

func (*AddRecordRequest) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*AddRecordRequest) Validate

func (s *AddRecordRequest) Validate() error

type AddSetOK

type AddSetOK struct{}

AddSetOK is response for AddSet operation.

type AddSetRequest

type AddSetRequest struct {
	SetSpec        string    `json:"set_spec"`
	SetName        string    `json:"set_name"`
	SetDescription OptString `json:"set_description"`
}

Ref: #/components/schemas/AddSetRequest

func (*AddSetRequest) Decode

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

Decode decodes AddSetRequest from json.

func (*AddSetRequest) Encode

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

Encode implements json.Marshaler.

func (*AddSetRequest) GetSetDescription

func (s *AddSetRequest) GetSetDescription() OptString

GetSetDescription returns the value of SetDescription.

func (*AddSetRequest) GetSetName

func (s *AddSetRequest) GetSetName() string

GetSetName returns the value of SetName.

func (*AddSetRequest) GetSetSpec

func (s *AddSetRequest) GetSetSpec() string

GetSetSpec returns the value of SetSpec.

func (*AddSetRequest) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*AddSetRequest) SetSetDescription

func (s *AddSetRequest) SetSetDescription(val OptString)

SetSetDescription sets the value of SetDescription.

func (*AddSetRequest) SetSetName

func (s *AddSetRequest) SetSetName(val string)

SetSetName sets the value of SetName.

func (*AddSetRequest) SetSetSpec

func (s *AddSetRequest) SetSetSpec(val string)

SetSetSpec sets the value of SetSpec.

func (*AddSetRequest) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*AddSetRequest) Validate

func (s *AddSetRequest) Validate() error

type ApiKey

type ApiKey struct {
	APIKey string
}

func (*ApiKey) GetAPIKey

func (s *ApiKey) GetAPIKey() string

GetAPIKey returns the value of APIKey.

func (*ApiKey) SetAPIKey

func (s *ApiKey) SetAPIKey(val string)

SetAPIKey sets the value of APIKey.

type Client

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

Client implements OAS client.

func NewClient

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

NewClient initializes new Client defined by OAS.

func (*Client) AddItem

func (c *Client) AddItem(ctx context.Context, request *AddItemRequest) error

AddItem invokes addItem operation.

Add item.

POST /add-item

func (*Client) AddMetadataFormat

func (c *Client) AddMetadataFormat(ctx context.Context, request *AddMetadataFormatRequest) error

AddMetadataFormat invokes addMetadataFormat operation.

Add a metadata format.

POST /add-metadata-format

func (*Client) AddRecord

func (c *Client) AddRecord(ctx context.Context, request *AddRecordRequest) error

AddRecord invokes addRecord operation.

Add record.

POST /add-record

func (*Client) AddSet

func (c *Client) AddSet(ctx context.Context, request *AddSetRequest) error

AddSet invokes addSet operation.

Add a set.

POST /add-set

func (*Client) DeleteRecord

func (c *Client) DeleteRecord(ctx context.Context, request *DeleteRecordRequest) error

DeleteRecord invokes deleteRecord operation.

Delete a record.

POST /delete-record

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 DeleteRecordOK

type DeleteRecordOK struct{}

DeleteRecordOK is response for DeleteRecord operation.

type DeleteRecordRequest

type DeleteRecordRequest struct {
	Identifier     string `json:"identifier"`
	MetadataPrefix string `json:"metadata_prefix"`
}

Ref: #/components/schemas/DeleteRecordRequest

func (*DeleteRecordRequest) Decode

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

Decode decodes DeleteRecordRequest from json.

func (*DeleteRecordRequest) Encode

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

Encode implements json.Marshaler.

func (*DeleteRecordRequest) GetIdentifier

func (s *DeleteRecordRequest) GetIdentifier() string

GetIdentifier returns the value of Identifier.

func (*DeleteRecordRequest) GetMetadataPrefix

func (s *DeleteRecordRequest) GetMetadataPrefix() string

GetMetadataPrefix returns the value of MetadataPrefix.

func (*DeleteRecordRequest) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*DeleteRecordRequest) SetIdentifier

func (s *DeleteRecordRequest) SetIdentifier(val string)

SetIdentifier sets the value of Identifier.

func (*DeleteRecordRequest) SetMetadataPrefix

func (s *DeleteRecordRequest) SetMetadataPrefix(val string)

SetMetadataPrefix sets the value of MetadataPrefix.

func (*DeleteRecordRequest) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*DeleteRecordRequest) Validate

func (s *DeleteRecordRequest) Validate() error

type Error

type Error struct {
	Code    int64  `json:"code"`
	Message string `json:"message"`
}

Ref: #/components/schemas/Error

func (*Error) Decode

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

Decode decodes Error from json.

func (*Error) Encode

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

Encode implements json.Marshaler.

func (*Error) GetCode

func (s *Error) GetCode() int64

GetCode returns the value of Code.

func (*Error) GetMessage

func (s *Error) GetMessage() string

GetMessage returns the value of Message.

func (*Error) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*Error) SetCode

func (s *Error) SetCode(val int64)

SetCode sets the value of Code.

func (*Error) SetMessage

func (s *Error) SetMessage(val string)

SetMessage sets the value of Message.

func (*Error) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type ErrorHandler

type ErrorHandler = ogenerrors.ErrorHandler

ErrorHandler is error handler.

type ErrorStatusCode

type ErrorStatusCode struct {
	StatusCode int
	Response   Error
}

ErrorStatusCode wraps Error with StatusCode.

func (*ErrorStatusCode) Error

func (s *ErrorStatusCode) Error() string

func (*ErrorStatusCode) GetResponse

func (s *ErrorStatusCode) GetResponse() Error

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

SetResponse sets the value of Response.

func (*ErrorStatusCode) SetStatusCode

func (s *ErrorStatusCode) SetStatusCode(val int)

SetStatusCode sets the value of StatusCode.

type Handler

type Handler interface {
	// AddItem implements addItem operation.
	//
	// Add item.
	//
	// POST /add-item
	AddItem(ctx context.Context, req *AddItemRequest) error
	// AddMetadataFormat implements addMetadataFormat operation.
	//
	// Add a metadata format.
	//
	// POST /add-metadata-format
	AddMetadataFormat(ctx context.Context, req *AddMetadataFormatRequest) error
	// AddRecord implements addRecord operation.
	//
	// Add record.
	//
	// POST /add-record
	AddRecord(ctx context.Context, req *AddRecordRequest) error
	// AddSet implements addSet operation.
	//
	// Add a set.
	//
	// POST /add-set
	AddSet(ctx context.Context, req *AddSetRequest) error
	// DeleteRecord implements deleteRecord operation.
	//
	// Delete a record.
	//
	// POST /delete-record
	DeleteRecord(ctx context.Context, req *DeleteRecordRequest) 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 Middleware

type Middleware = middleware.Middleware

Middleware is middleware type.

type OptString

type OptString struct {
	Value string
	Set   bool
}

OptString is optional string.

func NewOptString

func NewOptString(v string) OptString

NewOptString returns new OptString with value set to v.

func (*OptString) Decode

func (o *OptString) Decode(d *jx.Decoder) error

Decode decodes string from json.

func (OptString) Encode

func (o OptString) Encode(e *jx.Encoder)

Encode encodes string as json.

func (OptString) Get

func (o OptString) Get() (v string, ok bool)

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

func (OptString) IsSet

func (o OptString) IsSet() bool

IsSet returns true if OptString was set.

func (OptString) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (OptString) Or

func (o OptString) Or(d string) string

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

func (*OptString) Reset

func (o *OptString) Reset()

Reset unsets value.

func (*OptString) SetTo

func (o *OptString) SetTo(v string)

SetTo sets value to v.

func (*OptString) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

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 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 {
	// HandleApiKey handles apiKey security.
	HandleApiKey(ctx context.Context, operationName string, t ApiKey) (context.Context, error)
}

SecurityHandler is handler for security parameters.

type SecuritySource

type SecuritySource interface {
	// ApiKey provides apiKey security value.
	ApiKey(ctx context.Context, operationName string) (ApiKey, error)
}

SecuritySource is provider of security values (tokens, passwords, etc.).

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 Service

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

func NewService

func NewService(repo *repositories.Repo) *Service

func (*Service) AddItem

func (s *Service) AddItem(ctx context.Context, req *AddItemRequest) error

func (*Service) AddMetadataFormat

func (s *Service) AddMetadataFormat(ctx context.Context, req *AddMetadataFormatRequest) error

func (*Service) AddRecord

func (s *Service) AddRecord(ctx context.Context, req *AddRecordRequest) error

func (*Service) AddSet

func (s *Service) AddSet(ctx context.Context, req *AddSetRequest) error

func (*Service) DeleteRecord

func (s *Service) DeleteRecord(ctx context.Context, req *DeleteRecordRequest) error

func (*Service) NewError

func (s *Service) NewError(ctx context.Context, err error) *ErrorStatusCode

type UnimplementedHandler

type UnimplementedHandler struct{}

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

func (UnimplementedHandler) AddItem

AddItem implements addItem operation.

Add item.

POST /add-item

func (UnimplementedHandler) AddMetadataFormat

func (UnimplementedHandler) AddMetadataFormat(ctx context.Context, req *AddMetadataFormatRequest) error

AddMetadataFormat implements addMetadataFormat operation.

Add a metadata format.

POST /add-metadata-format

func (UnimplementedHandler) AddRecord

AddRecord implements addRecord operation.

Add record.

POST /add-record

func (UnimplementedHandler) AddSet

AddSet implements addSet operation.

Add a set.

POST /add-set

func (UnimplementedHandler) DeleteRecord

DeleteRecord implements deleteRecord operation.

Delete a record.

POST /delete-record

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.

Jump to

Keyboard shortcuts

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