apiserver

package
v0.0.0-...-a0d7459 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2017 License: AGPL-3.0 Imports: 157 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AboutToRestoreError = errors.New("restore preparation in progress")
View Source
var MaintenanceNoLoginError = errors.New("login failed - maintenance in progress")
View Source
var RestoreInProgressError = errors.New("restore in progress")

Functions

func DescribeFacades

func DescribeFacades() []params.FacadeVersions

DescribeFacades returns the list of available Facades and their Versions

func IsMethodAllowedDuringMigration

func IsMethodAllowedDuringMigration(facadeName, methodName string) bool

func IsMethodAllowedDuringUpgrade

func IsMethodAllowedDuringUpgrade(facadeName, methodName string) bool

func NewAllWatcher

func NewAllWatcher(context facade.Context) (facade.Facade, error)

NewAllWatcher returns a new API server endpoint for interacting with a watcher created by the WatchAll and WatchAllModels API calls.

Types

type CharmsHTTPHandler

type CharmsHTTPHandler struct {
	PostHandler FailableHandlerFunc
	GetHandler  FailableHandlerFunc
}

CharmsHTTPHandler creates is a http.Handler which serves POST requests to a PostHandler and GET requests to a GetHandler.

TODO(katco): This is the beginning of inverting the dependencies in this callstack by splitting out the serving mechanism from the modules that are processing the requests. The next step is to publically expose construction of a suitable PostHandler and GetHandler whose goals should be clearly called out in their names, (e.g. charmPersitAPI for POSTs).

To accomplish this, we'll have to make the httpContext type public so that we can pass it into these public functions.

After we do this, we can then test the individual funcs/structs without standing up an entire HTTP server. I.e. actual unit tests. If you're in this area and can, please chissle away at this problem and update this TODO as needed! Many thanks, hacker!

func (*CharmsHTTPHandler) ServeHTTP

