/
api_op_StartBackupJob.go
265 lines (215 loc) · 8.52 KB
/
api_op_StartBackupJob.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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package backup
import (
"context"
"time"
"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"
)
type StartBackupJobInput struct {
_ struct{} `type:"structure"`
// The name of a logical container where backups are stored. Backup vaults are
// identified by names that are unique to the account used to create them and
// the AWS Region where they are created. They consist of lowercase letters,
// numbers, and hyphens.
//
// BackupVaultName is a required field
BackupVaultName *string `type:"string" required:"true"`
// A value in minutes after a backup job is successfully started before it must
// be completed or it will be canceled by AWS Backup. This value is optional.
CompleteWindowMinutes *int64 `type:"long"`
// Specifies the IAM role ARN used to create the target recovery point; for
// example, arn:aws:iam::123456789012:role/S3Access.
//
// IamRoleArn is a required field
IamRoleArn *string `type:"string" required:"true"`
// A customer chosen string that can be used to distinguish between calls to
// StartBackupJob.
IdempotencyToken *string `type:"string"`
// The lifecycle defines when a protected resource is transitioned to cold storage
// and when it expires. AWS Backup will transition and expire backups automatically
// according to the lifecycle that you define.
//
// Backups transitioned to cold storage must be stored in cold storage for a
// minimum of 90 days. Therefore, the “expire after days” setting must be
// 90 days greater than the “transition to cold after days” setting. The
// “transition to cold after days” setting cannot be changed after a backup
// has been transitioned to cold.
Lifecycle *Lifecycle `type:"structure"`
// To help organize your resources, you can assign your own metadata to the
// resources that you create. Each tag is a key-value pair.
RecoveryPointTags map[string]string `type:"map" sensitive:"true"`
// An Amazon Resource Name (ARN) that uniquely identifies a resource. The format
// of the ARN depends on the resource type.
//
// ResourceArn is a required field
ResourceArn *string `type:"string" required:"true"`
// A value in minutes after a backup is scheduled before a job will be canceled
// if it doesn't start successfully. This value is optional.
StartWindowMinutes *int64 `type:"long"`
}
// String returns the string representation
func (s StartBackupJobInput) String() string {
return awsutil.Prettify(s)
}
// Validate inspects the fields of the type to determine if they are valid.
func (s *StartBackupJobInput) Validate() error {
invalidParams := aws.ErrInvalidParams{Context: "StartBackupJobInput"}
if s.BackupVaultName == nil {
invalidParams.Add(aws.NewErrParamRequired("BackupVaultName"))
}
if s.IamRoleArn == nil {
invalidParams.Add(aws.NewErrParamRequired("IamRoleArn"))
}
if s.ResourceArn == nil {
invalidParams.Add(aws.NewErrParamRequired("ResourceArn"))
}
if invalidParams.Len() > 0 {
return invalidParams
}
return nil
}
// MarshalFields encodes the AWS API shape using the passed in protocol encoder.
func (s StartBackupJobInput) MarshalFields(e protocol.FieldEncoder) error {
e.SetValue(protocol.HeaderTarget, "Content-Type", protocol.StringValue("application/json"), protocol.Metadata{})
if s.BackupVaultName != nil {
v := *s.BackupVaultName
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "BackupVaultName", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
if s.CompleteWindowMinutes != nil {
v := *s.CompleteWindowMinutes
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "CompleteWindowMinutes", protocol.Int64Value(v), metadata)
}
if s.IamRoleArn != nil {
v := *s.IamRoleArn
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "IamRoleArn", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
if s.IdempotencyToken != nil {
v := *s.IdempotencyToken
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "IdempotencyToken", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
if s.Lifecycle != nil {
v := s.Lifecycle
metadata := protocol.Metadata{}
e.SetFields(protocol.BodyTarget, "Lifecycle", v, metadata)
}
if s.RecoveryPointTags != nil {
v := s.RecoveryPointTags
metadata := protocol.Metadata{}
ms0 := e.Map(protocol.BodyTarget, "RecoveryPointTags", metadata)
ms0.Start()
for k1, v1 := range v {
ms0.MapSetValue(k1, protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)})
}
ms0.End()
}
if s.ResourceArn != nil {
v := *s.ResourceArn
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "ResourceArn", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
if s.StartWindowMinutes != nil {
v := *s.StartWindowMinutes
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "StartWindowMinutes", protocol.Int64Value(v), metadata)
}
return nil
}
type StartBackupJobOutput struct {
_ struct{} `type:"structure"`
// Uniquely identifies a request to AWS Backup to back up a resource.
BackupJobId *string `type:"string"`
// The date and time that a backup job is started, in Unix format and Coordinated
// Universal Time (UTC). The value of CreationDate is accurate to milliseconds.
// For example, the value 1516925490.087 represents Friday, January 26, 2018
// 12:11:30.087 AM.
CreationDate *time.Time `type:"timestamp"`
// An ARN that uniquely identifies a recovery point; for example, arn:aws:backup:us-east-1:123456789012:recovery-point:1EB3B5E7-9EB0-435A-A80B-108B488B0D45.
RecoveryPointArn *string `type:"string"`
}
// String returns the string representation
func (s StartBackupJobOutput) String() string {
return awsutil.Prettify(s)
}
// MarshalFields encodes the AWS API shape using the passed in protocol encoder.
func (s StartBackupJobOutput) MarshalFields(e protocol.FieldEncoder) error {
if s.BackupJobId != nil {
v := *s.BackupJobId
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "BackupJobId", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
if s.CreationDate != nil {
v := *s.CreationDate
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "CreationDate",
protocol.TimeValue{V: v, Format: protocol.UnixTimeFormatName, QuotedFormatTime: true}, metadata)
}
if s.RecoveryPointArn != nil {
v := *s.RecoveryPointArn
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "RecoveryPointArn", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
return nil
}
const opStartBackupJob = "StartBackupJob"
// StartBackupJobRequest returns a request value for making API operation for
// AWS Backup.
//
// Starts a job to create a one-time backup of the specified resource.
//
// // Example sending a request using StartBackupJobRequest.
// req := client.StartBackupJobRequest(params)
// resp, err := req.Send(context.TODO())
// if err == nil {
// fmt.Println(resp)
// }
//
// Please also see https://docs.aws.amazon.com/goto/WebAPI/backup-2018-11-15/StartBackupJob
func (c *Client) StartBackupJobRequest(input *StartBackupJobInput) StartBackupJobRequest {
op := &aws.Operation{
Name: opStartBackupJob,
HTTPMethod: "PUT",
HTTPPath: "/backup-jobs",
}
if input == nil {
input = &StartBackupJobInput{}
}
req := c.newRequest(op, input, &StartBackupJobOutput{})
return StartBackupJobRequest{Request: req, Input: input, Copy: c.StartBackupJobRequest}
}
// StartBackupJobRequest is the request type for the
// StartBackupJob API operation.
type StartBackupJobRequest struct {
*aws.Request
Input *StartBackupJobInput
Copy func(*StartBackupJobInput) StartBackupJobRequest
}
// Send marshals and sends the StartBackupJob API request.
func (r StartBackupJobRequest) Send(ctx context.Context) (*StartBackupJobResponse, error) {
r.Request.SetContext(ctx)
err := r.Request.Send()
if err != nil {
return nil, err
}
resp := &StartBackupJobResponse{
StartBackupJobOutput: r.Request.Data.(*StartBackupJobOutput),
response: &aws.Response{Request: r.Request},
}
return resp, nil
}
// StartBackupJobResponse is the response type for the
// StartBackupJob API operation.
type StartBackupJobResponse struct {
*StartBackupJobOutput
response *aws.Response
}
// SDKResponseMetdata returns the response metadata for the
// StartBackupJob request.
func (r *StartBackupJobResponse) SDKResponseMetdata() *aws.Response {
return r.response
}