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

package apiserver

import "github.com/juju/juju/apiserver"

Index

Package Files

admin.go allfacades.go apiserver.go apiservermetrics.go backup.go charms.go config.go debuglog.go debuglog_db.go gui.go httpcontext.go introspection.go leadership.go listener.go localofferauth.go logsink.go logstream.go logtransfer.go pinger.go pubsub.go registration.go resources.go resources_mig.go resources_unit.go rest.go restrict_anonymous.go restrict_caasmodel.go restrict_controller.go restrict_migrations.go restrict_model.go restrict_restore.go restrict_upgrades.go restricted_root.go root.go shared.go tools.go watcher.go

Constants

const MetricLabelEndpoint = "endpoint"

MetricLabelEndpoint defines a constant for the APIConnections abd PingFailureCount Labels

const MetricLabelModelUUID = "model_uuid"

MetricLabelModelUUID defines a constant for the PingFailureCount and LogWriteCount Labels Note: prometheus doesn't allow hyphens only underscores

const MetricLabelState = "state"

MetricLabelState defines a constant for the LogWriteCount Label

Variables

var MaintenanceNoLoginError = errors.New("login failed - maintenance in progress")
var MetricAPIConnectionsLabelNames = []string{
    MetricLabelEndpoint,
}

MetricAPIConnectionsLabelNames defines a series of labels for the APIConnections metric.

var MetricLogLabelNames = []string{
    MetricLabelModelUUID,
    MetricLabelState,
}

MetricLogLabelNames defines a series of labels for the LogWrite and LogRead metric

var MetricPingFailureLabelNames = []string{
    MetricLabelModelUUID,
    MetricLabelEndpoint,
}

MetricPingFailureLabelNames defines a series of labels for the PingFailure metric.

func AdminFacadeDetails Uses

func AdminFacadeDetails() []facade.Details

AdminFacadeDetails returns information on the Admin facade provided at login time. The Facade field of the returned slice elements will be nil.

func AllFacades Uses

func AllFacades() *facade.Registry

AllFacades returns a registry containing all known API facades.

This will panic if facade registration fails, but there is a unit test to guard against that.

func DescribeFacades Uses

func DescribeFacades(registry *facade.Registry) []params.FacadeVersions

DescribeFacades returns the list of available Facades and their Versions

func IsAnonymousFacade Uses

func IsAnonymousFacade(facadeName string) bool

IsAnonymousFacade reports whether the given facade name can be accessed using an anonymous connection.

func IsControllerFacade Uses

func IsControllerFacade(facadeName string) bool

IsControllerFacade reports whether the given facade name can be accessed using a controller connection.

func IsMethodAllowedDuringMigration Uses

func IsMethodAllowedDuringMigration(facadeName, methodName string) bool

func IsMethodAllowedDuringUpgrade Uses

func IsMethodAllowedDuringUpgrade(facadeName, methodName string) bool

func IsModelFacade Uses

func IsModelFacade(facadeName string) bool

IsModelFacade reports whether the given facade name can be accessed using a model connection.

func NewAllWatcher Uses

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.

type CharmsHTTPHandler Uses

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 Uses

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

type Collector Uses

type Collector struct {
    TotalConnections   prometheus.Counter
    LoginAttempts      prometheus.Gauge
    APIConnections     *prometheus.GaugeVec
    APIRequestDuration *prometheus.SummaryVec
    PingFailureCount   *prometheus.CounterVec
    LogWriteCount      *prometheus.CounterVec
    LogReadCount       *prometheus.CounterVec

    DeprecatedAPIConnections     prometheus.Gauge
    DeprecatedAPIRequestsTotal   *prometheus.CounterVec
    DeprecatedAPIRequestDuration *prometheus.SummaryVec
}

Collector is a prometheus.Collector that collects metrics based on apiserver status.

func NewMetricsCollector Uses

func NewMetricsCollector() *Collector

NewMetricsCollector returns a new Collector.

func (*Collector) Collect Uses

func (c *Collector) Collect(ch chan<- prometheus.Metric)

