client

package
v0.0.0-...-921daf7 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2016 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusNotInstalled = "not installed"
	StatusInstalled    = "installed"
	StatusActive       = "active"
	StatusRemoved      = "removed"

	TypeApp       = "app"
	TypeFramework = "framework"
	TypeKernel    = "kernel"
	TypeGadget    = "gadget"
	TypeOS        = "os"
)

Statuses and types a snap may have.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

A Client knows how to talk to the snappy daemon.

func New

func New(config *Config) *Client

New returns a new instance of Client

func (*Client) ActivateSnap

func (client *Client) ActivateSnap(name string) (string, error)

ActivateSnap activates the snap with the given name, returning the UUID of the background operation upon success.

func (*Client) AddSkill

func (client *Client) AddSkill(skill *Skill) error

AddSkill adds a skill to the system.

func (*Client) AddSlot

func (client *Client) AddSlot(slot *Slot) error

AddSlot adds a slot to the system.

func (*Client) AddSnap

func (client *Client) AddSnap(name string) (string, error)

AddSnap adds the snap with the given name, returning the UUID of the background operation upon success.

func (*Client) AllSkills

func (client *Client) AllSkills() (grants []SkillGrants, err error)

AllSkills returns information about all the skills and their grants.

func (*Client) Assert

func (client *Client) Assert(b []byte) error

Assert 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) Asserts

func (client *Client) Asserts(assertTypeName string, headers map[string]string) ([]asserts.Assertion, error)

Asserts queries assertions with type assertTypeName and matching assertion headers.

func (*Client) DeactivateSnap

func (client *Client) DeactivateSnap(name string) (string, error)

DeactivateSnap deactivates the snap with the given name, returning the UUID of the background operation upon success.

func (*Client) FilterSnaps

func (client *Client) FilterSnaps(filter SnapFilter) (map[string]*Snap, error)

FilterSnaps returns a list of snaps per Snaps() but filtered by source, name and/or type

func (*Client) Grant

func (client *Client) Grant(skillSnapName, skillName, slotSnapName, slotName string) error

Grant grants the named skill to the named slot of the given snap. The skill and the slot must have the same type.

func (*Client) Icon

func (c *Client) Icon(pkgID string) (*Icon, error)

Icon returns the Icon belonging to an installed snap

func (*Client) Operation

func (client *Client) Operation(uuid string) (Operation, error)

Operation fetches information about an operation given its UUID

func (*Client) PurgeSnap

func (client *Client) PurgeSnap(name string) (string, error)

PurgeSnap purges the snap with the given name, returning the UUID of the background operation upon success.

TODO: nuke purge, when we have snapshots/backups done

func (*Client) RefreshSnap

func (client *Client) RefreshSnap(name string) (string, error)

RefreshSnap refreshes the snap with the given name, returning the UUID of the background operation upon success.

func (*Client) RemoveSkill

func (client *Client) RemoveSkill(snapName, skillName string) error

RemoveSkill removes a skill from the system.

func (*Client) RemoveSlot

func (client *Client) RemoveSlot(snapName, slotName string) error

RemoveSlot removes a slot from the system.

func (*Client) RemoveSnap

func (client *Client) RemoveSnap(name string) (string, error)

RemoveSnap removes the snap with the given name, returning the UUID of the background operation upon success.

func (*Client) Revoke

func (client *Client) Revoke(skillSnapName, skillName, slotSnapName, slotName string) error

Revoke revokes the named skill from the slot of the given snap.

func (*Client) RollbackSnap

func (client *Client) RollbackSnap(name string) (string, error)

RollbackSnap rolls back the snap with the given name, returning the UUID of the background operation upon success.

func (*Client) Services

func (client *Client) Services(pkg string) (map[string]*Service, error)

Services returns the list of services belonging to an *active* Snap

func (*Client) Snap

func (client *Client) Snap(name string) (*Snap, error)

Snap returns the most recently published revision of the snap with the provided name.

func (*Client) Snaps

func (client *Client) Snaps() (map[string]*Snap, error)

