client

package
v0.0.0-...-554ba31 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: GPL-3.0 Imports: 15 Imported by: 28

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func New

func New() *Client

func NewForUids

func NewForUids(uids ...int) *Client

NewForUids creates a Client that sends requests to a specific list of uids only.

func (*Client) FinishRefreshNotification

func (client *Client) FinishRefreshNotification(ctx context.Context, closeInfo *FinishedSnapRefreshInfo) error

FinishRefreshNotification closes notification about a snap refresh.

func (*Client) PendingRefreshNotification

func (client *Client) PendingRefreshNotification(ctx context.Context, refreshInfo *PendingSnapRefreshInfo) error

PendingRefreshNotification broadcasts information about a refresh.

func (*Client) ServiceStatus

func (client *Client) ServiceStatus(ctx context.Context, services []string) (map[int][]ServiceUnitStatus, map[int][]ServiceFailure, error)

func (*Client) ServicesDaemonReload

func (client *Client) ServicesDaemonReload(ctx context.Context) error

func (*Client) ServicesRestart

func (client *Client) ServicesRestart(ctx context.Context, services []string, reload bool) (restartFailures []ServiceFailure, err error)

ServicesRestart attempts to restart or reload active services in `services`. If the reload flag is set then "systemctl reload-or-restart" is attempted.

func (*Client) ServicesStart

func (client *Client) ServicesStart(ctx context.Context, services []string, opts ClientServicesStartOptions) (startFailures, stopFailures []ServiceFailure, err error)

ServicesStop attempts to start the services in `services`. If the enable flag is provided, then services listed will also be enabled. If the map of disabled services is set, then on a per-uid basis the services listed in `services` can be filtered out.

func (*Client) ServicesStop

func (client *Client) ServicesStop(ctx context.Context, services []string, disable bool) (stopFailures []ServiceFailure, err error)

ServicesStop attempts to stop the services in `services`. If the disable flag is set then the services listed also will be disabled.

func (*Client) SessionInfo

func (client *Client) SessionInfo(ctx context.Context) (info map[int]SessionInfo, err error)

type ClientServicesStartOptions

type ClientServicesStartOptions struct {
	// Enable determines whether the service should be enabled before
	// its being started.
	Enable bool
	// DisabledServices is a list of services per-uid that can be provided
	// which will then be ignored for the start or enable operation.
	DisabledServices map[int][]string
}

type Error

type Error struct {
	Kind    string      `json:"kind"`
	Value   interface{} `json:"value"`
	Message string      `json:"message"`
}

func (*Error) Error

func (e *Error) Error() string

type FinishedSnapRefreshInfo

type FinishedSnapRefreshInfo struct {
	InstanceName string `json:"instance-name"`
}

FinishedSnapRefreshInfo holds information about a finished refresh provided to userd.

type PendingSnapRefreshInfo

type PendingSnapRefreshInfo struct {
	InstanceName        string        `json:"instance-name"`
	TimeRemaining       time.Duration `json:"time-remaining,omitempty"`
	BusyAppName         string        `json:"busy-app-name,omitempty"`
	BusyAppDesktopEntry string        `json:"busy-app-desktop-entry,omitempty"`
}

PendingSnapRefreshInfo holds information about pending snap refresh provided to userd.

type ServiceFailure

type ServiceFailure struct {
	Uid     int
	Service string
	Error   string
}

type ServiceInstruction

type ServiceInstruction struct {
	Action   string   `json:"action"`
	Services []string `json:"services,omitempty"`

	// StartServices options
	Enable bool `json:"enable,omitempty"`

	// StopServices options
	Disable bool `json:"disable,omitempty"`

	// RestartServices options
	Reload bool `json:"reload,omitempty"`
}

ServiceInstruction is the json representation of possible arguments for the user session rest api to control services. Arguments allowed for start/stop/restart are all listed here, and closely reflect possible arguments for similar options in the wrappers package.

type ServiceUnitStatus

type ServiceUnitStatus struct {
	Daemon           string   `json:"daemon"`
	Id               string   `json:"id"`
	Name             string   `json:"name"`
	Names            []string `json:"names"`
	Enabled          bool     `json:"enabled"`
	Active           bool     `json:"active"`
	Installed        bool     `json:"installed"`
	NeedDaemonReload bool     `json:"needs-reload"`
}

ServiceUnitStatus is a JSON encoding representing systemd.UnitStatus for a user service.

func (*ServiceUnitStatus) SystemdUnitStatus

func (us *ServiceUnitStatus) SystemdUnitStatus() *systemd.UnitStatus

type SessionInfo

type SessionInfo struct {
	Version string `json:"version"`
}

Jump to

Keyboard shortcuts

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