Collect is part of the prometheus.Collector interface.

func (*Collector) Describe Uses

func (c *Collector) Describe(ch chan<- *prometheus.Desc)

Describe is part of the prometheus.Collector interface.

type EntitiesWatcher Uses

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 Uses

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

type Hub Uses

type Hub interface {
    Publish(string, interface{}) (<-chan struct{}, error)
}

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

type LogSinkConfig Uses

type LogSinkConfig struct {
    // DBLoggerBufferSize is the capacity of the database logger's buffer.
    DBLoggerBufferSize int

    // DBLoggerFlushInterval is the amount of time to allow a log record
    // to sit in the buffer before being flushed to the database.
    DBLoggerFlushInterval time.Duration

    // RateLimitBurst defines the number of log messages that will be let
    // through before we start rate limiting.
    RateLimitBurst int64

    // RateLimitRefill defines the rate at which log messages will be let
    // through once the initial burst amount has been depleted.
    RateLimitRefill time.Duration
}

LogSinkConfig holds parameters to control the API server's logsink endpoint behaviour.

func DefaultLogSinkConfig Uses

func DefaultLogSinkConfig() LogSinkConfig

DefaultLogSinkConfig returns a LogSinkConfig with default values.

func (LogSinkConfig) Validate Uses

func (cfg LogSinkConfig) Validate() error

Validate validates the logsink endpoint configuration.

type Pinger Uses

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

pinger describes a resource that can be pinged and stopped.

func NewPinger Uses

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 RateLimitConfig Uses

type RateLimitConfig struct {
    LoginRateLimit     int
    LoginMinPause      time.Duration
    LoginMaxPause      time.Duration
    LoginRetryPause    time.Duration
    ConnMinPause       time.Duration
    ConnMaxPause       time.Duration
    ConnLookbackWindow time.Duration
    ConnLowerThreshold int
    ConnUpperThreshold int
}

RateLimitConfig holds parameters to control aspects of rate limiting connections and logins.

func DefaultRateLimitConfig Uses

func DefaultRateLimitConfig() RateLimitConfig

DefaultRateLimitConfig returns a RateLimtConfig struct with all attributes set to their default values.

func (RateLimitConfig) Validate Uses

func (c RateLimitConfig) Validate() error

Validate validates the rate limit configuration. We apply arbitrary but sensible upper limits to prevent typos from introducing obviously bad config.

type ResourcesBackend Uses

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 Uses

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

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

func (*ResourcesHandler) ServeHTTP Uses

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

ServeHTTP implements http.Handler.

type RestHTTPHandler Uses

type RestHTTPHandler struct {
    GetHandler FailableHandlerFunc
}

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

func (*RestHTTPHandler) ServeHTTP Uses

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

ServeHTTP is defined on handler.Handler.

type Server Uses

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

Server holds the server side of the API.

func NewServer Uses

func NewServer(cfg ServerConfig) (*Server, error)

NewServer serves API requests using the given configuration.

func (*Server) Dead Uses

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

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

func (*Server) GetAuditConfig Uses

func (srv *Server) GetAuditConfig() auditlog.Config

GetAuditConfig returns a copy of the current audit logging configuration.

func (*Server) Kill Uses

func (srv *Server) Kill()

Kill implements worker.Worker.Kill.

func (*Server) Stop Uses

func (srv *Server) Stop() error

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

func (*Server) Wait Uses

func (srv *Server) Wait() error

Wait implements worker.Worker.Wait.

type ServerConfig Uses

