/
api_op_PutObjectLegalHold.go
235 lines (193 loc) · 7.31 KB
/
api_op_PutObjectLegalHold.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 s3
import (
"context"
"fmt"
"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/checksum"
"github.com/aws/aws-sdk-go-v2/private/protocol"
"github.com/aws/aws-sdk-go-v2/service/s3/internal/arn"
)
type PutObjectLegalHoldInput struct {
_ struct{} `type:"structure" payload:"LegalHold"`
// The bucket name containing the object that you want to place a Legal Hold
// on.
//
// When using this API with an access point, you must direct requests to the
// access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com.
// When using this operation using an access point through the AWS SDKs, you
// provide the access point ARN in place of the bucket name. For more information
// about access point ARNs, see Using Access Points (https://docs.aws.amazon.com/AmazonS3/latest/dev/using-access-points.html)
// in the Amazon Simple Storage Service Developer Guide.
//
// Bucket is a required field
Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
// The key name for the object that you want to place a Legal Hold on.
//
// Key is a required field
Key *string `location:"uri" locationName:"Key" min:"1" type:"string" required:"true"`
// Container element for the Legal Hold configuration you want to apply to the
// specified object.
LegalHold *ObjectLockLegalHold `locationName:"LegalHold" type:"structure" xmlURI:"http://s3.amazonaws.com/doc/2006-03-01/"`
// Confirms that the requester knows that they will be charged for the request.
// Bucket owners need not specify this parameter in their requests. For information
// about downloading objects from requester pays buckets, see Downloading Objects
// in Requestor Pays Buckets (https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html)
// in the Amazon S3 Developer Guide.
RequestPayer RequestPayer `location:"header" locationName:"x-amz-request-payer" type:"string" enum:"true"`
// The version ID of the object that you want to place a Legal Hold on.
VersionId *string `location:"querystring" locationName:"versionId" type:"string"`
}
// String returns the string representation
func (s PutObjectLegalHoldInput) String() string {
return awsutil.Prettify(s)
}
// Validate inspects the fields of the type to determine if they are valid.
func (s *PutObjectLegalHoldInput) Validate() error {
invalidParams := aws.ErrInvalidParams{Context: "PutObjectLegalHoldInput"}
if s.Bucket == nil {
invalidParams.Add(aws.NewErrParamRequired("Bucket"))
}
if s.Key == nil {
invalidParams.Add(aws.NewErrParamRequired("Key"))
}
if s.Key != nil && len(*s.Key) < 1 {
invalidParams.Add(aws.NewErrParamMinLen("Key", 1))
}
if invalidParams.Len() > 0 {
return invalidParams
}
return nil
}
func (s *PutObjectLegalHoldInput) getBucket() (v string) {
if s.Bucket == nil {
return v
}
return *s.Bucket
}
// MarshalFields encodes the AWS API shape using the passed in protocol encoder.
func (s PutObjectLegalHoldInput) MarshalFields(e protocol.FieldEncoder) error {
if len(s.RequestPayer) > 0 {
v := s.RequestPayer
metadata := protocol.Metadata{}
e.SetValue(protocol.HeaderTarget, "x-amz-request-payer", v, metadata)
}
if s.Bucket != nil {
v := *s.Bucket
metadata := protocol.Metadata{}
e.SetValue(protocol.PathTarget, "Bucket", protocol.StringValue(v), metadata)
}
if s.Key != nil {
v := *s.Key
metadata := protocol.Metadata{}
e.SetValue(protocol.PathTarget, "Key", protocol.StringValue(v), metadata)
}
if s.LegalHold != nil {
v := s.LegalHold
metadata := protocol.Metadata{XMLNamespaceURI: "http://s3.amazonaws.com/doc/2006-03-01/"}
e.SetFields(protocol.PayloadTarget, "LegalHold", v, metadata)
}
if s.VersionId != nil {
v := *s.VersionId
metadata := protocol.Metadata{}
e.SetValue(protocol.QueryTarget, "versionId", protocol.StringValue(v), metadata)
}
return nil
}
func (s *PutObjectLegalHoldInput) getEndpointARN() (arn.Resource, error) {
if s.Bucket == nil {
return nil, fmt.Errorf("member Bucket is nil")
}
return parseEndpointARN(*s.Bucket)
}
func (s *PutObjectLegalHoldInput) hasEndpointARN() bool {
if s.Bucket == nil {
return false
}
return arn.IsARN(*s.Bucket)
}
type PutObjectLegalHoldOutput struct {
_ struct{} `type:"structure"`
// If present, indicates that the requester was successfully charged for the
// request.
RequestCharged RequestCharged `location:"header" locationName:"x-amz-request-charged" type:"string" enum:"true"`
}
// String returns the string representation
func (s PutObjectLegalHoldOutput) String() string {
return awsutil.Prettify(s)
}
// MarshalFields encodes the AWS API shape using the passed in protocol encoder.
func (s PutObjectLegalHoldOutput) MarshalFields(e protocol.FieldEncoder) error {
if len(s.RequestCharged) > 0 {
v := s.RequestCharged
metadata := protocol.Metadata{}
e.SetValue(protocol.HeaderTarget, "x-amz-request-charged", v, metadata)
}
return nil
}
const opPutObjectLegalHold = "PutObjectLegalHold"
// PutObjectLegalHoldRequest returns a request value for making API operation for
// Amazon Simple Storage Service.
//
// Applies a Legal Hold configuration to the specified object.
//
// Related Resources
//
// * Locking Objects (https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lock.html)
//
// // Example sending a request using PutObjectLegalHoldRequest.
// req := client.PutObjectLegalHoldRequest(params)
// resp, err := req.Send(context.TODO())
// if err == nil {
// fmt.Println(resp)
// }
//
// Please also see https://docs.aws.amazon.com/goto/WebAPI/s3-2006-03-01/PutObjectLegalHold
func (c *Client) PutObjectLegalHoldRequest(input *PutObjectLegalHoldInput) PutObjectLegalHoldRequest {
op := &aws.Operation{
Name: opPutObjectLegalHold,
HTTPMethod: "PUT",
HTTPPath: "/{Bucket}/{Key+}?legal-hold",
}
if input == nil {
input = &PutObjectLegalHoldInput{}
}
req := c.newRequest(op, input, &PutObjectLegalHoldOutput{})
req.Handlers.Build.PushBackNamed(aws.NamedHandler{
Name: "contentMd5Handler",
Fn: checksum.AddBodyContentMD5Handler,
})
return PutObjectLegalHoldRequest{Request: req, Input: input, Copy: c.PutObjectLegalHoldRequest}
}
// PutObjectLegalHoldRequest is the request type for the
// PutObjectLegalHold API operation.
type PutObjectLegalHoldRequest struct {
*aws.Request
Input *PutObjectLegalHoldInput
Copy func(*PutObjectLegalHoldInput) PutObjectLegalHoldRequest
}
// Send marshals and sends the PutObjectLegalHold API request.
func (r PutObjectLegalHoldRequest) Send(ctx context.Context) (*PutObjectLegalHoldResponse, error) {
r.Request.SetContext(ctx)
err := r.Request.Send()
if err != nil {
return nil, err
}
resp := &PutObjectLegalHoldResponse{
PutObjectLegalHoldOutput: r.Request.Data.(*PutObjectLegalHoldOutput),
response: &aws.Response{Request: r.Request},
}
return resp, nil
}
// PutObjectLegalHoldResponse is the response type for the
// PutObjectLegalHold API operation.
type PutObjectLegalHoldResponse struct {
*PutObjectLegalHoldOutput
response *aws.Response
}
// SDKResponseMetdata returns the response metadata for the
// PutObjectLegalHold request.
func (r *PutObjectLegalHoldResponse) SDKResponseMetdata() *aws.Response {
return r.response
}