Skip to content

Commit 3d782f0

Browse files
authored
docs: update endpoint section (#5781)
1 parent 8c0b29e commit 3d782f0

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

supplemental-docs/CLIENTS.md

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,14 @@ const client = new S3Client({
147147
### Custom Endpoint `endpoint`
148148

149149
Each SDK client, by default, resolves the target endpoint with rule-based system
150-
whose base template for any given operation is included in the service model or schema.
151-
At runtime any and all inputs are potentially read to resolve the final endpoint.
150+
described by the service model.
152151

153-
Inputs used to resolve the endpoint for an operation include the region, FIPS/dual-stack options as mentioned above, and in some cases even request-specific parameters.
152+
- Refer to https://smithy.io/2.0/additional-specs/rules-engine/specification.html
153+
154+
At runtime many sources of data are read to resolve the final endpoint.
155+
156+
Sources include the region, FIPS/dual-stack options as mentioned further below,
157+
the operation, and in some cases even request-specific parameters.
154158

155159
You may override all that logic by providing a custom endpoint to the Client
156160
constructor. The simplest form is a URL string.
@@ -182,6 +186,39 @@ new S3Client({
182186
For more information about these structural alternative endpoint types,
183187
use your IDE's type hints or refer to the API documentation linked above.
184188

189+
#### Retrieving the endpoint without making a request
190+
191+
If you would like to know the endpoint of an SDK operation without making a request,
192+
you can make ad hoc use of our internal endpoint resolver.
193+
194+
**This interface is not public/stable**. Do not use this in production, or be prepared
195+
to verify it every time you upgrade the SDK version.
196+
197+
```ts
198+
// Example: resolving an endpoint without a request.
199+
import { GetObjectCommand, S3Client } from "@aws-sdk/client-s3";
200+
import { getEndpointFromInstructions } from "@smithy/middleware-endpoint";
201+
202+
// Initialize your client with whatever parameters you would
203+
// use. They may have an effect on the resolved endpoint,
204+
// especially in case of the AWS region.
205+
const client = new S3Client({
206+
region: "us-east-1",
207+
});
208+
209+
// Minimally, 3 bits of information are needed
210+
// to resolve the endpoint.
211+
212+
/**
213+
* @internal do not directly use in production.
214+
*/
215+
const endpoint = await getEndpointFromInstructions(
216+
{ Key: "foo", Bucket: "bar" }, // 1. the command's input.
217+
GetObjectCommand, // 2. the Command class.
218+
client.config // 3. the client config.
219+
);
220+
```
221+
185222
### Request Handler `requestHandler`
186223

187224
The requestHandler is used in the final step of sending an SDK request and the first receiver of

0 commit comments

Comments
 (0)