Documentation ¶
Index ¶
- Constants
- Variables
- func IsTwoFactorError(err error) bool
- type AppInfo
- 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) Change(id string) (*Change, error)
- func (client *Client) Changes(opts *ChangesOptions) ([]*Change, error)
- func (client *Client) Connect(plugSnapName, plugName, slotSnapName, slotName string) (changeID string, err error)
- func (client *Client) Disconnect(plugSnapName, plugName, slotSnapName, slotName string) (changeID string, err error)
- func (client *Client) Find(opts *FindOptions) ([]*Snap, *ResultInfo, error)
- func (c *Client) Icon(pkgID string) (*Icon, error)
- func (client *Client) Install(name string, options *SnapOptions) (changeID string, err error)
- func (client *Client) InstallPath(path string, options *SnapOptions) (changeID string, err error)
- func (client *Client) Interfaces() (interfaces Interfaces, err error)
- func (client *Client) Known(assertTypeName string, headers map[string]string) ([]asserts.Assertion, error)
- func (client *Client) List(names []string) ([]*Snap, error)
- func (client *Client) LoggedIn() bool
- func (client *Client) Login(username, password, otp string) (*User, error)
- func (client *Client) Logout() error
- func (client *Client) Refresh(name string, options *SnapOptions) (changeID string, err error)
- func (client *Client) Remove(name string, options *SnapOptions) (changeID string, err error)
- func (client *Client) ServerVersion() (string, error)
- func (client *Client) Snap(name string) (*Snap, *ResultInfo, error)
- func (client *Client) SysInfo() (*SysInfo, error)
- func (client *Client) Try(path string, options *SnapOptions) (changeID string, err error)
- type Config
- type Error
- type FindOptions
- type Icon
- type InterfaceAction
- type Interfaces
- type Plug
- type PlugRef
- type ResultInfo
- type Slot
- type SlotRef
- type Snap
- type SnapOptions
- type SysInfo
- type Task
- type TaskProgress
- type User
Constants ¶
const ( ErrorKindTwoFactorRequired = "two-factor-required" ErrorKindTwoFactorFailed = "two-factor-failed" ErrorKindLoginRequired = "login-required" )
const ( StatusAvailable = "available" StatusInstalled = "installed" StatusActive = "active" StatusRemoved = "removed" TypeApp = "app" TypeKernel = "kernel" TypeGadget = "gadget" TypeOS = "os" StrictConfinement = "strict" DevmodeConfinement = "devmode" )
Statuses and types a snap may have.
Variables ¶
var ErrNoData = fmt.Errorf("data entry not found")
Functions ¶
func IsTwoFactorError ¶
IsTwoFactorError returns whether the given error is due to problems in two-factor authentication.
Types ¶
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) 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) Disconnect ¶
func (client *Client) Disconnect(plugSnapName, plugName, slotSnapName, slotName string) (changeID string, err error)
Disconnect breaks the connection between a plug and a slot.
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) 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) InstallPath ¶
func (client *Client) InstallPath(path string, options *SnapOptions) (changeID string, err error)
InstallPath sideloads the snap with the given path, returning the UUID of the background operation upon success.
func (*Client) Interfaces ¶
func (client *Client) Interfaces() (interfaces Interfaces, err error)
Interfaces returns all plugs, slots and their connections.
func (*Client) Known ¶
func (client *Client) Known(assertTypeName string, headers map[string]string) ([]asserts.Assertion, error)
Known queries assertions with type assertTypeName and matching assertion headers.
func (*Client) List ¶
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) 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) Remove ¶
func (client *Client) Remove(name string, options *SnapOptions) (changeID string, err error)
Remove removes the snap with the given name.
func (*Client) ServerVersion ¶
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.
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 }
Config allows to customize client behavior.
type FindOptions ¶
FindOptions supports exactly one of the following options: - Refresh: only return snaps that are refreshable - Query: only return snaps that match the query string
type InterfaceAction ¶
type InterfaceAction struct { Action string `json:"action"` Plugs []Plug `json:"plugs,omitempty"` Slots []Slot `json:"slots,omitempty"` }
InterfaceAction represents an action performed on the interface system.
type Interfaces ¶
Interfaces contains information about all plugs, slots and their connections
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 ResultInfo ¶
type ResultInfo struct {
SuggestedCurrency string `json:"suggested-currency"`
}
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"` Summary string `json:"summary"` Description string `json:"description"` DownloadSize int64 `json:"download-size"` Icon string `json:"icon"` InstalledSize int64 `json:"installed-size"` InstallDate time.Time `json:"install-date"` Name string `json:"name"` Developer string `json:"developer"` Status string `json:"status"` Type string `json:"type"` Version string `json:"version"` Channel string `json:"channel"` Revision snap.Revision `json:"revision"` Confinement string `json:"confinement"` Private bool `json:"private"` DevMode bool `json:"devmode"` TryMode bool `json:"trymode"` Apps []AppInfo `json:"apps"` Prices map[string]float64 `json:"prices"` }
Snap holds the data for a snap as obtained from snapd.
type SnapOptions ¶
type SysInfo ¶
type SysInfo struct { Series string `json:"series,omitempty"` Version string `json:"version,omitempty"` }
SysInfo holds system information
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.