gen

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2024 License: MIT Imports: 27 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 BasicAuth

type BasicAuth struct {
	Username string
	Password string
}

func (*BasicAuth) GetPassword

func (s *BasicAuth) GetPassword() string

GetPassword returns the value of Password.

func (*BasicAuth) GetUsername

func (s *BasicAuth) GetUsername() string

GetUsername returns the value of Username.

func (*BasicAuth) SetPassword

func (s *BasicAuth) SetPassword(val string)

SetPassword sets the value of Password.

func (*BasicAuth) SetUsername

func (s *BasicAuth) SetUsername(val string)

SetUsername sets the value of Username.

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

func (c *Client) ClusterNamesGet(ctx context.Context, params ClusterNamesGetParams) ([]string, error)

ClusterNamesGet invokes GET /clusterNames operation.

Retrieve list of available OMNIBus clusters.

GET /clusterNames

func (*Client) RawSQLPost

func (c *Client) RawSQLPost(ctx context.Context, request *RawSQLRequest, params RawSQLPostParams) (RawSQLListResponse, error)

RawSQLPost invokes POST /rawSQL operation.

Send SQL request to OMNIbus clusters.

POST /rawSQL

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 ClusterNamesGetParams

type ClusterNamesGetParams struct {
	// Unique ID, required for all API requests.
	XRequestID string
}

ClusterNamesGetParams is parameters of GET /clusterNames operation.

type ErrorHandler

type ErrorHandler = ogenerrors.ErrorHandler

ErrorHandler is error handler.

type ErrorResponse

type ErrorResponse struct {
	// Error 'business' code.
	Error ErrorResponseError `json:"error"`
	// Error message.
	Message string `json:"message"`
	// Details about error.
	Reason OptString `json:"reason"`
}

Ref: #/components/schemas/ErrorResponse

func (*ErrorResponse) Decode

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

Decode decodes ErrorResponse from json.

func (*ErrorResponse) Encode

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

Encode implements json.Marshaler.

func (*ErrorResponse) GetError

func (s *ErrorResponse) GetError() ErrorResponseError

GetError returns the value of Error.

func (*ErrorResponse) GetMessage

func (s *ErrorResponse) GetMessage() string

GetMessage returns the value of Message.

func (*ErrorResponse) GetReason

func (s *ErrorResponse) GetReason() OptString

GetReason returns the value of Reason.

func (*ErrorResponse) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*ErrorResponse) SetError

func (s *ErrorResponse) SetError(val ErrorResponseError)

SetError sets the value of Error.

func (*ErrorResponse) SetMessage

func (s *ErrorResponse) SetMessage(val string)

SetMessage sets the value of Message.

func (*ErrorResponse) SetReason

func (s *ErrorResponse) SetReason(val OptString)

SetReason sets the value of Reason.

func (*ErrorResponse) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*ErrorResponse) Validate

func (s *ErrorResponse) Validate() error

type ErrorResponseError

type ErrorResponseError string

Error 'business' code.

const (
	ErrorResponseErrorERRUNKNOWN                ErrorResponseError = "ERR_UNKNOWN"
	ErrorResponseErrorERRTIMEOUT                ErrorResponseError = "ERR_TIMEOUT"
	ErrorResponseErrorERRUNAVAILABLE            ErrorResponseError = "ERR_UNAVAILABLE"
	ErrorResponseErrorERRVALIDATION             ErrorResponseError = "ERR_VALIDATION"
	ErrorResponseErrorERRINCORRECTOPERATION     ErrorResponseError = "ERR_INCORRECT_OPERATION"
	ErrorResponseErrorERRINSUFFICIENTPRIVILEGES ErrorResponseError = "ERR_INSUFFICIENT_PRIVILEGES"
)

func (ErrorResponseError) AllValues

func (ErrorResponseError) AllValues() []ErrorResponseError

AllValues returns all ErrorResponseError values.

func (*ErrorResponseError) Decode

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

Decode decodes ErrorResponseError from json.

func (ErrorResponseError) Encode

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

Encode encodes ErrorResponseError as json.

func (ErrorResponseError) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (ErrorResponseError) MarshalText

func (s ErrorResponseError) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*ErrorResponseError) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*ErrorResponseError) UnmarshalText

func (s *ErrorResponseError) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

