oas

package
v0.0.0-...-45d8632 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2025 License: Apache-2.0 Imports: 26 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 AddIncidentBadRequest

type AddIncidentBadRequest struct{}

AddIncidentBadRequest is response for AddIncident operation.

type AddIncidentRes

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

type AddIncidentUnprocessableEntity

type AddIncidentUnprocessableEntity struct{}

AddIncidentUnprocessableEntity is response for AddIncident operation.

type BearerAuth

type BearerAuth struct {
	Token string
}

func (*BearerAuth) GetToken

func (s *BearerAuth) GetToken() string

GetToken returns the value of Token.

func (*BearerAuth) SetToken

func (s *BearerAuth) SetToken(val string)

SetToken sets the value of Token.

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

func (c *Client) AddIncident(ctx context.Context, request *Incident) (AddIncidentRes, error)

AddIncident invokes addIncident operation.

Add a new incidents.

POST /incidents

func (*Client) DeleteIncident

func (c *Client) DeleteIncident(ctx context.Context, params DeleteIncidentParams) (DeleteIncidentRes, error)

DeleteIncident invokes deleteIncident operation.

Delete an incidents.

DELETE /incidents/{incidentId}

func (*Client) GetIncidentById

func (c *Client) GetIncidentById(ctx context.Context, params GetIncidentByIdParams) (GetIncidentByIdRes, error)

GetIncidentById invokes getIncidentById operation.

Returns a single incidents.

GET /incidents/{incidentId}

func (*Client) GetIncidents

func (c *Client) GetIncidents(ctx context.Context) (GetIncidentsRes, error)

GetIncidents invokes getIncidents operation.

List of incidents.

GET /incidents

func (*Client) GetStatuses

func (c *Client) GetStatuses(ctx context.Context) (GetStatusesRes, error)

GetStatuses invokes getStatuses operation.

Получение списка статусов.

GET /statuses

func (*Client) UpdateIncident

func (c *Client) UpdateIncident(ctx context.Context, request *Incident) (UpdateIncidentRes, error)

UpdateIncident invokes updateIncident operation.

Update an existing incidents by Id.

PUT /incidents

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 DeleteIncidentBadRequest

type DeleteIncidentBadRequest struct{}

DeleteIncidentBadRequest is response for DeleteIncident operation.

type DeleteIncidentOK

type DeleteIncidentOK struct{}

DeleteIncidentOK is response for DeleteIncident operation.

type DeleteIncidentParams

type DeleteIncidentParams struct {
	// Request id to delete.
	IncidentId int
}

DeleteIncidentParams is parameters of deleteIncident operation.

type DeleteIncidentRes

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

type ErrorHandler

type ErrorHandler = ogenerrors.ErrorHandler

ErrorHandler is error handler.

type GetIncidentByIdBadRequest

type GetIncidentByIdBadRequest struct{}

GetIncidentByIdBadRequest is response for GetIncidentById operation.

type GetIncidentByIdNotFound

type GetIncidentByIdNotFound struct{}

GetIncidentByIdNotFound is response for GetIncidentById operation.

type GetIncidentByIdParams

type GetIncidentByIdParams struct {
	// ID of Incidents to return.
	IncidentId int
}

GetIncidentByIdParams is parameters of getIncidentById operation.

type GetIncidentByIdRes

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

type GetIncidentsBadRequest

type GetIncidentsBadRequest struct{}

GetIncidentsBadRequest is response for GetIncidents operation.

type GetIncidentsRes

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

type GetStatusesBadRequest

type GetStatusesBadRequest struct{}

GetStatusesBadRequest is response for GetStatuses operation.

type GetStatusesRes

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

type Handler

type Handler interface {
	IncidentsHandler
	StatusesHandler
}

Handler handles operations described by OpenAPI v3 specification.

type Incident

type Incident struct {
	// Incident id.
	ID       OptInt `json:"id"`
	Region   string `json:"region"`
	Fio      string `json:"fio"`
	StatusId string `json:"statusId"`
	Date     string `json:"date"`
}

Ref: #/components/schemas/Incident

func (*Incident) Decode

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

Decode decodes Incident from json.

func (*Incident) Encode

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

Encode implements json.Marshaler.

func (*Incident) GetDate

func (s *Incident) GetDate() string

GetDate returns the value of Date.

