options.go 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. // Code generated by smithy-go-codegen DO NOT EDIT.
  2. package costexplorer
  3. import (
  4. "context"
  5. "github.com/aws/aws-sdk-go-v2/aws"
  6. awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
  7. internalauthsmithy "github.com/aws/aws-sdk-go-v2/internal/auth/smithy"
  8. smithyauth "github.com/aws/smithy-go/auth"
  9. "github.com/aws/smithy-go/logging"
  10. "github.com/aws/smithy-go/metrics"
  11. "github.com/aws/smithy-go/middleware"
  12. "github.com/aws/smithy-go/tracing"
  13. smithyhttp "github.com/aws/smithy-go/transport/http"
  14. "net/http"
  15. )
  16. type HTTPClient interface {
  17. Do(*http.Request) (*http.Response, error)
  18. }
  19. type Options struct {
  20. // Set of options to modify how an operation is invoked. These apply to all
  21. // operations invoked for this client. Use functional options on operation call to
  22. // modify this list for per operation behavior.
  23. APIOptions []func(*middleware.Stack) error
  24. // The optional application specific identifier appended to the User-Agent header.
  25. AppID string
  26. // This endpoint will be given as input to an EndpointResolverV2. It is used for
  27. // providing a custom base endpoint that is subject to modifications by the
  28. // processing EndpointResolverV2.
  29. BaseEndpoint *string
  30. // Configures the events that will be sent to the configured logger.
  31. ClientLogMode aws.ClientLogMode
  32. // The credentials object to use when signing requests.
  33. Credentials aws.CredentialsProvider
  34. // The configuration DefaultsMode that the SDK should use when constructing the
  35. // clients initial default settings.
  36. DefaultsMode aws.DefaultsMode
  37. // The endpoint options to be used when attempting to resolve an endpoint.
  38. EndpointOptions EndpointResolverOptions
  39. // The service endpoint resolver.
  40. //
  41. // Deprecated: Deprecated: EndpointResolver and WithEndpointResolver. Providing a
  42. // value for this field will likely prevent you from using any endpoint-related
  43. // service features released after the introduction of EndpointResolverV2 and
  44. // BaseEndpoint.
  45. //
  46. // To migrate an EndpointResolver implementation that uses a custom endpoint, set
  47. // the client option BaseEndpoint instead.
  48. EndpointResolver EndpointResolver
  49. // Resolves the endpoint used for a particular service operation.
  50. EndpointResolverV2 EndpointResolverV2
  51. // Signature Version 4 (SigV4) Signer
  52. HTTPSignerV4 HTTPSignerV4
  53. // The logger writer interface to write logging messages to.
  54. Logger logging.Logger
  55. // The client meter provider.
  56. MeterProvider metrics.MeterProvider
  57. // The region to send requests to. (Required)
  58. Region string
  59. // RetryMaxAttempts specifies the maximum number attempts an API client will call
  60. // an operation that fails with a retryable error. A value of 0 is ignored, and
  61. // will not be used to configure the API client created default retryer, or modify
  62. // per operation call's retry max attempts.
  63. //
  64. // If specified in an operation call's functional options with a value that is
  65. // different than the constructed client's Options, the Client's Retryer will be
  66. // wrapped to use the operation's specific RetryMaxAttempts value.
  67. RetryMaxAttempts int
  68. // RetryMode specifies the retry mode the API client will be created with, if
  69. // Retryer option is not also specified.
  70. //
  71. // When creating a new API Clients this member will only be used if the Retryer
  72. // Options member is nil. This value will be ignored if Retryer is not nil.
  73. //
  74. // Currently does not support per operation call overrides, may in the future.
  75. RetryMode aws.RetryMode
  76. // Retryer guides how HTTP requests should be retried in case of recoverable
  77. // failures. When nil the API client will use a default retryer. The kind of
  78. // default retry created by the API client can be changed with the RetryMode
  79. // option.
  80. Retryer aws.Retryer
  81. // The RuntimeEnvironment configuration, only populated if the DefaultsMode is set
  82. // to DefaultsModeAuto and is initialized using config.LoadDefaultConfig . You
  83. // should not populate this structure programmatically, or rely on the values here
  84. // within your applications.
  85. RuntimeEnvironment aws.RuntimeEnvironment
  86. // The client tracer provider.
  87. TracerProvider tracing.TracerProvider
  88. // The initial DefaultsMode used when the client options were constructed. If the
  89. // DefaultsMode was set to aws.DefaultsModeAuto this will store what the resolved
  90. // value was at that point in time.
  91. //
  92. // Currently does not support per operation call overrides, may in the future.
  93. resolvedDefaultsMode aws.DefaultsMode
  94. // The HTTP client to invoke API calls with. Defaults to client's default HTTP
  95. // implementation if nil.
  96. HTTPClient HTTPClient
  97. // Client registry of operation interceptors.
  98. Interceptors smithyhttp.InterceptorRegistry
  99. // The auth scheme resolver which determines how to authenticate for each
  100. // operation.
  101. AuthSchemeResolver AuthSchemeResolver
  102. // The list of auth schemes supported by the client.
  103. AuthSchemes []smithyhttp.AuthScheme
  104. // Priority list of preferred auth scheme names (e.g. sigv4a).
  105. AuthSchemePreference []string
  106. }
  107. // Copy creates a clone where the APIOptions list is deep copied.
  108. func (o Options) Copy() Options {
  109. to := o
  110. to.APIOptions = make([]func(*middleware.Stack) error, len(o.APIOptions))
  111. copy(to.APIOptions, o.APIOptions)
  112. to.Interceptors = o.Interceptors.Copy()
  113. return to
  114. }
  115. func (o Options) GetIdentityResolver(schemeID string) smithyauth.IdentityResolver {
  116. if schemeID == "aws.auth#sigv4" {
  117. return getSigV4IdentityResolver(o)
  118. }
  119. if schemeID == "smithy.api#noAuth" {
  120. return &smithyauth.AnonymousIdentityResolver{}
  121. }
  122. return nil
  123. }
  124. // WithAPIOptions returns a functional option for setting the Client's APIOptions
  125. // option.
  126. func WithAPIOptions(optFns ...func(*middleware.Stack) error) func(*Options) {
  127. return func(o *Options) {
  128. o.APIOptions = append(o.APIOptions, optFns...)
  129. }
  130. }
  131. // Deprecated: EndpointResolver and WithEndpointResolver. Providing a value for
  132. // this field will likely prevent you from using any endpoint-related service
  133. // features released after the introduction of EndpointResolverV2 and BaseEndpoint.
  134. //
  135. // To migrate an EndpointResolver implementation that uses a custom endpoint, set
  136. // the client option BaseEndpoint instead.
  137. func WithEndpointResolver(v EndpointResolver) func(*Options) {
  138. return func(o *Options) {
  139. o.EndpointResolver = v
  140. }
  141. }
  142. // WithEndpointResolverV2 returns a functional option for setting the Client's
  143. // EndpointResolverV2 option.
  144. func WithEndpointResolverV2(v EndpointResolverV2) func(*Options) {
  145. return func(o *Options) {
  146. o.EndpointResolverV2 = v
  147. }
  148. }
  149. func getSigV4IdentityResolver(o Options) smithyauth.IdentityResolver {
  150. if o.Credentials != nil {
  151. return &internalauthsmithy.CredentialsProviderAdapter{Provider: o.Credentials}
  152. }
  153. return nil
  154. }
  155. // WithSigV4SigningName applies an override to the authentication workflow to
  156. // use the given signing name for SigV4-authenticated operations.
  157. //
  158. // This is an advanced setting. The value here is FINAL, taking precedence over
  159. // the resolved signing name from both auth scheme resolution and endpoint
  160. // resolution.
  161. func WithSigV4SigningName(name string) func(*Options) {
  162. fn := func(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
  163. out middleware.InitializeOutput, metadata middleware.Metadata, err error,
  164. ) {
  165. return next.HandleInitialize(awsmiddleware.SetSigningName(ctx, name), in)
  166. }
  167. return func(o *Options) {
  168. o.APIOptions = append(o.APIOptions, func(s *middleware.Stack) error {
  169. return s.Initialize.Add(
  170. middleware.InitializeMiddlewareFunc("withSigV4SigningName", fn),
  171. middleware.Before,
  172. )
  173. })
  174. }
  175. }
  176. // WithSigV4SigningRegion applies an override to the authentication workflow to
  177. // use the given signing region for SigV4-authenticated operations.
  178. //
  179. // This is an advanced setting. The value here is FINAL, taking precedence over
  180. // the resolved signing region from both auth scheme resolution and endpoint
  181. // resolution.
  182. func WithSigV4SigningRegion(region string) func(*Options) {
  183. fn := func(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
  184. out middleware.InitializeOutput, metadata middleware.Metadata, err error,
  185. ) {
  186. return next.HandleInitialize(awsmiddleware.SetSigningRegion(ctx, region), in)
  187. }
  188. return func(o *Options) {
  189. o.APIOptions = append(o.APIOptions, func(s *middleware.Stack) error {
  190. return s.Initialize.Add(
  191. middleware.InitializeMiddlewareFunc("withSigV4SigningRegion", fn),
  192. middleware.Before,
  193. )
  194. })
  195. }
  196. }
  197. func ignoreAnonymousAuth(options *Options) {
  198. if aws.IsCredentialsProvider(options.Credentials, (*aws.AnonymousCredentials)(nil)) {
  199. options.Credentials = nil
  200. }
  201. }