1package aws
2
3import (
4 "fmt"
5)
6
7// DualStackEndpointState is a constant to describe the dual-stack endpoint resolution behavior.
8type DualStackEndpointState uint
9
10const (
11 // DualStackEndpointStateUnset is the default value behavior for dual-stack endpoint resolution.
12 DualStackEndpointStateUnset DualStackEndpointState = iota
13
14 // DualStackEndpointStateEnabled enables dual-stack endpoint resolution for service endpoints.
15 DualStackEndpointStateEnabled
16
17 // DualStackEndpointStateDisabled disables dual-stack endpoint resolution for endpoints.
18 DualStackEndpointStateDisabled
19)
20
21// GetUseDualStackEndpoint takes a service's EndpointResolverOptions and returns the UseDualStackEndpoint value.
22// Returns boolean false if the provided options does not have a method to retrieve the DualStackEndpointState.
23func GetUseDualStackEndpoint(options ...interface{}) (value DualStackEndpointState, found bool) {
24 type iface interface {
25 GetUseDualStackEndpoint() DualStackEndpointState
26 }
27 for _, option := range options {
28 if i, ok := option.(iface); ok {
29 value = i.GetUseDualStackEndpoint()
30 found = true
31 break
32 }
33 }
34 return value, found
35}
36
37// FIPSEndpointState is a constant to describe the FIPS endpoint resolution behavior.
38type FIPSEndpointState uint
39
40const (
41 // FIPSEndpointStateUnset is the default value behavior for FIPS endpoint resolution.
42 FIPSEndpointStateUnset FIPSEndpointState = iota
43
44 // FIPSEndpointStateEnabled enables FIPS endpoint resolution for service endpoints.
45 FIPSEndpointStateEnabled
46
47 // FIPSEndpointStateDisabled disables FIPS endpoint resolution for endpoints.
48 FIPSEndpointStateDisabled
49)
50
51// GetUseFIPSEndpoint takes a service's EndpointResolverOptions and returns the UseDualStackEndpoint value.
52// Returns boolean false if the provided options does not have a method to retrieve the DualStackEndpointState.
53func GetUseFIPSEndpoint(options ...interface{}) (value FIPSEndpointState, found bool) {
54 type iface interface {
55 GetUseFIPSEndpoint() FIPSEndpointState
56 }
57 for _, option := range options {
58 if i, ok := option.(iface); ok {
59 value = i.GetUseFIPSEndpoint()
60 found = true
61 break
62 }
63 }
64 return value, found
65}
66
67// Endpoint represents the endpoint a service client should make API operation
68// calls to.
69//
70// The SDK will automatically resolve these endpoints per API client using an
71// internal endpoint resolvers. If you'd like to provide custom endpoint
72// resolving behavior you can implement the EndpointResolver interface.
73//
74// Deprecated: This structure was used with the global [EndpointResolver]
75// interface, which has been deprecated in favor of service-specific endpoint
76// resolution. See the deprecation docs on that interface for more information.
77type Endpoint struct {
78 // The base URL endpoint the SDK API clients will use to make API calls to.
79 // The SDK will suffix URI path and query elements to this endpoint.
80 URL string
81
82 // Specifies if the endpoint's hostname can be modified by the SDK's API
83 // client.
84 //
85 // If the hostname is mutable the SDK API clients may modify any part of
86 // the hostname based on the requirements of the API, (e.g. adding, or
87 // removing content in the hostname). Such as, Amazon S3 API client
88 // prefixing "bucketname" to the hostname, or changing the
89 // hostname service name component from "s3." to "s3-accesspoint.dualstack."
90 // for the dualstack endpoint of an S3 Accesspoint resource.
91 //
92 // Care should be taken when providing a custom endpoint for an API. If the
93 // endpoint hostname is mutable, and the client cannot modify the endpoint
94 // correctly, the operation call will most likely fail, or have undefined
95 // behavior.
96 //
97 // If hostname is immutable, the SDK API clients will not modify the
98 // hostname of the URL. This may cause the API client not to function
99 // correctly if the API requires the operation specific hostname values
100 // to be used by the client.
101 //
102 // This flag does not modify the API client's behavior if this endpoint
103 // will be used instead of Endpoint Discovery, or if the endpoint will be
104 // used to perform Endpoint Discovery. That behavior is configured via the
105 // API Client's Options.
106 HostnameImmutable bool
107
108 // The AWS partition the endpoint belongs to.
109 PartitionID string
110
111 // The service name that should be used for signing the requests to the
112 // endpoint.
113 SigningName string
114
115 // The region that should be used for signing the request to the endpoint.
116 SigningRegion string
117
118 // The signing method that should be used for signing the requests to the
119 // endpoint.
120 SigningMethod string
121
122 // The source of the Endpoint. By default, this will be EndpointSourceServiceMetadata.
123 // When providing a custom endpoint, you should set the source as EndpointSourceCustom.
124 // If source is not provided when providing a custom endpoint, the SDK may not
125 // perform required host mutations correctly. Source should be used along with
126 // HostnameImmutable property as per the usage requirement.
127 Source EndpointSource
128}
129
130// EndpointSource is the endpoint source type.
131//
132// Deprecated: The global [Endpoint] structure is deprecated.
133type EndpointSource int
134
135const (
136 // EndpointSourceServiceMetadata denotes service modeled endpoint metadata is used as Endpoint Source.
137 EndpointSourceServiceMetadata EndpointSource = iota
138
139 // EndpointSourceCustom denotes endpoint is a custom endpoint. This source should be used when
140 // user provides a custom endpoint to be used by the SDK.
141 EndpointSourceCustom
142)
143
144// EndpointNotFoundError is a sentinel error to indicate that the
145// EndpointResolver implementation was unable to resolve an endpoint for the
146// given service and region. Resolvers should use this to indicate that an API
147// client should fallback and attempt to use it's internal default resolver to
148// resolve the endpoint.
149type EndpointNotFoundError struct {
150 Err error
151}
152
153// Error is the error message.
154func (e *EndpointNotFoundError) Error() string {
155 return fmt.Sprintf("endpoint not found, %v", e.Err)
156}
157
158// Unwrap returns the underlying error.
159func (e *EndpointNotFoundError) Unwrap() error {
160 return e.Err
161}
162
163// EndpointResolver is an endpoint resolver that can be used to provide or
164// override an endpoint for the given service and region. API clients will
165// attempt to use the EndpointResolver first to resolve an endpoint if
166// available. If the EndpointResolver returns an EndpointNotFoundError error,
167// API clients will fallback to attempting to resolve the endpoint using its
168// internal default endpoint resolver.
169//
170// Deprecated: The global endpoint resolution interface is deprecated. The API
171// for endpoint resolution is now unique to each service and is set via the
172// EndpointResolverV2 field on service client options. Setting a value for
173// EndpointResolver on aws.Config or service client options will prevent you
174// from using any endpoint-related service features released after the
175// introduction of EndpointResolverV2. You may also encounter broken or
176// unexpected behavior when using the old global interface with services that
177// use many endpoint-related customizations such as S3.
178type EndpointResolver interface {
179 ResolveEndpoint(service, region string) (Endpoint, error)
180}
181
182// EndpointResolverFunc wraps a function to satisfy the EndpointResolver interface.
183//
184// Deprecated: The global endpoint resolution interface is deprecated. See
185// deprecation docs on [EndpointResolver].
186type EndpointResolverFunc func(service, region string) (Endpoint, error)
187
188// ResolveEndpoint calls the wrapped function and returns the results.
189func (e EndpointResolverFunc) ResolveEndpoint(service, region string) (Endpoint, error) {
190 return e(service, region)
191}
192
193// EndpointResolverWithOptions is an endpoint resolver that can be used to provide or
194// override an endpoint for the given service, region, and the service client's EndpointOptions. API clients will
195// attempt to use the EndpointResolverWithOptions first to resolve an endpoint if
196// available. If the EndpointResolverWithOptions returns an EndpointNotFoundError error,
197// API clients will fallback to attempting to resolve the endpoint using its
198// internal default endpoint resolver.
199//
200// Deprecated: The global endpoint resolution interface is deprecated. See
201// deprecation docs on [EndpointResolver].
202type EndpointResolverWithOptions interface {
203 ResolveEndpoint(service, region string, options ...interface{}) (Endpoint, error)
204}
205
206// EndpointResolverWithOptionsFunc wraps a function to satisfy the EndpointResolverWithOptions interface.
207//
208// Deprecated: The global endpoint resolution interface is deprecated. See
209// deprecation docs on [EndpointResolver].
210type EndpointResolverWithOptionsFunc func(service, region string, options ...interface{}) (Endpoint, error)
211
212// ResolveEndpoint calls the wrapped function and returns the results.
213func (e EndpointResolverWithOptionsFunc) ResolveEndpoint(service, region string, options ...interface{}) (Endpoint, error) {
214 return e(service, region, options...)
215}
216
217// GetDisableHTTPS takes a service's EndpointResolverOptions and returns the DisableHTTPS value.
218// Returns boolean false if the provided options does not have a method to retrieve the DisableHTTPS.
219func GetDisableHTTPS(options ...interface{}) (value bool, found bool) {
220 type iface interface {
221 GetDisableHTTPS() bool
222 }
223 for _, option := range options {
224 if i, ok := option.(iface); ok {
225 value = i.GetDisableHTTPS()
226 found = true
227 break
228 }
229 }
230 return value, found
231}
232
233// GetResolvedRegion takes a service's EndpointResolverOptions and returns the ResolvedRegion value.
234// Returns boolean false if the provided options does not have a method to retrieve the ResolvedRegion.
235func GetResolvedRegion(options ...interface{}) (value string, found bool) {
236 type iface interface {
237 GetResolvedRegion() string
238 }
239 for _, option := range options {
240 if i, ok := option.(iface); ok {
241 value = i.GetResolvedRegion()
242 found = true
243 break
244 }
245 }
246 return value, found
247}