func (ErrorResponseError) Validate

func (s ErrorResponseError) Validate() error

type ErrorResponseStatusCode

type ErrorResponseStatusCode struct {
	StatusCode int
	Response   ErrorResponse
}

ErrorResponseStatusCode wraps ErrorResponse with StatusCode.

func (*ErrorResponseStatusCode) Error

func (s *ErrorResponseStatusCode) Error() string

func (*ErrorResponseStatusCode) GetResponse

func (s *ErrorResponseStatusCode) GetResponse() ErrorResponse

GetResponse returns the value of Response.

func (*ErrorResponseStatusCode) GetStatusCode

func (s *ErrorResponseStatusCode) GetStatusCode() int

GetStatusCode returns the value of StatusCode.

func (*ErrorResponseStatusCode) SetResponse

func (s *ErrorResponseStatusCode) SetResponse(val ErrorResponse)

SetResponse sets the value of Response.

func (*ErrorResponseStatusCode) SetStatusCode

func (s *ErrorResponseStatusCode) SetStatusCode(val int)

SetStatusCode sets the value of StatusCode.

func (*ErrorResponseStatusCode) Validate

func (s *ErrorResponseStatusCode) Validate() error

type Handler

type Handler interface {
	// ClusterNamesGet implements GET /clusterNames operation.
	//
	// Retrieve list of available OMNIBus clusters.
	//
	// GET /clusterNames
	ClusterNamesGet(ctx context.Context, params ClusterNamesGetParams) ([]string, error)
	// RawSQLPost implements POST /rawSQL operation.
	//
	// Send SQL request to OMNIbus clusters.
	//
	// POST /rawSQL
	RawSQLPost(ctx context.Context, req *RawSQLRequest, params RawSQLPostParams) (RawSQLListResponse, error)
	// NewError creates *ErrorResponseStatusCode from error returned by handler.
	//
	// Used for common default response.
	NewError(ctx context.Context, err error) *ErrorResponseStatusCode
}

Handler handles operations described by OpenAPI v3 specification.

type Invoker

type Invoker interface {
	// ClusterNamesGet invokes GET /clusterNames operation.
	//
	// Retrieve list of available OMNIBus clusters.
	//
	// GET /clusterNames
	ClusterNamesGet(ctx context.Context, params ClusterNamesGetParams) ([]string, error)
	// RawSQLPost invokes POST /rawSQL operation.
	//
	// Send SQL request to OMNIbus clusters.
	//
	// POST /rawSQL
	RawSQLPost(ctx context.Context, request *RawSQLRequest, params RawSQLPostParams) (RawSQLListResponse, 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 OptErrorResponse

type OptErrorResponse struct {
	Value ErrorResponse
	Set   bool
}

OptErrorResponse is optional ErrorResponse.

func NewOptErrorResponse

func NewOptErrorResponse(v ErrorResponse) OptErrorResponse

NewOptErrorResponse returns new OptErrorResponse with value set to v.

func (*OptErrorResponse) Decode

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

Decode decodes ErrorResponse from json.

func (OptErrorResponse) Encode

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

Encode encodes ErrorResponse as json.

func (OptErrorResponse) Get

func (o OptErrorResponse) Get() (v ErrorResponse, ok bool)

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

func (OptErrorResponse) IsSet

func (o OptErrorResponse) IsSet() bool

IsSet returns true if OptErrorResponse was set.

func (OptErrorResponse) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (OptErrorResponse) Or

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

func (*OptErrorResponse) Reset

func (o *OptErrorResponse) Reset()

Reset unsets value.

func (*OptErrorResponse) SetTo

func (o *OptErrorResponse) SetTo(v ErrorResponse)

SetTo sets value to v.

func (*OptErrorResponse) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

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 RawSQLListResponse

type RawSQLListResponse []RawSQLResponse

func (*RawSQLListResponse) Decode

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

Decode decodes RawSQLListResponse from json.

func (RawSQLListResponse) Encode

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

Encode encodes RawSQLListResponse as json.

func (RawSQLListResponse) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*RawSQLListResponse) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (RawSQLListResponse) Validate

func (s RawSQLListResponse) Validate() error

type RawSQLPostParams

type RawSQLPostParams struct {
	// Unique ID, required for all API requests.
	XRequestID string
}

RawSQLPostParams is parameters of POST /rawSQL operation.

type RawSQLRequest

type RawSQLRequest struct {
	// SQL query to execute.
	SQL string `json:"sql"`
	// List of cluster names to send the query to.
	Clusters []string `json:"clusters"`
}

Ref: #/components/schemas/RawSQLRequest

func (*RawSQLRequest) Decode

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

Decode decodes RawSQLRequest from json.

func (*RawSQLRequest) Encode

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

Encode implements json.Marshaler.

func (*RawSQLRequest) GetClusters

func (s *RawSQLRequest) GetClusters() []string

GetClusters returns the value of Clusters.

func (*RawSQLRequest) GetSQL

func (s *RawSQLRequest) GetSQL() string

GetSQL returns the value of SQL.

func (*RawSQLRequest) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*RawSQLRequest) SetClusters

