juju: github.com/juju/juju/api Index | Files | Directories

package api

import "github.com/juju/juju/api"

Index

Package Files

allwatcher.go apiclient.go certpool.go client.go facadeversions.go http.go interface.go monitor.go state.go

Constants

const PingPeriod = 1 * time.Minute

PingPeriod defines how often the internal connection health check will run.

func CreateCertPool Uses

func CreateCertPool(caCert string) (*x509.CertPool, error)

CreateCertPool creates a new x509.CertPool and adds in the caCert passed in. All certs from the cert directory (/etc/juju/cert.d on ubuntu) are also added.

func NewCharmDownloader Uses

func NewCharmDownloader(client *Client) *downloader.Downloader

NewCharmDownloader returns a new charm downloader that wraps the provided API client.

type AllWatcher Uses

type AllWatcher struct {
    // contains filtered or unexported fields
}

AllWatcher holds information allowing us to get Deltas describing changes to the entire model or all models (depending on the watcher type).

func NewAllModelWatcher Uses

func NewAllModelWatcher(caller base.APICaller, id *string) *AllWatcher

NewAllModelWatcher returns an AllWatcher instance which interacts with a watcher created by the WatchAllModels API call.

There should be no need to call this from outside of the api package. It is only used by Client.WatchAllModels in api/controller.

func NewAllWatcher Uses

func NewAllWatcher(caller base.APICaller, id *string) *AllWatcher

NewAllWatcher returns an AllWatcher instance which interacts with a watcher created by the WatchAll API call.

There should be no need to call this from outside of the api package. It is only used by Client.WatchAll in this package.

func (*AllWatcher) Next Uses

func (watcher *AllWatcher) Next() ([]multiwatcher.Delta, error)

Next returns a new set of deltas from a watcher previously created by the WatchAll or WatchAllModels API calls. It will block until there are deltas to return.

func (*AllWatcher) Stop Uses

func (watcher *AllWatcher) Stop() error

Stop shutdowns down a watcher previously created by the WatchAll or WatchAllModels API calls

type Client Uses

type Client struct {
    base.ClientFacade
    // contains filtered or unexported fields
}

Client represents the client-accessible part of the state.

func (*Client) APIHostPorts Uses

func (c *Client) APIHostPorts() ([][]network.HostPort, error)

APIHostPorts returns a slice of network.HostPort for each API server.

func (*Client) AbortCurrentUpgrade Uses

func (c *Client) AbortCurrentUpgrade() error

AbortCurrentUpgrade aborts and archives the current upgrade synchronisation record, if any.

func (*Client) AddCharm Uses

func (c *Client) AddCharm(curl *charm.URL, channel csparams.Channel) error

AddCharm adds the given charm URL (which must include revision) to the model, if it does not exist yet. Local charms are not supported, only charm store URLs. See also AddLocalCharm() in the client-side API.

If the AddCharm API call fails because of an authorization error when retrieving the charm from the charm store, an error satisfying params.IsCodeUnauthorized will be returned.

func (*Client) AddCharmWithAuthorization Uses

func (c *Client) AddCharmWithAuthorization(curl *charm.URL, channel csparams.Channel, csMac *macaroon.Macaroon) error

AddCharmWithAuthorization is like AddCharm except it also provides the given charmstore macaroon for the juju server to use when obtaining the charm from the charm store. The macaroon is conventionally obtained from the /delegatable-macaroon endpoint in the charm store.

If the AddCharmWithAuthorization API call fails because of an authorization error when retrieving the charm from the charm store, an error satisfying params.IsCodeUnauthorized will be returned.

func (*Client) AddLocalCharm Uses

func (c *Client) AddLocalCharm(curl *charm.URL, ch charm.Charm) (*charm.URL, error)

AddLocalCharm prepares the given charm with a local: schema in its URL, and uploads it via the API server, returning the assigned charm URL.

func (*Client) AddMachines Uses

func (c *Client) AddMachines(machineParams []params.AddMachineParams) ([]params.AddMachinesResult, error)

AddMachines adds new machines with the supplied parameters.

func (*Client) AgentVersion Uses

