Documentation
¶
Index ¶
- Constants
- func IsErrorCode(err error, appCode string) bool
- func IsTerminalOperationState(state string) bool
- func Run(_ config.Configuration, ...) error
- func RunAction(_ config.Configuration, _ string) error
- func ServiceStatus(_ config.Configuration) (string, error)
- type AcceptedOperation
- type Client
- func (c *Client) CancelOperation(ctx context.Context, operationID string) error
- func (c *Client) GetBranding(ctx context.Context) (branding.Branding, error)
- func (c *Client) GetServiceInfo(ctx context.Context) (ServiceInfo, error)
- func (c *Client) InstallItem(ctx context.Context, itemName string) (AcceptedOperation, error)
- func (c *Client) ListOptionalInstalls(ctx context.Context) ([]OptionalInstallItem, error)
- func (c *Client) RemoveItem(ctx context.Context, itemName string) (AcceptedOperation, error)
- func (c *Client) StreamOperationStatus(ctx context.Context, operationID string, callback func(OperationStatus) error) error
- type Command
- type CommandResponse
- type Error
- type ErrorData
- type OperationStatus
- type OptionalInstallItem
- type ServiceInfo
Constants ¶
const DefaultPipeName = "sofcat-service"
Variables ¶
This section is empty.
Functions ¶
func IsErrorCode ¶
IsErrorCode reports whether err is a service error with data.code appCode.
func Run ¶
func Run(_ config.Configuration, _ func(config.Configuration, installer.ProgressFn, *installer.Cancels) (*report.Report, error)) error
func ServiceStatus ¶
func ServiceStatus(_ config.Configuration) (string, error)
Types ¶
type AcceptedOperation ¶
type AcceptedOperation struct {
OperationID string `json:"operationId,omitempty"`
Accepted bool `json:"accepted"`
QueuedAtUTC string `json:"queuedAtUtc"`
// RequestedBy is the user who called, as the service resolved it from the
// connection: DOMAIN\user on Windows, "" when unresolved.
RequestedBy string `json:"requestedBy"`
}
type Client ¶
Client is the typed SofCat service client shared by command-line and UI callers. Timeouts default to five seconds for connecting and 30 seconds for ordinary responses and stream acknowledgements.
func (*Client) CancelOperation ¶
CancelOperation asks the service to cancel operationID. The service refuses with operation_not_cancelable once the item's install or removal has started, the operation has finished, or the operation is unknown.
func (*Client) GetBranding ¶
GetBranding returns the organisation branding the service resolved from policy and config. Unset fields are empty strings.
func (*Client) GetServiceInfo ¶
func (c *Client) GetServiceInfo(ctx context.Context) (ServiceInfo, error)
GetServiceInfo returns the service's version, protocol and capabilities, and whether a managed run is under way.
func (*Client) InstallItem ¶
func (*Client) ListOptionalInstalls ¶
func (c *Client) ListOptionalInstalls(ctx context.Context) ([]OptionalInstallItem, error)
func (*Client) RemoveItem ¶
func (*Client) StreamOperationStatus ¶
func (c *Client) StreamOperationStatus(ctx context.Context, operationID string, callback func(OperationStatus) error) error
StreamOperationStatus calls callback with each of operationID's status records, from the first, until the terminal one.
type CommandResponse ¶
type CommandResponse struct {
Status string `json:"status"`
Message string `json:"message,omitempty"`
Items []string `json:"items,omitempty"`
OptionalItems []OptionalInstallItem `json:"optionalItems,omitempty"`
OperationID string `json:"operationId,omitempty"`
RequestedBy string `json:"requestedBy,omitempty"`
Branding *branding.Branding `json:"branding,omitempty"`
// contains filtered or unexported fields
}
func SendCommand ¶
func SendCommand(cfg config.Configuration, spec string) (CommandResponse, error)
type Error ¶
type Error struct {
Code int `json:"code"`
Message string `json:"message"`
Data ErrorData `json:"data"`
}
Error is a JSON-RPC error object from the service. Data.Code is the stable application code (operation_not_cancelable, server_busy, ...).
type OperationStatus ¶
type OperationStatus struct {
OperationID string `json:"operationId"`
Seq int `json:"seq"`
TimestampUTC string `json:"timestampUtc"`
ItemName string `json:"itemName"`
DisplayName string `json:"displayName"`
State string `json:"state"`
ProgressPercent int `json:"progressPercent"`
Message string `json:"message"`
ErrorCode string `json:"errorCode,omitempty"`
ErrorMessage string `json:"errorMessage,omitempty"`
CanceledBy string `json:"canceledBy,omitempty"`
RequestedBy string `json:"requestedBy"`
}
OperationStatus is one status record, the params of an operationStatus notification. Seq numbers an operation's records from 1 in the order the service recorded them, so a client can order records that arrive out of order. RequestedBy is the user whose request started the operation, "" when the service could not resolve it. ProgressPercent is scoped to ItemName and may reset when the item changes; it is not aggregate operation progress. Only Succeeded, Failed, Deferred, and Canceled end an operation.
type OptionalInstallItem ¶
type OptionalInstallItem struct {
ItemName string `json:"itemName"`
DisplayName string `json:"displayName"`
Version string `json:"version"`
Catalog string `json:"catalog"`
Description string `json:"description,omitempty"`
Category string `json:"category,omitempty"`
Developer string `json:"developer,omitempty"`
IconName string `json:"iconName,omitempty"`
RestartAction string `json:"restartAction,omitempty"`
IsManaged bool `json:"isManaged"`
IsRequired bool `json:"isRequired"`
IsInstalled bool `json:"isInstalled"`
Status string `json:"status"`
StatusUpdatedAtUTC string `json:"statusUpdatedAtUtc"`
LastOperationID string `json:"lastOperationId,omitempty"`
}
OptionalInstallItem is one offered self-service item. IsRequired is whether an admin manifest also lists it in managed_installs: it is installed for everyone and cannot be removed through self-service.
type ServiceInfo ¶
type ServiceInfo struct {
Version string `json:"version"`
ProtocolVersion string `json:"protocolVersion"`
APIVersion int `json:"apiVersion"`
Capabilities []string `json:"capabilities"`
Busy bool `json:"busy"`
UptimeSeconds int64 `json:"uptimeSeconds"`
}
ServiceInfo is getServiceInfo's result. It skips the command queue, so it doubles as a cheap health check.