func (*Incident) GetFio

func (s *Incident) GetFio() string

GetFio returns the value of Fio.

func (*Incident) GetID

func (s *Incident) GetID() OptInt

GetID returns the value of ID.

func (*Incident) GetRegion

func (s *Incident) GetRegion() string

GetRegion returns the value of Region.

func (*Incident) GetStatusId

func (s *Incident) GetStatusId() string

GetStatusId returns the value of StatusId.

func (*Incident) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*Incident) SetDate

func (s *Incident) SetDate(val string)

SetDate sets the value of Date.

func (*Incident) SetFio

func (s *Incident) SetFio(val string)

SetFio sets the value of Fio.

func (*Incident) SetID

func (s *Incident) SetID(val OptInt)

SetID sets the value of ID.

func (*Incident) SetRegion

func (s *Incident) SetRegion(val string)

SetRegion sets the value of Region.

func (*Incident) SetStatusId

func (s *Incident) SetStatusId(val string)

SetStatusId sets the value of StatusId.

func (*Incident) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type IncidentResponse

type IncidentResponse struct {
	TrackingId string   `json:"trackingId"`
	Status     string   `json:"status"`
	Data       Incident `json:"data"`
}

Ref: #/components/schemas/IncidentResponse

func (*IncidentResponse) Decode

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

Decode decodes IncidentResponse from json.

func (*IncidentResponse) Encode

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

Encode implements json.Marshaler.

func (*IncidentResponse) GetData

func (s *IncidentResponse) GetData() Incident

GetData returns the value of Data.

func (*IncidentResponse) GetStatus

func (s *IncidentResponse) GetStatus() string

GetStatus returns the value of Status.

func (*IncidentResponse) GetTrackingId

func (s *IncidentResponse) GetTrackingId() string

GetTrackingId returns the value of TrackingId.

func (*IncidentResponse) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*IncidentResponse) SetData

func (s *IncidentResponse) SetData(val Incident)

SetData sets the value of Data.

func (*IncidentResponse) SetStatus

func (s *IncidentResponse) SetStatus(val string)

SetStatus sets the value of Status.

func (*IncidentResponse) SetTrackingId

func (s *IncidentResponse) SetTrackingId(val string)

SetTrackingId sets the value of TrackingId.

func (*IncidentResponse) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type IncidentsHandler

type IncidentsHandler interface {
	// AddIncident implements addIncident operation.
	//
	// Add a new incidents.
	//
	// POST /incidents
	AddIncident(ctx context.Context, req *Incident) (AddIncidentRes, error)
	// DeleteIncident implements deleteIncident operation.
	//
	// Delete an incidents.
	//
	// DELETE /incidents/{incidentId}
	DeleteIncident(ctx context.Context, params DeleteIncidentParams) (DeleteIncidentRes, error)
	// GetIncidentById implements getIncidentById operation.
	//
	// Returns a single incidents.
	//
	// GET /incidents/{incidentId}
	GetIncidentById(ctx context.Context, params GetIncidentByIdParams) (GetIncidentByIdRes, error)
	// GetIncidents implements getIncidents operation.
	//
	// List of incidents.
	//
	// GET /incidents
	GetIncidents(ctx context.Context) (GetIncidentsRes, error)
	// UpdateIncident implements updateIncident operation.
	//
	// Update an existing incidents by Id.
	//
	// PUT /incidents
	UpdateIncident(ctx context.Context, req *Incident) (UpdateIncidentRes, error)
}

IncidentsHandler handles operations described by OpenAPI v3 specification.

x-ogen-operation-group: Incidents

type IncidentsInvoker

type IncidentsInvoker interface {
	// AddIncident invokes addIncident operation.
	//
	// Add a new incidents.
	//
	// POST /incidents
	AddIncident(ctx context.Context, request *Incident) (AddIncidentRes, error)
	// DeleteIncident invokes deleteIncident operation.
	//
	// Delete an incidents.
	//
	// DELETE /incidents/{incidentId}
	DeleteIncident(ctx context.Context, params DeleteIncidentParams) (DeleteIncidentRes, error)
	// GetIncidentById invokes getIncidentById operation.
	//
	// Returns a single incidents.
	//
	// GET /incidents/{incidentId}
	GetIncidentById(ctx context.Context, params GetIncidentByIdParams) (GetIncidentByIdRes, error)
	// GetIncidents invokes getIncidents operation.
	//
	// List of incidents.
	//
	// GET /incidents
	GetIncidents(ctx context.Context) (GetIncidentsRes, error)
	// UpdateIncident invokes updateIncident operation.
	//
	// Update an existing incidents by Id.
	//
	// PUT /incidents
	UpdateIncident(ctx context.Context, request *Incident) (UpdateIncidentRes, error)
}

