base

package
v0.0.0-...-9ec3720 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2021 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClientFacade

func NewClientFacade(caller APICallCloser, facadeName string) (ClientFacade, FacadeCaller)

NewClientFacade prepares a client-facing facade for work against the API. It is expected that most client-facing facades will embed a ClientFacade and will use a FacadeCaller so this function returns both.

Types

type APICallCloser

type APICallCloser interface {
	APICaller

	// Close is used when we have finished with this connection.
	Close() error
}

APICallCloser is the same as APICaller, but also provides a Close() method for when we are done with this connection.

type APICaller

type APICaller interface {
	// APICall makes a call to the API server with the given object type,
	// id, request and parameters. The response is filled in with the
	// call's result if the call is successful.
	APICall(objType string, version int, id, request string, params, response interface{}) error

	// BestFacadeVersion returns the newest version of 'objType' that this
	// client can use with the current API server.
	BestFacadeVersion(facade string) int

	// ModelTag returns the tag of the model the client is connected
	// to if there is one. It returns false for a controller-only connection.
	ModelTag() (names.ModelTag, bool)

	// HTTPClient returns an httprequest.Client that can be used
	// to make HTTP requests to the API. URLs passed to the client
	// will be made relative to the API host and the current model.
	//
	// Note that the URLs in HTTP requests passed to the Client.Do
	// method should not include a host part.
	HTTPClient() (*httprequest.Client, error)

	// BakeryClient returns the bakery client for this connection.
	BakeryClient() MacaroonDischarger

	// Context returns the standard context for this connection.
	Context() context.Context

	StreamConnector
	ControllerStreamConnector
}

