-
Notifications
You must be signed in to change notification settings - Fork 44
/
model_sub_job.go
101 lines (79 loc) · 2.13 KB
/
model_sub_job.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
package model
import (
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
"errors"
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
"strings"
)
// SubJob
type SubJob struct {
// Job的状态。 - SUCCESS:成功。 - RUNNING:运行中。 - FAIL:失败。 - INIT:正在初始化。
Status *SubJobStatus `json:"status,omitempty"`
Entities *SubJobEntities `json:"entities,omitempty"`
// 子任务的ID。
JobId *string `json:"job_id,omitempty"`
// 子任务的类型。
JobType *string `json:"job_type,omitempty"`
// 开始时间。
BeginTime *string `json:"begin_time,omitempty"`
// 结束时间。
EndTime *string `json:"end_time,omitempty"`
// Job执行失败时的错误码。 Job执行成功后,该值为null。
ErrorCode *string `json:"error_code,omitempty"`
// Job执行失败时的错误原因。 Job执行成功后,该值为null。
FailReason *string `json:"fail_reason,omitempty"`
}
func (o SubJob) String() string {
data, err := utils.Marshal(o)
if err != nil {
return "SubJob struct{}"
}
return strings.Join([]string{"SubJob", string(data)}, " ")
}
type SubJobStatus struct {
value string
}
type SubJobStatusEnum struct {
SUCCESS SubJobStatus
RUNNING SubJobStatus
FAIL SubJobStatus
INIT SubJobStatus
}
func GetSubJobStatusEnum() SubJobStatusEnum {
return SubJobStatusEnum{
SUCCESS: SubJobStatus{
value: "SUCCESS",
},
RUNNING: SubJobStatus{
value: "RUNNING",
},
FAIL: SubJobStatus{
value: "FAIL",
},
INIT: SubJobStatus{
value: "INIT",
},
}
}
func (c SubJobStatus) Value() string {
return c.value
}
func (c SubJobStatus) MarshalJSON() ([]byte, error) {
return utils.Marshal(c.value)
}
func (c *SubJobStatus) UnmarshalJSON(b []byte) error {
myConverter := converter.StringConverterFactory("string")
if myConverter == nil {
return errors.New("unsupported StringConverter type: string")
}
interf, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
if err != nil {
return err
}
if val, ok := interf.(string); ok {
c.value = val
return nil
} else {
return errors.New("convert enum data to string error")
}
}