api

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package api provides primitives to interact with the openapi HTTP API.

Code generated by unknown module path version unknown version DO NOT EDIT.

Package api provides primitives to interact with the openapi HTTP API.

Code generated by unknown module path version unknown version DO NOT EDIT.

Package api provides primitives to interact with the openapi HTTP API.

Code generated by unknown module path version unknown version DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(w http.ResponseWriter, p Problem)

Error creates an detailed error response.

func Handler

func Handler(si ServerInterface) http.Handler

Handler creates http.Handler with routing matching OpenAPI spec.

func HandlerFromMux

func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler

HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.

func HandlerFromMuxWithBaseURL

func HandlerFromMuxWithBaseURL(si ServerInterface, r chi.Router, baseURL string) http.Handler

func HandlerWithOptions

func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler

HandlerWithOptions creates http.Handler with additional options

func NewGetSegmentBlobRequest

func NewGetSegmentBlobRequest(server string, segmentId SegmentID) (*http.Request, error)

NewGetSegmentBlobRequest generates requests for GetSegmentBlob

func NewGetSegmentRequest

func NewGetSegmentRequest(server string, segmentId SegmentID) (*http.Request, error)

NewGetSegmentRequest generates requests for GetSegment

func NewGetSegmentsRequest

func NewGetSegmentsRequest(server string, params *GetSegmentsParams) (*http.Request, error)

NewGetSegmentsRequest generates requests for GetSegments

func SegID

func SegID(s *seg.PathSegment) string

SegID makes a hex encoded string of the segment id.

Types

type ChiServerOptions

