-
Notifications
You must be signed in to change notification settings - Fork 4
/
tasks.go
123 lines (92 loc) · 4.61 KB
/
tasks.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package isegosdk
import (
"fmt"
"strings"
"github.com/go-resty/resty/v2"
)
type TasksService service
type ResponseTasksGetAllTaskStatus []ResponseItemTasksGetAllTaskStatus // Array of ResponseTasksGetAllTaskStatus
// ResponseTasksGetTaskStatus is deprecated and does not have valid alias
// type ResponseTasksGetTaskStatus = ResponseTasksGetAllTaskStatus
type ResponseItemTasksGetAllTaskStatus struct {
DetailStatus *[]ResponseItemTasksGetAllTaskStatusDetailStatus `json:"detailStatus,omitempty"` //
ExecutionStatus string `json:"executionStatus,omitempty"` //
FailCount *int `json:"failCount,omitempty"` //
ID string `json:"id,omitempty"` //
ModuleType string `json:"moduleType,omitempty"` //
ResourcesCount *int `json:"resourcesCount,omitempty"` //
StartTime string `json:"startTime,omitempty"` //
SuccessCount *int `json:"successCount,omitempty"` //
}
// ResponseItemTasksGetTaskStatus is deprecated, please use ResponseItemTasksGetAllTaskStatus
type ResponseItemTasksGetTaskStatus = ResponseItemTasksGetAllTaskStatus
type ResponseItemTasksGetAllTaskStatusDetailStatus interface{}
// ResponseItemTasksGetTaskStatusDetailStatus is deprecated, please use ResponseItemTasksGetAllTaskStatusDetailStatus
type ResponseItemTasksGetTaskStatusDetailStatus = ResponseItemTasksGetAllTaskStatusDetailStatus
type ResponseTasksGetTaskStatus struct {
DetailStatus *[]ResponseTasksGetTaskStatusDetailStatus `json:"detailStatus,omitempty"` //
ExecutionStatus string `json:"executionStatus,omitempty"` //
FailCount *int `json:"failCount,omitempty"` //
ID string `json:"id,omitempty"` //
ModuleType string `json:"moduleType,omitempty"` //
ResourcesCount *int `json:"resourcesCount,omitempty"` //
StartTime string `json:"startTime,omitempty"` //
SuccessCount *int `json:"successCount,omitempty"` //
}
// ResponseTasksGetTaskStatusByID is deprecated, please use ResponseTasksGetTaskStatus
type ResponseTasksGetTaskStatusByID = ResponseTasksGetTaskStatus
type ResponseTasksGetTaskStatusDetailStatus interface{}
// ResponseTasksGetTaskStatusByIDDetailStatus is deprecated, please use ResponseTasksGetTaskStatusDetailStatus
type ResponseTasksGetTaskStatusByIDDetailStatus = ResponseTasksGetTaskStatusDetailStatus
//GetAllTaskStatus get all task status
/* get all task status
*/
func (s *TasksService) GetAllTaskStatus() (*ResponseTasksGetAllTaskStatus, *resty.Response, error) {
setHost(s.client, "_ui")
path := "/api/v1/task"
setCSRFToken(s.client)
response, err := s.client.R().
SetHeader("Content-Type", "application/json").
SetHeader("Accept", "application/json").
SetResult(&ResponseTasksGetAllTaskStatus{}).
SetError(&Error).
Get(path)
if err != nil {
return nil, nil, err
}
if response.IsError() {
return nil, response, fmt.Errorf("error with operation GetAllTaskStatus")
}
getCSFRToken(response.Header())
result := response.Result().(*ResponseTasksGetAllTaskStatus)
return result, response, err
}
//GetTaskStatus Monitor task status
/* Monitor task status
@param taskID taskId path parameter. The id of the task executed before
*/
func (s *TasksService) GetTaskStatus(taskID string) (*ResponseTasksGetTaskStatus, *resty.Response, error) {
setHost(s.client, "_ui")
path := "/api/v1/task/{taskId}"
path = strings.Replace(path, "{taskId}", fmt.Sprintf("%v", taskID), -1)
setCSRFToken(s.client)
response, err := s.client.R().
SetHeader("Content-Type", "application/json").
SetHeader("Accept", "application/json").
SetResult(&ResponseTasksGetTaskStatus{}).
SetError(&Error).
Get(path)
if err != nil {
return nil, nil, err
}
if response.IsError() {
return nil, response, fmt.Errorf("error with operation GetTaskStatus")
}
getCSFRToken(response.Header())
result := response.Result().(*ResponseTasksGetTaskStatus)
return result, response, err
}
//Alias of GetTaskStatus Monitor task status
func (s *TasksService) GetTaskStatusByID(taskID string) (*ResponseTasksGetTaskStatus, *resty.Response, error) {
return s.GetTaskStatus(taskID)
}