Documentation ¶
Index ¶
- Constants
- Variables
- func InternalSnapctlCmdNeedsStdin(name string) bool
- func IsAssertionNotFoundError(err error) bool
- func IsInterfacesUnchangedError(err error) bool
- func IsRetryable(err error) bool
- func IsTwoFactorError(err error) bool
- func MockDoTimings(retry, timeout time.Duration) (restore func())
- type AliasStatus
- type AppActivator
- type AppInfo
- type AppOptions
- type AuthorizationError
- type BuyOptions
- type BuyResult
- type Change
- type ChangeSelector
- type ChangesOptions
- type Client
- func (client *Client) Abort(id string) (*Change, error)
- func (client *Client) Ack(b []byte) error
- func (client *Client) Alias(snapName, app, alias string) (changeID string, err error)
- func (client *Client) Aliases() (allStatuses map[string]map[string]AliasStatus, err error)
- func (client *Client) ApplyValidationSet(accountID, name string, opts *ValidateApplyOptions) error
- func (client *Client) Apps(names []string, opts AppOptions) ([]*AppInfo, error)
- func (client *Client) AssertionTypes() ([]string, error)
- func (client *Client) Buy(opts *BuyOptions) (*BuyResult, error)
- func (client *Client) Change(id string) (*Change, error)
- func (client *Client) Changes(opts *ChangesOptions) ([]*Change, error)
- func (client *Client) CheckSnapshots(setID uint64, snaps []string, users []string) (changeID string, err error)
- func (client *Client) Conf(snapName string, keys []string) (configuration map[string]interface{}, err error)
- func (client *Client) Connect(plugSnapName, plugName, slotSnapName, slotName string) (changeID string, err error)
- func (client *Client) Connections(opts *ConnectionOptions) (Connections, error)
- func (client *Client) CreateCohorts(snaps []string) (map[string]string, error)
- func (client *Client) CreateUser(options *CreateUserOptions) (*CreateUserResult, error)
- func (client *Client) CreateUsers(options []*CreateUserOptions) ([]*CreateUserResult, error)
- func (client *Client) CurrentModelAssertion() (*asserts.Model, error)
- func (client *Client) CurrentSerialAssertion() (*asserts.Serial, error)
- func (client *Client) Debug(action string, params interface{}, result interface{}) error
- func (client *Client) DebugGet(aspect string, result interface{}, params map[string]string) error
- func (client *Client) Disable(name string, options *SnapOptions) (changeID string, err error)
- func (client *Client) DisableAllAliases(snapName string) (changeID string, err error)
- func (client *Client) Disconnect(plugSnapName, plugName, slotSnapName, slotName string, opts *DisconnectOptions) (changeID string, err error)
- func (client *Client) DoSystemAction(systemLabel string, action *SystemAction) error
- func (client *Client) Download(name string, options *DownloadOptions) (dlInfo *DownloadInfo, r io.ReadCloser, err error)
- func (client *Client) Enable(name string, options *SnapOptions) (changeID string, err error)
- func (client *Client) EnsureQuota(groupName string, parent string, snaps []string, maxMemory quantity.Size) (changeID string, err error)
- func (client *Client) Find(opts *FindOptions) ([]*Snap, *ResultInfo, error)
- func (client *Client) FindOne(name string) (*Snap, *ResultInfo, error)
- func (client *Client) ForgetSnapshots(setID uint64, snaps []string) (changeID string, err error)
- func (client *Client) ForgetValidationSet(accountID, name string, sequence int) error
- func (client *Client) GetQuotaGroup(groupName string) (*QuotaGroupResult, error)
- func (client *Client) Hijack(f func(*http.Request) (*http.Response, error))
- func (c *Client) Icon(pkgID string) (*Icon, error)
- func (client *Client) Install(name string, options *SnapOptions) (changeID string, err error)
- func (client *Client) InstallMany(names []string, options *SnapOptions) (changeID string, err error)
- func (client *Client) InstallPath(path, name string, options *SnapOptions) (changeID string, err error)
- func (client *Client) Interfaces(opts *InterfaceOptions) ([]*Interface, error)
- func (client *Client) InternalConsoleConfStart() ([]string, []string, error)
- func (client *Client) Known(assertTypeName string, headers map[string]string, opts *KnownOptions) ([]asserts.Assertion, error)
- func (client *Client) List(names []string, opts *ListOptions) ([]*Snap, error)
- func (client *Client) ListSystems() ([]System, error)
- func (client *Client) ListValidationsSets() ([]*ValidationSetResult, error)
- func (client *Client) LoggedInUser() *User
- func (client *Client) Login(email, password, otp string) (*User, error)
- func (client *Client) Logout() error
- func (client *Client) Logs(names []string, opts LogOptions) (<-chan Log, error)
- func (client *Client) Maintenance() error
- func (client *Client) Okay(t time.Time) error
- func (client *Client) Prefer(snapName string) (changeID string, err error)
- func (client *Client) Quotas() ([]*QuotaGroupResult, error)
- func (client *Client) ReadyToBuy() error
- func (client *Client) RebootToSystem(systemLabel, mode string) error
- func (client *Client) Refresh(name string, options *SnapOptions) (changeID string, err error)
- func (client *Client) RefreshMany(names []string, options *SnapOptions) (changeID string, err error)
- func (client *Client) Remodel(b []byte) (changeID string, err error)
- func (client *Client) Remove(name string, options *SnapOptions) (changeID string, err error)
- func (client *Client) RemoveManualAlias(alias string) (changeID string, err error)
- func (client *Client) RemoveMany(names []string, options *SnapOptions) (changeID string, err error)
- func (client *Client) RemoveQuotaGroup(groupName string) (changeID string, err error)
- func (client *Client) RemoveUser(options *RemoveUserOptions) (removed []*User, err error)
- func (client *Client) Restart(names []string, opts RestartOptions) (changeID string, err error)
- func (client *Client) RestoreSnapshots(setID uint64, snaps []string, users []string) (changeID string, err error)
- func (client *Client) Revert(name string, options *SnapOptions) (changeID string, err error)
- func (client *Client) RunSnapctl(options *SnapCtlOptions, stdin io.Reader) (stdout, stderr []byte, err error)
- func (client *Client) Sections() ([]string, error)
- func (client *Client) ServerVersion() (*ServerVersion, error)
- func (client *Client) SetConf(snapName string, patch map[string]interface{}) (changeID string, err error)
- func (client *Client) Snap(name string) (*Snap, *ResultInfo, error)
- func (client *Client) SnapshotExport(setID uint64) (stream io.ReadCloser, contentLength int64, err error)
- func (client *Client) SnapshotImport(exportStream io.Reader, size int64) (SnapshotImportSet, error)
- func (client *Client) SnapshotMany(names []string, users []string) (setID uint64, changeID string, err error)
- func (client *Client) SnapshotSets(setID uint64, snapNames []string) ([]SnapshotSet, error)
- func (client *Client) Start(names []string, opts StartOptions) (changeID string, err error)
- func (client *Client) Stop(names []string, opts StopOptions) (changeID string, err error)
- func (client *Client) StoreAccount(accountID string) (*snap.StoreAccount, error)
- func (client *Client) Switch(name string, options *SnapOptions) (changeID string, err error)
- func (client *Client) SysInfo() (*SysInfo, error)
- func (client *Client) SystemRecoveryKeys(result interface{}) error
- func (client *Client) Try(path string, options *SnapOptions) (changeID string, err error)
- func (client *Client) Unalias(aliasOrSnap string) (changeID string, err error)
- func (client *Client) Users() ([]*User, error)
- func (client *Client) ValidationSet(accountID, name string, sequence int) (*ValidationSetResult, error)
- func (client *Client) Warnings(opts WarningsOptions) ([]*Warning, error)
- func (client *Client) WarningsSummary() (count int, timestamp time.Time)
- func (client *Client) WhoAmI() (string, error)
- type CohortAction
- type Config
- type Connection
- type ConnectionError
- type ConnectionOptions
- type Connections
- type CreateUserOptions
- type CreateUserResult
- type DisconnectOptions
- type DownloadInfo
- type DownloadOptions
- type Error
- type ErrorKind
- type FindOptions
- type Icon
- type Interface
- type InterfaceAction
- type InterfaceOptions
- type InternalConsoleConfStartResponse
- type KnownOptions
- type ListOptions
- type Log
- type LogOptions
- type OSRelease
- type Plug
- type PlugRef
- type QuotaGroupResult
- type QuotaValues
- type RefreshInfo
- type RemoveUserOptions
- type RequestError
- type RestartOptions
- type ResultInfo
- type ServerVersion
- type Slot
- type SlotRef
- type Snap
- type SnapCtlOptions
- type SnapCtlPostData
- type SnapHealth
- type SnapOptions
- type Snapshot
- type SnapshotImportSet
- type SnapshotSet
- type StartOptions
- type StopOptions
- type SysInfo
- type System
- type SystemAction
- type SystemModelData
- type SystemRecoveryKeysResponse
- type Task
- type TaskProgress
- type User
- type ValidateApplyOptions
- type ValidationSetResult
- type Warning
- type WarningsOptions
Constants ¶
const ( StatusAvailable = "available" StatusInstalled = "installed" StatusActive = "active" StatusRemoved = "removed" StatusPriced = "priced" TypeApp = "app" TypeKernel = "kernel" TypeGadget = "gadget" TypeOS = "os" StrictConfinement = "strict" DevModeConfinement = "devmode" ClassicConfinement = "classic" )
Statuses and types a snap may have.
const AllowInteractionHeader = "X-Allow-Interaction"
AllowInteractionHeader is the HTTP request header used to indicate that the client is willing to allow interaction.
const SnapshotExportMediaType = "application/x.snapd.snapshot"
SnapshotExportMediaType is the media type used to identify snapshot exports in the API.
Variables ¶
var ( ErrSnapshotSetNotFound = errors.New("no snapshot set with the given ID") ErrSnapshotSnapsNotFound = errors.New("no snapshot for the requested snaps found in the set with the given ID") )
var ErrDangerousNotApplicable = fmt.Errorf("dangerous option only meaningful when installing from a local file")
var ErrNoData = fmt.Errorf("data entry not found")
var ErrNoNames = errors.New(`"names" must not be empty`)
ErrNoNames is returned by Start, Stop, or Restart, when the given list of things on which to operate is empty.
var ErrNoSnapsInstalled = errors.New("no snaps installed")
Functions ¶
func InternalSnapctlCmdNeedsStdin ¶
InternalSnapctlCmdNeedsStdin returns true if the given snapctl command needs data from stdin
func IsAssertionNotFoundError ¶
IsAssertionNotFoundError returns whether the given error means that the assertion wasn't found and thus the device isn't ready/seeded.
func IsInterfacesUnchangedError ¶
IsInterfacesUnchangedError returns whether the given error means the requested change to interfaces was not made, because there was nothing to do.
func IsRetryable ¶
IsRetryable returns true if the given error is an error that can be retried later.
func IsTwoFactorError ¶
IsTwoFactorError returns whether the given error is due to problems in two-factor authentication.
func MockDoTimings ¶
MockDoTimings mocks the delay used by the do retry loop and request timeout.
Types ¶
type AliasStatus ¶
type AliasStatus struct { Command string `json:"command"` Status string `json:"status"` Manual string `json:"manual,omitempty"` Auto string `json:"auto,omitempty"` }
AliasStatus represents the status of an alias.
type AppActivator ¶
type AppActivator struct { Name string // Type describes the type of the unit, either timer or socket Type string Active bool Enabled bool }
AppActivator is a thing that activates the app that is a service in the system.
type AppInfo ¶
type AppInfo struct { Snap string `json:"snap,omitempty"` Name string `json:"name"` DesktopFile string `json:"desktop-file,omitempty"` Daemon string `json:"daemon,omitempty"` DaemonScope snap.DaemonScope `json:"daemon-scope,omitempty"` Enabled bool `json:"enabled,omitempty"` Active bool `json:"active,omitempty"` CommonID string `json:"common-id,omitempty"` Activators []AppActivator `json:"activators,omitempty"` }
AppInfo describes a single snap application.
type AppOptions ¶
type AppOptions struct { // If Service is true, only return apps that are services // (app.IsService() is true); otherwise, return all. Service bool }
AppOptions represent the options of the Apps call.
type AuthorizationError ¶
type AuthorizationError struct {
// contains filtered or unexported fields
}
func (AuthorizationError) Error ¶
func (e AuthorizationError) Error() string
type BuyOptions ¶
type BuyOptions struct { SnapID string `json:"snap-id"` Price float64 `json:"price"` Currency string `json:"currency"` // ISO 4217 code as string }
BuyOptions specifies parameters to buy from the store.
type BuyResult ¶
type BuyResult struct {
State string `json:"state,omitempty"`
}
BuyResult holds the state of a buy attempt.
type Change ¶
type Change struct { ID string `json:"id"` Kind string `json:"kind"` Summary string `json:"summary"` Status string `json:"status"` Tasks []*Task `json:"tasks,omitempty"` Ready bool `json:"ready"` Err string `json:"err,omitempty"` SpawnTime time.Time `json:"spawn-time,omitempty"` ReadyTime time.Time `json:"ready-time,omitempty"` // contains filtered or unexported fields }
A Change is a modification to the system state.
type ChangeSelector ¶
type ChangeSelector uint8
const ( ChangesInProgress ChangeSelector = 1 << iota ChangesReady ChangesAll = ChangesReady | ChangesInProgress )
func (ChangeSelector) String ¶
func (c ChangeSelector) String() string
type ChangesOptions ¶
type ChangesOptions struct { SnapName string // if empty, no filtering by name is done Selector ChangeSelector }
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A Client knows how to talk to the snappy daemon.
func (*Client) Ack ¶
Ack tries to add an assertion to the system assertion database. To succeed the assertion must be valid, its signature verified with a known public key and the assertion consistent with and its prerequisite in the database.
func (*Client) Aliases ¶
func (client *Client) Aliases() (allStatuses map[string]map[string]AliasStatus, err error)
Aliases returns a map snap -> alias -> AliasStatus for all snaps and aliases in the system.
func (*Client) ApplyValidationSet ¶
func (client *Client) ApplyValidationSet(accountID, name string, opts *ValidateApplyOptions) error
ApplyValidationSet applies the given validation set identified by account and name.
func (*Client) Apps ¶
func (client *Client) Apps(names []string, opts AppOptions) ([]*AppInfo, error)
Apps returns information about all matching apps. Each name can be either a snap or a snap.app. If names is empty, list all (that satisfy opts).
func (*Client) AssertionTypes ¶
AssertionTypes returns a list of assertion type names.
func (*Client) CheckSnapshots ¶
func (client *Client) CheckSnapshots(setID uint64, snaps []string, users []string) (changeID string, err error)
CheckSnapshots verifies the archive checksums in the given snapshot set.
If snaps or users are non-empty, limit to checking only those archives of the snapshot.
func (*Client) Conf ¶
func (client *Client) Conf(snapName string, keys []string) (configuration map[string]interface{}, err error)
Conf asks for a snap's current configuration.
Note that the configuration may include json.Numbers.
func (*Client) Connect ¶
func (client *Client) Connect(plugSnapName, plugName, slotSnapName, slotName string) (changeID string, err error)
Connect establishes a connection between a plug and a slot. The plug and the slot must have the same interface.
func (*Client) Connections ¶
func (client *Client) Connections(opts *ConnectionOptions) (Connections, error)
Connections returns matching plugs, slots and their connections. Unless specified by matching options, returns established connections.
func (*Client) CreateCohorts ¶
func (*Client) CreateUser ¶
func (client *Client) CreateUser(options *CreateUserOptions) (*CreateUserResult, error)
CreateUser creates a local system user. See CreateUserOptions for details.
func (*Client) CreateUsers ¶
func (client *Client) CreateUsers(options []*CreateUserOptions) ([]*CreateUserResult, error)
CreateUsers creates multiple local system users. See CreateUserOptions for details.
Results may be provided even if there are errors.
func (*Client) CurrentModelAssertion ¶
CurrentModelAssertion returns the current model assertion
func (*Client) CurrentSerialAssertion ¶
CurrentSerialAssertion returns the current serial assertion
func (*Client) Debug ¶
Debug is only useful when writing test code, it will trigger an internal action with the given parameters.
func (*Client) Disable ¶
func (client *Client) Disable(name string, options *SnapOptions) (changeID string, err error)
func (*Client) DisableAllAliases ¶
// DisableAllAliases disables all aliases of a snap, removing all manual ones.
func (*Client) Disconnect ¶
func (client *Client) Disconnect(plugSnapName, plugName, slotSnapName, slotName string, opts *DisconnectOptions) (changeID string, err error)
Disconnect breaks the connection between a plug and a slot.
func (*Client) DoSystemAction ¶
func (client *Client) DoSystemAction(systemLabel string, action *SystemAction) error
DoSystemAction issues a request to perform an action using the given seed system and its mode.
func (*Client) Download ¶
func (client *Client) Download(name string, options *DownloadOptions) (dlInfo *DownloadInfo, r io.ReadCloser, err error)
Download will stream the given snap to the client
func (*Client) Enable ¶
func (client *Client) Enable(name string, options *SnapOptions) (changeID string, err error)
func (*Client) EnsureQuota ¶
func (client *Client) EnsureQuota(groupName string, parent string, snaps []string, maxMemory quantity.Size) (changeID string, err error)
EnsureQuota creates a quota group or updates an existing group. The list of snaps can be empty.
func (*Client) Find ¶
func (client *Client) Find(opts *FindOptions) ([]*Snap, *ResultInfo, error)
Find returns a list of snaps available for install from the store for this system and that match the query
func (*Client) ForgetSnapshots ¶
ForgetSnapshots permanently removes the snapshot set, limited to the given snaps (if non-empty).
func (*Client) ForgetValidationSet ¶
ForgetValidationSet forgets the given validation set identified by account, name and optional sequence (if non-zero).
func (*Client) GetQuotaGroup ¶
func (client *Client) GetQuotaGroup(groupName string) (*QuotaGroupResult, error)
func (*Client) Install ¶
func (client *Client) Install(name string, options *SnapOptions) (changeID string, err error)
Install adds the snap with the given name from the given channel (or the system default channel if not).
func (*Client) InstallMany ¶
func (client *Client) InstallMany(names []string, options *SnapOptions) (changeID string, err error)
func (*Client) InstallPath ¶
func (client *Client) InstallPath(path, name string, options *SnapOptions) (changeID string, err error)
InstallPath sideloads the snap with the given path under optional provided name, returning the UUID of the background operation upon success.
func (*Client) Interfaces ¶
func (client *Client) Interfaces(opts *InterfaceOptions) ([]*Interface, error)
func (*Client) InternalConsoleConfStart ¶
InternalConsoleConfStart invokes the dedicated console-conf start support to handle intervening auto-refreshes. Not for general use.
func (*Client) Known ¶
func (client *Client) Known(assertTypeName string, headers map[string]string, opts *KnownOptions) ([]asserts.Assertion, error)
Known queries assertions with type assertTypeName and matching assertion headers.
func (*Client) List ¶
func (client *Client) List(names []string, opts *ListOptions) ([]*Snap, error)
List returns the list of all snaps installed on the system with names in the given list; if the list is empty, all snaps.
func (*Client) ListSystems ¶
ListSystems list all systems available for seeding or recovery.
func (*Client) ListValidationsSets ¶
func (client *Client) ListValidationsSets() ([]*ValidationSetResult, error)
ListValidationsSets queries all validation sets.
func (*Client) LoggedInUser ¶
LoggedInUser returns the logged in User or nil
func (*Client) Logs ¶
func (client *Client) Logs(names []string, opts LogOptions) (<-chan Log, error)
Logs asks for the logs of a series of services, by name.
func (*Client) Maintenance ¶
Maintenance returns an error reflecting the daemon maintenance status or nil.
func (*Client) Okay ¶
Okay asks snapd to chill about the warnings that would have been returned by Warnings at the given time.
func (*Client) Prefer ¶
Prefer enables all aliases of a snap in preference to conflicting aliases of other snaps whose aliases will be disabled (removed for manual ones).
func (*Client) Quotas ¶
func (client *Client) Quotas() ([]*QuotaGroupResult, error)
func (*Client) ReadyToBuy ¶
func (*Client) RebootToSystem ¶
RebootToSystem issues a request to reboot into system with the given label and the given mode.
When called without a systemLabel and without a mode it will just trigger a regular reboot.
When called without a systemLabel but with a mode it will use the current system to enter the given mode.
Note that "recover" and "run" modes are only available for the current system.
func (*Client) Refresh ¶
func (client *Client) Refresh(name string, options *SnapOptions) (changeID string, err error)
Refresh refreshes the snap with the given name (switching it to track the given channel if given).
func (*Client) RefreshMany ¶
func (client *Client) RefreshMany(names []string, options *SnapOptions) (changeID string, err error)
func (*Client) Remove ¶
func (client *Client) Remove(name string, options *SnapOptions) (changeID string, err error)
Remove removes the snap with the given name.
func (*Client) RemoveManualAlias ¶
RemoveManualAlias removes a manual alias.
func (*Client) RemoveMany ¶
func (client *Client) RemoveMany(names []string, options *SnapOptions) (changeID string, err error)
func (*Client) RemoveQuotaGroup ¶
func (*Client) RemoveUser ¶
func (client *Client) RemoveUser(options *RemoveUserOptions) (removed []*User, err error)
RemoveUser removes a local system user.
func (*Client) Restart ¶
func (client *Client) Restart(names []string, opts RestartOptions) (changeID string, err error)
Restart services.
It takes a list of names that can be snaps, of which all their services are restarted, or snap.service which are individual services to restart; it shouldn't be empty. If the service is not running, starts it.
func (*Client) RestoreSnapshots ¶
func (client *Client) RestoreSnapshots(setID uint64, snaps []string, users []string) (changeID string, err error)
RestoreSnapshots extracts the given snapshot set.
If snaps or users are non-empty, limit to checking only those archives of the snapshot.
func (*Client) Revert ¶
func (client *Client) Revert(name string, options *SnapOptions) (changeID string, err error)
Revert rolls the snap back to the previous on-disk state
func (*Client) RunSnapctl ¶
func (client *Client) RunSnapctl(options *SnapCtlOptions, stdin io.Reader) (stdout, stderr []byte, err error)
RunSnapctl requests a snapctl run for the given options.
func (*Client) ServerVersion ¶
func (client *Client) ServerVersion() (*ServerVersion, error)
func (*Client) SetConf ¶
func (client *Client) SetConf(snapName string, patch map[string]interface{}) (changeID string, err error)
SetConf requests a snap to apply the provided patch to the configuration.
func (*Client) Snap ¶
func (client *Client) Snap(name string) (*Snap, *ResultInfo, error)
Snap returns the most recently published revision of the snap with the provided name.
func (*Client) SnapshotExport ¶
func (client *Client) SnapshotExport(setID uint64) (stream io.ReadCloser, contentLength int64, err error)
SnapshotExport streams the requested snapshot set.
The return value includes the length of the returned stream.
func (*Client) SnapshotImport ¶
SnapshotImport imports an exported snapshot set.
func (*Client) SnapshotMany ¶
func (client *Client) SnapshotMany(names []string, users []string) (setID uint64, changeID string, err error)
SnapshotMany snapshots many snaps (all, if names empty) for many users (all, if users is empty).
func (*Client) SnapshotSets ¶
func (client *Client) SnapshotSets(setID uint64, snapNames []string) ([]SnapshotSet, error)
SnapshotSets lists the snapshot sets in the system that belong to the given set (if non-zero) and are for the given snaps (if non-empty).
func (*Client) Start ¶
func (client *Client) Start(names []string, opts StartOptions) (changeID string, err error)
Start services.
It takes a list of names that can be snaps, of which all their services are started, or snap.service which are individual services to start; it shouldn't be empty.
func (*Client) Stop ¶
func (client *Client) Stop(names []string, opts StopOptions) (changeID string, err error)
Stop services.
It takes a list of names that can be snaps, of which all their services are stopped, or snap.service which are individual services to stop; it shouldn't be empty.
func (*Client) StoreAccount ¶
func (client *Client) StoreAccount(accountID string) (*snap.StoreAccount, error)
StoreAccount returns the full store account info for the specified accountID
func (*Client) Switch ¶
func (client *Client) Switch(name string, options *SnapOptions) (changeID string, err error)
Switch moves the snap to a different channel without a refresh
func (*Client) SystemRecoveryKeys ¶
func (*Client) Try ¶
func (client *Client) Try(path string, options *SnapOptions) (changeID string, err error)
Try
func (*Client) Unalias ¶
Unalias tears down a manual alias or disables all aliases of a snap (removing all manual ones)
func (*Client) ValidationSet ¶
func (client *Client) ValidationSet(accountID, name string, sequence int) (*ValidationSetResult, error)
ValidationSet queries the given validation set identified by account/name.
func (*Client) Warnings ¶
func (client *Client) Warnings(opts WarningsOptions) ([]*Warning, error)
Warnings returns the list of un-okayed warnings.
func (*Client) WarningsSummary ¶
WarningsSummary returns the number of warnings that are ready to be shown to the user, and the timestamp of the most recently added warning (useful for silencing the warning alerts, and OKing the returned warnings).
type CohortAction ¶
type Config ¶
type Config struct { // BaseURL contains the base URL where snappy daemon is expected to be. // It can be empty for a default behavior of talking over a unix socket. BaseURL string // DisableAuth controls whether the client should send an // Authorization header from reading the auth.json data. DisableAuth bool // Interactive controls whether the client runs in interactive mode. // At present, this only affects whether interactive polkit // authorisation is requested. Interactive bool // Socket is the path to the unix socket to use Socket string // DisableKeepAlive indicates whether the connections should not be kept // alive for later reuse DisableKeepAlive bool // User-Agent to sent to the snapd daemon UserAgent string }
Config allows to customize client behavior.
type Connection ¶
type Connection struct { Slot SlotRef `json:"slot"` Plug PlugRef `json:"plug"` Interface string `json:"interface"` // Manual is set for connections that were established manually. Manual bool `json:"manual"` // Gadget is set for connections that were enabled by the gadget snap. Gadget bool `json:"gadget"` // SlotAttrs is the list of attributes of the slot side of the connection. SlotAttrs map[string]interface{} `json:"slot-attrs,omitempty"` // PlugAttrs is the list of attributes of the plug side of the connection. PlugAttrs map[string]interface{} `json:"plug-attrs,omitempty"` }
Connection describes a connection between a plug and a slot.
type ConnectionError ¶
type ConnectionError struct{ Err error }
func (ConnectionError) Error ¶
func (e ConnectionError) Error() string
func (ConnectionError) Unwrap ¶
func (e ConnectionError) Unwrap() error
type ConnectionOptions ¶
type ConnectionOptions struct { // Snap selects connections with the snap on one of the sides, as well // as plugs and slots of a given snap. Snap string // Interface selects connections, plugs or slots using given interface. Interface string // All when true, selects established and undesired connections as well // as all disconnected plugs and slots. All bool }
ConnectionOptions contains criteria for selecting matching connections, plugs and slots.
type Connections ¶
type Connections struct { // Established is the list of connections that are currently present. Established []Connection `json:"established"` // Undersired is a list of connections that are manually denied. Undesired []Connection `json:"undesired"` Plugs []Plug `json:"plugs"` Slots []Slot `json:"slots"` }
Connections contains information about connections, as well as related plugs and slots.
type CreateUserOptions ¶
type CreateUserOptions struct { Email string `json:"email,omitempty"` Sudoer bool `json:"sudoer,omitempty"` Known bool `json:"known,omitempty"` ForceManaged bool `json:"force-managed,omitempty"` // Automatic is for internal snapd use, behavior might evolve Automatic bool `json:"automatic,omitempty"` }
CreateUserOptions holds options for creating a local system user.
If Known is false, the provided email is used to query the store for username and SSH key details.
If Known is true, the user will be created by looking through existing system-user assertions and looking for a matching email. If Email is empty then all such assertions are considered and multiple users may be created.
type CreateUserResult ¶
type CreateUserResult struct { Username string `json:"username"` SSHKeys []string `json:"ssh-keys"` }
CreateUserResult holds the result of a user creation.
type DisconnectOptions ¶
type DisconnectOptions struct {
Forget bool
}
DisconnectOptions represents extra options for disconnect op
type DownloadInfo ¶
type DownloadOptions ¶
type DownloadOptions struct { SnapOptions HeaderPeek bool ResumeToken string Resume int64 }
type Error ¶
type Error struct { Kind ErrorKind `json:"kind"` Value interface{} `json:"value"` Message string `json:"message"` StatusCode int }
Error is the real value of response.Result when an error occurs.
type ErrorKind ¶
type ErrorKind string
ErrorKind distinguishes kind of errors.
const ( // ErrorKindTwoFactorRequired: the client needs to retry the // `login` command including an OTP. ErrorKindTwoFactorRequired ErrorKind = "two-factor-required" // ErrorKindTwoFactorFailed: the OTP provided wasn't recognised. ErrorKindTwoFactorFailed ErrorKind = "two-factor-failed" // ErrorKindLoginRequired: the requested operation cannot be // performed without an authenticated user. This is the kind // of any other 401 Unauthorized response. ErrorKindLoginRequired ErrorKind = "login-required" // ErrorKindInvalidAuthData: the authentication data provided // failed to validate (e.g. a malformed email address). The // `value` of the error is an object with a key per failed field // and a list of the failures on each field. ErrorKindInvalidAuthData ErrorKind = "invalid-auth-data" // ErrorKindPasswordPolicy: provided password doesn't meet // system policy. ErrorKindPasswordPolicy ErrorKind = "password-policy" // ErrorKindAuthCancelled: authentication was cancelled by the user. ErrorKindAuthCancelled ErrorKind = "auth-cancelled" // ErrorKindTermsNotAccepted: deprecated, do not document. ErrorKindTermsNotAccepted ErrorKind = "terms-not-accepted" // ErrorKindNoPaymentMethods: deprecated, do not document. ErrorKindNoPaymentMethods ErrorKind = "no-payment-methods" // ErrorKindPaymentDeclined: deprecated, do not document. ErrorKindPaymentDeclined ErrorKind = "payment-declined" // ErrorKindSnapAlreadyInstalled: the requested snap is // already installed. ErrorKindSnapAlreadyInstalled ErrorKind = "snap-already-installed" // ErrorKindSnapNotInstalled: the requested snap is not installed. ErrorKindSnapNotInstalled ErrorKind = "snap-not-installed" // ErrorKindSnapNotFound: the requested snap couldn't be found. ErrorKindSnapNotFound ErrorKind = "snap-not-found" // ErrorKindAppNotFound: the requested app couldn't be found. ErrorKindAppNotFound ErrorKind = "app-not-found" // ErrorKindSnapLocal: cannot perform operation on local snap. ErrorKindSnapLocal ErrorKind = "snap-local" // ErrorKindSnapNeedsDevMode: the requested snap needs devmode // to be installed. ErrorKindSnapNeedsDevMode ErrorKind = "snap-needs-devmode" // ErrorKindSnapNeedsClassic: the requested snap needs classic // confinement to be installed. ErrorKindSnapNeedsClassic ErrorKind = "snap-needs-classic" // ErrorKindSnapNeedsClassicSystem: the requested snap can't // be installed on the current non-classic system. ErrorKindSnapNeedsClassicSystem ErrorKind = "snap-needs-classic-system" // ErrorKindSnapNotClassic: snap not compatible with classic mode. ErrorKindSnapNotClassic ErrorKind = "snap-not-classic" // ErrorKindSnapNoUpdateAvailable: the requested snap does not // have an update available. ErrorKindSnapNoUpdateAvailable ErrorKind = "snap-no-update-available" // ErrorKindSnapRevisionNotAvailable: no snap revision available // as specified. ErrorKindSnapRevisionNotAvailable ErrorKind = "snap-revision-not-available" // ErrorKindSnapChannelNotAvailable: no snap revision on specified // channel. The `value` of the error is a rich object with // requested `snap-name`, `action`, `channel`, `architecture`, and // actually available `releases` as list of // `{"architecture":... , "channel": ...}` objects. ErrorKindSnapChannelNotAvailable ErrorKind = "snap-channel-not-available" // ErrorKindSnapArchitectureNotAvailable: no snap revision on // specified architecture. Value has the same format as for // `snap-channel-not-available`. ErrorKindSnapArchitectureNotAvailable ErrorKind = "snap-architecture-not-available" // ErrorKindSnapChangeConflict: the requested operation would // conflict with currently ongoing change. This is a temporary // error. The error `value` is an object with optional fields // `snap-name`, `change-kind` of the ongoing change. ErrorKindSnapChangeConflict ErrorKind = "snap-change-conflict" // ErrorKindQuotaChangeConflict: the requested operation would // conflict with a currently ongoing change affecting the quota // group. This is a temporary error. The error `value` is an // object with optional fields `quota-name`, `change-kind` of the // ongoing change. ErrorKindQuotaChangeConflict ErrorKind = "quota-change-conflict" // ErrorKindNotSnap: the given snap or directory does not // look like a snap. ErrorKindNotSnap ErrorKind = "snap-not-a-snap" // ErrorKindInterfacesUnchanged: the requested interfaces' // operation would have no effect. ErrorKindInterfacesUnchanged ErrorKind = "interfaces-unchanged" // ErrorKindBadQuery: a bad query was provided. ErrorKindBadQuery ErrorKind = "bad-query" // ErrorKindConfigNoSuchOption: the given configuration option // does not exist. ErrorKindConfigNoSuchOption ErrorKind = "option-not-found" // ErrorKindAssertionNotFound: assertion can not be found. ErrorKindAssertionNotFound ErrorKind = "assertion-not-found" // ErrorKindUnsuccessful: snapctl command was unsuccessful. ErrorKindUnsuccessful ErrorKind = "unsuccessful" // ErrorKindNetworkTimeout: a timeout occurred during the request. ErrorKindNetworkTimeout ErrorKind = "network-timeout" // ErrorKindDNSFailure: DNS not responding. ErrorKindDNSFailure ErrorKind = "dns-failure" // ErrorKindInsufficientDiskSpace: not enough disk space to perform the request. ErrorKindInsufficientDiskSpace ErrorKind = "insufficient-disk-space" // ErrorKindValidationSetNotFound: validation set cannot be found. ErrorKindValidationSetNotFound ErrorKind = "validation-set-not-found" )
Error kinds. Keep https://forum.snapcraft.io/t/using-the-rest-api/18603#heading--errors in sync using doc/error-kinds.go.
const ( // ErrorKindDaemonRestart: daemon is restarting. ErrorKindDaemonRestart ErrorKind = "daemon-restart" // ErrorKindSystemRestart: system is restarting. ErrorKindSystemRestart ErrorKind = "system-restart" )
Maintenance error kinds. These are used only inside the maintenance field of responses. Keep https://forum.snapcraft.io/t/using-the-rest-api/18603#heading--maint-errors in sync using doc/error-kinds.go.
type FindOptions ¶
type FindOptions struct { // Query is a term to search by or a prefix (if Prefix is true) Query string Prefix bool CommonID string Section string Private bool Scope string Refresh bool }
FindOptions supports exactly one of the following options: - Refresh: only return snaps that are refreshable - Private: return snaps that are private - Query: only return snaps that match the query string
type Interface ¶
type Interface struct { Name string `json:"name,omitempty"` Summary string `json:"summary,omitempty"` DocURL string `json:"doc-url,omitempty"` Plugs []Plug `json:"plugs,omitempty"` Slots []Slot `json:"slots,omitempty"` }
Interface holds information about a given interface and its instances.
type InterfaceAction ¶
type InterfaceAction struct { Action string `json:"action"` Forget bool `json:"forget,omitempty"` Plugs []Plug `json:"plugs,omitempty"` Slots []Slot `json:"slots,omitempty"` }
InterfaceAction represents an action performed on the interface system.
type InterfaceOptions ¶
InterfaceOptions represents opt-in elements include in responses.
type InternalConsoleConfStartResponse ¶
type InternalConsoleConfStartResponse struct { ActiveAutoRefreshChanges []string `json:"active-auto-refreshes,omitempty"` ActiveAutoRefreshSnaps []string `json:"active-auto-refresh-snaps,omitempty"` }
InternalConsoleConfStartResponse is the response from console-conf start support
type KnownOptions ¶
type KnownOptions struct { // If Remote is true, the store is queried to find the assertion Remote bool }
KnownOptions represent the options of the Known call.
type ListOptions ¶
type ListOptions struct {
All bool
}
type Log ¶
type Log struct { Timestamp time.Time `json:"timestamp"` // Timestamp of the event, in RFC3339 format to µs precision. Message string `json:"message"` // The log message itself SID string `json:"sid"` // The syslog identifier PID string `json:"pid"` // The process identifier }
A Log holds the information of a single syslog entry
func (Log) StringInUTC ¶
StringInUTC will format the log entry with the timestamp in UTC
type LogOptions ¶
type LogOptions struct { N int // The maximum number of log lines to retrieve initially. If <0, no limit. Follow bool // Whether to continue returning new lines as they appear }
LogOptions represent the options of the Logs call.
type Plug ¶
type Plug struct { Snap string `json:"snap"` Name string `json:"plug"` Interface string `json:"interface,omitempty"` Attrs map[string]interface{} `json:"attrs,omitempty"` Apps []string `json:"apps,omitempty"` Label string `json:"label,omitempty"` Connections []SlotRef `json:"connections,omitempty"` }
Plug represents the potential of a given snap to connect to a slot.
type QuotaGroupResult ¶
type QuotaGroupResult struct { GroupName string `json:"group-name"` Parent string `json:"parent,omitempty"` Subgroups []string `json:"subgroups,omitempty"` Snaps []string `json:"snaps,omitempty"` Constraints *QuotaValues `json:"constraints,omitempty"` Current *QuotaValues `json:"current,omitempty"` }
type QuotaValues ¶
type RefreshInfo ¶
type RefreshInfo struct { // Timer contains the refresh.timer setting. Timer string `json:"timer,omitempty"` // Schedule contains the legacy refresh.schedule setting. Schedule string `json:"schedule,omitempty"` Last string `json:"last,omitempty"` Hold string `json:"hold,omitempty"` Next string `json:"next,omitempty"` }
RefreshInfo contains information about refreshes.
type RemoveUserOptions ¶
type RemoveUserOptions struct { // Username indicates which user to remove. Username string `json:"username,omitempty"` }
RemoveUserOptions holds options for removing a local system user.
type RequestError ¶
type RequestError struct {
// contains filtered or unexported fields
}
func (RequestError) Error ¶
func (e RequestError) Error() string
type RestartOptions ¶
type RestartOptions struct { // Reload the services, if possible (i.e. if the App has a // ReloadCommand, invoque it), instead of restarting. Reload bool `json:"reload,omitempty"` }
RestartOptions represent the different options of the Restart call.
type ResultInfo ¶
type ResultInfo struct {
SuggestedCurrency string `json:"suggested-currency"`
}
type ServerVersion ¶
type Slot ¶
type Slot struct { Snap string `json:"snap"` Name string `json:"slot"` Interface string `json:"interface,omitempty"` Attrs map[string]interface{} `json:"attrs,omitempty"` Apps []string `json:"apps,omitempty"` Label string `json:"label,omitempty"` Connections []PlugRef `json:"connections,omitempty"` }
Slot represents a capacity offered by a snap.
type Snap ¶
type Snap struct { ID string `json:"id"` Title string `json:"title,omitempty"` Summary string `json:"summary"` Description string `json:"description"` DownloadSize int64 `json:"download-size,omitempty"` Icon string `json:"icon,omitempty"` InstalledSize int64 `json:"installed-size,omitempty"` InstallDate time.Time `json:"install-date,omitempty"` Name string `json:"name"` Publisher *snap.StoreAccount `json:"publisher,omitempty"` StoreURL string `json:"store-url,omitempty"` // Developer is also the publisher's username for historic reasons. Developer string `json:"developer"` Status string `json:"status"` Type string `json:"type"` Base string `json:"base,omitempty"` Version string `json:"version"` Channel string `json:"channel"` TrackingChannel string `json:"tracking-channel,omitempty"` IgnoreValidation bool `json:"ignore-validation"` Revision snap.Revision `json:"revision"` Confinement string `json:"confinement"` Private bool `json:"private"` DevMode bool `json:"devmode"` JailMode bool `json:"jailmode"` TryMode bool `json:"trymode,omitempty"` Apps []AppInfo `json:"apps,omitempty"` Broken string `json:"broken,omitempty"` Contact string `json:"contact"` License string `json:"license,omitempty"` CommonIDs []string `json:"common-ids,omitempty"` MountedFrom string `json:"mounted-from,omitempty"` CohortKey string `json:"cohort-key,omitempty"` Website string `json:"website,omitempty"` Prices map[string]float64 `json:"prices,omitempty"` Screenshots []snap.ScreenshotInfo `json:"screenshots,omitempty"` Media snap.MediaInfos `json:"media,omitempty"` // The flattended channel map with $track/$risk Channels map[string]*snap.ChannelSnapInfo `json:"channels,omitempty"` // The ordered list of tracks that contains channels Tracks []string `json:"tracks,omitempty"` Health *SnapHealth `json:"health,omitempty"` }
Snap holds the data for a snap as obtained from snapd.
func (*Snap) MarshalJSON ¶
type SnapCtlOptions ¶
type SnapCtlOptions struct { // ContextID is a string used to determine the context of this call (e.g. // which context and handler should be used, etc.) ContextID string `json:"context-id"` // Args contains a list of parameters to use for this invocation. Args []string `json:"args"` }
SnapCtlOptions holds the various options with which snapctl is invoked.
type SnapCtlPostData ¶
type SnapCtlPostData struct { SnapCtlOptions Stdin []byte `json:"stdin,omitempty"` }
SnapCtlPostData is the data posted to the daemon /v2/snapctl endpoint TODO: this can be removed again once we no longer need to pass stdin data
but instead use a real stdin stream
type SnapHealth ¶
type SnapOptions ¶
type SnapOptions struct { Channel string `json:"channel,omitempty"` Revision string `json:"revision,omitempty"` CohortKey string `json:"cohort-key,omitempty"` LeaveCohort bool `json:"leave-cohort,omitempty"` DevMode bool `json:"devmode,omitempty"` JailMode bool `json:"jailmode,omitempty"` Classic bool `json:"classic,omitempty"` Dangerous bool `json:"dangerous,omitempty"` IgnoreValidation bool `json:"ignore-validation,omitempty"` IgnoreRunning bool `json:"ignore-running,omitempty"` Unaliased bool `json:"unaliased,omitempty"` Purge bool `json:"purge,omitempty"` Amend bool `json:"amend,omitempty"` Users []string `json:"users,omitempty"` }
type Snapshot ¶
type Snapshot struct { // SetID is the ID of the snapshot set (a snapshot set is the result of a "snap save" invocation) SetID uint64 `json:"set"` // the time this snapshot's data collection was started Time time.Time `json:"time"` // information about the snap this data is for Snap string `json:"snap"` Revision snap.Revision `json:"revision"` SnapID string `json:"snap-id,omitempty"` Epoch snap.Epoch `json:"epoch,omitempty"` Summary string `json:"summary"` Version string `json:"version"` // the snap's configuration at snapshot time Conf map[string]interface{} `json:"conf,omitempty"` // the hash of the archives' data, keyed by archive path // (either 'archive.tgz' for the system archive, or // user/<username>.tgz for each user) SHA3_384 map[string]string `json:"sha3-384"` // the sum of the archive sizes Size int64 `json:"size,omitempty"` // if the snapshot failed to open this will be the reason why Broken string `json:"broken,omitempty"` // set if the snapshot was created automatically on snap removal; // note, this is only set inside actual snapshot file for old snapshots; // newer snapd just updates this flag on the fly for snapshots // returned by List(). Auto bool `json:"auto,omitempty"` }
A Snapshot is a collection of archives with a simple metadata json file (and hashsums of everything).
func (*Snapshot) ContentHash ¶
ContentHash returns a hash that can be used to identify the snapshot by its content, leaving out metadata like "time" or "set-id".
type SnapshotImportSet ¶
SnapshotImportSet is a snapshot import created by a "snap import-snapshot".
type SnapshotSet ¶
A SnapshotSet is a set of snapshots created by a single "snap save".
func (SnapshotSet) ContentHash ¶
func (ss SnapshotSet) ContentHash() ([]byte, error)
ContentHash returns a hash that can be used to identify the SnapshotSet by its content.
func (SnapshotSet) Size ¶
func (ss SnapshotSet) Size() int64
Size returns the sum of the set's sizes.
func (SnapshotSet) Time ¶
func (ss SnapshotSet) Time() time.Time
Time returns the earliest time in the set.
type StartOptions ¶
type StartOptions struct { // Enable, as well as starting, the listed services. A // disabled service does not start on boot. Enable bool `json:"enable,omitempty"` }
StartOptions represent the different options of the Start call.
type StopOptions ¶
type StopOptions struct { // Disable, as well as stopping, the listed services. A // service that is not disabled starts on boot. Disable bool `json:"disable,omitempty"` }
StopOptions represent the different options of the Stop call.
type SysInfo ¶
type SysInfo struct { Series string `json:"series,omitempty"` Version string `json:"version,omitempty"` BuildID string `json:"build-id"` OSRelease OSRelease `json:"os-release"` OnClassic bool `json:"on-classic"` Managed bool `json:"managed"` KernelVersion string `json:"kernel-version,omitempty"` Architecture string `json:"architecture,omitempty"` Virtualization string `json:"virtualization,omitempty"` Refresh RefreshInfo `json:"refresh,omitempty"` Confinement string `json:"confinement"` SandboxFeatures map[string][]string `json:"sandbox-features,omitempty"` }
SysInfo holds system information
type System ¶
type System struct { // Current is true when the system running now was installed from that // recovery seed Current bool `json:"current,omitempty"` // Label of the recovery system Label string `json:"label,omitempty"` // Model information Model SystemModelData `json:"model,omitempty"` // Brand information Brand snap.StoreAccount `json:"brand,omitempty"` // Actions available for this system Actions []SystemAction `json:"actions,omitempty"` }
type SystemAction ¶
type SystemModelData ¶
type SystemModelData struct { // Model as the model assertion Model string `json:"model,omitempty"` // BrandID corresponds to brand-id in the model assertion BrandID string `json:"brand-id,omitempty"` // DisplayName is human friendly name, corresponds to display-name in // the model assertion DisplayName string `json:"display-name,omitempty"` }
SystemModelData contains information about the model
type Task ¶
type Task struct { ID string `json:"id"` Kind string `json:"kind"` Summary string `json:"summary"` Status string `json:"status"` Log []string `json:"log,omitempty"` Progress TaskProgress `json:"progress"` SpawnTime time.Time `json:"spawn-time,omitempty"` ReadyTime time.Time `json:"ready-time,omitempty"` }
A Task is an operation done to change the system's state.
type TaskProgress ¶
type User ¶
type User struct { ID int `json:"id,omitempty"` Username string `json:"username,omitempty"` Email string `json:"email,omitempty"` Macaroon string `json:"macaroon,omitempty"` Discharges []string `json:"discharges,omitempty"` }
User holds logged in user information.
type ValidateApplyOptions ¶
ValidateApplyOptions carries options for ApplyValidationSet.
type ValidationSetResult ¶
type ValidationSetResult struct { AccountID string `json:"account-id"` Name string `json:"name"` // set sequence key and optional pinned-at (=) Sequence int `json:"sequence,omitempty"` PinnedAt int `json:"pinned-at,omitempty"` // set current state Mode string `json:"mode"` Valid bool `json:"valid"` }
ValidationSetResult holds information about a single validation set.
type Warning ¶
type Warning struct { Message string `json:"message"` FirstAdded time.Time `json:"first-added"` LastAdded time.Time `json:"last-added"` LastShown time.Time `json:"last-shown,omitempty"` ExpireAfter time.Duration `json:"expire-after,omitempty"` RepeatAfter time.Duration `json:"repeat-after,omitempty"` }
A Warning is a short messages that's meant to alert about system events. There'll only ever be one Warning with the same message, and it can be silenced for a while before repeating. After a (supposedly longer) while it'll go away on its own (unless it recurrs).
type WarningsOptions ¶
type WarningsOptions struct {
All bool
}
WarningsOptions contains options for querying snapd for warnings supported options: - All: return all warnings, instead of only the un-okayed ones.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package clientutil offers utilities to turn snap.Info and related structs into client structs and to work with the latter.
|
Package clientutil offers utilities to turn snap.Info and related structs into client structs and to work with the latter. |