forked from zaquestion/aws-sdk-go-v2
/
service.go
121 lines (103 loc) · 3.69 KB
/
service.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
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package s3
import (
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
"github.com/aws/aws-sdk-go-v2/private/protocol/restxml"
)
// S3 provides the API operation methods for making requests to
// Amazon Simple Storage Service. See this package's package overview docs
// for details on the service.
//
// S3 methods are safe to use concurrently. It is not safe to
// modify mutate any of the struct's properties though.
type S3 struct {
*aws.Client
// Service specific configurations. (codegen: service_specific_config.go)
// Disables the S3 client from using the Expect: 100-Continue header to wait for
// the service to respond with a 100 status code before sending the HTTP request
// body.
//
// You should disable 100-Continue if you experience issues with proxies or third
// party S3 compatible services.
//
// See http.Transport's ExpectContinueTimeout for information on adjusting the
// continue wait timeout. https://golang.org/pkg/net/http/#Transport
Disable100Continue bool
// Forces the client to use path-style addressing for S3 API operations. By
// default the S3 client will use virtual hosted bucket addressing when possible.
// The S3 client will automatically fall back to path-style when the bucket name
// is not DNS compatible.
//
// With ForcePathStyle
//
// https://s3.us-west-2.amazonaws.com/BUCKET/KEY
//
// Without ForcePathStyle
//
// https://BUCKET.s3.us-west-2.amazonaws.com/KEY
//
// See http://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html
ForcePathStyle bool
// Enables S3 Accelerate feature for API operation that support S3 Accelerate.
// For all operations compatible with S3 Accelerate will use the accelerate
// endpoint for requests. Requests not compatible will fall back to normal S3
// requests.
//
// The bucket must be enable for accelerate to be used with S3 client with
// accelerate enabled. If the bucket is not enabled for accelerate an error will
// be returned. The bucket name must be DNS compatible to also work with
// accelerate.
//
UseAccelerate bool
}
// Used for custom client initialization logic
var initClient func(*S3)
// Used for custom request initialization logic
var initRequest func(*S3, *aws.Request)
// Service information constants
const (
ServiceName = "s3" // Service endpoint prefix API calls made to.
EndpointsID = ServiceName // Service ID for Regions and Endpoints metadata.
)
// New creates a new instance of the S3 client with a config.
//
// Example:
// // Create a S3 client from just a config.
// svc := s3.New(myConfig)
func New(config aws.Config) *S3 {
var signingName string
signingRegion := config.Region
svc := &S3{
Client: aws.NewClient(
config,
aws.Metadata{
ServiceName: ServiceName,
SigningName: signingName,
SigningRegion: signingRegion,
APIVersion: "2006-03-01",
},
),
}
// Handlers
svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
svc.Handlers.Build.PushBackNamed(restxml.BuildHandler)
svc.Handlers.Unmarshal.PushBackNamed(restxml.UnmarshalHandler)
svc.Handlers.UnmarshalMeta.PushBackNamed(restxml.UnmarshalMetaHandler)
svc.Handlers.UnmarshalError.PushBackNamed(restxml.UnmarshalErrorHandler)
// Run custom client initialization if present
if initClient != nil {
initClient(svc)
}
return svc
}
// newRequest creates a new request for a S3 operation and runs any
// custom request initialization.
func (c *S3) newRequest(op *aws.Operation, params, data interface{}) *aws.Request {
req := c.NewRequest(op, params, data)
// Run custom request initialization if present
if initRequest != nil {
initRequest(c, req)
}
return req
}