gs

package
v0.7.7 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: Apache-2.0 Imports: 13 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// StateTypeError is used for states of type error
	StateTypeError = 0
	// StateTypeOK is used for states of type OK
	StateTypeOK = 1
	// StateTypePending is used for states of type Pending
	StateTypePending = 2
)

State types defined for GS resources by the Engine

Variables

View Source
var (
	// ErrStateError is returned if a resource could not be provisioned (state "Error")
	ErrStateError = errors.New("resource is in an error state")

	// ErrStateUnknown is returned if a resource has an unknown state
	ErrStateUnknown = errors.New("resource is in an unknown state")
)

Functions

func AwaitCompletion

func AwaitCompletion(ctx context.Context, a types.API, o objectWithStateRetriever) error

AwaitCompletion blocks until an object is no longer pending

func EndpointURL added in v0.6.0

func EndpointURL(ctx context.Context, obj types.Object, resourcePath string) (*url.URL, error)

EndpointURL is a helper function which can be wrapped by API bindings to enable the filter helper

func RequestBody added in v0.6.0

func RequestBody(ctx context.Context, br func() interface{}) (interface{}, error)

RequestBody prevents decoding of delete responses as they are not compatible with the objects type

Types

type GenericService

type GenericService struct{}

GenericService has methods overridden for all GS objects in the same way

func (*GenericService) FilterAPIResponse

func (gs *GenericService) FilterAPIResponse(ctx context.Context, res *http.Response) (*http.Response, error)

FilterAPIResponse replaces the API response with an empty json object

type HasState

type HasState struct {
	State State `json:"state"`
}

func (HasState) StateError

func (hs HasState) StateError() bool

StateError checks if the state is marking any failure

func (HasState) StateOK

func (hs HasState) StateOK() bool

StateOK checks if the state is one of the successful ones

func (HasState) StatePending

func (hs HasState) StatePending() bool

StatePending checks if the state is marking any change currently being applied

type PartialResourceList added in v0.5.1

type PartialResourceList []common.PartialResource

PartialResourceList represents a linked resource list in GS

func (PartialResourceList) MarshalJSON added in v0.5.1

func (prl PartialResourceList) MarshalJSON() ([]byte, error)

MarshalJSON unfolds the resources to their identifier as a comma-separated string

type State

type State struct {
	// programatically usable enum value
	ID string `json:"id"`

	// human readable status text
	Text string `json:"text"`

	Type int `json:"type"`
}

State represents the state object available on GS resources

func (State) MarshalJSON

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

func (State) StateError

func (s State) StateError() bool

StateError checks if the state is marking any failure

func (State) StateOK

func (s State) StateOK() bool

StateOK checks if the state is one of the successful ones

func (State) StatePending

func (s State) StatePending() bool

StatePending checks if the state is marking any change currently being applied

type StateRetriever

type StateRetriever interface {
	StateOK() bool
	StatePending() bool
	StateError() bool
}

StateRetriever is an interface Objects can implement to provide unified state information

Jump to

Keyboard shortcuts

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