func (h *CharmsHTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type EntitiesWatcher

type EntitiesWatcher interface {
	state.StringsWatcher

	// MapChanges maps the received strings to their according tag strings.
	// The EntityFinder interface representing state or a mock has to be
	// upcasted into the needed sub-interface of state for the real mapping.
	MapChanges(in []string) ([]string, error)
}

EntitiesWatcher defines an interface based on the StringsWatcher but also providing a method for the mapping of the received strings to the tags of the according entities.

type FailableHandlerFunc

type FailableHandlerFunc func(http.ResponseWriter, *http.Request) error

type Hub

type Hub interface {
	Publish(pubsub.Topic, interface{}) (<-chan struct{}, error)
}

Hub defines the publish method that the handler uses to publish messages on the centralhub of the apiserver.

type LoggingStrategy

type LoggingStrategy interface {
	// Authenticate should check that the request identifies the kind
	// of client that is expected to be talking to this endpoint.
	Authenticate(*http.Request) error

	// Start prepares any underlying loggers before sending them
	// messages. This should only be called once.
	Start()

	// Log writes out the given record to any backing loggers for the strategy.
	Log(params.LogRecord) bool

	// Stop tells the strategy that there are no more log messages
	// coming, so it can clean up any resources it holds and close any
	// loggers. Once Stop has been called no more log messages can be
	// written.
	Stop()
}

LoggingStrategy handles the authentication and logging details for a particular logsink handler.

type LoginValidator

type LoginValidator func(params.LoginRequest) error

LoginValidator functions are used to decide whether login requests are to be allowed. The validator is called before credentials are checked.

type Pinger

type Pinger interface {
	Ping()
	Stop() error
}

pinger describes a resource that can be pinged and stopped.

func NewPinger

func NewPinger(st *state.State, resources facade.Resources, authorizer facade.Authorizer) (Pinger, error)

NewPinger returns an object that can be pinged by calling its Ping method. If this method is not called frequently enough, the connection will be dropped.

type ResourcesBackend

type ResourcesBackend interface {
	// OpenResource returns the identified resource and its content.
	OpenResource(applicationID, name string) (resource.Resource, io.ReadCloser, error)

	// GetResource returns the identified resource.
	GetResource(applicationID, name string) (resource.Resource, error)

	// GetPendingResource returns the identified resource.
	GetPendingResource(applicationID, name, pendingID string) (resource.Resource, error)

	// SetResource adds the resource to blob storage and updates the metadata.
	SetResource(applicationID, userID string, res charmresource.Resource, r io.Reader) (resource.Resource, error)

	// UpdatePendingResource adds the resource to blob storage and updates the metadata.
	UpdatePendingResource(applicationID, pendingID, userID string, res charmresource.Resource, r io.Reader) (resource.Resource, error)
}

ResourcesBackend is the functionality of Juju's state needed for the resources API.

type ResourcesHandler

type ResourcesHandler struct {
	StateAuthFunc func(*http.Request, ...string) (ResourcesBackend, func(), names.Tag, error)
}

ResourcesHandler is the HTTP handler for client downloads and uploads of resources.

func (*ResourcesHandler) ServeHTTP

func (h *ResourcesHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request)

ServeHTTP implements http.Handler.

type RestHTTPHandler

type RestHTTPHandler struct {
	GetHandler FailableHandlerFunc
}

RestHTTPHandler creates is a http.Handler which serves ReST requests.

func (*RestHTTPHandler) ServeHTTP

func (h *RestHTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP is defined on handler.Handler.

type Server

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

Server holds the server side of the API.

func NewServer

func NewServer(s *state.State, lis net.Listener, cfg ServerConfig) (*Server, error)

NewServer serves the given state by accepting requests on the given listener, using the given certificate and key (in PEM format) for authentication.

The Server will close the listener when it exits, even if returns an error.

func (*Server) ConnectionCount

func (srv *Server) ConnectionCount() int64

func (*Server) Dead

func (srv *Server) Dead() <-chan struct{}

Dead returns a channel that signals when the server has exited.

func (*Server) Kill

func (srv *Server) Kill()

Kill implements worker.Worker.Kill.

func (*Server) Stop

func (srv *Server) Stop() error

Stop stops the server and returns when all running requests have completed.

func (*Server) Wait

func (srv *Server) Wait() error

Wait implements worker.Worker.Wait.

type ServerConfig

type ServerConfig struct {
	Clock       clock.Clock
	PingClock   clock.Clock
	Cert        string
	Key         string
	Tag         names.Tag
	DataDir     string
	LogDir      string
	Validator   LoginValidator
	Hub         *pubsub.StructuredHub
	CertChanged <-chan params.StateServingInfo

	// AutocertDNSName holds the DNS name for which
	// official TLS certificates will be obtained. If this is
	// empty, no certificates will be requested.
	AutocertDNSName string

	// AutocertURL holds the URL from which official
	// TLS certificates will be obtained. By default,
	// acme.LetsEncryptURL will be used.
	AutocertURL string

	// AllowModelAccess holds whether users will be allowed to
	// access models that they have access rights to even when
	// they don't have access to the controller.
	AllowModelAccess bool

	// NewObserver is a function which will return an observer. This
	// is used per-connection to instantiate a new observer to be
	// notified of key events during API requests.
	NewObserver observer.ObserverFactory

	// StatePool is created by the machine agent and passed in.
	StatePool *state.StatePool

	// RegisterIntrospectionHandlers is a function that will
	// call a function with (path, http.Handler) tuples. This
	// is to support registering the handlers underneath the
	// "/introspection" prefix.
	RegisterIntrospectionHandlers func(func(string, http.Handler))
}

ServerConfig holds parameters required to set up an API server.

func (*ServerConfig) Validate

func (c *ServerConfig) Validate() error

type SrvAllWatcher

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

SrvAllWatcher defines the API methods on a state.Multiwatcher. which watches any changes to the state. Each client has its own current set of watchers, stored in resources. It is used by both the AllWatcher and AllModelWatcher facades.

func (*SrvAllWatcher) Next

func (*SrvAllWatcher) Stop

func (w *SrvAllWatcher) Stop() error

Stop stops the watcher.

type UnitResourcesHandler

type UnitResourcesHandler struct {
	NewOpener func(*http.Request, ...string) (resource.Opener, func(), error)
}

ResourcesHandler is the HTTP handler for unit agent downloads of resources.

func (*UnitResourcesHandler) ServeHTTP

func (h *UnitResourcesHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request)

ServeHTTP implements http.Handler.

Directories

Path Synopsis
Package application contains api calls for functionality related to deploying and managing applications and their related charms.
Package application contains api calls for functionality related to deploying and managing applications and their related charms.
Package bundle defines an API endpoint for functions dealing with bundles.
Package bundle defines an API endpoint for functions dealing with bundles.
Package cloud defines an API end point for functions dealing with the controller's cloud definition, and cloud credentials.
Package cloud defines an API end point for functions dealing with the controller's cloud definition, and cloud credentials.
storagecommon
Package storagecommon provides common storage-related services for API server facades.
Package storagecommon provides common storage-related services for API server facades.
The controller package defines an API end point for functions dealing with controllers as a whole.
The controller package defines an API end point for functions dealing with controllers as a whole.
Package crossmodel provides an API server facade for managing cross model relations.
Package crossmodel provides an API server facade for managing cross model relations.
Package hostkeyreporter implements the API facade used by the hostkeyreporter worker.
Package hostkeyreporter implements the API facade used by the hostkeyreporter worker.
Package httpattachment provides facilities for attaching a streaming blob of data and associated metadata to an HTTP API request, and for reading that blob on the server side.
Package httpattachment provides facilities for attaching a streaming blob of data and associated metadata to an HTTP API request, and for reading that blob on the server side.
The machiner package implements the API interface used by the machiner worker.
The machiner package implements the API interface used by the machiner worker.
machineactions implements the the apiserver side of running actions on machines
machineactions implements the the apiserver side of running actions on machines
Package meterstatus provides the meter status API facade.
Package meterstatus provides the meter status API facade.
Package metricsdebug contains the implementation of an api endpoint for metrics debug functionality.
Package metricsdebug contains the implementation of an api endpoint for metrics debug functionality.
Package metricsender contains functions for sending metrics from a controller to a remote metric collector.
Package metricsender contains functions for sending metrics from a controller to a remote metric collector.
Package metricsmanager contains the implementation of an api endpoint for calling metrics functions in state.
Package metricsmanager contains the implementation of an api endpoint for calling metrics functions in state.
This package defines the API facade for use by the migration master worker when communicating to it's own controller.
This package defines the API facade for use by the migration master worker when communicating to it's own controller.
Package migrationminion defines the API facade for use by the migration minion worker to monitor the progress of, and interact with, model migrations.
Package migrationminion defines the API facade for use by the migration minion worker to monitor the progress of, and interact with, model migrations.
This package defines the API facade for use by the migration master worker when interacting with the target controller during a migration.
This package defines the API facade for use by the migration master worker when interacting with the target controller during a migration.
Package modelmanager defines an API end point for functions dealing with models.
Package modelmanager defines an API end point for functions dealing with models.
metricobserver
Package metricobserver provides an implementation of apiserver/observer.ObserverFactory that maintains Prometheus metrics.
Package metricobserver provides an implementation of apiserver/observer.ObserverFactory that maintains Prometheus metrics.
The resumer package implements the API interface used by the resumer worker.
The resumer package implements the API interface used by the resumer worker.
Package sshclient implements the API endpoint required for Juju clients that wish to make SSH connections to Juju managed machines.
Package sshclient implements the API endpoint required for Juju clients that wish to make SSH connections to Juju managed machines.
Package storage provides an API server facade for managing storage entities.
Package storage provides an API server facade for managing storage entities.

Jump to

Keyboard shortcuts

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