tasks

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2025 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TaskStateNew      = TaskState("NEW")
	TaskStateRunning  = TaskState("RUNNING")
	TaskStateFinished = TaskState("FINISHED")
	TaskStateError    = TaskState("ERROR")

	TaskSortingOldFirst   = TaskOrderByChoices("asc")
	TaskSortingToNewFirst = TaskOrderByChoices("desc")
)

Variables

This section is empty.

Functions

func ExtractTasksInto

func ExtractTasksInto(r pagination.Page, v interface{}) error

func List deprecated

List returns a Pager which allows you to iterate over a collection of active tasks.

Deprecated: Use ListActive for getting the active tasks or ListWithOpts for greater filtering flexibility.

func ListActive added in v0.13.0

ListActive returns a Pager which allows you to iterate over a collection of active tasks.

func ListWithOpts added in v0.13.0

ListWithOpts returns a Pager which allows you to iterate over a collection of tasks. It accepts a ListOpts struct, which allows you to filter and sort the returned collection for greater efficiency.

func WaitForStatus

func WaitForStatus(client *gcorecloud.ServiceClient, id string, status TaskState, secs int, stopOnTaskError bool) error

WaitForStatus will continually poll the task resource, checking for a particular status. It will do this for the amount of seconds defined.

func WaitTaskAndProcessResult

func WaitTaskAndProcessResult(
	client *gcorecloud.ServiceClient, task TaskID, stopOnTaskError bool, waitSeconds int, taskProcessor CheckTaskResult) error

WaitTaskAndProcessResult periodically check status state and invoke taskProcessor when when task is finished

func WaitTaskAndReturnResult

func WaitTaskAndReturnResult(
	client *gcorecloud.ServiceClient, task TaskID, stopOnTaskError bool,
	waitSeconds int, taskProcessor RetrieveTaskResult) (interface{}, error)

WaitTaskAndReturnResult periodically check status state and return changed object when task is finished

Types

type CheckTaskResult

type CheckTaskResult func(task TaskID) error

type CreateResult

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

CreateResult represents the result of a create operation. Call its Extract method to interpret it as a Network.

func (CreateResult) Extract

func (r CreateResult) Extract() (*Task, error)

Extract is a function that accepts a result and extracts a task resource.

func (CreateResult) ExtractInto

func (r CreateResult) ExtractInto(v interface{}) error

type DeleteResult

type DeleteResult struct {
	gcorecloud.ErrResult
}

DeleteResult represents the result of a delete operation. Call its ExtractErr method to determine if the request succeeded or failed.

type GetResult

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

GetResult represents the result of a get operation. Call its Extract method to interpret it as a Network.

func Get

func Get(c *gcorecloud.ServiceClient, id string) (r GetResult)

Get retrieves a specific cluster template based on its unique ID.

func (GetResult) Extract

func (r GetResult) Extract() (*Task, error)

Extract is a function that accepts a result and extracts a task resource.

func (GetResult) ExtractInto

func (r GetResult) ExtractInto(v interface{}) error

type ListOpts added in v0.13.0

type ListOpts struct {
	ProjectID     *int                `q:"project_id"`
	State         []TaskState         `q:"state"`
	TaskType      *string             `q:"task_type"`
	Sorting       *TaskOrderByChoices `q:"sorting"`
	FromTimestamp *string             `q:"from_timestamp"`
}

ListOpts allows the filtering and sorting List API response.

func (ListOpts) ToTaskListQuery added in v0.13.0

func (opts ListOpts) ToTaskListQuery() (string, error)

ToTaskListQuery formats a ListOpts into a query string.

type ListOptsBuilder added in v0.13.0

type ListOptsBuilder interface {
	ToTaskListQuery() (string, error)
}

ListOptsBuilder allows extensions to add additional parameters to the List request.

type Result

type Result struct {
	gcorecloud.Result
}

Result represents the operation result that returns tasks

func (Result) Extract

func (r Result) Extract() (*TaskResults, error)

Extract is a function that accepts a result and extracts a task resource.

type RetrieveTaskResult

type RetrieveTaskResult func(task TaskID) (interface{}, error)

type Task

type Task struct {
	ID               string                     `json:"id"`
	TaskType         string                     `json:"task_type"`
	ProjectID        int                        `json:"project_id,omitempty"`
	ClientID         int                        `json:"client_id"`
	RegionID         *int                       `json:"region_id"`
	UserID           int                        `json:"user_id"`
	UserClientID     int                        `json:"user_client_id"`
	State            TaskState                  `json:"state"`
	CreatedOn        gcorecloud.JSONRFC3339NoZ  `json:"created_on"`
	UpdatedOn        *gcorecloud.JSONRFC3339NoZ `json:"updated_on"`
	FinishedOn       *gcorecloud.JSONRFC3339NoZ `json:"finished_on"`
	AcknowledgedAt   *gcorecloud.JSONRFC3339NoZ `json:"acknowledged_at"`
	AcknowledgedBy   *int                       `json:"acknowledged_by"`
	CreatedResources *map[string]interface{}    `json:"created_resources"`
	RequestID        *string                    `json:"request_id"`
	Error            *string                    `json:"error"`
	Data             *map[string]interface{}    `json:"data"`
}

func ListAll added in v0.13.0

func ListAll(c *gcorecloud.ServiceClient, opts ListOptsBuilder) ([]Task, error)

ListAll returns all Tasks. It accepts a ListOpts struct, which allows you to filter and sort the returned slice for greater efficiency.

type TaskID

type TaskID string

type TaskOrderByChoices added in v0.13.0

type TaskOrderByChoices string

type TaskPage

type TaskPage struct {
	pagination.LinkedPageBase
}

ClusterPage is the page returned by a pager when traversing over a collection of tasks.

func (TaskPage) IsEmpty

func (r TaskPage) IsEmpty() (bool, error)

IsEmpty checks whether a ClusterPage struct is empty.

func (TaskPage) NextPageURL

func (r TaskPage) NextPageURL() (string, error)

NextPageURL is invoked when a paginated collection of cluster has reached the end of a page and the pager seeks to traverse over a new one. In order to do this, it needs to construct the next page's URL.

type TaskResults

type TaskResults struct {
	Tasks []TaskID `json:"tasks"`
}

type TaskState

type TaskState string

type Tasks

type Tasks []Task

func ExtractTasks

func ExtractTasks(r pagination.Page) (Tasks, error)

ExtractTasks accepts a Page struct, specifically a ClusterPage struct, and extracts the elements into a slice of Task structs. In other words, a generic collection is mapped into a relevant slice.

type UpdateResult

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

UpdateResult represents the result of an update operation. Call its Extract method to interpret it as a Network.

func (UpdateResult) Extract

func (r UpdateResult) Extract() (*Task, error)

Extract is a function that accepts a result and extracts a task resource.

func (UpdateResult) ExtractInto

func (r UpdateResult) ExtractInto(v interface{}) error

Directories

Path Synopsis
tasks unit tests
tasks unit tests

Jump to

Keyboard shortcuts

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