1package aws
2
3import (
4 "net/http"
5
6 smithybearer "github.com/aws/smithy-go/auth/bearer"
7 "github.com/aws/smithy-go/logging"
8 "github.com/aws/smithy-go/middleware"
9)
10
11// HTTPClient provides the interface to provide custom HTTPClients. Generally
12// *http.Client is sufficient for most use cases. The HTTPClient should not
13// follow 301 or 302 redirects.
14type HTTPClient interface {
15 Do(*http.Request) (*http.Response, error)
16}
17
18// A Config provides service configuration for service clients.
19type Config struct {
20 // The region to send requests to. This parameter is required and must
21 // be configured globally or on a per-client basis unless otherwise
22 // noted. A full list of regions is found in the "Regions and Endpoints"
23 // document.
24 //
25 // See http://docs.aws.amazon.com/general/latest/gr/rande.html for
26 // information on AWS regions.
27 Region string
28
29 // The credentials object to use when signing requests.
30 // Use the LoadDefaultConfig to load configuration from all the SDK's supported
31 // sources, and resolve credentials using the SDK's default credential chain.
32 Credentials CredentialsProvider
33
34 // The Bearer Authentication token provider to use for authenticating API
35 // operation calls with a Bearer Authentication token. The API clients and
36 // operation must support Bearer Authentication scheme in order for the
37 // token provider to be used. API clients created with NewFromConfig will
38 // automatically be configured with this option, if the API client support
39 // Bearer Authentication.
40 //
41 // The SDK's config.LoadDefaultConfig can automatically populate this
42 // option for external configuration options such as SSO session.
43 // https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html
44 BearerAuthTokenProvider smithybearer.TokenProvider
45
46 // The HTTP Client the SDK's API clients will use to invoke HTTP requests.
47 // The SDK defaults to a BuildableClient allowing API clients to create
48 // copies of the HTTP Client for service specific customizations.
49 //
50 // Use a (*http.Client) for custom behavior. Using a custom http.Client
51 // will prevent the SDK from modifying the HTTP client.
52 HTTPClient HTTPClient
53
54 // An endpoint resolver that can be used to provide or override an endpoint
55 // for the given service and region.
56 //
57 // See the `aws.EndpointResolver` documentation for additional usage
58 // information.
59 //
60 // Deprecated: See Config.EndpointResolverWithOptions
61 EndpointResolver EndpointResolver
62
63 // An endpoint resolver that can be used to provide or override an endpoint
64 // for the given service and region.
65 //
66 // When EndpointResolverWithOptions is specified, it will be used by a
67 // service client rather than using EndpointResolver if also specified.
68 //
69 // See the `aws.EndpointResolverWithOptions` documentation for additional
70 // usage information.
71 //
72 // Deprecated: with the release of endpoint resolution v2 in API clients,
73 // EndpointResolver and EndpointResolverWithOptions are deprecated.
74 // Providing a value for this field will likely prevent you from using
75 // newer endpoint-related service features. See API client options
76 // EndpointResolverV2 and BaseEndpoint.
77 EndpointResolverWithOptions EndpointResolverWithOptions
78
79 // RetryMaxAttempts specifies the maximum number attempts an API client
80 // will call an operation that fails with a retryable error.
81 //
82 // API Clients will only use this value to construct a retryer if the
83 // Config.Retryer member is not nil. This value will be ignored if
84 // Retryer is not nil.
85 RetryMaxAttempts int
86
87 // RetryMode specifies the retry model the API client will be created with.
88 //
89 // API Clients will only use this value to construct a retryer if the
90 // Config.Retryer member is not nil. This value will be ignored if
91 // Retryer is not nil.
92 RetryMode RetryMode
93
94 // Retryer is a function that provides a Retryer implementation. A Retryer
95 // guides how HTTP requests should be retried in case of recoverable
96 // failures. When nil the API client will use a default retryer.
97 //
98 // In general, the provider function should return a new instance of a
99 // Retryer if you are attempting to provide a consistent Retryer
100 // configuration across all clients. This will ensure that each client will
101 // be provided a new instance of the Retryer implementation, and will avoid
102 // issues such as sharing the same retry token bucket across services.
103 //
104 // If not nil, RetryMaxAttempts, and RetryMode will be ignored by API
105 // clients.
106 Retryer func() Retryer
107
108 // ConfigSources are the sources that were used to construct the Config.
109 // Allows for additional configuration to be loaded by clients.
110 ConfigSources []interface{}
111
112 // APIOptions provides the set of middleware mutations modify how the API
113 // client requests will be handled. This is useful for adding additional
114 // tracing data to a request, or changing behavior of the SDK's client.
115 APIOptions []func(*middleware.Stack) error
116
117 // The logger writer interface to write logging messages to. Defaults to
118 // standard error.
119 Logger logging.Logger
120
121 // Configures the events that will be sent to the configured logger. This
122 // can be used to configure the logging of signing, retries, request, and
123 // responses of the SDK clients.
124 //
125 // See the ClientLogMode type documentation for the complete set of logging
126 // modes and available configuration.
127 ClientLogMode ClientLogMode
128
129 // The configured DefaultsMode. If not specified, service clients will
130 // default to legacy.
131 //
132 // Supported modes are: auto, cross-region, in-region, legacy, mobile,
133 // standard
134 DefaultsMode DefaultsMode
135
136 // The RuntimeEnvironment configuration, only populated if the DefaultsMode
137 // is set to DefaultsModeAuto and is initialized by
138 // `config.LoadDefaultConfig`. You should not populate this structure
139 // programmatically, or rely on the values here within your applications.
140 RuntimeEnvironment RuntimeEnvironment
141
142 // AppId is an optional application specific identifier that can be set.
143 // When set it will be appended to the User-Agent header of every request
144 // in the form of App/{AppId}. This variable is sourced from environment
145 // variable AWS_SDK_UA_APP_ID or the shared config profile attribute sdk_ua_app_id.
146 // See https://docs.aws.amazon.com/sdkref/latest/guide/settings-reference.html for
147 // more information on environment variables and shared config settings.
148 AppID string
149
150 // BaseEndpoint is an intermediary transfer location to a service specific
151 // BaseEndpoint on a service's Options.
152 BaseEndpoint *string
153
154 // DisableRequestCompression toggles if an operation request could be
155 // compressed or not. Will be set to false by default. This variable is sourced from
156 // environment variable AWS_DISABLE_REQUEST_COMPRESSION or the shared config profile attribute
157 // disable_request_compression
158 DisableRequestCompression bool
159
160 // RequestMinCompressSizeBytes sets the inclusive min bytes of a request body that could be
161 // compressed. Will be set to 10240 by default and must be within 0 and 10485760 bytes inclusively.
162 // This variable is sourced from environment variable AWS_REQUEST_MIN_COMPRESSION_SIZE_BYTES or
163 // the shared config profile attribute request_min_compression_size_bytes
164 RequestMinCompressSizeBytes int64
165
166 // Controls how a resolved AWS account ID is handled for endpoint routing.
167 AccountIDEndpointMode AccountIDEndpointMode
168}
169
170// NewConfig returns a new Config pointer that can be chained with builder
171// methods to set multiple configuration values inline without using pointers.
172func NewConfig() *Config {
173 return &Config{}
174}
175
176// Copy will return a shallow copy of the Config object.
177func (c Config) Copy() Config {
178 cp := c
179 return cp
180}
181
182// EndpointDiscoveryEnableState indicates if endpoint discovery is
183// enabled, disabled, auto or unset state.
184//
185// Default behavior (Auto or Unset) indicates operations that require endpoint
186// discovery will use Endpoint Discovery by default. Operations that
187// optionally use Endpoint Discovery will not use Endpoint Discovery
188// unless EndpointDiscovery is explicitly enabled.
189type EndpointDiscoveryEnableState uint
190
191// Enumeration values for EndpointDiscoveryEnableState
192const (
193 // EndpointDiscoveryUnset represents EndpointDiscoveryEnableState is unset.
194 // Users do not need to use this value explicitly. The behavior for unset
195 // is the same as for EndpointDiscoveryAuto.
196 EndpointDiscoveryUnset EndpointDiscoveryEnableState = iota
197
198 // EndpointDiscoveryAuto represents an AUTO state that allows endpoint
199 // discovery only when required by the api. This is the default
200 // configuration resolved by the client if endpoint discovery is neither
201 // enabled or disabled.
202 EndpointDiscoveryAuto // default state
203
204 // EndpointDiscoveryDisabled indicates client MUST not perform endpoint
205 // discovery even when required.
206 EndpointDiscoveryDisabled
207
208 // EndpointDiscoveryEnabled indicates client MUST always perform endpoint
209 // discovery if supported for the operation.
210 EndpointDiscoveryEnabled
211)