type ChiServerOptions struct {
	BaseURL          string
	BaseRouter       chi.Router
	Middlewares      []MiddlewareFunc
	ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type Client

type Client struct {
	// The endpoint of the server conforming to this interface, with scheme,
	// https://api.deepmap.com for example. This can contain a path relative
	// to the server, such as https://api.deepmap.com/dev-test, and all the
	// paths in the swagger spec will be appended to the server.
	Server string

	// Doer for performing requests, typically a *http.Client with any
	// customized settings, such as certificate chains.
	Client HttpRequestDoer

	// A list of callbacks for modifying requests which are generated before sending over
	// the network.
	RequestEditors []RequestEditorFn
}

Client which conforms to the OpenAPI3 specification for this service.

func NewClient

func NewClient(server string, opts ...ClientOption) (*Client, error)

Creates a new Client, with reasonable defaults

func (*Client) GetSegment

func (c *Client) GetSegment(ctx context.Context, segmentId SegmentID, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetSegmentBlob

func (c *Client) GetSegmentBlob(ctx context.Context, segmentId SegmentID, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetSegments

func (c *Client) GetSegments(ctx context.Context, params *GetSegmentsParams, reqEditors ...RequestEditorFn) (*http.Response, error)

type ClientInterface

type ClientInterface interface {
	// GetSegments request
	GetSegments(ctx context.Context, params *GetSegmentsParams, reqEditors ...RequestEditorFn) (*http.Response, error)

	// GetSegment request
	GetSegment(ctx context.Context, segmentId SegmentID, reqEditors ...RequestEditorFn) (*http.Response, error)

	// GetSegmentBlob request
	GetSegmentBlob(ctx context.Context, segmentId SegmentID, reqEditors ...RequestEditorFn) (*http.Response, error)
}

The interface specification for the client above.

type ClientOption

type ClientOption func(*Client) error

ClientOption allows setting custom parameters during construction

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL overrides the baseURL.

func WithHTTPClient

func WithHTTPClient(doer HttpRequestDoer) ClientOption

WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client. This is useful for tests.

func WithRequestEditorFn

func WithRequestEditorFn(fn RequestEditorFn) ClientOption

WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request. This can be used to mutate the request.

type ClientWithResponses

type ClientWithResponses struct {
	ClientInterface
}

ClientWithResponses builds on ClientInterface to offer response payloads

func NewClientWithResponses

func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error)

NewClientWithResponses creates a new ClientWithResponses, which wraps Client with return type handling

func (*ClientWithResponses) GetSegmentBlobWithResponse

func (c *ClientWithResponses) GetSegmentBlobWithResponse(ctx context.Context, segmentId SegmentID, reqEditors ...RequestEditorFn) (*GetSegmentBlobResponse, error)

GetSegmentBlobWithResponse request returning *GetSegmentBlobResponse

func (*ClientWithResponses) GetSegmentWithResponse

func (c *ClientWithResponses) GetSegmentWithResponse(ctx context.Context, segmentId SegmentID, reqEditors ...RequestEditorFn) (*GetSegmentResponse, error)

GetSegmentWithResponse request returning *GetSegmentResponse

func (*ClientWithResponses) GetSegmentsWithResponse

func (c *ClientWithResponses) GetSegmentsWithResponse(ctx context.Context, params *GetSegmentsParams, reqEditors ...RequestEditorFn) (*GetSegmentsResponse, error)

GetSegmentsWithResponse request returning *GetSegmentsResponse

type ClientWithResponsesInterface

type ClientWithResponsesInterface interface {
	// GetSegmentsWithResponse request
	GetSegmentsWithResponse(ctx context.Context, params *GetSegmentsParams, reqEditors ...RequestEditorFn) (*GetSegmentsResponse, error)

	// GetSegmentWithResponse request
	GetSegmentWithResponse(ctx context.Context, segmentId SegmentID, reqEditors ...RequestEditorFn) (*GetSegmentResponse, error)

	// GetSegmentBlobWithResponse request
	GetSegmentBlobWithResponse(ctx context.Context, segmentId SegmentID, reqEditors ...RequestEditorFn) (*GetSegmentBlobResponse, error)
}

ClientWithResponsesInterface is the interface specification for the client with responses above.

type GetSegmentBlobResponse

type GetSegmentBlobResponse struct {
	Body                      []byte
	HTTPResponse              *http.Response
	ApplicationproblemJSON400 *Problem
}

func ParseGetSegmentBlobResponse

func ParseGetSegmentBlobResponse(rsp *http.Response) (*GetSegmentBlobResponse, error)

ParseGetSegmentBlobResponse parses an HTTP response from a GetSegmentBlobWithResponse call

func (GetSegmentBlobResponse) Status

func (r GetSegmentBlobResponse) Status() string

Status returns HTTPResponse.Status

func (GetSegmentBlobResponse) StatusCode

func (r GetSegmentBlobResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type GetSegmentResponse

type GetSegmentResponse struct {
	Body                      []byte
	HTTPResponse              *http.Response
	JSON200                   *Segment
	ApplicationproblemJSON400 *Problem
}

func ParseGetSegmentResponse

func ParseGetSegmentResponse(rsp *http.Response) (*GetSegmentResponse, error)

ParseGetSegmentResponse parses an HTTP response from a GetSegmentWithResponse call

func (GetSegmentResponse) Status

func (r GetSegmentResponse) Status() string

Status returns HTTPResponse.Status

func (GetSegmentResponse) StatusCode

func (r GetSegmentResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type GetSegmentsParams

type GetSegmentsParams struct {
	// StartIsdAs Start ISD-AS of segment.
	StartIsdAs *IsdAs `form:"start_isd_as,omitempty" json:"start_isd_as,omitempty"`

	// EndIsdAs Terminal AS of segment.
	EndIsdAs *IsdAs `form:"end_isd_as,omitempty" json:"end_isd_as,omitempty"`
}

GetSegmentsParams defines parameters for GetSegments.

type GetSegmentsResponse

type GetSegmentsResponse struct {
	Body                      []byte
	HTTPResponse              *http.Response
	JSON200                   *[]SegmentBrief
	ApplicationproblemJSON400 *Problem
}

func ParseGetSegmentsResponse

func ParseGetSegmentsResponse(rsp *http.Response) (*GetSegmentsResponse, error)

ParseGetSegmentsResponse parses an HTTP response from a GetSegmentsWithResponse call

func (GetSegmentsResponse) Status

func (r GetSegmentsResponse) Status() string

Status returns HTTPResponse.Status

func (GetSegmentsResponse) StatusCode

func (r GetSegmentsResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type Hop

type Hop struct {
	Interface int   `json:"interface"`
	IsdAs     IsdAs `json:"isd_as"`
}

Hop defines model for Hop.

type HttpRequestDoer

type HttpRequestDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

Doer performs HTTP requests.

The standard http.Client implements this interface.

type InvalidParamFormatError

type InvalidParamFormatError struct {
	ParamName string
	Err       error
}

func (*InvalidParamFormatError) Error

func (e *InvalidParamFormatError) Error() string

func (*InvalidParamFormatError) Unwrap

func (e *InvalidParamFormatError) Unwrap() error

type IsdAs

type IsdAs = string

IsdAs defines model for IsdAs.

type MiddlewareFunc

type MiddlewareFunc func(http.Handler) http.Handler

type Problem

type Problem struct {
	// Detail A human readable explanation specific to this occurrence of the problem that is helpful to locate the problem and give advice on how to proceed. Written in English and readable for engineers, usually not suited for non technical stakeholders and not localized.
	Detail *string `json:"detail,omitempty"`

	// Instance A URI reference that identifies the specific occurrence of the problem, e.g. by adding a fragment identifier or sub-path to the problem type. May be used to locate the root of this problem in the source code.
	Instance *string `json:"instance,omitempty"`

	// Status The HTTP status code generated by the origin server for this occurrence of the problem.
	Status int `json:"status"`

	// Title A short summary of the problem type. Written in English and readable for engineers, usually not suited for non technical stakeholders and not localized.
	Title string `json:"title"`

	// Type A URI reference that uniquely identifies the problem type only in the context of the provided API. Opposed to the specification in RFC-7807, it is neither recommended to be dereferencable and point to a human-readable documentation nor globally unique for the problem type.
	Type *string `json:"type,omitempty"`
}

Problem defines model for Problem.

type RequestEditorFn

type RequestEditorFn func(ctx context.Context, req *http.Request) error

RequestEditorFn is the function signature for the RequestEditor callback function

type RequiredHeaderError

type RequiredHeaderError struct {
	ParamName string
	Err       error
}

func (*RequiredHeaderError) Error

func (e *RequiredHeaderError) Error() string

func (*RequiredHeaderError) Unwrap

func (e *RequiredHeaderError) Unwrap() error

type RequiredParamError

type RequiredParamError struct {
	ParamName string
}

func (*RequiredParamError) Error

func (e *RequiredParamError) Error() string

type Segment

type Segment struct {
	Expiration  time.Time `json:"expiration"`
	Hops        []Hop     `json:"hops"`
	Id          SegmentID `json:"id"`
	LastUpdated time.Time `json:"last_updated"`
	Timestamp   time.Time `json:"timestamp"`
}

Segment defines model for Segment.

type SegmentBrief

type SegmentBrief struct {
	EndIsdAs IsdAs     `json:"end_isd_as"`
	Id       SegmentID `json:"id"`

	// Length Length of the segment.
	Length     int   `json:"length"`
	StartIsdAs IsdAs `json:"start_isd_as"`
}

SegmentBrief defines model for SegmentBrief.

type SegmentID

type SegmentID = string

SegmentID defines model for SegmentID.

type SegmentStore

type SegmentStore interface {
	Get(context.Context, *query.Params) (query.Results, error)
}

type Server

type Server struct {
	Segments SegmentStore
}

func (*Server) GetSegment

func (s *Server) GetSegment(w http.ResponseWriter, r *http.Request, segmentID SegmentID)

GetSegment gets a segments details specified by its ID.

func (*Server) GetSegmentBlob

func (s *Server) GetSegmentBlob(w http.ResponseWriter, r *http.Request, segmentID SegmentID)

GetSegmentBlob gets a segment (specified by its ID) as a pem encoded blob.

func (*Server) GetSegments

func (s *Server) GetSegments(w http.ResponseWriter, r *http.Request, params GetSegmentsParams)

GetSegments gets the stored in the PathDB.

type ServerInterface

type ServerInterface interface {
	// List the SCION path segments
	// (GET /segments)
	GetSegments(w http.ResponseWriter, r *http.Request, params GetSegmentsParams)
	// Get the SCION path segment description
	// (GET /segments/{segment-id})
	GetSegment(w http.ResponseWriter, r *http.Request, segmentId SegmentID)
	// Get the SCION path segment blob
	// (GET /segments/{segment-id}/blob)
	GetSegmentBlob(w http.ResponseWriter, r *http.Request, segmentId SegmentID)
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
	ErrorHandlerFunc   func(w http.ResponseWriter, r *http.Request, err error)
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) GetSegment

func (siw *ServerInterfaceWrapper) GetSegment(w http.ResponseWriter, r *http.Request)

GetSegment operation middleware

func (*ServerInterfaceWrapper) GetSegmentBlob

func (siw *ServerInterfaceWrapper) GetSegmentBlob(w http.ResponseWriter, r *http.Request)

GetSegmentBlob operation middleware

func (*ServerInterfaceWrapper) GetSegments

func (siw *ServerInterfaceWrapper) GetSegments(w http.ResponseWriter, r *http.Request)

GetSegments operation middleware

type TooManyValuesForParamError

type TooManyValuesForParamError struct {
	ParamName string
	Count     int
}

func (*TooManyValuesForParamError) Error

type UnescapedCookieParamError

type UnescapedCookieParamError struct {
	ParamName string
	Err       error
}

func (*UnescapedCookieParamError) Error

func (e *UnescapedCookieParamError) Error() string

func (*UnescapedCookieParamError) Unwrap

func (e *UnescapedCookieParamError) Unwrap() error

type Unimplemented added in v0.10.0

type Unimplemented struct{}

func (Unimplemented) GetSegment added in v0.10.0

func (_ Unimplemented) GetSegment(w http.ResponseWriter, r *http.Request, segmentId SegmentID)

Get the SCION path segment description (GET /segments/{segment-id})

func (Unimplemented) GetSegmentBlob added in v0.10.0

func (_ Unimplemented) GetSegmentBlob(w http.ResponseWriter, r *http.Request, segmentId SegmentID)

Get the SCION path segment blob (GET /segments/{segment-id}/blob)

func (Unimplemented) GetSegments added in v0.10.0

func (_ Unimplemented) GetSegments(w http.ResponseWriter, r *http.Request, params GetSegmentsParams)

List the SCION path segments (GET /segments)

type UnmarshalingParamError

type UnmarshalingParamError struct {
	ParamName string
	Err       error
}

func (*UnmarshalingParamError) Error

func (e *UnmarshalingParamError) Error() string

func (*UnmarshalingParamError) Unwrap

func (e *UnmarshalingParamError) Unwrap() error

Directories

Path Synopsis
Package mock_api is a generated GoMock package.
Package mock_api is a generated GoMock package.

Jump to

Keyboard shortcuts

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