type ServerConfig struct {
    Clock         clock.Clock
    PingClock     clock.Clock
    Tag           names.Tag
    DataDir       string
    LogDir        string
    Hub           *pubsub.StructuredHub
    Presence      presence.Recorder
    Mux           *apiserverhttp.Mux
    Authenticator httpcontext.LocalMacaroonAuthenticator

    // StatePool is the StatePool used for looking up State
    // to pass to facades. StatePool will not be closed by the
    // server; it is the callers responsibility to close it
    // after the apiserver has exited.
    StatePool *state.StatePool

    // Controller is the in-memory representation of the models
    // in the controller. It is kept up to date with an all model
    // watcher and the modelcache worker.
    Controller *cache.Controller

    // UpgradeComplete is a function that reports whether or not
    // the if the agent running the API server has completed
    // running upgrade steps. This is used by the API server to
    // limit logins during upgrades.
    UpgradeComplete func() bool

    // RestoreStatus is a function that reports the restore
    // status most recently observed by the agent running the
    // API server. This is used by the API server to limit logins
    // during a restore.
    RestoreStatus func() state.RestoreStatus

    // PublicDNSName is reported to the API clients who connect.
    PublicDNSName 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

    // 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))

    // RateLimitConfig holds parameters to control
    // aspects of rate limiting connections and logins.
    RateLimitConfig RateLimitConfig

    // LogSinkConfig holds parameters to control the API server's
    // logsink endpoint behaviour. If this is nil, the values from
    // DefaultLogSinkConfig() will be used.
    LogSinkConfig *LogSinkConfig

    // GetAuditConfig holds a function that returns the current audit
    // logging config. The function may return updated values, so
    // should be called every time a new login is handled.
    GetAuditConfig func() auditlog.Config

    // LeaseManager gives access to leadership and singular claimers
    // and checkers for use in API facades.
    LeaseManager lease.Manager

    // MetricsCollector defines all the metrics to be collected for the
    // apiserver
    MetricsCollector *Collector
}

ServerConfig holds parameters required to set up an API server.

func (ServerConfig) Validate Uses

func (c ServerConfig) Validate() error

Validate validates the API server configuration.

type SharedHub Uses

type SharedHub interface {
    Publish(topic string, data interface{}) (<-chan struct{}, error)
    Subscribe(topic string, handler interface{}) (func(), error)
}

SharedHub represents the methods of the pubsub.StructuredHub that are used. The context uses an interface to allow mocking of the hub.

type SrvAllWatcher Uses

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 Uses

func (aw *SrvAllWatcher) Next() (params.AllWatcherNextResults, error)

func (*SrvAllWatcher) Stop Uses

func (w *SrvAllWatcher) Stop() error

Stop stops the watcher.

type UnitResourcesHandler Uses

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

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

func (*UnitResourcesHandler) ServeHTTP Uses

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

ServeHTTP implements http.Handler.

Directories

