-
Notifications
You must be signed in to change notification settings - Fork 623
/
api_op_CancelJobExecution.go
205 lines (169 loc) · 6.64 KB
/
api_op_CancelJobExecution.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package iot
import (
"context"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/internal/awsutil"
"github.com/aws/aws-sdk-go-v2/private/protocol"
"github.com/aws/aws-sdk-go-v2/private/protocol/restjson"
)
type CancelJobExecutionInput struct {
_ struct{} `type:"structure"`
// (Optional) The expected current version of the job execution. Each time you
// update the job execution, its version is incremented. If the version of the
// job execution stored in Jobs does not match, the update is rejected with
// a VersionMismatch error, and an ErrorResponse that contains the current job
// execution status data is returned. (This makes it unnecessary to perform
// a separate DescribeJobExecution request in order to obtain the job execution
// status data.)
ExpectedVersion *int64 `locationName:"expectedVersion" type:"long"`
// (Optional) If true the job execution will be canceled if it has status IN_PROGRESS
// or QUEUED, otherwise the job execution will be canceled only if it has status
// QUEUED. If you attempt to cancel a job execution that is IN_PROGRESS, and
// you do not set force to true, then an InvalidStateTransitionException will
// be thrown. The default is false.
//
// Canceling a job execution which is "IN_PROGRESS", will cause the device to
// be unable to update the job execution status. Use caution and ensure that
// the device is able to recover to a valid state.
Force *bool `location:"querystring" locationName:"force" type:"boolean"`
// The ID of the job to be canceled.
//
// JobId is a required field
JobId *string `location:"uri" locationName:"jobId" min:"1" type:"string" required:"true"`
// A collection of name/value pairs that describe the status of the job execution.
// If not specified, the statusDetails are unchanged. You can specify at most
// 10 name/value pairs.
StatusDetails map[string]string `locationName:"statusDetails" type:"map"`
// The name of the thing whose execution of the job will be canceled.
//
// ThingName is a required field
ThingName *string `location:"uri" locationName:"thingName" min:"1" type:"string" required:"true"`
}
// String returns the string representation
func (s CancelJobExecutionInput) String() string {
return awsutil.Prettify(s)
}
// Validate inspects the fields of the type to determine if they are valid.
func (s *CancelJobExecutionInput) Validate() error {
invalidParams := aws.ErrInvalidParams{Context: "CancelJobExecutionInput"}
if s.JobId == nil {
invalidParams.Add(aws.NewErrParamRequired("JobId"))
}
if s.JobId != nil && len(*s.JobId) < 1 {
invalidParams.Add(aws.NewErrParamMinLen("JobId", 1))
}
if s.ThingName == nil {
invalidParams.Add(aws.NewErrParamRequired("ThingName"))
}
if s.ThingName != nil && len(*s.ThingName) < 1 {
invalidParams.Add(aws.NewErrParamMinLen("ThingName", 1))
}
if invalidParams.Len() > 0 {
return invalidParams
}
return nil
}
// MarshalFields encodes the AWS API shape using the passed in protocol encoder.
func (s CancelJobExecutionInput) MarshalFields(e protocol.FieldEncoder) error {
e.SetValue(protocol.HeaderTarget, "Content-Type", protocol.StringValue("application/json"), protocol.Metadata{})
if s.ExpectedVersion != nil {
v := *s.ExpectedVersion
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "expectedVersion", protocol.Int64Value(v), metadata)
}
if s.StatusDetails != nil {
v := s.StatusDetails
metadata := protocol.Metadata{}
ms0 := e.Map(protocol.BodyTarget, "statusDetails", metadata)
ms0.Start()
for k1, v1 := range v {
ms0.MapSetValue(k1, protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)})
}
ms0.End()
}
if s.JobId != nil {
v := *s.JobId
metadata := protocol.Metadata{}
e.SetValue(protocol.PathTarget, "jobId", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
if s.ThingName != nil {
v := *s.ThingName
metadata := protocol.Metadata{}
e.SetValue(protocol.PathTarget, "thingName", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
if s.Force != nil {
v := *s.Force
metadata := protocol.Metadata{}
e.SetValue(protocol.QueryTarget, "force", protocol.BoolValue(v), metadata)
}
return nil
}
type CancelJobExecutionOutput struct {
_ struct{} `type:"structure"`
}
// String returns the string representation
func (s CancelJobExecutionOutput) String() string {
return awsutil.Prettify(s)
}
// MarshalFields encodes the AWS API shape using the passed in protocol encoder.
func (s CancelJobExecutionOutput) MarshalFields(e protocol.FieldEncoder) error {
return nil
}
const opCancelJobExecution = "CancelJobExecution"
// CancelJobExecutionRequest returns a request value for making API operation for
// AWS IoT.
//
// Cancels the execution of a job for a given thing.
//
// // Example sending a request using CancelJobExecutionRequest.
// req := client.CancelJobExecutionRequest(params)
// resp, err := req.Send(context.TODO())
// if err == nil {
// fmt.Println(resp)
// }
func (c *Client) CancelJobExecutionRequest(input *CancelJobExecutionInput) CancelJobExecutionRequest {
op := &aws.Operation{
Name: opCancelJobExecution,
HTTPMethod: "PUT",
HTTPPath: "/things/{thingName}/jobs/{jobId}/cancel",
}
if input == nil {
input = &CancelJobExecutionInput{}
}
req := c.newRequest(op, input, &CancelJobExecutionOutput{})
req.Handlers.Unmarshal.Remove(restjson.UnmarshalHandler)
req.Handlers.Unmarshal.PushBackNamed(protocol.UnmarshalDiscardBodyHandler)
return CancelJobExecutionRequest{Request: req, Input: input, Copy: c.CancelJobExecutionRequest}
}
// CancelJobExecutionRequest is the request type for the
// CancelJobExecution API operation.
type CancelJobExecutionRequest struct {
*aws.Request
Input *CancelJobExecutionInput
Copy func(*CancelJobExecutionInput) CancelJobExecutionRequest
}
// Send marshals and sends the CancelJobExecution API request.
func (r CancelJobExecutionRequest) Send(ctx context.Context) (*CancelJobExecutionResponse, error) {
r.Request.SetContext(ctx)
err := r.Request.Send()
if err != nil {
return nil, err
}
resp := &CancelJobExecutionResponse{
CancelJobExecutionOutput: r.Request.Data.(*CancelJobExecutionOutput),
response: &aws.Response{Request: r.Request},
}
return resp, nil
}
// CancelJobExecutionResponse is the response type for the
// CancelJobExecution API operation.
type CancelJobExecutionResponse struct {
*CancelJobExecutionOutput
response *aws.Response
}
// SDKResponseMetdata returns the response metadata for the
// CancelJobExecution request.
func (r *CancelJobExecutionResponse) SDKResponseMetdata() *aws.Response {
return r.response
}