func (s *RawSQLRequest) SetClusters(val []string)

SetClusters sets the value of Clusters.

func (*RawSQLRequest) SetSQL

func (s *RawSQLRequest) SetSQL(val string)

SetSQL sets the value of SQL.

func (*RawSQLRequest) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type RawSQLResponse

type RawSQLResponse struct {
	ClusterName string `json:"clusterName"`
	// Rows returned from the cluster.
	Rows []RawSQLResponseRowsItem `json:"rows"`
	// Number of rows affected by the query.
	AffectedRows int              `json:"affectedRows"`
	Error        OptErrorResponse `json:"error"`
}

Ref: #/components/schemas/RawSQLResponse

func (*RawSQLResponse) Decode

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

Decode decodes RawSQLResponse from json.

func (*RawSQLResponse) Encode

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

Encode implements json.Marshaler.

func (*RawSQLResponse) GetAffectedRows

func (s *RawSQLResponse) GetAffectedRows() int

GetAffectedRows returns the value of AffectedRows.

func (*RawSQLResponse) GetClusterName

func (s *RawSQLResponse) GetClusterName() string

GetClusterName returns the value of ClusterName.

func (*RawSQLResponse) GetError

func (s *RawSQLResponse) GetError() OptErrorResponse

GetError returns the value of Error.

func (*RawSQLResponse) GetRows

func (s *RawSQLResponse) GetRows() []RawSQLResponseRowsItem

GetRows returns the value of Rows.

func (*RawSQLResponse) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*RawSQLResponse) SetAffectedRows

func (s *RawSQLResponse) SetAffectedRows(val int)

SetAffectedRows sets the value of AffectedRows.

func (*RawSQLResponse) SetClusterName

func (s *RawSQLResponse) SetClusterName(val string)

SetClusterName sets the value of ClusterName.

func (*RawSQLResponse) SetError

func (s *RawSQLResponse) SetError(val OptErrorResponse)

SetError sets the value of Error.

func (*RawSQLResponse) SetRows

func (s *RawSQLResponse) SetRows(val []RawSQLResponseRowsItem)

SetRows sets the value of Rows.

func (*RawSQLResponse) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*RawSQLResponse) Validate

func (s *RawSQLResponse) Validate() error

type RawSQLResponseRowsItem

type RawSQLResponseRowsItem map[string]jx.Raw

func (*RawSQLResponseRowsItem) Decode

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

Decode decodes RawSQLResponseRowsItem from json.

func (RawSQLResponseRowsItem) Encode

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

Encode implements json.Marshaler.

func (RawSQLResponseRowsItem) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*RawSQLResponseRowsItem) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

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

SecurityHandler is handler for security parameters.

type SecuritySource

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

type UnimplementedHandler struct{}

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

func (UnimplementedHandler) ClusterNamesGet

func (UnimplementedHandler) ClusterNamesGet(ctx context.Context, params ClusterNamesGetParams) (r []string, _ error)

ClusterNamesGet implements GET /clusterNames operation.

Retrieve list of available OMNIBus clusters.

GET /clusterNames

func (UnimplementedHandler) NewError

NewError creates *ErrorResponseStatusCode from error returned by handler.

Used for common default response.

func (UnimplementedHandler) RawSQLPost

RawSQLPost implements POST /rawSQL operation.

Send SQL request to OMNIbus clusters.

POST /rawSQL

Jump to

Keyboard shortcuts

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