github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/servicestage/v2/jobs/results.go (about)

     1  package jobs
     2  
     3  import "github.com/chnsz/golangsdk/pagination"
     4  
     5  // JobResp is the structure that represents the detail of the deployment job and task list.
     6  type JobResp struct {
     7  	// Number of tasks.
     8  	TaskCount int `json:"task_count"`
     9  	// Job parameters.
    10  	Job Job `json:"job"`
    11  	// Task parameters.
    12  	Tasks []Task `json:"tasks"`
    13  }
    14  
    15  // Job is the structure that represents the detail of the deployment action.
    16  type Job struct {
    17  	// Creator.
    18  	Creator string `json:"created_by"`
    19  	// Execution status.
    20  	ExecutionStatus string `json:"execution_status"`
    21  	// Job description.
    22  	Description string `json:"job_desc"`
    23  	// Job ID.
    24  	ID string `json:"job_id"`
    25  	// Job name.
    26  	Name string `json:"job_name"`
    27  	// Type.
    28  	Type string `json:"job_type"`
    29  	// Order ID.
    30  	OrderId string `json:"order_id"`
    31  	// Tenant's project ID.
    32  	ProjectId string `json:"project_id"`
    33  	// Instance ID.
    34  	InstanceId string `json:"service_instance_id"`
    35  }
    36  
    37  // Task is the structure that represents the detail of the deployment task.
    38  type Task struct {
    39  	// Creation time.
    40  	CreatedAt string `json:"created_at"`
    41  	// Health check time.
    42  	LastHealthCheck string `json:"last_health_check"`
    43  	// Message.
    44  	Messages string `json:"messages"`
    45  	// Creator ID.
    46  	OwnerId string `json:"owner_id"`
    47  	// Task ID.
    48  	ID string `json:"task_id"`
    49  	// Task index.
    50  	Index int `json:"task_index"`
    51  	// Task name.
    52  	Name string `json:"task_name"`
    53  	// Task status.
    54  	Status string `json:"task_status"`
    55  	// Task type.
    56  	Type string `json:"task_type"`
    57  }
    58  
    59  // TaskPage is a single page maximum result representing a query by offset page.
    60  type TaskPage struct {
    61  	pagination.OffsetPageBase
    62  }
    63  
    64  // IsEmpty checks whether a TaskPage is empty.
    65  func (b TaskPage) IsEmpty() (bool, error) {
    66  	arr, err := ExtractTasks(b)
    67  	return len(arr) == 0, err
    68  }
    69  
    70  // ExtractTasks is a method to extract the list of task details for ServiceStage component.
    71  func ExtractTasks(r pagination.Page) ([]Task, error) {
    72  	var s []Task
    73  	err := r.(TaskPage).Result.ExtractIntoSlicePtr(&s, "tasks")
    74  	return s, err
    75  }