api

package
v0.0.0-...-345d9e2 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2024 License: GPL-3.0 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

func WithServerURL

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

WithServerURL sets context key to override server URL.

Types

type AccessToken

type AccessToken struct {
	AccessToken string `json:"accessToken"`
}

Ref: #/components/schemas/AccessToken

func (*AccessToken) Decode

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

Decode decodes AccessToken from json.

func (*AccessToken) Encode

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

Encode implements json.Marshaler.

func (*AccessToken) GetAccessToken

func (s *AccessToken) GetAccessToken() string

GetAccessToken returns the value of AccessToken.

func (*AccessToken) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*AccessToken) SetAccessToken

func (s *AccessToken) SetAccessToken(val string)

SetAccessToken sets the value of AccessToken.

func (*AccessToken) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

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

func (c *Client) LogIn(ctx context.Context, request *Credentials) (LogInRes, error)

LogIn invokes LogIn operation.

Log into account and create a session.

POST /login

func (*Client) LogoutFromSession

func (c *Client) LogoutFromSession(ctx context.Context) (LogoutFromSessionRes, error)

LogoutFromSession invokes LogoutFromSession operation.

Log out from the account using refresh token.

POST /logout

func (*Client) RefreshAccessToken

func (c *Client) RefreshAccessToken(ctx context.Context) (RefreshAccessTokenRes, error)

RefreshAccessToken invokes RefreshAccessToken operation.

Create a new access token using refresh token.

POST /access

func (*Client) RefreshPair

func (c *Client) RefreshPair(ctx context.Context) (RefreshPairRes, error)

RefreshPair invokes RefreshPair operation.

Refresh pair of tokens using refresh token.

POST /refresh

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 Credentials

type Credentials struct {
	Phone    string `json:"phone"`
	Password string `json:"password"`
}

Ref: #/components/schemas/Credentials

func (*Credentials) Decode

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

Decode decodes Credentials from json.

func (*Credentials) Encode

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

Encode implements json.Marshaler.

func (*Credentials) GetPassword

func (s *Credentials) GetPassword() string

GetPassword returns the value of Password.

func (*Credentials) GetPhone

func (s *Credentials) GetPhone() string

GetPhone returns the value of Phone.

func (*Credentials) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*Credentials) SetPassword

func (s *Credentials) SetPassword(val string)

SetPassword sets the value of Password.

func (*Credentials) SetPhone

func (s *Credentials) SetPhone(val string)

SetPhone sets the value of Phone.

func (*Credentials) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type Error

type Error struct {
	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) 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) 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 Handler

type Handler interface {
	// LogIn implements LogIn operation.
	//
	// Log into account and create a session.
	//
	// POST /login
	LogIn(ctx context.Context, req *Credentials) (LogInRes, error)
	// LogoutFromSession implements LogoutFromSession operation.
	//
	// Log out from the account using refresh token.
	//
	// POST /logout
	LogoutFromSession(ctx context.Context) (LogoutFromSessionRes, error)
	// RefreshAccessToken implements RefreshAccessToken operation.
	//
	// Create a new access token using refresh token.
	//
	// POST /access
	RefreshAccessToken(ctx context.Context) (RefreshAccessTokenRes, error)
	// RefreshPair implements RefreshPair operation.
	//
	// Refresh pair of tokens using refresh token.
	//
	// POST /refresh
	RefreshPair(ctx context.Context) (RefreshPairRes, error)
}

Handler handles operations described by OpenAPI v3 specification.

type Invoker

type Invoker interface {
	// LogIn invokes LogIn operation.
	//
	// Log into account and create a session.
	//
	// POST /login
	LogIn(ctx context.Context, request *Credentials) (LogInRes, error)
	// LogoutFromSession invokes LogoutFromSession operation.
	//
	// Log out from the account using refresh token.
	//
	// POST /logout
	LogoutFromSession(ctx context.Context) (LogoutFromSessionRes, error)
	// RefreshAccessToken invokes RefreshAccessToken operation.
	//
	// Create a new access token using refresh token.
	//
	// POST /access
	RefreshAccessToken(ctx context.Context) (RefreshAccessTokenRes, error)
	// RefreshPair invokes RefreshPair operation.
	//
	// Refresh pair of tokens using refresh token.
	//
	// POST /refresh
	RefreshPair(ctx context.Context) (RefreshPairRes, error)
}

Invoker invokes operations described by OpenAPI v3 specification.

type LogInBadRequest

type LogInBadRequest Error

func (*LogInBadRequest) Decode

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

Decode decodes LogInBadRequest from json.

func (*LogInBadRequest) Encode

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

Encode encodes LogInBadRequest as json.

func (*LogInBadRequest) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*LogInBadRequest) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type LogInInternalServerError

type LogInInternalServerError Error

func (*LogInInternalServerError) Decode

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

Decode decodes LogInInternalServerError from json.

func (*LogInInternalServerError) Encode

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

Encode encodes LogInInternalServerError as json.

func (*LogInInternalServerError) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*LogInInternalServerError) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type LogInRes

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

type LogoutFromSessionBadRequest

type LogoutFromSessionBadRequest Error

func (*LogoutFromSessionBadRequest) Decode

Decode decodes LogoutFromSessionBadRequest from json.

func (*LogoutFromSessionBadRequest) Encode

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

