/
api_op_StartCopyJob.go
235 lines (191 loc) · 7.44 KB
/
api_op_StartCopyJob.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
// 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 StartCopyJobInput struct {
_ struct{} `type:"structure"`
// An Amazon Resource Name (ARN) that uniquely identifies a destination backup
// vault to copy to; for example, arn:aws:backup:us-east-1:123456789012:vault:aBackupVault.
//
// DestinationBackupVaultArn is a required field
DestinationBackupVaultArn *string `type:"string" required:"true"`
// Specifies the IAM role ARN used to copy 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
// StartCopyJob.
IdempotencyToken *string `type:"string"`
// Contains an array of Transition objects specifying how long in days before
// a recovery point transitions to cold storage or is deleted.
//
// Backups transitioned to cold storage must be stored in cold storage for a
// minimum of 90 days. Therefore, on the console, 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"`
// An ARN that uniquely identifies a recovery point to use for the copy job;
// for example, arn:aws:backup:us-east-1:123456789012:recovery-point:1EB3B5E7-9EB0-435A-A80B-108B488B0D45.
//
// RecoveryPointArn is a required field
RecoveryPointArn *string `type:"string" required:"true"`
// The name of a logical source 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.
//
// SourceBackupVaultName is a required field
SourceBackupVaultName *string `type:"string" required:"true"`
}
// String returns the string representation
func (s StartCopyJobInput) String() string {
return awsutil.Prettify(s)
}
// Validate inspects the fields of the type to determine if they are valid.
func (s *StartCopyJobInput) Validate() error {
invalidParams := aws.ErrInvalidParams{Context: "StartCopyJobInput"}
if s.DestinationBackupVaultArn == nil {
invalidParams.Add(aws.NewErrParamRequired("DestinationBackupVaultArn"))
}
if s.IamRoleArn == nil {
invalidParams.Add(aws.NewErrParamRequired("IamRoleArn"))
}
if s.RecoveryPointArn == nil {
invalidParams.Add(aws.NewErrParamRequired("RecoveryPointArn"))
}
if s.SourceBackupVaultName == nil {
invalidParams.Add(aws.NewErrParamRequired("SourceBackupVaultName"))
}
if invalidParams.Len() > 0 {
return invalidParams
}
return nil
}
// MarshalFields encodes the AWS API shape using the passed in protocol encoder.
func (s StartCopyJobInput) MarshalFields(e protocol.FieldEncoder) error {
e.SetValue(protocol.HeaderTarget, "Content-Type", protocol.StringValue("application/json"), protocol.Metadata{})
if s.DestinationBackupVaultArn != nil {
v := *s.DestinationBackupVaultArn
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "DestinationBackupVaultArn", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(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.RecoveryPointArn != nil {
v := *s.RecoveryPointArn
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "RecoveryPointArn", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
if s.SourceBackupVaultName != nil {
v := *s.SourceBackupVaultName
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "SourceBackupVaultName", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
return nil
}
type StartCopyJobOutput struct {
_ struct{} `type:"structure"`
// Uniquely identifies a copy job.
CopyJobId *string `type:"string"`
// The date and time that a copy 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"`
}
// String returns the string representation
func (s StartCopyJobOutput) String() string {
return awsutil.Prettify(s)
}
// MarshalFields encodes the AWS API shape using the passed in protocol encoder.
func (s StartCopyJobOutput) MarshalFields(e protocol.FieldEncoder) error {
if s.CopyJobId != nil {
v := *s.CopyJobId
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "CopyJobId", 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)
}
return nil
}
const opStartCopyJob = "StartCopyJob"
// StartCopyJobRequest returns a request value for making API operation for
// AWS Backup.
//
// Starts a job to create a one-time copy of the specified resource.
//
// // Example sending a request using StartCopyJobRequest.
// req := client.StartCopyJobRequest(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/StartCopyJob
func (c *Client) StartCopyJobRequest(input *StartCopyJobInput) StartCopyJobRequest {
op := &aws.Operation{
Name: opStartCopyJob,
HTTPMethod: "PUT",
HTTPPath: "/copy-jobs",
}
if input == nil {
input = &StartCopyJobInput{}
}
req := c.newRequest(op, input, &StartCopyJobOutput{})
return StartCopyJobRequest{Request: req, Input: input, Copy: c.StartCopyJobRequest}
}
// StartCopyJobRequest is the request type for the
// StartCopyJob API operation.
type StartCopyJobRequest struct {
*aws.Request
Input *StartCopyJobInput
Copy func(*StartCopyJobInput) StartCopyJobRequest
}
// Send marshals and sends the StartCopyJob API request.
func (r StartCopyJobRequest) Send(ctx context.Context) (*StartCopyJobResponse, error) {
r.Request.SetContext(ctx)
err := r.Request.Send()
if err != nil {
return nil, err
}
resp := &StartCopyJobResponse{
StartCopyJobOutput: r.Request.Data.(*StartCopyJobOutput),
response: &aws.Response{Request: r.Request},
}
return resp, nil
}
// StartCopyJobResponse is the response type for the
// StartCopyJob API operation.
type StartCopyJobResponse struct {
*StartCopyJobOutput
response *aws.Response
}
// SDKResponseMetdata returns the response metadata for the
// StartCopyJob request.
func (r *StartCopyJobResponse) SDKResponseMetdata() *aws.Response {
return r.response
}