api

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2021 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ParamOffset        = "offset"
	ParamLimit         = "limit"
	ParamLabelSelector = "labelSelector"
)
View Source
const (
	RelationSelf      = "self"
	RelationNext      = "next"
	RelationPrev      = "prev"
	RelationAlternate = "alternate"
	RelationLabels    = "https://stormforge.io/rel/labels"
	RelationTrials    = "https://stormforge.io/rel/trials"
	RelationNextTrial = "https://stormforge.io/rel/next-trial"
)

Variables

This section is empty.

Functions

func CanonicalLinkRelation added in v0.0.11

func CanonicalLinkRelation(rel string) string

CanonicalLinkRelation returns the supplied link relation name normalized for previously accepted values. The returned value can be compared case-insensitively to the supplied `Relation*` constants.

func IsUnauthorized added in v0.0.11

func IsUnauthorized(err error) bool

IsUnauthorized checks to see if the error is an "unauthorized" error.

func UnmarshalJSON added in v0.0.11

func UnmarshalJSON(b []byte, v interface{}) error

UnmarshalJSON extracts the supplied JSON, preserving the "_metadata" field if necessary. This should only be necessary on items in index (list) representations as top-level "_metadata" fields should normally be populated from HTTP headers.

Types

type Client

type Client interface {
	// URL returns the location of the specified endpoint
	URL(endpoint string) *url.URL
	// Do performs the interaction specified by the HTTP request
	Do(context.Context, *http.Request) (*http.Response, []byte, error)
}

Client is used to handle interactions with the API Server.

func NewClient

func NewClient(address string, transport http.RoundTripper) (Client, error)

NewClient returns a new client for accessing API server.

type Error added in v0.0.11

type Error struct {
	Type       ErrorType     `json:"-"`
	Message    string        `json:"error"`
	RetryAfter time.Duration `json:"-"`
	Location   string        `json:"-"`
}

Error represents the API specific error messages and may be used in response to HTTP status codes

func NewError added in v0.0.11

func NewError(t ErrorType, resp *http.Response, body []byte) *Error

NewError returns a new error with an API specific error condition, it also captures the details of the response

func NewUnexpectedError added in v0.0.11

func NewUnexpectedError(resp *http.Response, body []byte) *Error

NewUnexpectedError returns an error in situations where the API returned an undocumented status for the requested resource.

func (*Error) Error added in v0.0.11

func (e *Error) Error() string

Error returns the message associated with this API error.

type ErrorType added in v0.0.11

type ErrorType string

ErrorType is an identifying token for errors.

const (
	ErrUnauthorized ErrorType = "unauthorized"
	ErrUnexpected   ErrorType = "unexpected"
)

type IndexQuery added in v0.0.11

type IndexQuery map[string][]string

IndexQuery represents the query parameter of an index resource.

func (*IndexQuery) SetLabelSelector added in v0.0.11

func (q *IndexQuery) SetLabelSelector(kv map[string]string)

SetLabelSelector is a helper to set label selectors used to filter the index.

func (*IndexQuery) SetLimit added in v0.0.11

func (q *IndexQuery) SetLimit(limit int)

SetLimit sets the maximum number of items to include with the index.

func (*IndexQuery) SetOffset added in v0.0.11

func (q *IndexQuery) SetOffset(offset int)

SetOffset sets the number of items to skip from the beginning of the index.

type Metadata added in v0.0.11

type Metadata map[string][]string

Metadata is used to hold single or multi-value metadata from list responses.

func (Metadata) LastModified added in v0.0.11

func (m Metadata) LastModified() time.Time
func (m Metadata) Link(rel string) string

func (Metadata) Location added in v0.0.11

func (m Metadata) Location() string

func (Metadata) Title added in v0.0.11

func (m Metadata) Title() string

Directories

Path Synopsis
experiments
internal

Jump to

Keyboard shortcuts

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