func (c *Client) AgentVersion() (version.Number, error)

AgentVersion reports the version number of the api server.

func (*Client) CACert Uses

func (c *Client) CACert() (string, error)

CACert returns the CA certificate associated with the connection.

func (*Client) Close Uses

func (c *Client) Close() error

Close closes the Client's underlying State connection Client is unique among the api.State facades in closing its own State connection, but it is conventional to use a Client object without any access to its underlying state connection.

func (*Client) DestroyMachines Uses

func (c *Client) DestroyMachines(machines ...string) error

DestroyMachines removes a given set of machines.

NOTE(axw) this exists only for backwards compatibility, when MachineManager facade v3 is not available. The MachineManager.DestroyMachines method should be preferred.

TODO(axw) 2017-03-16 #1673323 Drop this in Juju 3.0.

func (*Client) DestroyMachinesWithParams Uses

func (c *Client) DestroyMachinesWithParams(force, keep bool, machines ...string) error

DestroyMachinesWithParams removes a given set of machines and all associated units.

NOTE(wallyworld) this exists only for backwards compatibility, when MachineManager facade v4 is not available. The MachineManager.DestroyMachinesWithParams method should be preferred.

TODO(wallyworld) 2017-03-16 #1673323 Drop this in Juju 3.0.

func (*Client) FindTools Uses

func (c *Client) FindTools(majorVersion, minorVersion int, series, arch string) (result params.FindToolsResult, err error)

FindTools returns a List containing all tools matching the specified parameters.

func (*Client) ForceDestroyMachines Uses

func (c *Client) ForceDestroyMachines(machines ...string) error

ForceDestroyMachines removes a given set of machines and all associated units.

NOTE(axw) this exists only for backwards compatibility, when MachineManager facade v3 is not available. The MachineManager.ForceDestroyMachines method should be preferred.

TODO(axw) 2017-03-16 #1673323 Drop this in Juju 3.0.

func (*Client) GetModelConstraints Uses

func (c *Client) GetModelConstraints() (constraints.Value, error)

GetModelConstraints returns the constraints for the model.

func (*Client) ModelUUID Uses

func (c *Client) ModelUUID() (string, bool)

ModelUUID returns the model UUID from the client connection and reports whether it is valud.

func (*Client) ModelUserInfo Uses

func (c *Client) ModelUserInfo() ([]params.ModelUserInfo, error)

ModelUserInfo returns information on all users in the model.

func (*Client) OpenCharm Uses

func (c *Client) OpenCharm(curl *charm.URL) (io.ReadCloser, error)

OpenCharm streams out the identified charm from the controller via the API.

func (*Client) OpenURI Uses

func (c *Client) OpenURI(uri string, query url.Values) (io.ReadCloser, error)

OpenURI performs a GET on a Juju HTTP endpoint returning the

func (*Client) PrivateAddress Uses

func (c *Client) PrivateAddress(target string) (string, error)

PrivateAddress returns the private address of the specified machine or unit.

func (*Client) ProvisioningScript Uses

func (c *Client) ProvisioningScript(args params.ProvisioningScriptParams) (script string, err error)

ProvisioningScript returns a shell script that, when run, provisions a machine agent on the machine executing the script.

func (*Client) PublicAddress Uses

func (c *Client) PublicAddress(target string) (string, error)

PublicAddress returns the public address of the specified machine or unit. For a machine, target is an id not a tag.

func (*Client) ResolveCharm Uses

func (c *Client) ResolveCharm(ref *charm.URL) (*charm.URL, error)

ResolveCharm resolves the best available charm URLs with series, for charm locations without a series specified.

func (*Client) Resolved Uses

func (c *Client) Resolved(unit string, retry bool) error

Resolved clears errors on a unit.

func (*Client) RetryProvisioning Uses

func (c *Client) RetryProvisioning(machines ...names.MachineTag) ([]params.ErrorResult, error)

RetryProvisioning updates the provisioning status of a machine allowing the provisioner to retry.

func (*Client) SetModelAgentVersion Uses

func (c *Client) SetModelAgentVersion(version version.Number) error

