snapdapi

package
v0.0.0-...-99fe3a6 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionDevice

type ActionDevice struct {
	Brand        string `json:"brand"`
	Model        string `json:"model"`
	SerialNumber string `json:"serial"`
	StoreID      string `json:"store"`
	DeviceKey    string `json:"deviceKey"`
}

ActionDevice has basic information of a device

type ClientAdapter

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

ClientAdapter adapts our expectations to the snapd client API.

func NewClientAdapter

func NewClientAdapter() *ClientAdapter

NewClientAdapter creates a new ClientAdapter as a singleton

func (*ClientAdapter) Ack

func (a *ClientAdapter) Ack(b []byte) error

Ack adds a new assertion to the system

func (*ClientAdapter) Apps

func (a *ClientAdapter) Apps(names []string, opts *client.AppOptions) ([]*client.AppInfo, error)

func (*ClientAdapter) Change

func (a *ClientAdapter) Change(id string) (*client.Change, error)

func (*ClientAdapter) Changes

func (a *ClientAdapter) Changes(opts *client.ChangesOptions) ([]*client.Change, error)

func (*ClientAdapter) Conf

func (a *ClientAdapter) Conf(name string) (map[string]interface{}, error)

Conf gets the snap's current configuration

func (*ClientAdapter) CreateUser

func (*ClientAdapter) DeviceInfo

func (a *ClientAdapter) DeviceInfo() (ActionDevice, error)

DeviceInfo fetches the basic details of the device

func (*ClientAdapter) Disable

func (a *ClientAdapter) Disable(name string, options *client.SnapOptions) (string, error)

Disable deactivates the snap with the given name.

func (*ClientAdapter) Enable

func (a *ClientAdapter) Enable(name string, options *client.SnapOptions) (string, error)

Enable activates the snap with the given name.

func (*ClientAdapter) GetEncodedAssertions

func (a *ClientAdapter) GetEncodedAssertions(assertionType string) ([]byte, error)

GetEncodedAssertions fetches the encoded model and serial assertions

func (*ClientAdapter) Install

func (a *ClientAdapter) Install(name string, options *client.SnapOptions) (string, error)

Install adds the snap with the given name from the given channel (or the system default channel if not).

func (*ClientAdapter) Known

func (a *ClientAdapter) Known(assertTypeName string, headers map[string]string) ([]asserts.Assertion, error)

Known queries assertions with type assertTypeName and matching assertion headers.

func (*ClientAdapter) List

func (a *ClientAdapter) List(names []string, opts *client.ListOptions) ([]*client.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 (*ClientAdapter) Logs

func (a *ClientAdapter) Logs(opts client.LogOptions) (<-chan client.Log, error)

Logs requests syslog logs from the snapd api

func (*ClientAdapter) Refresh

func (a *ClientAdapter) Refresh(name string, options *client.SnapOptions) (string, error)

Refresh updates the snap with the given name from the given channel (or the system default channel if not).

func (*ClientAdapter) Remove

func (a *ClientAdapter) Remove(name string, options *client.SnapOptions) (string, error)

Remove removes the snap with the given name.

func (*ClientAdapter) RemoveUser

func (a *ClientAdapter) RemoveUser(opts *client.RemoveUserOptions) ([]*client.User, error)

func (*ClientAdapter) Restart

func (a *ClientAdapter) Restart(names []string, opts client.RestartOptions) (changeID string, err error)

func (*ClientAdapter) Revert

func (a *ClientAdapter) Revert(name string, options *client.SnapOptions) (string, error)

Revert rolls the snap back to the previous on-disk state

func (*ClientAdapter) ServerVersion

func (a *ClientAdapter) ServerVersion() (*client.ServerVersion, error)

ServerVersion returns information about the snapd server.

func (*ClientAdapter) SetConf

func (a *ClientAdapter) SetConf(name string, patch map[string]interface{}) (string, error)

SetConf requests a snap to apply the provided patch to the configuration

func (*ClientAdapter) Snap

func (a *ClientAdapter) Snap(name string) (*client.Snap, *client.ResultInfo, error)

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

func (*ClientAdapter) Snaps

func (a *ClientAdapter) Snaps() ([]*client.Snap, error)

func (*ClientAdapter) SnapshotExport

func (a *ClientAdapter) SnapshotExport(setID uint64) (stream io.ReadCloser, contentLength int64, err error)

SnapshotExport returns an archive data stream of the Snapshot set created by the SnapshotMany function

func (*ClientAdapter) SnapshotMany

func (a *ClientAdapter) SnapshotMany(names []string, users []string) (setID uint64, changeID string, err error)

SnapshotMany creates snapshots of the provided snaps under the provided users. If an array is empty, it will take a snapshot of all snaps with users (or both)

func (*ClientAdapter) Start

func (a *ClientAdapter) Start(names []string, opts client.StartOptions) (changeID string, err error)

func (*ClientAdapter) Stop

func (a *ClientAdapter) Stop(names []string, opts client.StopOptions) (changeID string, err error)

func (*ClientAdapter) Switch

func (a *ClientAdapter) Switch(name string, options *client.SnapOptions) (string, error)

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type SnapdClient

type SnapdClient interface {
	Apps(names []string, opts *client.AppOptions) ([]*client.AppInfo, error)
	Start(names []string, opts client.StartOptions) (changeID string, err error)
	Stop(names []string, opts client.StopOptions) (changeID string, err error)
	Restart(names []string, opts client.RestartOptions) (changeID string, err error)
	Snap(name string) (*client.Snap, *client.ResultInfo, error)
	List(names []string, opts *client.ListOptions) ([]*client.Snap, error)
	Install(name string, options *client.SnapOptions) (string, error)
	Refresh(name string, options *client.SnapOptions) (string, error)
	Revert(name string, options *client.SnapOptions) (string, error)
	Remove(name string, options *client.SnapOptions) (string, error)
	Enable(name string, options *client.SnapOptions) (string, error)
	Disable(name string, options *client.SnapOptions) (string, error)
	ServerVersion() (*client.ServerVersion, error)
	Ack(b []byte) error
	Known(assertTypeName string, headers map[string]string) ([]asserts.Assertion, error)
	Conf(name string) (map[string]interface{}, error)
	SetConf(name string, patch map[string]interface{}) (string, error)
	GetEncodedAssertions(assertionType string) ([]byte, error)
	DeviceInfo() (ActionDevice, error)
	Snaps() ([]*client.Snap, error)
	Switch(name string, options *client.SnapOptions) (string, error)
	Logs(opts client.LogOptions) (<-chan client.Log, error)
	SnapshotMany(names []string, users []string) (setID uint64, changeID string, err error)
	SnapshotExport(setID uint64) (stream io.ReadCloser, contentLength int64, err error)
	CreateUser(opts *client.CreateUserOptions) (*client.CreateUserResult, error)
	RemoveUser(opts *client.RemoveUserOptions) ([]*client.User, error)
	Changes(opts *client.ChangesOptions) ([]*client.Change, error)
	Change(id string) (*client.Change, error)
}

SnapdClient is a client of the snapd REST API

Jump to

Keyboard shortcuts

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