Documentation
¶
Index ¶
- Constants
- func WithServerURL(ctx context.Context, u *url.URL) context.Context
- type Client
- func (c *Client) CreateToken(ctx context.Context, request *Config) (*Credential, error)
- func (c *Client) DeleteToken(ctx context.Context, params DeleteTokenParams) error
- func (c *Client) GetToken(ctx context.Context, params GetTokenParams) (*Token, error)
- func (c *Client) ListTokens(ctx context.Context) ([]Token, error)
- func (c *Client) RefreshToken(ctx context.Context, params RefreshTokenParams) (*Credential, error)
- func (c *Client) UpdateToken(ctx context.Context, request *Config, params UpdateTokenParams) error
- type ClientOption
- type Config
- func (s *Config) Decode(d *jx.Decoder) error
- func (s *Config) Encode(e *jx.Encoder)
- func (s *Config) GetHeaders() []NameValue
- func (s *Config) GetHost() OptString
- func (s *Config) GetLabel() OptString
- func (s *Config) GetPath() OptString
- func (s *Config) MarshalJSON() ([]byte, error)
- func (s *Config) SetHeaders(val []NameValue)
- func (s *Config) SetHost(val OptString)
- func (s *Config) SetLabel(val OptString)
- func (s *Config) SetPath(val OptString)
- func (s *Config) UnmarshalJSON(data []byte) error
- func (s *Config) Validate() error
- type Credential
- func (s *Credential) Decode(d *jx.Decoder) error
- func (s *Credential) Encode(e *jx.Encoder)
- func (s *Credential) GetID() int
- func (s *Credential) GetKey() string
- func (s *Credential) MarshalJSON() ([]byte, error)
- func (s *Credential) SetID(val int)
- func (s *Credential) SetKey(val string)
- func (s *Credential) UnmarshalJSON(data []byte) error
- type DeleteTokenNoContent
- type DeleteTokenParams
- type ErrorHandler
- type GetTokenParams
- type Handler
- type Invoker
- type Middleware
- type NameValue
- func (s *NameValue) Decode(d *jx.Decoder) error
- func (s *NameValue) Encode(e *jx.Encoder)
- func (s *NameValue) GetName() string
- func (s *NameValue) GetValue() string
- func (s *NameValue) MarshalJSON() ([]byte, error)
- func (s *NameValue) SetName(val string)
- func (s *NameValue) SetValue(val string)
- func (s *NameValue) UnmarshalJSON(data []byte) error
- func (s *NameValue) Validate() error
- type OptDateTime
- func (o *OptDateTime) Decode(d *jx.Decoder, format func(*jx.Decoder) (time.Time, error)) error
- func (o OptDateTime) Encode(e *jx.Encoder, format func(*jx.Encoder, time.Time))
- func (o OptDateTime) Get() (v time.Time, ok bool)
- func (o OptDateTime) IsSet() bool
- func (s OptDateTime) MarshalJSON() ([]byte, error)
- func (o OptDateTime) Or(d time.Time) time.Time
- func (o *OptDateTime) Reset()
- func (o *OptDateTime) SetTo(v time.Time)
- func (s *OptDateTime) UnmarshalJSON(data []byte) error
- type OptString
- func (o *OptString) Decode(d *jx.Decoder) error
- func (o OptString) Encode(e *jx.Encoder)
- func (o OptString) Get() (v string, ok bool)
- func (o OptString) IsSet() bool
- func (s OptString) MarshalJSON() ([]byte, error)
- func (o OptString) Or(d string) string
- func (o *OptString) Reset()
- func (o *OptString) SetTo(v string)
- func (s *OptString) UnmarshalJSON(data []byte) error
- type Option
- type RefreshTokenParams
- type Route
- type Server
- type ServerOption
- func WithErrorHandler(h ErrorHandler) ServerOption
- func WithMaxMultipartMemory(max int64) ServerOption
- func WithMethodNotAllowed(methodNotAllowed func(w http.ResponseWriter, r *http.Request, allowed string)) ServerOption
- func WithMiddleware(m ...Middleware) ServerOption
- func WithNotFound(notFound http.HandlerFunc) ServerOption
- func WithPathPrefix(prefix string) ServerOption
- type Token
- func (s *Token) Decode(d *jx.Decoder) error
- func (s *Token) Encode(e *jx.Encoder)
- func (s *Token) GetCreatedAt() time.Time
- func (s *Token) GetHeaders() []NameValue
- func (s *Token) GetHost() string
- func (s *Token) GetID() int
- func (s *Token) GetKeyID() string
- func (s *Token) GetLabel() string
- func (s *Token) GetLastAccessAt() OptDateTime
- func (s *Token) GetPath() string
- func (s *Token) GetRequests() int64
- func (s *Token) GetUpdatedAt() time.Time
- func (s *Token) GetUser() string
- func (s *Token) MarshalJSON() ([]byte, error)
- func (s *Token) SetCreatedAt(val time.Time)
- func (s *Token) SetHeaders(val []NameValue)
- func (s *Token) SetHost(val string)
- func (s *Token) SetID(val int)
- func (s *Token) SetKeyID(val string)
- func (s *Token) SetLabel(val string)
- func (s *Token) SetLastAccessAt(val OptDateTime)
- func (s *Token) SetPath(val string)
- func (s *Token) SetRequests(val int64)
- func (s *Token) SetUpdatedAt(val time.Time)
- func (s *Token) SetUser(val string)
- func (s *Token) UnmarshalJSON(data []byte) error
- func (s *Token) Validate() error
- type UpdateTokenNoContent
- type UpdateTokenParams
Constants ¶
const Prefix = "/api/v1"
Variables ¶
This section is empty.
Functions ¶
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) CreateToken ¶
CreateToken invokes createToken operation.
Create new token for user.
POST /tokens
func (*Client) DeleteToken ¶
func (c *Client) DeleteToken(ctx context.Context, params DeleteTokenParams) error
DeleteToken invokes deleteToken operation.
Delete token for user.
DELETE /tokens/{token}
func (*Client) GetToken ¶
GetToken invokes getToken operation.
Get tokens by ID and for the current user.
GET /tokens/{token}
func (*Client) ListTokens ¶
ListTokens invokes listTokens operation.
List all tokens for user.
GET /tokens
func (*Client) RefreshToken ¶
func (c *Client) RefreshToken(ctx context.Context, params RefreshTokenParams) (*Credential, error)
RefreshToken invokes refreshToken operation.
Regenerate token key.
POST /tokens/{token}
func (*Client) UpdateToken ¶
UpdateToken invokes updateToken operation.
Update token for user. Supports partial update.
PATCH /tokens/{token}
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 Config ¶
type Config struct {
// Custom token description.
Label OptString `json:"label"`
// Allowed hosts. Supports globs. Empty means "allow all".
Host OptString `json:"host"`
// Allowed path. Supports globs. Empty means "allow all".
Path OptString `json:"path"`
// Custom headers which will be added after successfull authorization.
Headers []NameValue `json:"headers"`
}
Ref: #/components/schemas/Config
func (*Config) GetHeaders ¶
GetHeaders returns the value of Headers.
func (*Config) MarshalJSON ¶
MarshalJSON implements stdjson.Marshaler.
func (*Config) SetHeaders ¶
SetHeaders sets the value of Headers.
func (*Config) UnmarshalJSON ¶
UnmarshalJSON implements stdjson.Unmarshaler.
type Credential ¶
type Credential struct {
// Token ID.
ID int `json:"id"`
// Raw token key.
Key string `json:"key"`
}
Ref: #/components/schemas/Credential
func (*Credential) Decode ¶
func (s *Credential) Decode(d *jx.Decoder) error
Decode decodes Credential from json.
func (*Credential) Encode ¶
func (s *Credential) Encode(e *jx.Encoder)
Encode implements json.Marshaler.
func (*Credential) MarshalJSON ¶
func (s *Credential) MarshalJSON() ([]byte, error)
MarshalJSON implements stdjson.Marshaler.
func (*Credential) UnmarshalJSON ¶
func (s *Credential) UnmarshalJSON(data []byte) error
UnmarshalJSON implements stdjson.Unmarshaler.
type DeleteTokenNoContent ¶
type DeleteTokenNoContent struct{}
DeleteTokenNoContent is response for DeleteToken operation.
type DeleteTokenParams ¶
type DeleteTokenParams struct {
// Token ID.
Token int
}
DeleteTokenParams is parameters of deleteToken operation.
type GetTokenParams ¶
type GetTokenParams struct {
// Token ID.
Token int
}
GetTokenParams is parameters of getToken operation.
type Handler ¶
type Handler interface {
// CreateToken implements createToken operation.
//
// Create new token for user.
//
// POST /tokens
CreateToken(ctx context.Context, req *Config) (*Credential, error)
// DeleteToken implements deleteToken operation.
//
// Delete token for user.
//
// DELETE /tokens/{token}
DeleteToken(ctx context.Context, params DeleteTokenParams) error
// GetToken implements getToken operation.
//
// Get tokens by ID and for the current user.
//
// GET /tokens/{token}
GetToken(ctx context.Context, params GetTokenParams) (*Token, error)
// ListTokens implements listTokens operation.
//
// List all tokens for user.
//
// GET /tokens
ListTokens(ctx context.Context) ([]Token, error)
// RefreshToken implements refreshToken operation.
//
// Regenerate token key.
//
// POST /tokens/{token}
RefreshToken(ctx context.Context, params RefreshTokenParams) (*Credential, error)
// UpdateToken implements updateToken operation.
//
// Update token for user. Supports partial update.
//
// PATCH /tokens/{token}
UpdateToken(ctx context.Context, req *Config, params UpdateTokenParams) error
}
Handler handles operations described by OpenAPI v3 specification.
type Invoker ¶
type Invoker interface {
// CreateToken invokes createToken operation.
//
// Create new token for user.
//
// POST /tokens
CreateToken(ctx context.Context, request *Config) (*Credential, error)
// DeleteToken invokes deleteToken operation.
//
// Delete token for user.
//
// DELETE /tokens/{token}
DeleteToken(ctx context.Context, params DeleteTokenParams) error
// GetToken invokes getToken operation.
//
// Get tokens by ID and for the current user.
//
// GET /tokens/{token}
GetToken(ctx context.Context, params GetTokenParams) (*Token, error)
// ListTokens invokes listTokens operation.
//
// List all tokens for user.
//
// GET /tokens
ListTokens(ctx context.Context) ([]Token, error)
// RefreshToken invokes refreshToken operation.
//
// Regenerate token key.
//
// POST /tokens/{token}
RefreshToken(ctx context.Context, params RefreshTokenParams) (*Credential, error)
// UpdateToken invokes updateToken operation.
//
// Update token for user. Supports partial update.
//
// PATCH /tokens/{token}
UpdateToken(ctx context.Context, request *Config, params UpdateTokenParams) error
}
Invoker invokes operations described by OpenAPI v3 specification.
type NameValue ¶
Ref: #/components/schemas/NameValue
func (*NameValue) MarshalJSON ¶
MarshalJSON implements stdjson.Marshaler.
func (*NameValue) UnmarshalJSON ¶
UnmarshalJSON implements stdjson.Unmarshaler.
type OptDateTime ¶
OptDateTime is optional time.Time.
func NewOptDateTime ¶
func NewOptDateTime(v time.Time) OptDateTime
NewOptDateTime returns new OptDateTime with value set to v.
func (OptDateTime) Get ¶
func (o OptDateTime) Get() (v time.Time, ok bool)
Get returns value and boolean that denotes whether value was set.
func (OptDateTime) IsSet ¶
func (o OptDateTime) IsSet() bool
IsSet returns true if OptDateTime was set.
func (OptDateTime) MarshalJSON ¶
func (s OptDateTime) MarshalJSON() ([]byte, error)
MarshalJSON implements stdjson.Marshaler.
func (OptDateTime) Or ¶
func (o OptDateTime) Or(d time.Time) time.Time
Or returns value if set, or given parameter if does not.
func (*OptDateTime) UnmarshalJSON ¶
func (s *OptDateTime) UnmarshalJSON(data []byte) error
UnmarshalJSON implements stdjson.Unmarshaler.
type OptString ¶
OptString is optional string.
func NewOptString ¶
NewOptString returns new OptString with value set to v.
func (OptString) MarshalJSON ¶
MarshalJSON implements stdjson.Marshaler.
func (*OptString) UnmarshalJSON ¶
UnmarshalJSON implements stdjson.Unmarshaler.
type RefreshTokenParams ¶
type RefreshTokenParams struct {
// Token ID.
Token int
}
RefreshTokenParams is parameters of refreshToken operation.
type Route ¶
type Route struct {
// contains filtered or unexported fields
}
Route is route object.
func (Route) OperationID ¶
OperationID returns OpenAPI operationId.
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.
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 Token ¶
type Token struct {
// Unique token ID.
ID int `json:"id"`
// Time when token was initially created.
CreatedAt time.Time `json:"createdAt"`
// Time when token was updated last time.
UpdatedAt time.Time `json:"updatedAt"`
// Tentative time when token was last time used.
LastAccessAt OptDateTime `json:"lastAccessAt"`
// Unique first several bytes for token which is used for fast identification.
KeyID string `json:"keyID"`
// User which created token.
User string `json:"user"`
// Custom token description.
Label string `json:"label"`
// Allowed hosts. Supports globs. Empty means "allow all".
Host string `json:"host"`
// Allowed path. Supports globs. Empty means "allow all".
Path string `json:"path"`
// Custom headers which will be added after successfull authorization.
Headers []NameValue `json:"headers"`
// Tentative number of requests used this token.
Requests int64 `json:"requests"`
}
Ref: #/components/schemas/Token
func (*Token) GetCreatedAt ¶
GetCreatedAt returns the value of CreatedAt.
func (*Token) GetHeaders ¶
GetHeaders returns the value of Headers.
func (*Token) GetLastAccessAt ¶
func (s *Token) GetLastAccessAt() OptDateTime
GetLastAccessAt returns the value of LastAccessAt.
func (*Token) GetRequests ¶
GetRequests returns the value of Requests.
func (*Token) GetUpdatedAt ¶
GetUpdatedAt returns the value of UpdatedAt.
func (*Token) MarshalJSON ¶
MarshalJSON implements stdjson.Marshaler.
func (*Token) SetCreatedAt ¶
SetCreatedAt sets the value of CreatedAt.
func (*Token) SetHeaders ¶
SetHeaders sets the value of Headers.
func (*Token) SetLastAccessAt ¶
func (s *Token) SetLastAccessAt(val OptDateTime)
SetLastAccessAt sets the value of LastAccessAt.
func (*Token) SetRequests ¶
SetRequests sets the value of Requests.
func (*Token) SetUpdatedAt ¶
SetUpdatedAt sets the value of UpdatedAt.
func (*Token) UnmarshalJSON ¶
UnmarshalJSON implements stdjson.Unmarshaler.
type UpdateTokenNoContent ¶
type UpdateTokenNoContent struct{}
UpdateTokenNoContent is response for UpdateToken operation.
type UpdateTokenParams ¶
type UpdateTokenParams struct {
// Token ID.
Token int
}
UpdateTokenParams is parameters of updateToken operation.
Source Files
¶
- generate.go
- oas_cfg_gen.go
- oas_client_gen.go
- oas_handlers_gen.go
- oas_json_gen.go
- oas_middleware_gen.go
- oas_parameters_gen.go
- oas_request_decoders_gen.go
- oas_request_encoders_gen.go
- oas_response_decoders_gen.go
- oas_response_encoders_gen.go
- oas_router_gen.go
- oas_schemas_gen.go
- oas_server_gen.go
- oas_validators_gen.go