1package aws
2
3import (
4	"net/http"
5
6	"github.com/aws/smithy-go/logging"
7	"github.com/aws/smithy-go/middleware"
8)
9
10// HTTPClient provides the interface to provide custom HTTPClients. Generally
11// *http.Client is sufficient for most use cases. The HTTPClient should not
12// follow redirects.
13type HTTPClient interface {
14	Do(*http.Request) (*http.Response, error)
15}
16
17// A Config provides service configuration for service clients.
18type Config struct {
19	// The region to send requests to. This parameter is required and must
20	// be configured globally or on a per-client basis unless otherwise
21	// noted. A full list of regions is found in the "Regions and Endpoints"
22	// document.
23	//
24	// See http://docs.aws.amazon.com/general/latest/gr/rande.html for
25	// information on AWS regions.
26	Region string
27
28	// The credentials object to use when signing requests. Defaults to a
29	// chain of credential providers to search for credentials in environment
30	// variables, shared credential file, and EC2 Instance Roles.
31	Credentials CredentialsProvider
32
33	// The HTTP Client the SDK's API clients will use to invoke HTTP requests.
34	// The SDK defaults to a BuildableClient allowing API clients to create
35	// copies of the HTTP Client for service specific customizations.
36	//
37	// Use a (*http.Client) for custom behavior. Using a custom http.Client
38	// will prevent the SDK from modifying the HTTP client.
39	HTTPClient HTTPClient
40
41	// An endpoint resolver that can be used to provide or override an endpoint for the given
42	// service and region Please see the `aws.EndpointResolver` documentation on usage.
43	EndpointResolver EndpointResolver
44
45	// Retryer is a function that provides a Retryer implementation. A Retryer guides how HTTP requests should be
46	// retried in case of recoverable failures. When nil the API client will use a default
47	// retryer.
48	//
49	// In general, the provider function should return a new instance of a Retyer if you are attempting
50	// to provide a consistent Retryer configuration across all clients. This will ensure that each client will be
51	// provided a new instance of the Retryer implementation, and will avoid issues such as sharing the same retry token
52	// bucket across services.
53	Retryer func() Retryer
54
55	// ConfigSources are the sources that were used to construct the Config.
56	// Allows for additional configuration to be loaded by clients.
57	ConfigSources []interface{}
58
59	// APIOptions provides the set of middleware mutations modify how the API
60	// client requests will be handled. This is useful for adding additional
61	// tracing data to a request, or changing behavior of the SDK's client.
62	APIOptions []func(*middleware.Stack) error
63
64	// The logger writer interface to write logging messages to. Defaults to
65	// standard error.
66	Logger logging.Logger
67
68	// Configures the events that will be sent to the configured logger.
69	// This can be used to configure the logging of signing, retries, request, and responses
70	// of the SDK clients.
71	//
72	// See the ClientLogMode type documentation for the complete set of logging modes and available
73	// configuration.
74	ClientLogMode ClientLogMode
75}
76
77// NewConfig returns a new Config pointer that can be chained with builder
78// methods to set multiple configuration values inline without using pointers.
79func NewConfig() *Config {
80	return &Config{}
81}
82
83// Copy will return a shallow copy of the Config object. If any additional
84// configurations are provided they will be merged into the new config returned.
85func (c Config) Copy() Config {
86	cp := c
87	return cp
88}
89