PathSynopsis
apiserverhttp
authentication
bakeryutil
common
common/apihttp
common/cloudspec
common/credentialcommon
common/crossmodel
common/firewall
common/imagecommon
common/mocksPackage mocks is a generated GoMock package.
common/networkingcommon
common/storagecommonPackage storagecommon provides common storage-related services for API server facades.
common/testing
facade
facade/facadetest
facade/mocksPackage mocks is a generated GoMock package.
facades/agent/agent
facades/agent/caasagent
facades/agent/caasoperator
facades/agent/credentialvalidator
facades/agent/deployer
facades/agent/diskmanager
facades/agent/fanconfigurer
facades/agent/hostkeyreporterPackage hostkeyreporter implements the API facade used by the hostkeyreporter worker.
facades/agent/instancemutater
facades/agent/instancemutater/mocksPackage mocks is a generated GoMock package.
facades/agent/keyupdater
facades/agent/leadership
facades/agent/logger
facades/agent/machineThe machiner package implements the API interface used by the machiner worker.
facades/agent/machineactionsmachineactions implements the the apiserver side of running actions on machines
facades/agent/meterstatusPackage meterstatus provides the meter status API facade.
facades/agent/meterstatus/mocksPackage mocks is a generated GoMock package.
facades/agent/meterstatus/testing
facades/agent/metricsadder
facades/agent/metricsenderPackage metricsender contains functions for sending metrics from a controller to a remote metric collector.
facades/agent/metricsender/testing
facades/agent/migrationflag
facades/agent/migrationminionPackage migrationminion defines the API facade for use by the migration minion worker to monitor the progress of, and interact with, model migrations.
facades/agent/payloadshookcontext
facades/agent/presence
facades/agent/provisioner
facades/agent/provisioner/mocksPackage mocks is a generated GoMock package.
facades/agent/proxyupdater
facades/agent/reboot
facades/agent/resourceshookcontext
facades/agent/retrystrategy
facades/agent/storageprovisioner
facades/agent/storageprovisioner/internal/filesystemwatcher
facades/agent/unitassigner
facades/agent/uniterPackage uniter implements the API interface used by the uniter worker.
facades/agent/uniter/mocksPackage mocks is a generated GoMock package.
facades/agent/upgrader
facades/agent/upgradeseries
facades/agent/upgradesteps
facades/agent/upgradesteps/mocksPackage mocks is a generated GoMock package.
facades/client/action
facades/client/annotations
facades/client/applicationPackage application contains api calls for functionality related to deploying and managing applications and their related charms.
facades/client/application/mocksPackage mocks is a generated GoMock package.
facades/client/applicationoffers
facades/client/backups
facades/client/block
facades/client/bundlePackage bundle defines an API endpoint for functions dealing with bundles.
facades/client/charms
facades/client/client
facades/client/cloudPackage cloud defines an API end point for functions dealing with the controller's cloud definition, and cloud credentials.
facades/client/controllerThe controller package defines an API end point for functions dealing with controllers as a whole.
facades/client/credentialmanager
facades/client/firewallrules
facades/client/highavailability
facades/client/imagemanager
facades/client/imagemetadatamanager
facades/client/keymanager
facades/client/keymanager/testing
facades/client/machinemanager
facades/client/metricsdebugPackage metricsdebug contains the implementation of an api endpoint for metrics debug functionality.
facades/client/modelconfig
facades/client/modelgeneration
facades/client/modelgeneration/mocksPackage mocks is a generated GoMock package.
facades/client/modelmanagerPackage modelmanager defines an API end point for functions dealing with models.
facades/client/payloads
facades/client/resources
facades/client/spaces
facades/client/sshclientPackage sshclient implements the API endpoint required for Juju clients that wish to make SSH connections to Juju managed machines.
facades/client/storagePackage storage provides an API server facade for managing storage entities.
facades/client/subnets
facades/client/usermanager
facades/controller/actionpruner
facades/controller/agenttools
facades/controller/applicationscaler
facades/controller/caasfirewaller
facades/controller/caasoperatorprovisioner
facades/controller/caasoperatorupgrader
facades/controller/caasunitprovisioner
facades/controller/charmrevisionupdater
facades/controller/charmrevisionupdater/testing
facades/controller/cleaner
facades/controller/crosscontroller
facades/controller/crossmodelrelations
facades/controller/externalcontrollerupdater
facades/controller/firewaller
facades/controller/imagemetadata
facades/controller/instancepoller
facades/controller/lifeflag
facades/controller/logfwd
facades/controller/machineundertaker
facades/controller/metricsmanagerPackage metricsmanager contains the implementation of an api endpoint for calling metrics functions in state.
facades/controller/migrationmasterThis package defines the API facade for use by the migration master worker when communicating to it's own controller.
facades/controller/migrationtargetThis package defines the API facade for use by the migration master worker when interacting with the target controller during a migration.
facades/controller/modelupgrader
facades/controller/remoterelations
facades/controller/resumerThe resumer package implements the API interface used by the resumer worker.
facades/controller/singular
facades/controller/statushistory
facades/controller/undertaker
httpattachmentPackage 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.
httpcontext
logsink
logsink/mocksPackage mocks is a generated GoMock package.
observer
observer/fakeobserver
observer/metricobserverPackage metricobserver provides an implementation of apiserver/observer.ObserverFactory that maintains Prometheus metrics.
observer/metricobserver/mocksPackage mocks is a generated GoMock package.
params
stateauthenticator
testing
testserver
websocket
websocket/websockettest

Package apiserver imports 185 packages (graph) and is imported by 100 packages. Updated 2019-10-19. Refresh now. Tools for package owners.