SetModelAgentVersion sets the model agent-version setting to the given value.

func (*Client) SetModelConstraints Uses

func (c *Client) SetModelConstraints(constraints constraints.Value) error

SetModelConstraints specifies the constraints for the model.

func (*Client) Status Uses

func (c *Client) Status(patterns []string) (*params.FullStatus, error)

Status returns the status of the juju model.

func (*Client) StatusHistory Uses

func (c *Client) StatusHistory(kind status.HistoryKind, tag names.Tag, filter status.StatusHistoryFilter) (status.History, error)

StatusHistory retrieves the last <size> results of <kind:combined|agent|workload|machine|machineinstance|container|containerinstance> status for <name> unit

func (*Client) UploadCharm Uses

func (c *Client) UploadCharm(curl *charm.URL, content io.ReadSeeker) (*charm.URL, error)

UploadCharm sends the content to the API server using an HTTP post.

func (*Client) UploadTools Uses

func (c *Client) UploadTools(r io.ReadSeeker, vers version.Binary, additionalSeries ...string) (tools.List, error)

UploadTools uploads tools at the specified location to the API server over HTTPS.

func (*Client) WatchAll Uses

func (c *Client) WatchAll() (*AllWatcher, error)

WatchAll returns an AllWatcher, from which you can request the Next collection of Deltas.

func (*Client) WatchDebugLog Uses

func (c *Client) WatchDebugLog(args common.DebugLogParams) (<-chan common.LogMessage, error)

WatchDebugLog returns a channel of structured Log Messages. Only log entries that match the filtering specified in the DebugLogParams are returned.

type Connection Uses

type Connection interface {

    // Close closes the connection.
    Close() error

    // Addr returns the address used to connect to the API server.
    Addr() string

    // IPAddr returns the IP address used to connect to the API server.
    IPAddr() string

    // APIHostPorts returns addresses that may be used to connect
    // to the API server, including the address used to connect.
    //
    // The addresses are scoped (public, cloud-internal, etc.), so
    // the client may choose which addresses to attempt. For the
    // Juju CLI, all addresses must be attempted, as the CLI may
    // be invoked both within and outside the model (think
    // private clouds).
    APIHostPorts() [][]network.HostPort

    // Broken returns a channel which will be closed if the connection
    // is detected to be broken, either because the underlying
    // connection has closed or because API pings have failed.
    Broken() <-chan struct{}

    // IsBroken returns whether the connection is broken. It checks
    // the Broken channel and if that is open, attempts a connection
    // ping.
    IsBroken() bool

    // PublicDNSName returns the host name for which an officially
    // signed certificate will be used for TLS connection to the server.
    // If empty, the private Juju CA certificate must be used to verify
    // the connection.
    PublicDNSName() string

    // These are a bit off -- ServerVersion is apparently not known until after
    // Login()? Maybe evidence of need for a separate AuthenticatedConnection..?
    Login(name names.Tag, password, nonce string, ms []macaroon.Slice) error
    ServerVersion() (version.Number, bool)

    // APICaller provides the facility to make API calls directly.
    // This should not be used outside the api/* packages or tests.
    base.APICaller

    // ControllerTag returns the tag of the controller.
    // This could be defined on base.APICaller.
    ControllerTag() names.ControllerTag

    // Ping makes an API request which checks if the connection is
    // still functioning.
    // NOTE: This method is deprecated. Please use IsBroken or Broken instead.
    Ping() error

    // I think this is actually dead code. It's tested, at least, so I'm
    // keeping it for now, but it's not apparently used anywhere else.
    AllFacadeVersions() map[string][]int

    // AuthTag returns the tag of the authorized user of the state API
    // connection.
    AuthTag() names.Tag

    // ModelAccess returns the access level of authorized user to the model.
    ModelAccess() string

    // ControllerAccess returns the access level of authorized user to the controller.
    ControllerAccess() string

    // CookieURL returns the URL that HTTP cookies for the API will be
    // associated with.
    CookieURL() *url.URL

    // These methods expose a bunch of worker-specific facades, and basically
    // just should not exist; but removing them is too noisy for a single CL.
    // Client in particular is intimately coupled with State -- and the others
    // will be easy to remove, but until we're using them via manifolds it's
    // prohibitively ugly to do so.
    Client() *Client
    Uniter() (*uniter.State, error)
    Upgrader() *upgrader.State
    Reboot() (reboot.State, error)
    InstancePoller() *instancepoller.API
    CharmRevisionUpdater() *charmrevisionupdater.State
    Cleaner() *cleaner.API
    MetadataUpdater() *imagemetadata.Client
    UnitAssigner() unitassigner.API
}

