options.go 8.5 KB

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