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: 22 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 NewGetCertificateBlobRequest

func NewGetCertificateBlobRequest(server string, chainId ChainID) (*http.Request, error)

NewGetCertificateBlobRequest generates requests for GetCertificateBlob

func NewGetCertificateRequest

func NewGetCertificateRequest(server string, chainId ChainID) (*http.Request, error)

NewGetCertificateRequest generates requests for GetCertificate

func NewGetCertificatesRequest

func NewGetCertificatesRequest(server string, params *GetCertificatesParams) (*http.Request, error)

NewGetCertificatesRequest generates requests for GetCertificates

func NewGetTrcBlobRequest

func NewGetTrcBlobRequest(server string, isd int, base int, serial int) (*http.Request, error)

NewGetTrcBlobRequest generates requests for GetTrcBlob

func NewGetTrcRequest

func NewGetTrcRequest(server string, isd int, base int, serial int) (*http.Request, error)

NewGetTrcRequest generates requests for GetTrc

func NewGetTrcsRequest

func NewGetTrcsRequest(server string, params *GetTrcsParams) (*http.Request, error)

NewGetTrcsRequest generates requests for GetTrcs

Types

type BadRequest

type BadRequest = StandardError

BadRequest defines model for BadRequest.

type Certificate

type Certificate struct {
	DistinguishedName string       `json:"distinguished_name"`
	IsdAs             IsdAs        `json:"isd_as"`
	SubjectKeyAlgo    string       `json:"subject_key_algo"`
	SubjectKeyId      SubjectKeyID `json:"subject_key_id"`
	Validity          Validity     `json:"validity"`
}

Certificate defines model for Certificate.

type Chain

type Chain struct {
	Issuer  Certificate `json:"issuer"`
	Subject Certificate `json:"subject"`
}

Chain defines model for Chain.

type ChainBrief

type ChainBrief struct {
	Id       ChainID  `json:"id"`
	Issuer   IsdAs    `json:"issuer"`
	Subject  IsdAs    `json:"subject"`
	Validity Validity `json:"validity"`
}

ChainBrief defines model for ChainBrief.

type ChainID

type ChainID = string

ChainID defines model for ChainID.

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

