api

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: Apache-2.0 Imports: 16 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"
	RelationUp        = "up"

	RelationExperiments     = "https://stormforge.io/rel/experiments"
	RelationLabels          = "https://stormforge.io/rel/labels"
	RelationNextTrial       = "https://stormforge.io/rel/next-trial"
	RelationRecommendations = "https://stormforge.io/rel/recommendations"
	RelationScenarios       = "https://stormforge.io/rel/scenarios"
	RelationTemplate        = "https://stormforge.io/rel/template"
	RelationTrials          = "https://stormforge.io/rel/trials"
)

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.

func UnmarshalMetadata added in v0.0.15

func UnmarshalMetadata(resp *http.Response, md *Metadata)

Types

type Client

type Client interface {
	// URL returns the location of the specified endpoint.
	URL(endpoint string) *url.URL
	// Do sends an HTTP request and returns the buffered body contents.
	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 Duration added in v0.0.25

type Duration time.Duration

Duration is an alternate duration type that marshals as a JSON string.

func (Duration) MarshalJSON added in v0.0.25

func (d Duration) MarshalJSON() ([]byte, error)

MarshalJSON produces a string formatted duration.

func (Duration) String added in v0.0.25

func (d Duration) String() string

String returns the string representation of the duration.

func (*Duration) UnmarshalJSON added in v0.0.25

func (d *Duration) UnmarshalJSON(bytes []byte) error

UnmarshalJSON handles the string formatted duration.

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) AppendToURL added in v0.0.15

func (q *IndexQuery) AppendToURL(u string) (string, error)

AppendToURL adds this index query to an existing URL.

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

type NumberOrString added in v0.0.15

type NumberOrString struct {
	IsString bool
	NumVal   json.Number
	StrVal   string
}

NumberOrString is value that can be a JSON number or string.

func FromFloat64 added in v0.0.15

func FromFloat64(val float64) NumberOrString

FromFloat64 returns the supplied value as a NumberOrString

func FromInt64 added in v0.0.15

func FromInt64(val int64) NumberOrString

FromInt64 returns the supplied value as a NumberOrString

func FromNumber added in v0.0.15

func FromNumber(val json.Number) NumberOrString

FromNumber returns the supplied value as a NumberOrString

func FromString added in v0.0.15

func FromString(val string) NumberOrString

FromString returns the supplied value as a NumberOrString

func FromValue added in v0.1.7

func FromValue(val string) NumberOrString

FromValue returns the supplied value as a NumberOrString based on an attempt to parse the supplied value as an int or float.

func (*NumberOrString) Float64Value added in v0.0.15

func (s *NumberOrString) Float64Value() float64

Float64Value coerces the value to a float64.

func (*NumberOrString) Int64Value added in v0.0.15

func (s *NumberOrString) Int64Value() int64

Int64Value coerces the value to an int64.

func (NumberOrString) MarshalJSON added in v0.0.15

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

MarshalJSON writes the value with the appropriate type.

func (*NumberOrString) Quantity added in v0.1.7

func (s *NumberOrString) Quantity() *big.Float

Quantity attempts to return a big float using the same logic as a Kubernetes quantity. If parsing fails, this will return nil.

func (*NumberOrString) String added in v0.0.15

func (s *NumberOrString) String() string

String coerces the value to a string.

func (*NumberOrString) UnmarshalJSON added in v0.0.15

func (s *NumberOrString) UnmarshalJSON(b []byte) error

UnmarshalJSON reads the value from either a string or number.

Directories

Path Synopsis
applications
v2
experiments
internal

Jump to

Keyboard shortcuts

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