Encode encodes LogoutFromSessionBadRequest as json.

func (*LogoutFromSessionBadRequest) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*LogoutFromSessionBadRequest) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type LogoutFromSessionInternalServerError

type LogoutFromSessionInternalServerError Error

func (*LogoutFromSessionInternalServerError) Decode

Decode decodes LogoutFromSessionInternalServerError from json.

func (*LogoutFromSessionInternalServerError) Encode

Encode encodes LogoutFromSessionInternalServerError as json.

func (*LogoutFromSessionInternalServerError) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*LogoutFromSessionInternalServerError) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type LogoutFromSessionOK

type LogoutFromSessionOK struct{}

LogoutFromSessionOK is response for LogoutFromSession operation.

type LogoutFromSessionRes

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

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 RefreshAccessTokenBadRequest

type RefreshAccessTokenBadRequest Error

func (*RefreshAccessTokenBadRequest) Decode

Decode decodes RefreshAccessTokenBadRequest from json.

func (*RefreshAccessTokenBadRequest) Encode

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

Encode encodes RefreshAccessTokenBadRequest as json.

func (*RefreshAccessTokenBadRequest) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*RefreshAccessTokenBadRequest) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type RefreshAccessTokenInternalServerError

type RefreshAccessTokenInternalServerError Error

func (*RefreshAccessTokenInternalServerError) Decode

Decode decodes RefreshAccessTokenInternalServerError from json.

func (*RefreshAccessTokenInternalServerError) Encode

Encode encodes RefreshAccessTokenInternalServerError as json.

func (*RefreshAccessTokenInternalServerError) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*RefreshAccessTokenInternalServerError) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type RefreshAccessTokenRes

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

type RefreshAuth

type RefreshAuth struct {
	APIKey string
}

func (*RefreshAuth) GetAPIKey

func (s *RefreshAuth) GetAPIKey() string

GetAPIKey returns the value of APIKey.

func (*RefreshAuth) SetAPIKey

func (s *RefreshAuth) SetAPIKey(val string)

SetAPIKey sets the value of APIKey.

type RefreshPairBadRequest

type RefreshPairBadRequest Error

func (*RefreshPairBadRequest) Decode

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

Decode decodes RefreshPairBadRequest from json.

func (*RefreshPairBadRequest) Encode

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

Encode encodes RefreshPairBadRequest as json.

func (*RefreshPairBadRequest) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*RefreshPairBadRequest) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type RefreshPairInternalServerError

type RefreshPairInternalServerError Error

func (*RefreshPairInternalServerError) Decode

Decode decodes RefreshPairInternalServerError from json.

func (*RefreshPairInternalServerError) Encode

Encode encodes RefreshPairInternalServerError as json.

func (*RefreshPairInternalServerError) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*RefreshPairInternalServerError) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type RefreshPairRes

type RefreshPairRes 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 SecurityHandler

type SecurityHandler interface {
	// HandleRefreshAuth handles refreshAuth security.
	HandleRefreshAuth(ctx context.Context, operationName string, t RefreshAuth) (context.Context, error)
}

SecurityHandler is handler for security parameters.

type SecuritySource

type SecuritySource interface {
	// RefreshAuth provides refreshAuth security value.
	RefreshAuth(ctx context.Context, operationName string) (RefreshAuth, 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 TokenPair

type TokenPair struct {
	AccessToken  string `json:"accessToken"`
	RefreshToken string `json:"refreshToken"`
}

Ref: #/components/schemas/TokenPair

func (*TokenPair) Decode

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

Decode decodes TokenPair from json.

func (*TokenPair) Encode

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

Encode implements json.Marshaler.

func (*TokenPair) GetAccessToken

func (s *TokenPair) GetAccessToken() string

GetAccessToken returns the value of AccessToken.

func (*TokenPair) GetRefreshToken

func (s *TokenPair) GetRefreshToken() string

GetRefreshToken returns the value of RefreshToken.

func (*TokenPair) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*TokenPair) SetAccessToken

func (s *TokenPair) SetAccessToken(val string)

SetAccessToken sets the value of AccessToken.

func (*TokenPair) SetRefreshToken

func (s *TokenPair) SetRefreshToken(val string)

SetRefreshToken sets the value of RefreshToken.

func (*TokenPair) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type UnimplementedHandler

type UnimplementedHandler struct{}

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

func (UnimplementedHandler) LogIn

LogIn implements LogIn operation.

Log into account and create a session.

POST /login

func (UnimplementedHandler) LogoutFromSession

func (UnimplementedHandler) LogoutFromSession(ctx context.Context) (r LogoutFromSessionRes, _ error)

LogoutFromSession implements LogoutFromSession operation.

Log out from the account using refresh token.

POST /logout

func (UnimplementedHandler) RefreshAccessToken

func (UnimplementedHandler) RefreshAccessToken(ctx context.Context) (r RefreshAccessTokenRes, _ error)

RefreshAccessToken implements RefreshAccessToken operation.

Create a new access token using refresh token.

POST /access

func (UnimplementedHandler) RefreshPair

func (UnimplementedHandler) RefreshPair(ctx context.Context) (r RefreshPairRes, _ error)

RefreshPair implements RefreshPair operation.

Refresh pair of tokens using refresh token.

POST /refresh

Jump to

Keyboard shortcuts

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