tasks

package
v0.53.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// TasksPath The endpoint for retrieving tasks
	TasksPath = "/api/cis/tasks"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Info added in v0.53.0

type Info struct {
	// Description of the operation associated with the task.
	Description rest.LocalizableMessage `json:"description"`

	// Service is the identifier of the service containing the operation.
	Service string `json:"service"`

	// Operation is the identifier of the operation associated with the task.
	Operation string `json:"operation"`

	// Parent of the current task.
	//
	// This field will be unset if the task has no parent.
	Parent *string `json:"parent,omitempty"`

	// Target is the identifier of the target created by the operation or an existing one
	// the operation performed on.
	//
	// This field will be unset if the operation has no target or multiple targets.
	Target map[string]string `json:"target,omitempty"`

	// Status of the operation associated with the task.
	Status Status `json:"status"`

	// Cancelable is a flag to indicate whether or not the operation can be cancelled.
	// The value may change as the operation progresses.
	Cancelable bool `json:"cancelable"`

	// Error is the description of the error if the operation status is "FAILED".
	//
	// If unset the description of why the operation failed will be included in the result of the operation
	// (see Info.Result).
	Error rest.Error `json:"error,omitempty"`

	// Start is the time when the operation is started.
	Start *time.Time `json:"start_time,omitempty"`

	// End is the time when the operation is completed.
	End *time.Time `json:"end_time,omitempty"`

	// User is the name of the user who performed the operation.
	//
	// This field will be unset if the operation is performed by the system.
	User *string `json:"user,omitempty"`

	// Progress of the operation.
	Progress Progress `json:"progress"`

	// Result of the operation.
	//
	// If an operation reports partial results before it completes, this
	// field could be set before the Status has the value SUCCEEDED. The value could change as the
	// operation progresses.
	//
	// This field will be unset if the operation does not return a result or if the result is not available
	// at the current step of the operation.
	Result json.RawMessage `json:"result,omitempty"`
}

Info contains information about a task.

func (*Info) Err added in v0.53.0

func (t *Info) Err() error

Err returns an error if the task state is Failed.

func (*Info) IsDone added in v0.53.0

func (t *Info) IsDone() bool

type Manager

type Manager struct {
	*rest.Client
	// contains filtered or unexported fields
}

Manager extends rest.Client, adding task related methods.

func NewManager

func NewManager(client *rest.Client) *Manager

NewManager creates a new Manager instance with the given client.

func NewManagerWithCustomInterval

func NewManagerWithCustomInterval(client *rest.Client, pollingInterval int) *Manager

NewManager creates a new Manager instance with the given client and custom polling interval

func (*Manager) Get added in v0.53.0

func (c *Manager) Get(ctx context.Context, taskId string) (*Info, error)

func (*Manager) WaitForCompletion

func (c *Manager) WaitForCompletion(ctx context.Context, taskId string) (*Info, error)

WaitForCompletion will wait for the task status to be in anything but the Pending or Running state.

func (*Manager) WaitForRunningOrError added in v0.53.0

func (c *Manager) WaitForRunningOrError(ctx context.Context, taskId string) (*Info, error)

WaitForRunningOrError will wait for the task status to be Running or Failed. If the task has failed, it will return the TaskInfo Error field as an error.

type Progress added in v0.53.0

type Progress struct {
	// Total is the total amount of work for the operation.
	Total uint64 `json:"total"`

	// Completed is the amount of work completed for the operation. The value can only be incremented.
	Completed uint64 `json:"completed"`

	// Message about the work progress.
	Message *rest.LocalizableMessage `json:"message,omitempty"`
}

Progress contains information describing the progress of an operation.

type Status added in v0.53.0

type Status string

Status defines the status values that can be reported for an operation.

const (

	// Pending indicates the operation is in pending state.
	Pending Status = "PENDING"

	// Running indicates the operation is in progress.
	Running Status = "RUNNING"

	// Blocked indicates the operation is blocked.
	Blocked Status = "BLOCKED"

	// Succeeded indicates the operation completed successfully.
	Succeeded Status = "SUCCEEDED"

	// Failed indicates the operation failed.
	Failed Status = "FAILED"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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