func (c *Client) GetCertificate(ctx context.Context, chainId ChainID, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetCertificateBlob

func (c *Client) GetCertificateBlob(ctx context.Context, chainId ChainID, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetCertificates

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

func (*Client) GetTrc

func (c *Client) GetTrc(ctx context.Context, isd int, base int, serial int, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetTrcBlob

func (c *Client) GetTrcBlob(ctx context.Context, isd int, base int, serial int, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetTrcs

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

type ClientInterface

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

	// GetCertificate request
	GetCertificate(ctx context.Context, chainId ChainID, reqEditors ...RequestEditorFn) (*http.Response, error)

	// GetCertificateBlob request
	GetCertificateBlob(ctx context.Context, chainId ChainID, reqEditors ...RequestEditorFn) (*http.Response, error)

	// GetTrcs request
	GetTrcs(ctx context.Context, params *GetTrcsParams, reqEditors ...RequestEditorFn) (*http.Response, error)

	// GetTrc request
	GetTrc(ctx context.Context, isd int, base int, serial int, reqEditors ...RequestEditorFn) (*http.Response, error)

	// GetTrcBlob request
	GetTrcBlob(ctx context.Context, isd int, base int, serial int, 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) GetCertificateBlobWithResponse

func (c *ClientWithResponses) GetCertificateBlobWithResponse(ctx context.Context, chainId ChainID, reqEditors ...RequestEditorFn) (*GetCertificateBlobResponse, error)

GetCertificateBlobWithResponse request returning *GetCertificateBlobResponse

func (*ClientWithResponses) GetCertificateWithResponse

func (c *ClientWithResponses) GetCertificateWithResponse(ctx context.Context, chainId ChainID, reqEditors ...RequestEditorFn) (*GetCertificateResponse, error)

GetCertificateWithResponse request returning *GetCertificateResponse

func (*ClientWithResponses) GetCertificatesWithResponse

func (c *ClientWithResponses) GetCertificatesWithResponse(ctx context.Context, params *GetCertificatesParams, reqEditors ...RequestEditorFn) (*GetCertificatesResponse, error)

GetCertificatesWithResponse request returning *GetCertificatesResponse

func (*ClientWithResponses) GetTrcBlobWithResponse

func (c *ClientWithResponses) GetTrcBlobWithResponse(ctx context.Context, isd int, base int, serial int, reqEditors ...RequestEditorFn) (*GetTrcBlobResponse, error)

GetTrcBlobWithResponse request returning *GetTrcBlobResponse

func (*ClientWithResponses) GetTrcWithResponse

func (c *ClientWithResponses) GetTrcWithResponse(ctx context.Context, isd int, base int, serial int, reqEditors ...RequestEditorFn) (*GetTrcResponse, error)

GetTrcWithResponse request returning *GetTrcResponse

func (*ClientWithResponses) GetTrcsWithResponse

func (c *ClientWithResponses) GetTrcsWithResponse(ctx context.Context, params *GetTrcsParams, reqEditors ...RequestEditorFn) (*GetTrcsResponse, error)

GetTrcsWithResponse request returning *GetTrcsResponse

type ClientWithResponsesInterface

type ClientWithResponsesInterface interface {
	// GetCertificatesWithResponse request
	GetCertificatesWithResponse(ctx context.Context, params *GetCertificatesParams, reqEditors ...RequestEditorFn) (*GetCertificatesResponse, error)

	// GetCertificateWithResponse request
	GetCertificateWithResponse(ctx context.Context, chainId ChainID, reqEditors ...RequestEditorFn) (*GetCertificateResponse, error)

	// GetCertificateBlobWithResponse request
	GetCertificateBlobWithResponse(ctx context.Context, chainId ChainID, reqEditors ...RequestEditorFn) (*GetCertificateBlobResponse, error)

	// GetTrcsWithResponse request
	GetTrcsWithResponse(ctx context.Context, params *GetTrcsParams, reqEditors ...RequestEditorFn) (*GetTrcsResponse, error)

	// GetTrcWithResponse request
	GetTrcWithResponse(ctx context.Context, isd int, base int, serial int, reqEditors ...RequestEditorFn) (*GetTrcResponse, error)

	// GetTrcBlobWithResponse request
	GetTrcBlobWithResponse(ctx context.Context, isd int, base int, serial int, reqEditors ...RequestEditorFn) (*GetTrcBlobResponse, error)
}

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

type GetCertificateBlobResponse

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

func ParseGetCertificateBlobResponse

func ParseGetCertificateBlobResponse(rsp *http.Response) (*GetCertificateBlobResponse, error)

ParseGetCertificateBlobResponse parses an HTTP response from a GetCertificateBlobWithResponse call

func (GetCertificateBlobResponse) Status

Status returns HTTPResponse.Status

func (GetCertificateBlobResponse) StatusCode

func (r GetCertificateBlobResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type GetCertificateResponse

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

func ParseGetCertificateResponse

func ParseGetCertificateResponse(rsp *http.Response) (*GetCertificateResponse, error)

ParseGetCertificateResponse parses an HTTP response from a GetCertificateWithResponse call

func (GetCertificateResponse) Status

func (r GetCertificateResponse) Status() string

Status returns HTTPResponse.Status

func (GetCertificateResponse) StatusCode

func (r GetCertificateResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type GetCertificatesParams

type GetCertificatesParams struct {
	IsdAs   *IsdAs     `form:"isd_as,omitempty" json:"isd_as,omitempty"`
	ValidAt *time.Time `form:"valid_at,omitempty" json:"valid_at,omitempty"`
	All     *bool      `form:"all,omitempty" json:"all,omitempty"`
}

GetCertificatesParams defines parameters for GetCertificates.

type GetCertificatesResponse

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

func ParseGetCertificatesResponse

func ParseGetCertificatesResponse(rsp *http.Response) (*GetCertificatesResponse, error)

ParseGetCertificatesResponse parses an HTTP response from a GetCertificatesWithResponse call

func (GetCertificatesResponse) Status

func (r GetCertificatesResponse) Status() string

Status returns HTTPResponse.Status

func (GetCertificatesResponse) StatusCode

func (r GetCertificatesResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type GetTrcBlobResponse

type GetTrcBlobResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON400      *BadRequest
}

func ParseGetTrcBlobResponse

func ParseGetTrcBlobResponse(rsp *http.Response) (*GetTrcBlobResponse, error)

ParseGetTrcBlobResponse parses an HTTP response from a GetTrcBlobWithResponse call

func (GetTrcBlobResponse) Status

func (r GetTrcBlobResponse) Status() string

Status returns HTTPResponse.Status

func (GetTrcBlobResponse) StatusCode

func (r GetTrcBlobResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type GetTrcResponse

type GetTrcResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *TRC
	JSON400      *BadRequest
}

func ParseGetTrcResponse

func ParseGetTrcResponse(rsp *http.Response) (*GetTrcResponse, error)

ParseGetTrcResponse parses an HTTP response from a GetTrcWithResponse call

func (GetTrcResponse) Status

func (r GetTrcResponse) Status() string

Status returns HTTPResponse.Status

func (GetTrcResponse) StatusCode

func (r GetTrcResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type GetTrcsParams

type GetTrcsParams struct {
	Isd *[]int `form:"isd,omitempty" json:"isd,omitempty"`
	All *bool  `form:"all,omitempty" json:"all,omitempty"`
}

GetTrcsParams defines parameters for GetTrcs.

type GetTrcsResponse

type GetTrcsResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *[]TRCBrief
	JSON400      *BadRequest
}

func ParseGetTrcsResponse

func ParseGetTrcsResponse(rsp *http.Response) (*GetTrcsResponse, error)

ParseGetTrcsResponse parses an HTTP response from a GetTrcsWithResponse call

func (GetTrcsResponse) Status

func (r GetTrcsResponse) Status() string

Status returns HTTPResponse.Status

func (GetTrcsResponse) StatusCode

func (r GetTrcsResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

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 Server

type Server struct {
	TrustDB storage.TrustDB
}

func (*Server) GetCertificate

func (s *Server) GetCertificate(w http.ResponseWriter, r *http.Request, chainID ChainID)

GetCertificate lists the certificate chain for a given ChainID

func (*Server) GetCertificateBlob

func (s *Server) GetCertificateBlob(w http.ResponseWriter, r *http.Request, chainID ChainID)

GetCertificateBlob gnerates a certificate chain blob response encoded as PEM for a given chainId.

func (*Server) GetCertificates

func (s *Server) GetCertificates(
	w http.ResponseWriter,
	r *http.Request,
	params GetCertificatesParams,
)

GetCertificates lists the certificate chains

func (*Server) GetTrc

func (s *Server) GetTrc(w http.ResponseWriter, r *http.Request, isd int, base int, serial int)

GetTrc gets the trc specified by it's isd bas and serial.

func (*Server) GetTrcBlob

func (s *Server) GetTrcBlob(w http.ResponseWriter, r *http.Request, isd int, base int, serial int)

GetTrcBlob gets the trc encoded pem blob.

func (*Server) GetTrcs

func (s *Server) GetTrcs(w http.ResponseWriter, r *http.Request, params GetTrcsParams)

type ServerInterface

type ServerInterface interface {
	// List the certificate chains
	// (GET /certificates)
	GetCertificates(w http.ResponseWriter, r *http.Request, params GetCertificatesParams)
	// Get the certificate chain
	// (GET /certificates/{chain-id})
	GetCertificate(w http.ResponseWriter, r *http.Request, chainId ChainID)
	// Get the certificate chain blob
	// (GET /certificates/{chain-id}/blob)
	GetCertificateBlob(w http.ResponseWriter, r *http.Request, chainId ChainID)
	// List the TRCs
	// (GET /trcs)
	GetTrcs(w http.ResponseWriter, r *http.Request, params GetTrcsParams)
	// Get the TRC
	// (GET /trcs/isd{isd}-b{base}-s{serial})
	GetTrc(w http.ResponseWriter, r *http.Request, isd int, base int, serial int)
	// Get the TRC blob
	// (GET /trcs/isd{isd}-b{base}-s{serial}/blob)
	GetTrcBlob(w http.ResponseWriter, r *http.Request, isd int, base int, serial int)
}

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

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

GetCertificate operation middleware

func (*ServerInterfaceWrapper) GetCertificateBlob

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

GetCertificateBlob operation middleware

func (*ServerInterfaceWrapper) GetCertificates

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

GetCertificates operation middleware

func (*ServerInterfaceWrapper) GetTrc

GetTrc operation middleware

func (*ServerInterfaceWrapper) GetTrcBlob

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

GetTrcBlob operation middleware

func (*ServerInterfaceWrapper) GetTrcs

GetTrcs operation middleware

type StandardError

type StandardError struct {
	// Error Error message
	Error string `json:"error"`
}

StandardError defines model for StandardError.

type SubjectKeyID

type SubjectKeyID = string

SubjectKeyID defines model for SubjectKeyID.

type TRC

type TRC struct {
	AuthoritativeAses []IsdAs  `json:"authoritative_ases"`
	CoreAses          []IsdAs  `json:"core_ases"`
	Description       string   `json:"description"`
	Id                TRCID    `json:"id"`
	Validity          Validity `json:"validity"`
}

TRC defines model for TRC.

type TRCBrief

type TRCBrief struct {
	Id TRCID `json:"id"`
}

TRCBrief defines model for TRCBrief.

type TRCID

type TRCID struct {
	BaseNumber   int `json:"base_number"`
	Isd          int `json:"isd"`
	SerialNumber int `json:"serial_number"`
}

TRCID defines model for TRCID.

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) GetCertificate added in v0.10.0

func (_ Unimplemented) GetCertificate(w http.ResponseWriter, r *http.Request, chainId ChainID)

Get the certificate chain (GET /certificates/{chain-id})

func (Unimplemented) GetCertificateBlob added in v0.10.0

func (_ Unimplemented) GetCertificateBlob(w http.ResponseWriter, r *http.Request, chainId ChainID)

Get the certificate chain blob (GET /certificates/{chain-id}/blob)

func (Unimplemented) GetCertificates added in v0.10.0

func (_ Unimplemented) GetCertificates(w http.ResponseWriter, r *http.Request, params GetCertificatesParams)

List the certificate chains (GET /certificates)

func (Unimplemented) GetTrc added in v0.10.0

func (_ Unimplemented) GetTrc(w http.ResponseWriter, r *http.Request, isd int, base int, serial int)

Get the TRC (GET /trcs/isd{isd}-b{base}-s{serial})

func (Unimplemented) GetTrcBlob added in v0.10.0

func (_ Unimplemented) GetTrcBlob(w http.ResponseWriter, r *http.Request, isd int, base int, serial int)

Get the TRC blob (GET /trcs/isd{isd}-b{base}-s{serial}/blob)

func (Unimplemented) GetTrcs added in v0.10.0

func (_ Unimplemented) GetTrcs(w http.ResponseWriter, r *http.Request, params GetTrcsParams)

List the TRCs (GET /trcs)

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

type Validity

type Validity struct {
	NotAfter  time.Time `json:"not_after"`
	NotBefore time.Time `json:"not_before"`
}

Validity defines model for Validity.

Jump to

Keyboard shortcuts

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