APICaller is implemented by the client-facing State object. It defines the lowest level of API calls and is used by the various API implementations to actually make the calls to the API. It should not be used outside of tests or the api/* hierarchy.

type ClientFacade

type ClientFacade interface {
	// BestAPIVersion returns the API version that we were able to
	// determine is supported by both the client and the API Server
	BestAPIVersion() int

	// Close the connection to the API server.
	Close() error
}

ClientFacade should be embedded by client-side facades that are intended as "client" (aka user facing) facades versus agent facing facades. They provide two common methods for writing the client side code. BestAPIVersion() is used to allow for compatibility testing, and Close() is used to indicate when we are done with the connection.

type ControllerStreamConnector

type ControllerStreamConnector interface {
	// ConnectControllerStream connects to the given HTTP websocket
	// endpoint path and returns the resulting connection. The given
	// values are used as URL query values when making the initial
	// HTTP request. Headers passed in will be added to the HTTP
	// request.
	//
	// The path must be absolute and can't start with "/model".
	ConnectControllerStream(path string, attrs url.Values, headers http.Header) (Stream, error)
}

ControllerStreamConnector is implemented by the client-facing State object.

type EntityCount

type EntityCount struct {
	Entity string
	Count  int64
}

EntityCount holds a count for a particular entity, for example machines or core count.

type FacadeCaller

type FacadeCaller interface {
	// FacadeCall will place a request against the API using the requested
	// Facade and the best version that the API server supports that is
	// also known to the client.
	FacadeCall(request string, params, response interface{}) error

	// Name returns the facade name.
	Name() string

	// BestAPIVersion returns the API version that we were able to
	// determine is supported by both the client and the API Server
	BestAPIVersion() int

	// RawAPICaller returns the wrapped APICaller. This can be used if you need
	// to switch what Facade you are calling (such as Facades that return
	// Watchers and then need to use the Watcher facade)
	RawAPICaller() APICaller
}

FacadeCaller is a wrapper for the common paradigm that a given client just wants to make calls on a facade using the best known version of the API. And without dealing with an id parameter.

func NewFacadeCaller

func NewFacadeCaller(caller APICaller, facadeName string) FacadeCaller

NewFacadeCaller wraps an APICaller for a given facade name and the best available version.

func NewFacadeCallerForVersion

func NewFacadeCallerForVersion(caller APICaller, facadeName string, version int) FacadeCaller

NewFacadeCallerForVersion wraps an APICaller for a given facade name and version.

type Filesystem

type Filesystem struct {
	Id         string
	ProviderId string
	Status     string
	Message    string
	Detachable bool
}

Filesystem holds information about a filesystem in a juju model.

type MacaroonDischarger

type MacaroonDischarger interface {
	// DischargeAll attempts to acquire discharge macaroons for all the
	// third party caveats in m, and returns a slice containing all
	// of them bound to m.
	DischargeAll(ctx context.Context, m *bakery.Macaroon) (macaroon.Slice, error)
}

MacaroonDischarger instances provide a method to discharge macaroons.

type Machine

type Machine struct {
	Id          string
	InstanceId  string
	DisplayName string
	HasVote     bool
	WantsVote   bool
	Status      string
	Message     string
	Hardware    *instance.HardwareCharacteristics
	// HAPrimary indicates whether this machine has a primary mongo instance in replicaset and,
	// thus, can be considered a primary controller machine in HA setup.
	HAPrimary *bool
}

Machine holds information about a machine in a juju model.

type MigrationSummary

type MigrationSummary struct {
	Status    string
	StartTime *time.Time
	EndTime   *time.Time
}

MigrationSummary holds information about a current migration attempt if there is one on progress.

type ModelInfo

type ModelInfo struct {
	Name            string
	UUID            string
	Type            model.ModelType
	ControllerUUID  string
	IsController    bool
	ProviderType    string
	DefaultSeries   string
	Cloud           string
	CloudRegion     string
	CloudCredential string
	Owner           string
	Life            life.Value
	Status          Status
	Users           []UserInfo
	Machines        []Machine
	AgentVersion    *version.Number
}

ModelInfo holds information about a model.

type ModelStatus

type ModelStatus struct {
	UUID               string
	Life               life.Value
	ModelType          model.ModelType
	Owner              string
	TotalMachineCount  int
	CoreCount          int
	HostedMachineCount int
	ApplicationCount   int
	UnitCount          int
	Machines           []Machine
	Volumes            []Volume
	Filesystems        []Filesystem
	Error              error
}

ModelStatus holds information about the status of a juju model.

type SLASummary

type SLASummary struct {
	Level string
	Owner string
}

SLASummary holds information about SLA.

type Status

type Status struct {
	Status status.Status
	Info   string
	Data   map[string]interface{}
	Since  *time.Time
}

Status represents the status of a machine, application, or unit.

type StoredCredential

type StoredCredential struct {
	// CloudCredential is a cloud credential id that identifies cloud credential on the controller.
	// The value is what CloudCredentialTag.Id() returns.
	CloudCredential string

	// Valid is a flag that indicates whether the credential is valid.
	Valid bool
}

StoredCredential contains information about the cloud credential stored on the controller and used by models.

type Stream

type Stream interface {
	io.Closer

	// NextReader is used to get direct access to the underlying Read methods
	// on the websocket. Mostly just to read the initial error resonse.
	NextReader() (messageType int, r io.Reader, err error)

	// WriteJSON encodes the given value as JSON
	// and writes it to the connection.
	WriteJSON(v interface{}) error

	// ReadJSON reads a JSON value from the stream
	// and decodes it into the element pointed to by
	// the given value, which should be a pointer.
	ReadJSON(v interface{}) error
}

Stream represents a streaming connection to the API.

type StreamConnector

type StreamConnector interface {
	// ConnectStream connects to the given HTTP websocket
	// endpoint path (interpreted relative to the receiver's
	// model) and returns the resulting connection.
	// The given parameters are used as URL query values
	// when making the initial HTTP request.
	//
	// The path must start with a "/".
	ConnectStream(path string, attrs url.Values) (Stream, error)
}

StreamConnector is implemented by the client-facing State object.

type UserInfo

type UserInfo struct {
	UserName       string
	DisplayName    string
	LastConnection *time.Time
	Access         string
}

UserInfo holds information about a user in a juju model.

type UserModel

type UserModel struct {
	Name           string
	UUID           string
	Type           model.ModelType
	Owner          string
	LastConnection *time.Time
}

UserModel holds information about a model and the last time the model was accessed for a particular user. This is a client side structure that translates the owner tag into a user facing string.

type UserModelSummary

type UserModelSummary struct {
	Name               string
	UUID               string
	Type               model.ModelType
	ControllerUUID     string
	IsController       bool
	ProviderType       string
	DefaultSeries      string
	Cloud              string
	CloudRegion        string
	CloudCredential    string
	Owner              string
	Life               life.Value
	Status             Status
	ModelUserAccess    string
	UserLastConnection *time.Time
	Counts             []EntityCount
	AgentVersion       *version.Number
	Error              error
	Migration          *MigrationSummary
	SLA                *SLASummary
}

UserModelSummary holds summary about a model for a user.

type Volume

type Volume struct {
	Id         string
	ProviderId string
	Status     string
	Message    string
	Detachable bool
}

Volume holds information about a volume in a juju model.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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