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