Connection represents a connection to a Juju API server.

func Open Uses

func Open(info *Info, opts DialOpts) (Connection, error)

Open establishes a connection to the API server using the Info given, returning a State instance which can be used to make API requests.

If the model is hosted on a different server, Open will return an error with a *RedirectError cause holding the details of another server to connect to.

See Connect for details of the connection mechanics.

type DNSCache Uses

type DNSCache interface {
    // Lookup returns the IP addresses associated
    // with the given host.
    Lookup(host string) []string
    // Add sets the IP addresses associated with
    // the given host name.
    Add(host string, ips []string)
}

DNSCache implements a cache of DNS lookup results.

type DialOpts Uses

type DialOpts struct {
    // DialAddressInterval is the amount of time to wait
    // before starting to dial another address.
    DialAddressInterval time.Duration

    // DialTimeout is the amount of time to wait for the dial
    // portion only of the api.Open to succeed. If this is zero,
    // there is no dial timeout.
    DialTimeout time.Duration

    // Timeout is the amount of time to wait for the entire
    // api.Open to succeed. If this is zero, there is no timeout.
    Timeout time.Duration

    // RetryDelay is the amount of time to wait between
    // unsuccessful connection attempts. If this is
    // zero, only one attempt will be made.
    RetryDelay time.Duration

    // BakeryClient is the httpbakery Client, which
    // is used to do the macaroon-based authorization.
    // This and the *http.Client inside it are copied
    // by Open, and any RoundTripper field
    // the HTTP client is ignored.
    BakeryClient *httpbakery.Client

    // InsecureSkipVerify skips TLS certificate verification
    // when connecting to the controller. This should only
    // be used in tests, or when verification cannot be
    // performed and the communication need not be secure.
    InsecureSkipVerify bool

    // DialWebsocket is used to make connections to API servers.
    // It will be called with a websocket URL to connect to,
    // and the TLS configuration to use to secure the connection.
    // If ipAddr is non-empty, the actual net.Dial should use
    // that IP address, regardless of the URL host.
    //
    // If DialWebsocket is nil, a default implementation using
    // gorilla websockets will be used.
    DialWebsocket func(ctx context.Context, urlStr string, tlsConfig *tls.Config, ipAddr string) (jsoncodec.JSONConn, error)

    // IPAddrResolver is used to resolve host names to IP addresses.
    // If it is nil, net.DefaultResolver will be used.
    IPAddrResolver IPAddrResolver

    // DNSCache is consulted to find and store cached DNS lookups.
    // If it is nil, no cache will be used or updated.
    DNSCache DNSCache

    // Clock is used as a time source for retries.
    // If it is nil, clock.WallClock will be used.
    Clock clock.Clock
}

DialOpts holds configuration parameters that control the Dialing behavior when connecting to a controller.

func DefaultDialOpts Uses

func DefaultDialOpts() DialOpts

DefaultDialOpts returns a DialOpts representing the default parameters for contacting a controller.

type HTTPDoer Uses

type HTTPDoer interface {
    // Do sends the given request.
    Do(req *http.Request, body io.ReadSeeker, resp interface{}) error
}

HTTPDoer exposes the functionality of httprequest.Client needed here.

type IPAddrResolver Uses

type IPAddrResolver interface {
    LookupIPAddr(ctx context.Context, host string) ([]net.IPAddr, error)
}

IPAddrResolver implements a resolved from host name to the set of IP addresses associated with it. It is notably implemented by net.Resolver.

type Info Uses

