code.dwrz.net

Go monorepo.
Log | Files | Refs

config.go (7302B)


      1 package aws
      2 
      3 import (
      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.
     14 type HTTPClient interface {
     15 	Do(*http.Request) (*http.Response, error)
     16 }
     17 
     18 // A Config provides service configuration for service clients.
     19 type 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 	EndpointResolverWithOptions EndpointResolverWithOptions
     72 
     73 	// RetryMaxAttempts specifies the maximum number attempts an API client
     74 	// will call an operation that fails with a retryable error.
     75 	//
     76 	// API Clients will only use this value to construct a retryer if the
     77 	// Config.Retryer member is not nil. This value will be ignored if
     78 	// Retryer is not nil.
     79 	RetryMaxAttempts int
     80 
     81 	// RetryMode specifies the retry model the API client will be created with.
     82 	//
     83 	// API Clients will only use this value to construct a retryer if the
     84 	// Config.Retryer member is not nil. This value will be ignored if
     85 	// Retryer is not nil.
     86 	RetryMode RetryMode
     87 
     88 	// Retryer is a function that provides a Retryer implementation. A Retryer
     89 	// guides how HTTP requests should be retried in case of recoverable
     90 	// failures. When nil the API client will use a default retryer.
     91 	//
     92 	// In general, the provider function should return a new instance of a
     93 	// Retryer if you are attempting to provide a consistent Retryer
     94 	// configuration across all clients. This will ensure that each client will
     95 	// be provided a new instance of the Retryer implementation, and will avoid
     96 	// issues such as sharing the same retry token bucket across services.
     97 	//
     98 	// If not nil, RetryMaxAttempts, and RetryMode will be ignored by API
     99 	// clients.
    100 	Retryer func() Retryer
    101 
    102 	// ConfigSources are the sources that were used to construct the Config.
    103 	// Allows for additional configuration to be loaded by clients.
    104 	ConfigSources []interface{}
    105 
    106 	// APIOptions provides the set of middleware mutations modify how the API
    107 	// client requests will be handled. This is useful for adding additional
    108 	// tracing data to a request, or changing behavior of the SDK's client.
    109 	APIOptions []func(*middleware.Stack) error
    110 
    111 	// The logger writer interface to write logging messages to. Defaults to
    112 	// standard error.
    113 	Logger logging.Logger
    114 
    115 	// Configures the events that will be sent to the configured logger. This
    116 	// can be used to configure the logging of signing, retries, request, and
    117 	// responses of the SDK clients.
    118 	//
    119 	// See the ClientLogMode type documentation for the complete set of logging
    120 	// modes and available configuration.
    121 	ClientLogMode ClientLogMode
    122 
    123 	// The configured DefaultsMode. If not specified, service clients will
    124 	// default to legacy.
    125 	//
    126 	// Supported modes are: auto, cross-region, in-region, legacy, mobile,
    127 	// standard
    128 	DefaultsMode DefaultsMode
    129 
    130 	// The RuntimeEnvironment configuration, only populated if the DefaultsMode
    131 	// is set to DefaultsModeAuto and is initialized by
    132 	// `config.LoadDefaultConfig`. You should not populate this structure
    133 	// programmatically, or rely on the values here within your applications.
    134 	RuntimeEnvironment RuntimeEnvironment
    135 }
    136 
    137 // NewConfig returns a new Config pointer that can be chained with builder
    138 // methods to set multiple configuration values inline without using pointers.
    139 func NewConfig() *Config {
    140 	return &Config{}
    141 }
    142 
    143 // Copy will return a shallow copy of the Config object. If any additional
    144 // configurations are provided they will be merged into the new config returned.
    145 func (c Config) Copy() Config {
    146 	cp := c
    147 	return cp
    148 }
    149 
    150 // EndpointDiscoveryEnableState indicates if endpoint discovery is
    151 // enabled, disabled, auto or unset state.
    152 //
    153 // Default behavior (Auto or Unset) indicates operations that require endpoint
    154 // discovery will use Endpoint Discovery by default. Operations that
    155 // optionally use Endpoint Discovery will not use Endpoint Discovery
    156 // unless EndpointDiscovery is explicitly enabled.
    157 type EndpointDiscoveryEnableState uint
    158 
    159 // Enumeration values for EndpointDiscoveryEnableState
    160 const (
    161 	// EndpointDiscoveryUnset represents EndpointDiscoveryEnableState is unset.
    162 	// Users do not need to use this value explicitly. The behavior for unset
    163 	// is the same as for EndpointDiscoveryAuto.
    164 	EndpointDiscoveryUnset EndpointDiscoveryEnableState = iota
    165 
    166 	// EndpointDiscoveryAuto represents an AUTO state that allows endpoint
    167 	// discovery only when required by the api. This is the default
    168 	// configuration resolved by the client if endpoint discovery is neither
    169 	// enabled or disabled.
    170 	EndpointDiscoveryAuto // default state
    171 
    172 	// EndpointDiscoveryDisabled indicates client MUST not perform endpoint
    173 	// discovery even when required.
    174 	EndpointDiscoveryDisabled
    175 
    176 	// EndpointDiscoveryEnabled indicates client MUST always perform endpoint
    177 	// discovery if supported for the operation.
    178 	EndpointDiscoveryEnabled
    179 )