forked from yunify/qingcloud-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
job.go
117 lines (98 loc) · 3.37 KB
/
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// +-------------------------------------------------------------------------
// | Copyright (C) 2016 Yunify, Inc.
// +-------------------------------------------------------------------------
// | Licensed under the Apache License, Version 2.0 (the "License");
// | you may not use this work except in compliance with the License.
// | You may obtain a copy of the License in the LICENSE file, or at:
// |
// | http://www.apache.org/licenses/LICENSE-2.0
// |
// | Unless required by applicable law or agreed to in writing, software
// | distributed under the License is distributed on an "AS IS" BASIS,
// | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// | See the License for the specific language governing permissions and
// | limitations under the License.
// +-------------------------------------------------------------------------
package service
import (
"fmt"
"time"
"github.com/yunify/qingcloud-sdk-go/config"
"github.com/yunify/qingcloud-sdk-go/request"
"github.com/yunify/qingcloud-sdk-go/request/data"
"github.com/yunify/qingcloud-sdk-go/request/errors"
)
var _ fmt.State
var _ time.Time
type JobService struct {
Config *config.Config
Properties *JobServiceProperties
}
type JobServiceProperties struct {
// QingCloud Zone ID
Zone *string `json:"zone" name:"zone"` // Required
}
func (s *QingCloudService) Job(zone string) (*JobService, error) {
properties := &JobServiceProperties{
Zone: &zone,
}
return &JobService{Config: s.Config, Properties: properties}, nil
}
// Documentation URL: https://docs.qingcloud.com/api/job/describe_jobs.html
func (s *JobService) DescribeJobs(i *DescribeJobsInput) (*DescribeJobsOutput, error) {
if i == nil {
i = &DescribeJobsInput{}
}
o := &data.Operation{
Config: s.Config,
Properties: s.Properties,
APIName: "DescribeJobs",
RequestMethod: "GET",
}
x := &DescribeJobsOutput{}
r, err := request.New(o, i, x)
if err != nil {
return nil, err
}
err = r.Send()
if err != nil {
return nil, err
}
return x, err
}
type DescribeJobsInput struct {
Jobs []*string `json:"jobs" name:"jobs" location:"params"`
Limit *int `json:"limit" name:"limit" default:"20" location:"params"`
Offset *int `json:"offset" name:"offset" default:"0" location:"params"`
Owner *string `json:"owner" name:"owner" location:"params"`
Status []*string `json:"status" name:"status" location:"params"`
// Verbose's available values: 0
Verbose *int `json:"verbose" name:"verbose" default:"0" location:"params"`
}
func (v *DescribeJobsInput) Validate() error {
if v.Verbose != nil {
verboseValidValues := []string{"0"}
verboseParameterValue := fmt.Sprint(*v.Verbose)
verboseIsValid := false
for _, value := range verboseValidValues {
if value == verboseParameterValue {
verboseIsValid = true
}
}
if !verboseIsValid {
return errors.ParameterValueNotAllowedError{
ParameterName: "Verbose",
ParameterValue: verboseParameterValue,
AllowedValues: verboseValidValues,
}
}
}
return nil
}
type DescribeJobsOutput struct {
Message *string `json:"message" name:"message"`
Action *string `json:"action" name:"action" location:"elements"`
JobSet []*Job `json:"job_set" name:"job_set" location:"elements"`
RetCode *int `json:"ret_code" name:"ret_code" location:"elements"`
TotalCount *int `json:"total_count" name:"total_count" location:"elements"`
}