type Info struct {

    // Addrs holds the addresses of the controllers.
    Addrs []string

    // SNIHostName optionally holds the host name to use for
    // server name indication (SNI) when connecting
    // to the addresses in Addrs above. If CACert is non-empty,
    // this field is ignored.
    SNIHostName string

    // CACert holds the CA certificate that will be used
    // to validate the controller's certificate, in PEM format.
    // If this is empty, the standard system root certificates
    // will be used.
    CACert string

    // ModelTag holds the model tag for the model we are
    // trying to connect to. If this is empty, a controller-only
    // login will be made.
    ModelTag names.ModelTag

    // SkipLogin, if true, skips the Login call on connection. It is an
    // error to set Tag, Password, or Macaroons if SkipLogin is true.
    SkipLogin bool `yaml:"-"`

    // Tag holds the name of the entity that is connecting.
    // If this is nil, and the password is empty, macaroon authentication
    // will be used to log in unless SkipLogin is true.
    Tag names.Tag

    // Password holds the password for the administrator or connecting entity.
    Password string

    // Macaroons holds a slice of macaroon.Slice that may be used to
    // authenticate with the API server.
    Macaroons []macaroon.Slice `yaml:",omitempty"`

    // Nonce holds the nonce used when provisioning the machine. Used
    // only by the machine agent.
    Nonce string `yaml:",omitempty"`
}

Info encapsulates information about a server holding juju state and can be used to make a connection to it.

func (*Info) Ports Uses

func (info *Info) Ports() []int

Ports returns the unique ports for the api addresses.

func (*Info) Validate Uses

func (info *Info) Validate() error

Validate validates the API info.

type OpenFunc Uses

type OpenFunc func(*Info, DialOpts) (Connection, error)

OpenFunc is the usual form of a function that opens an API connection.

type RedirectError Uses

type RedirectError struct {
    // Servers holds the sets of addresses of the redirected
    // servers.
    Servers [][]network.HostPort

    // CACert holds the certificate of the remote server.
    CACert string
}

RedirectError is returned from Open when the controller needs to inform the client that the model is hosted on a different set of API addresses.

func (*RedirectError) Error Uses

func (e *RedirectError) Error() string

Directories

PathSynopsis
action
agent
agenttools
annotations
applicationPackage application provides access to the application api facade.
applicationoffers
applicationscaler
authentication
backups
base
base/testing
block
charmrevisionupdater
charmscharms provides a client for accessing the charms API.
cleaner
cloud
common
common/cloudspec
common/stream
controller
crossmodelrelations
deployer
diskmanager
firewaller
firewallrules
highavailability
hostkeyreporterPackage hostkeyreporter implements the client-side API facade used by the hostkeyreporter worker.
http
imagemanager
imagemetadata
imagemetadatamanager
instancepoller
keymanager
keyupdater
leadershipPackage leadership implements the client to the analog leadership service.
lifeflag
logfwd
logger
logsenderPackage logsender implements the API for storing log messages on the API server.
logstream
machineactionsmachineactions implements the the api side of running actions on machines
machinemanager
machiner
machineundertaker
meterstatusPackage meterstatus contains an implementation of the api facade to watch the meter status of a unit for changes and return the current meter status.
metricsadderPackage metricsadder contains an implementation of the api facade to add metrics to the state.
metricsdebugThe metricsdebug package contains the implementation of a client to access metrics debug functions within state.
metricsmanagerThe metricsmanager package contains implementation for an api facade to access metrics functions within state
migrationflag
migrationmaster
migrationminion
migrationtargetPackage migrationtarget defines the client side API facade for use by the migration master worker when communicating with the target controller.
modelconfig
modelmanager
modelupgrader
provisioner
proxyupdater
pubsubPackage pubsub implements the API for streaming pubsub messages between api servers.
reboot
remoterelations
resumer
retrystrategy
singular
spaces
sshclient
statushistory
storage
storageprovisioner
subnets
testing
undertaker
unitassigner
uniter
upgrader
usermanager
watcher

Package api imports 63 packages (graph) and is imported by 1009 packages. Updated 2017-09-25. Refresh now. Tools for package owners.