IncidentsInvoker invokes operations described by OpenAPI v3 specification.

x-gen-operation-group: Incidents

type IncidentsResponse

type IncidentsResponse struct {
	TrackingId string     `json:"trackingId"`
	Status     string     `json:"status"`
	Data       []Incident `json:"data"`
}

Ref: #/components/schemas/IncidentsResponse

func (*IncidentsResponse) Decode

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

Decode decodes IncidentsResponse from json.

func (*IncidentsResponse) Encode

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

Encode implements json.Marshaler.

func (*IncidentsResponse) GetData

func (s *IncidentsResponse) GetData() []Incident

GetData returns the value of Data.

func (*IncidentsResponse) GetStatus

func (s *IncidentsResponse) GetStatus() string

GetStatus returns the value of Status.

func (*IncidentsResponse) GetTrackingId

func (s *IncidentsResponse) GetTrackingId() string

GetTrackingId returns the value of TrackingId.

func (*IncidentsResponse) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*IncidentsResponse) SetData

func (s *IncidentsResponse) SetData(val []Incident)

SetData sets the value of Data.

func (*IncidentsResponse) SetStatus

func (s *IncidentsResponse) SetStatus(val string)

SetStatus sets the value of Status.

func (*IncidentsResponse) SetTrackingId

func (s *IncidentsResponse) SetTrackingId(val string)

SetTrackingId sets the value of TrackingId.

func (*IncidentsResponse) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*IncidentsResponse) Validate

func (s *IncidentsResponse) Validate() error

type Invoker

type Invoker interface {
	IncidentsInvoker
	StatusesInvoker
}

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 OperationName

type OperationName = string

OperationName is the ogen operation name

const (
	AddIncidentOperation     OperationName = "AddIncident"
	DeleteIncidentOperation  OperationName = "DeleteIncident"
	GetIncidentByIdOperation OperationName = "GetIncidentById"
	GetIncidentsOperation    OperationName = "GetIncidents"
	GetStatusesOperation     OperationName = "GetStatuses"
	UpdateIncidentOperation  OperationName = "UpdateIncident"
)

type OptInt

type OptInt struct {
	Value int
	Set   bool
}

OptInt is optional int.

func NewOptInt

func NewOptInt(v int) OptInt

NewOptInt returns new OptInt with value set to v.

func (*OptInt) Decode

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

Decode decodes int from json.

func (OptInt) Encode

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

Encode encodes int as json.

func (OptInt) Get

func (o OptInt) Get() (v int, ok bool)

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

func (OptInt) IsSet

func (o OptInt) IsSet() bool

IsSet returns true if OptInt was set.

func (OptInt) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (OptInt) Or

func (o OptInt) Or(d int) int

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

func (*OptInt) Reset

func (o *OptInt) Reset()

Reset unsets value.

func (*OptInt) SetTo

func (o *OptInt) SetTo(v int)

SetTo sets value to v.

func (*OptInt) UnmarshalJSON

func (s *OptInt) 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 SecurityHandler

type SecurityHandler interface {
	// HandleBearerAuth handles bearerAuth security.
	HandleBearerAuth(ctx context.Context, operationName OperationName, t BearerAuth) (context.Context, error)
}

SecurityHandler is handler for security parameters.

type SecuritySource

