base

package
v0.0.0-...-3c75e53 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Root               = libweb.Root
	ProviderCollection = "providers"
	ProvidersRoot      = Root + "/" + ProviderCollection
	NsParam            = libweb.NsParam
	ProviderParam      = "provider"
	DetailParam        = "detail"
	NameParam          = "name"
)

Root - all routes.

Variables

View Source
var Settings = &settings.Settings

Application settings.

Functions

This section is empty.

Types

type Client

type Client interface {
	// Finder
	Finder() Finder
	// Get a resource.
	// The `resource` must be a pointer to a resource object.
	// Returns:
	//   ProviderNotSupportedErr
	//   ProviderNotReadyErr
	//   NotFoundErr
	Get(resource interface{}, id string) error
	// List a collection.
	// The `list` must be a pointer to a slice of resource object.
	// Returns:
	//   ProviderNotSupportedErr
	//   ProviderNotReadyErr
	//   NotFoundErr
	List(list interface{}, param ...Param) error
	// Get a resource by ref.
	// Returns:
	//   ProviderNotSupportedErr
	//   ProviderNotReadyErr
	//   NotFoundErr
	//   RefNotUniqueErr
	Find(resource interface{}, ref Ref) error
	// Find a VM by ref.
	// Returns the matching resource and:
	//   ProviderNotSupportedErr
	//   ProviderNotReadyErr
	//   NotFoundErr
	//   RefNotUniqueErr
	VM(ref *Ref) (interface{}, error)
	// Find a Network by ref.
	// Returns the matching resource and:
	//   ProviderNotSupportedErr
	//   ProviderNotReadyErr
	//   NotFoundErr
	//   RefNotUniqueErr
	Network(ref *Ref) (interface{}, error)
	// Find storage by ref.
	// Returns the matching resource and:
	//   ProviderNotSupportedErr
	//   ProviderNotReadyErr
	//   NotFoundErr
	//   RefNotUniqueErr
	Storage(ref *Ref) (interface{}, error)
	// Find host by ref.
	// Returns the matching resource and:
	//   ProviderNotSupportedErr
	//   ProviderNotReadyErr
	//   NotFoundErr
	//   RefNotUniqueErr
	Host(ref *Ref) (interface{}, error)
}

REST Client.

type Finder

type Finder interface {
	// Finder with client.
	With(client Client) Finder
	// Find a resource by ref.
	// Returns:
	//   ProviderNotSupportedErr
	//   ProviderNotReadyErr
	//   NotFoundErr
	//   RefNotUniqueErr
	ByRef(resource interface{}, ref Ref) error
	// Find a VM by ref.
	// Returns the matching resource and:
	//   ProviderNotSupportedErr
	//   ProviderNotReadyErr
	//   NotFoundErr
	//   RefNotUniqueErr
	VM(ref *Ref) (interface{}, error)
	// Find a Network by ref.
	// Returns the matching resource and:
	//   ProviderNotSupportedErr
	//   ProviderNotReadyErr
	//   NotFoundErr
	//   RefNotUniqueErr
	Network(ref *Ref) (interface{}, error)
	// Find storage by ref.
	// Returns the matching resource and:
	//   ProviderNotSupportedErr
	//   ProviderNotReadyErr
	//   NotFoundErr
	//   RefNotUniqueErr
	Storage(ref *Ref) (interface{}, error)
	// Find host by ref.
	// Returns the matching resource and:
	//   ProviderNotSupportedErr
	//   ProviderNotReadyErr
	//   NotFoundErr
	//   RefNotUniqueErr
	Host(ref *Ref) (interface{}, error)
}

Resource Finder.

type Handler

type Handler struct {
	libweb.Consistent
	libweb.Paged
	// Container
	Container *libcontainer.Container
	// Provider referenced in the request.
	Provider *api.Provider
	// Reconciler responsible for the provider.
	Reconciler libcontainer.Reconciler
	// Resources include details.
	Detail bool
}

Base handler.

func (h *Handler) Link(path string, params Params) string

Build link.

func (*Handler) Prepare

func (h *Handler) Prepare(ctx *gin.Context) int

Prepare to handle the request.

type NotFoundError

type NotFoundError struct {
	Ref
}

Resource not found.

func (NotFoundError) Error

func (r NotFoundError) Error() string

type Param

type Param struct {
	Key   string
	Value string
}

Web parameter.

type Params

type Params = map[string]string

Params

type Ref

type Ref = ref.Ref

Reference.

type RefNotUniqueError

type RefNotUniqueError struct {
	Ref
}

Reference matches multiple resources.

func (RefNotUniqueError) Error

func (r RefNotUniqueError) Error() string

type Resolver

type Resolver interface {
	// Find the API path for the specified resource.
	Path(resource interface{}, id string) (string, error)
}

Resolves resources to API paths.

type ResourceNotResolvedError

type ResourceNotResolvedError struct {
	Object interface{}
}

Resource kind cannot be resolved.

func (ResourceNotResolvedError) Error

func (r ResourceNotResolvedError) Error() string

type RestClient

type RestClient struct {
	Resolver
	// Bearer token.
	Token string
	// Host <host>:<port>
	Host string
	// Parameters
	Params Params
	// contains filtered or unexported fields
}

REST API client.

func (*RestClient) Get

func (c *RestClient) Get(resource interface{}, id string) (status int, err error)

Get a resource.

func (*RestClient) List

func (c *RestClient) List(list interface{}, param ...Param) (status int, err error)

List resources in a collection.

Jump to

Keyboard shortcuts

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