Documentation ¶
Index ¶
Constants ¶
View Source
const ( DefaultUserAgent = "go-katapult" DefaultTimeout = time.Second * 60 )
Variables ¶
View Source
var ( // Err is the top-most parent of any error returned by katapult. Err = errors.New("katapult") // ErrRequest is returned when there's an issue with building the request. ErrRequest = fmt.Errorf("%w: request", Err) // ErrConfig is returned when there's a configuration related issue. ErrConfig = fmt.Errorf("%w: config", Err) // ErrResponse is the parent of all response API related errors. ErrResponse = fmt.Errorf("%w", Err) // ErrResourceNotFound is a parent error of all resource-specific not found // errors. ErrResourceNotFound = fmt.Errorf("%w", ErrNotFound) // ErrRouteNotFound indicates the API endpoint called does not exist. This // generally will mean go-katapult is very old and needs to be updated. ErrRouteNotFound = fmt.Errorf("%w: route_not_found", ErrResponse) // ErrUnexpectedResponse is returned if the response body did not contain // expected data. ErrUnexpectedResponse = fmt.Errorf("%w: unexpected_response", ErrResponse) // ErrUnknown is returned if the response error could not be understood. ErrUnknown = fmt.Errorf("%w: unknown_error", ErrResponse) )
View Source
var ( ErrBadRequest = fmt.Errorf("%w: bad_request", ErrResponse) ErrForbidden = fmt.Errorf("%w", ErrUnauthorized) ErrNotFound = fmt.Errorf("%w: not_found", ErrResponse) ErrNotAcceptable = fmt.Errorf("%w: not_acceptable", ErrResponse) ErrConflict = fmt.Errorf("%w: conflict", ErrResponse) ErrUnprocessableEntity = fmt.Errorf("%w: unprocessable_entity", ErrResponse) ErrTooManyRequests = fmt.Errorf("%w: too_many_requests", ErrResponse) ErrInternalServerError = fmt.Errorf( "%w: internal_server_error", ErrResponse, ) ErrBadGateway = fmt.Errorf("%w: bad_gateway", ErrResponse) ErrGatewayTimeout = fmt.Errorf("%w: gateway_timeout", ErrResponse) )
HTTP status-based errors. These may be returned directly, or act as the parent error for a more specific error.
View Source
var DefaultURL = &url.URL{Scheme: "https", Host: "api.katapult.io"}
View Source
var ErrScopeNotGranted = fmt.Errorf("%w: scope_not_granted", ErrForbidden)
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { HTTPClient HTTPClient APIKey string UserAgent string BaseURL *url.URL }
type CommonError ¶ added in v0.1.5
type CommonError struct { Code string `json:"code,omitempty"` Description string `json:"description,omitempty"` // contains filtered or unexported fields }
CommonError handles common logic shared between all API-based error types.
func NewCommonError ¶ added in v0.1.5
func NewCommonError(parent error, code, description string) CommonError
func (*CommonError) BaseError ¶ added in v0.1.5
func (s *CommonError) BaseError() string
func (*CommonError) Error ¶ added in v0.1.5
func (s *CommonError) Error() string
func (*CommonError) Is ¶ added in v0.1.5
func (s *CommonError) Is(target error) bool
func (*CommonError) Unwrap ¶ added in v0.1.5
func (s *CommonError) Unwrap() error
type HTTPClient ¶ added in v0.1.5
type Option ¶ added in v0.1.7
func WithAPIKey ¶
func WithBaseURL ¶
func WithHTTPClient ¶ added in v0.1.2
func WithHTTPClient(hc HTTPClient) Option
func WithUserAgent ¶
type Pagination ¶
type Request ¶ added in v0.1.5
type Request struct { // Method is the HTTP method to perform when making the request. Method string // URL is the request URL to perform against Katapult's API. Generally the // only fields you need to set are Path and RawQuery, as it will be merged // with the Client's BaseURL value through its ResolveReference() method. URL *url.URL // NoAuth instructs Client not to send Authorization header containing the // APIKey. This is useful for public endpoints which do not require/use // authentication. NoAuth bool // Header holds request-specific HTTP headers. Client.Do() will set a number // of essential headers itself which cannot be customized through // Request.Headers. Header http.Header // ContentType allows sending a custom request body of any mimetype. If set // Body must be a io.Reader. If not set Body must be a object which can be // serialized with json.Marshal(). Content-Type header is only sent when // Body is not nil. ContentType string // Body can be any object which can be marshaled to JSON through // json.Marshal() when ContentType is not set. If ContentType is set, Body // must be a io.Reader, or nil. // // No validation is performed between Method and Body, making it possible to // send a body with a method that does not allow it. Body interface{} }
Request represents a HTTP request to the Katapult API, it is essentially similar to http.Request, but stripped down to the bare essentials, with some Katapult-specific attributes added.
func NewRequest ¶ added in v0.1.5
func NewRequest( method string, u *url.URL, body interface{}, opts ...RequestOption, ) *Request
type RequestOption ¶ added in v0.1.7
type RequestOption = func(r *Request)
func RequestSetHeader ¶ added in v0.1.7
func RequestSetHeader(key, value string) RequestOption
RequestSetHeader sets a header on the outgoing request. This replaces any headers that are currently specified with that key.
type Response ¶
type Response struct { *http.Response Pagination *Pagination Error *ResponseError }
func NewResponse ¶
type ResponseError ¶
type ResponseError struct { Code string `json:"code,omitempty"` Description string `json:"description,omitempty"` Detail json.RawMessage `json:"detail,omitempty"` // contains filtered or unexported fields }
func NewResponseError ¶ added in v0.1.5
func NewResponseError( httpStatus int, code string, description string, rawDetail json.RawMessage, ) *ResponseError
func (*ResponseError) Error ¶ added in v0.1.5
func (s *ResponseError) Error() string
func (*ResponseError) Is ¶ added in v0.1.5
func (s *ResponseError) Is(target error) bool
func (*ResponseError) Unwrap ¶ added in v0.1.5
func (s *ResponseError) Unwrap() error
type ScopeNotGrantedError ¶ added in v0.1.5
type ScopeNotGrantedError struct { CommonError Detail *ScopeNotGrantedErrorDetail `json:"detail,omitempty"` }
ScopeNotGrantedError: The scope required for this endpoint has not been granted to the authenticating identity.
func NewScopeNotGrantedError ¶ added in v0.1.5
func NewScopeNotGrantedError(theError *ResponseError) *ScopeNotGrantedError
func (*ScopeNotGrantedError) Error ¶ added in v0.1.5
func (s *ScopeNotGrantedError) Error() string
type ScopeNotGrantedErrorDetail ¶ added in v0.1.5
type ScopeNotGrantedErrorDetail struct {
Scopes []string `json:"scopes,omitempty"`
}
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package buildspec implements the Katapult Virtual Machine build spec XML document format.
|
Package buildspec implements the Katapult Virtual Machine build spec XML document format. |
Package katapult is a client for katapult.io's API.
|
Package katapult is a client for katapult.io's API. |
internal
|
|
testclient
Package testclient contains a fake Client used for testing.
|
Package testclient contains a fake Client used for testing. |
Package namegenerator provides various helper methods to generate randomized names for use on the Katapult platform.
|
Package namegenerator provides various helper methods to generate randomized names for use on the Katapult platform. |
Package next provides primitives to interact with the openapi HTTP API.
|
Package next provides primitives to interact with the openapi HTTP API. |
tools
|
|
Click to show internal directories.
Click to hide internal directories.