api

package
v0.0.0-...-00be380 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: GPL-3.0 Imports: 25 Imported by: 0

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

func (c *Client) GetCodeforcesProblem(ctx context.Context, params GetCodeforcesProblemParams) (*CodeforcesProblem, error)

GetCodeforcesProblem invokes get-codeforces-problem operation.

Get Codeforces Problem.

GET /codeforces/problems/{contest_id}/{index}

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 CodeforcesLanguage

type CodeforcesLanguage struct {
	ID   float64 `json:"id"`
	Name string  `json:"name"`
}

Ref: #/components/schemas/CodeforcesLanguage

func (*CodeforcesLanguage) Decode

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

Decode decodes CodeforcesLanguage from json.

func (*CodeforcesLanguage) Encode

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

Encode implements json.Marshaler.

func (*CodeforcesLanguage) GetID

func (s *CodeforcesLanguage) GetID() float64

GetID returns the value of ID.

func (*CodeforcesLanguage) GetName

func (s *CodeforcesLanguage) GetName() string

GetName returns the value of Name.

func (*CodeforcesLanguage) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*CodeforcesLanguage) SetID

func (s *CodeforcesLanguage) SetID(val float64)

SetID sets the value of ID.

func (*CodeforcesLanguage) SetName

func (s *CodeforcesLanguage) SetName(val string)

SetName sets the value of Name.

func (*CodeforcesLanguage) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*CodeforcesLanguage) Validate

func (s *CodeforcesLanguage) Validate() error

type CodeforcesProblem

type CodeforcesProblem struct {
	ContestID   float64              `json:"contest_id"`
	Index       string               `json:"index"`
	Name        string               `json:"name"`
	TimeLimit   int                  `json:"time_limit"`
	MemoryLimit int                  `json:"memory_limit"`
	Tags        []string             `json:"tags"`
	Languages   []CodeforcesLanguage `json:"languages"`
	Legend      string               `json:"legend"`
	Input       string               `json:"input"`
	Output      string               `json:"output"`
	Interaction OptString            `json:"interaction"`
	Scoring     OptString            `json:"scoring"`
	Notes       string               `json:"notes"`
	Examples    []CodeforcesTestcase `json:"examples"`
}

Ref: #/components/schemas/CodeforcesProblem

func (*CodeforcesProblem) Decode

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

Decode decodes CodeforcesProblem from json.

func (*CodeforcesProblem) Encode

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

Encode implements json.Marshaler.

func (*CodeforcesProblem) GetContestID

func (s *CodeforcesProblem) GetContestID() float64

GetContestID returns the value of ContestID.

func (*CodeforcesProblem) GetExamples

func (s *CodeforcesProblem) GetExamples() []CodeforcesTestcase

GetExamples returns the value of Examples.

func (*CodeforcesProblem) GetIndex

func (s *CodeforcesProblem) GetIndex() string

GetIndex returns the value of Index.

func (*CodeforcesProblem) GetInput

func (s *CodeforcesProblem) GetInput() string

GetInput returns the value of Input.

func (*CodeforcesProblem) GetInteraction

func (s *CodeforcesProblem) GetInteraction() OptString

GetInteraction returns the value of Interaction.

func (*CodeforcesProblem) GetLanguages

func (s *CodeforcesProblem) GetLanguages() []CodeforcesLanguage

GetLanguages returns the value of Languages.

func (*CodeforcesProblem) GetLegend

func (s *CodeforcesProblem) GetLegend() string

GetLegend returns the value of Legend.

func (*CodeforcesProblem) GetMemoryLimit

func (s *CodeforcesProblem) GetMemoryLimit() int

GetMemoryLimit returns the value of MemoryLimit.

func (*CodeforcesProblem) GetName

func (s *CodeforcesProblem) GetName() string

GetName returns the value of Name.

func (*CodeforcesProblem) GetNotes

func (s *CodeforcesProblem) GetNotes() string

GetNotes returns the value of Notes.

func (*CodeforcesProblem) GetOutput

func (s *CodeforcesProblem) GetOutput() string

GetOutput returns the value of Output.

func (*CodeforcesProblem) GetScoring

func (s *CodeforcesProblem) GetScoring() OptString

GetScoring returns the value of Scoring.

func (*CodeforcesProblem) GetTags

func (s *CodeforcesProblem) GetTags() []string

GetTags returns the value of Tags.

func (*CodeforcesProblem) GetTimeLimit

func (s *CodeforcesProblem) GetTimeLimit() int

GetTimeLimit returns the value of TimeLimit.

func (*CodeforcesProblem) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*CodeforcesProblem) SetContestID

func (s *CodeforcesProblem) SetContestID(val float64)

SetContestID sets the value of ContestID.

func (*CodeforcesProblem) SetExamples

func (s *CodeforcesProblem) SetExamples(val []CodeforcesTestcase)

SetExamples sets the value of Examples.

func (*CodeforcesProblem) SetIndex

func (s *CodeforcesProblem) SetIndex(val string)

SetIndex sets the value of Index.