type SecuritySource interface {
	// BearerAuth provides bearerAuth security value.
	BearerAuth(ctx context.Context, operationName OperationName) (BearerAuth, 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 Status

type Status struct {
	// Status id.
	ID   int    `json:"id"`
	Name string `json:"name"`
}

Ref: #/components/schemas/Status

func (*Status) Decode

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

Decode decodes Status from json.

func (*Status) Encode

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

Encode implements json.Marshaler.

func (*Status) GetID

func (s *Status) GetID() int

GetID returns the value of ID.

func (*Status) GetName

func (s *Status) GetName() string

GetName returns the value of Name.

func (*Status) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*Status) SetID

func (s *Status) SetID(val int)

SetID sets the value of ID.

func (*Status) SetName

func (s *Status) SetName(val string)

SetName sets the value of Name.

func (*Status) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type StatusesHandler

type StatusesHandler interface {
	// GetStatuses implements getStatuses operation.
	//
	// Получение списка статусов.
	//
	// GET /statuses
	GetStatuses(ctx context.Context) (GetStatusesRes, error)
}

StatusesHandler handles operations described by OpenAPI v3 specification.

x-ogen-operation-group: Statuses

type StatusesInvoker

type StatusesInvoker interface {
	// GetStatuses invokes getStatuses operation.
	//
	// Получение списка статусов.
	//
	// GET /statuses
	GetStatuses(ctx context.Context) (GetStatusesRes, error)
}

StatusesInvoker invokes operations described by OpenAPI v3 specification.

x-gen-operation-group: Statuses

type StatusesResponse

type StatusesResponse struct {
	TrackingId string   `json:"trackingId"`
	Status     string   `json:"status"`
	Data       []Status `json:"data"`
}

Ref: #/components/schemas/StatusesResponse

func (*StatusesResponse) Decode

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

Decode decodes StatusesResponse from json.

func (*StatusesResponse) Encode

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

Encode implements json.Marshaler.

func (*StatusesResponse) GetData

func (s *StatusesResponse) GetData() []Status

GetData returns the value of Data.

func (*StatusesResponse) GetStatus

func (s *StatusesResponse) GetStatus() string

GetStatus returns the value of Status.

func (*StatusesResponse) GetTrackingId

func (s *StatusesResponse) GetTrackingId() string

GetTrackingId returns the value of TrackingId.

func (*StatusesResponse) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*StatusesResponse) SetData

func (s *StatusesResponse) SetData(val []Status)

SetData sets the value of Data.

func (*StatusesResponse) SetStatus

func (s *StatusesResponse) SetStatus(val string)

SetStatus sets the value of Status.

func (*StatusesResponse) SetTrackingId

func (s *StatusesResponse) SetTrackingId(val string)

SetTrackingId sets the value of TrackingId.

func (*StatusesResponse) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*StatusesResponse) Validate

func (s *StatusesResponse) Validate() error

type UnimplementedHandler

type UnimplementedHandler struct{}

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

func (UnimplementedHandler) AddIncident

func (UnimplementedHandler) AddIncident(ctx context.Context, req *Incident) (r AddIncidentRes, _ error)

AddIncident implements addIncident operation.

Add a new incidents.

POST /incidents

func (UnimplementedHandler) DeleteIncident

DeleteIncident implements deleteIncident operation.

Delete an incidents.

DELETE /incidents/{incidentId}

func (UnimplementedHandler) GetIncidentById

GetIncidentById implements getIncidentById operation.

Returns a single incidents.

GET /incidents/{incidentId}

func (UnimplementedHandler) GetIncidents

func (UnimplementedHandler) GetIncidents(ctx context.Context) (r GetIncidentsRes, _ error)

GetIncidents implements getIncidents operation.

List of incidents.

GET /incidents

func (UnimplementedHandler) GetStatuses

func (UnimplementedHandler) GetStatuses(ctx context.Context) (r GetStatusesRes, _ error)

GetStatuses implements getStatuses operation.

Получение списка статусов.

GET /statuses

func (UnimplementedHandler) UpdateIncident

func (UnimplementedHandler) UpdateIncident(ctx context.Context, req *Incident) (r UpdateIncidentRes, _ error)

UpdateIncident implements updateIncident operation.

Update an existing incidents by Id.

PUT /incidents

type UpdateIncidentBadRequest

type UpdateIncidentBadRequest struct{}

UpdateIncidentBadRequest is response for UpdateIncident operation.

type UpdateIncidentNotFound

type UpdateIncidentNotFound struct{}

UpdateIncidentNotFound is response for UpdateIncident operation.

type UpdateIncidentRes

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

type UpdateIncidentUnprocessableEntity

type UpdateIncidentUnprocessableEntity struct{}

UpdateIncidentUnprocessableEntity is response for UpdateIncident operation.

Jump to

Keyboard shortcuts

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