Snaps returns the list of all snaps installed on the system and available for install from the store for this system.

func (*Client) SysInfo

func (client *Client) SysInfo() (*SysInfo, error)

SysInfo gets system information from the REST API.

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 Icon

type Icon struct {
	Filename string
	Content  []byte
}

Icon represents the icon of an installed snap

type Operation

type Operation interface {
	Running() bool
	Err() error
}

An Operation provides information about an asynchronous daemon operation

type Service

type Service struct {
	Op     string        `json:"op"`
	Spec   ServiceSpec   `json:"spec"`
	Status ServiceStatus `json:"status"`
}

Service represents a service belonging to a Snap

type ServicePort

type ServicePort struct {
	Port       string `json:",omitempty"`
	Negotiable bool   `json:",omitempty"`
}

ServicePort is a port a Service may listen on

type ServicePorts

type ServicePorts struct {
	Internal map[string]ServicePort `json:"internal,omitempty"`
	External map[string]ServicePort `json:"external,omitempty"`
}

ServicePorts are the collection of internal and external ports the Service may listen on

type ServiceSpec

type ServiceSpec struct {
	Name        string       `json:"name"`
	Description string       `json:"description,omitempty"`
	Start       string       `json:"start,omitempty"`
	StopTimeout string       `json:"stop-timeout,omitempty"`
	Ports       ServicePorts `json:"ports,omitempty"`
}

ServiceSpec represents the Service specification

type ServiceStatus

type ServiceStatus struct {
	ServiceFileName string `json:"service_file_name"`
	LoadState       string `json:"load_state"`
	ActiveState     string `json:"active_state"`
	SubState        string `json:"sub_state"`
	UnitFileState   string `json:"unit_file_state"`
	SnapName        string `json:"snap_name"`
	ServiceName     string `json:"service_name"`
}

ServiceStatus represents the status of a Service

type Skill

type Skill struct {
	Name  string                 `json:"name"`
	Snap  string                 `json:"snap"`
	Type  string                 `json:"type,omitempty"`
	Attrs map[string]interface{} `json:"attrs,omitempty"`
	Apps  []string               `json:"apps,omitempty"`
	Label string                 `json:"label,omitempty"`
}

Skill represents a capacity offered by a snap.

type SkillAction

type SkillAction struct {
	Action string `json:"action"`
	Skill  *Skill `json:"skill,omitempty"`
	Slot   *Slot  `json:"slot,omitempty"`
}

SkillAction represents an action performed on the skill system.

type SkillGrants

type SkillGrants struct {
	Skill
	GrantedTo []Slot `json:"granted_to"`
}

SkillGrants represents a single skill and slots that are using it.

type Slot

type Slot struct {
	Name  string                 `json:"name"`
	Snap  string                 `json:"snap"`
	Type  string                 `json:"type,omitempty"`
	Attrs map[string]interface{} `json:"attrs,omitempty"`
	Apps  []string               `json:"apps,omitempty"`
	Label string                 `json:"label,omitempty"`
}

Slot represents the potential of a given snap to use a skill.

type Snap

type Snap struct {
	Description   string `json:"description"`
	DownloadSize  int64  `json:"download_size"`
	Icon          string `json:"icon"`
	InstalledSize int64  `json:"installed_size"`
	Name          string `json:"name"`
	Origin        string `json:"origin"`
	Status        string `json:"status"`
	Type          string `json:"type"`
	Version       string `json:"version"`
}

Snap holds the data for a snap as obtained from snapd.

type SnapFilter

type SnapFilter struct {
	Sources []string
	Types   []string
	Query   string
}

SnapFilter is used to filter snaps by source, name and/or type

type SysInfo

type SysInfo struct {
	Flavor           string `json:"flavor"`
	Release          string `json:"release"`
	DefaultChannel   string `json:"default_channel"`
	APICompatibility string `json:"api_compat"`
	Store            string `json:"store,omitempty"`
}

SysInfo holds system information

Jump to

Keyboard shortcuts

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