func (*CodeforcesProblem) SetInput

func (s *CodeforcesProblem) SetInput(val string)

SetInput sets the value of Input.

func (*CodeforcesProblem) SetInteraction

func (s *CodeforcesProblem) SetInteraction(val OptString)

SetInteraction sets the value of Interaction.

func (*CodeforcesProblem) SetLanguages

func (s *CodeforcesProblem) SetLanguages(val []CodeforcesLanguage)

SetLanguages sets the value of Languages.

func (*CodeforcesProblem) SetLegend

func (s *CodeforcesProblem) SetLegend(val string)

SetLegend sets the value of Legend.

func (*CodeforcesProblem) SetMemoryLimit

func (s *CodeforcesProblem) SetMemoryLimit(val int)

SetMemoryLimit sets the value of MemoryLimit.

func (*CodeforcesProblem) SetName

func (s *CodeforcesProblem) SetName(val string)

SetName sets the value of Name.

func (*CodeforcesProblem) SetNotes

func (s *CodeforcesProblem) SetNotes(val string)

SetNotes sets the value of Notes.

func (*CodeforcesProblem) SetOutput

func (s *CodeforcesProblem) SetOutput(val string)

SetOutput sets the value of Output.

func (*CodeforcesProblem) SetScoring

func (s *CodeforcesProblem) SetScoring(val OptString)

SetScoring sets the value of Scoring.

func (*CodeforcesProblem) SetTags

func (s *CodeforcesProblem) SetTags(val []string)

SetTags sets the value of Tags.

func (*CodeforcesProblem) SetTimeLimit

func (s *CodeforcesProblem) SetTimeLimit(val int)

SetTimeLimit sets the value of TimeLimit.

func (*CodeforcesProblem) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*CodeforcesProblem) Validate

func (s *CodeforcesProblem) Validate() error

type CodeforcesTestcase

type CodeforcesTestcase struct {
	Input  string `json:"input"`
	Output string `json:"output"`
}

Ref: #/components/schemas/CodeforcesTestcase

func (*CodeforcesTestcase) Decode

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

Decode decodes CodeforcesTestcase from json.

func (*CodeforcesTestcase) Encode

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

Encode implements json.Marshaler.

func (*CodeforcesTestcase) GetInput

func (s *CodeforcesTestcase) GetInput() string

GetInput returns the value of Input.

func (*CodeforcesTestcase) GetOutput

func (s *CodeforcesTestcase) GetOutput() string

GetOutput returns the value of Output.

func (*CodeforcesTestcase) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*CodeforcesTestcase) SetInput

func (s *CodeforcesTestcase) SetInput(val string)

SetInput sets the value of Input.

func (*CodeforcesTestcase) SetOutput

func (s *CodeforcesTestcase) SetOutput(val string)

SetOutput sets the value of Output.

func (*CodeforcesTestcase) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type Error

type Error struct {
	Code    string `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() string

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

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 GetCodeforcesProblemParams

type GetCodeforcesProblemParams struct {
	// Contest ID.
	ContestID int
	// Problem Index. Usually, a letter or letter with digit(s) indicating the problem index in a contest.
	Index string
}

GetCodeforcesProblemParams is parameters of get-codeforces-problem operation.

type Handler

type Handler interface {
	// GetCodeforcesProblem implements get-codeforces-problem operation.
	//
	// Get Codeforces Problem.
	//
	// GET /codeforces/problems/{contest_id}/{index}
	GetCodeforcesProblem(ctx context.Context, params GetCodeforcesProblemParams) (*CodeforcesProblem, 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 Invoker

type Invoker interface {
	// GetCodeforcesProblem invokes get-codeforces-problem operation.
	//
	// Get Codeforces Problem.
	//
	// GET /codeforces/problems/{contest_id}/{index}
	GetCodeforcesProblem(ctx context.Context, params GetCodeforcesProblemParams) (*CodeforcesProblem, error)
}

Invoker invokes operations described by OpenAPI v3 specification.

type Labeler

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

Labeler is used to allow adding custom attributes to the server request metrics.

func LabelerFromContext

func LabelerFromContext(ctx context.Context) (*Labeler, bool)

LabelerFromContext retrieves the Labeler from the provided context, if present.

If no Labeler was found in the provided context a new, empty Labeler is returned and the second return value is false. In this case it is safe to use the Labeler but any attributes added to it will not be used.

func (*Labeler) Add

func (l *Labeler) Add(attrs ...attribute.KeyValue)

Add attributes to the Labeler.

func (*Labeler) AttributeSet

func (l *Labeler) AttributeSet() attribute.Set

AttributeSet returns the attributes added to the Labeler as an attribute.Set.

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.

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

func (UnimplementedHandler) GetCodeforcesProblem(ctx context.Context, params GetCodeforcesProblemParams) (r *CodeforcesProblem, _ error)

GetCodeforcesProblem implements get-codeforces-problem operation.

Get Codeforces Problem.

GET /codeforces/problems/{contest_id}/{index}

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