Skip to content

Commit df24484

Browse files
authored
chore(clients): convert second argument of resolve to options (#2523)
* chore(middleware-endpoint-discovery): pass Ctor in options * chore(middleware-sdk-sts): pass Ctor in options * chore(middleware-endpoint-discovery): use destructuring in resolve function * chore(codegen): set keys for resolve function arguments * chore(clients): convert second argument of resolve to options
1 parent 93b5cfd commit df24484

File tree

9 files changed

+36
-16
lines changed

9 files changed

+36
-16
lines changed

clients/client-dynamodb/DynamoDBClient.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,9 @@ export class DynamoDBClient extends __Client<
454454
let _config_4 = resolveHostHeaderConfig(_config_3);
455455
let _config_5 = resolveAwsAuthConfig(_config_4);
456456
let _config_6 = resolveUserAgentConfig(_config_5);
457-
let _config_7 = resolveEndpointDiscoveryConfig(_config_6, DescribeEndpointsCommand);
457+
let _config_7 = resolveEndpointDiscoveryConfig(_config_6, {
458+
endpointDiscoveryCommandCtor: DescribeEndpointsCommand,
459+
});
458460
super(_config_7);
459461
this.config = _config_7;
460462
this.middlewareStack.use(getRetryPlugin(this.config));

clients/client-sts/STSClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ export class STSClient extends __Client<
244244
let _config_2 = resolveEndpointsConfig(_config_1);
245245
let _config_3 = resolveRetryConfig(_config_2);
246246
let _config_4 = resolveHostHeaderConfig(_config_3);
247-
let _config_5 = resolveStsAuthConfig(_config_4, STSClient);
247+
let _config_5 = resolveStsAuthConfig(_config_4, { stsClientCtor: STSClient });
248248
let _config_6 = resolveUserAgentConfig(_config_5);
249249
super(_config_6);
250250
this.config = _config_6;

clients/client-timestream-query/TimestreamQueryClient.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,9 @@ export class TimestreamQueryClient extends __Client<
240240
let _config_4 = resolveHostHeaderConfig(_config_3);
241241
let _config_5 = resolveAwsAuthConfig(_config_4);
242242
let _config_6 = resolveUserAgentConfig(_config_5);
243-
let _config_7 = resolveEndpointDiscoveryConfig(_config_6, DescribeEndpointsCommand);
243+
let _config_7 = resolveEndpointDiscoveryConfig(_config_6, {
244+
endpointDiscoveryCommandCtor: DescribeEndpointsCommand,
245+
});
244246
super(_config_7);
245247
this.config = _config_7;
246248
this.middlewareStack.use(getRetryPlugin(this.config));

clients/client-timestream-write/TimestreamWriteClient.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,9 @@ export class TimestreamWriteClient extends __Client<
283283
let _config_4 = resolveHostHeaderConfig(_config_3);
284284
let _config_5 = resolveAwsAuthConfig(_config_4);
285285
let _config_6 = resolveUserAgentConfig(_config_5);
286-
let _config_7 = resolveEndpointDiscoveryConfig(_config_6, DescribeEndpointsCommand);
286+
let _config_7 = resolveEndpointDiscoveryConfig(_config_6, {
287+
endpointDiscoveryCommandCtor: DescribeEndpointsCommand,
288+
});
287289
super(_config_7);
288290
this.config = _config_7;
289291
this.middlewareStack.use(getRetryPlugin(this.config));

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddAwsAuthPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ && isAwsService(s)
107107
.withConventions(AwsDependency.STS_MIDDLEWARE.dependency,
108108
"StsAuth", HAS_CONFIG)
109109
.additionalResolveFunctionParamsSupplier((m, s, o) -> new HashMap<String, Object>() {{
110-
put("STSClient", Symbol.builder().name("STSClient").build());
110+
put("stsClientCtor", Symbol.builder().name("STSClient").build());
111111
}})
112112
.servicePredicate((m, s) -> testServiceId(s, "STS"))
113113
.build(),

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddEndpointDiscoveryPlugin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ public List<RuntimeClientPlugin> getClientPlugins() {
7171
"EndpointDiscovery", RuntimeClientPlugin.Convention.HAS_CONFIG)
7272
// ToDo: The Endpoint Discovery Command Name needs to be read from ClientEndpointDiscoveryTrait.
7373
.additionalResolveFunctionParamsSupplier((m, s, o) -> new HashMap<String, Object>() {{
74-
put("DescribeEndpointsCommand", Symbol.builder().name("DescribeEndpointsCommand").build());
74+
put("endpointDiscoveryCommandCtor",
75+
Symbol.builder().name("DescribeEndpointsCommand").build());
7576
}})
7677
.servicePredicate((m, s) -> hasClientEndpointDiscovery(s))
7778
.build(),

packages/middleware-endpoint-discovery/src/resolveEndpointDiscoveryConfig.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe(resolveEndpointDiscoveryConfig.name, () => {
1717
});
1818

1919
it("assigns endpointDiscoveryCommandCtor in resolvedConfig", () => {
20-
const resolvedConfig = resolveEndpointDiscoveryConfig(mockInput, endpointDiscoveryCommandCtor);
20+
const resolvedConfig = resolveEndpointDiscoveryConfig(mockInput, { endpointDiscoveryCommandCtor });
2121
expect(resolvedConfig.endpointDiscoveryCommandCtor).toStrictEqual(endpointDiscoveryCommandCtor);
2222
});
2323

@@ -29,13 +29,13 @@ describe(resolveEndpointDiscoveryConfig.name, () => {
2929
...mockInput,
3030
endpointCacheSize,
3131
},
32-
endpointDiscoveryCommandCtor
32+
{ endpointDiscoveryCommandCtor }
3333
);
3434
expect(EndpointCache).toBeCalledWith(endpointCacheSize);
3535
});
3636

3737
it("creates cache of size 1000 if endpointCacheSize not passed", () => {
38-
resolveEndpointDiscoveryConfig(mockInput, endpointDiscoveryCommandCtor);
38+
resolveEndpointDiscoveryConfig(mockInput, { endpointDiscoveryCommandCtor });
3939
expect(EndpointCache).toBeCalledWith(1000);
4040
});
4141
});
@@ -47,15 +47,15 @@ describe(resolveEndpointDiscoveryConfig.name, () => {
4747
...mockInput,
4848
endpointDiscoveryEnabled,
4949
},
50-
endpointDiscoveryCommandCtor
50+
{ endpointDiscoveryCommandCtor }
5151
);
5252
expect(resolvedConfig.endpointDiscoveryEnabled()).resolves.toBe(endpointDiscoveryEnabled);
5353
expect(mockInput.endpointDiscoveryEnabledProvider).not.toHaveBeenCalled();
5454
expect(resolvedConfig.isClientEndpointDiscoveryEnabled).toStrictEqual(true);
5555
});
5656

5757
it(`sets to endpointDiscoveryEnabledProvider if value is not passed`, () => {
58-
const resolvedConfig = resolveEndpointDiscoveryConfig(mockInput, endpointDiscoveryCommandCtor);
58+
const resolvedConfig = resolveEndpointDiscoveryConfig(mockInput, { endpointDiscoveryCommandCtor });
5959
expect(resolvedConfig.endpointDiscoveryEnabled).toBe(mockInput.endpointDiscoveryEnabledProvider);
6060
expect(resolvedConfig.isClientEndpointDiscoveryEnabled).toStrictEqual(false);
6161
});

packages/middleware-endpoint-discovery/src/resolveEndpointDiscoveryConfig.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,16 @@ export interface EndpointDiscoveryResolvedConfig {
5151
isClientEndpointDiscoveryEnabled: boolean;
5252
}
5353

54+
export interface EndpointDiscoveryConfigOptions {
55+
/**
56+
* The constructor of the Command used for discovering endpoints.
57+
*/
58+
endpointDiscoveryCommandCtor: new (comandConfig: any) => any;
59+
}
60+
5461
export const resolveEndpointDiscoveryConfig = <T>(
5562
input: T & PreviouslyResolved & EndpointDiscoveryInputConfig,
56-
endpointDiscoveryCommandCtor: new (comandConfig: any) => any
63+
{ endpointDiscoveryCommandCtor }: EndpointDiscoveryConfigOptions
5764
): T & EndpointDiscoveryResolvedConfig => ({
5865
...input,
5966
endpointDiscoveryCommandCtor,

packages/middleware-sdk-sts/src/index.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,23 @@ export interface StsAuthResolvedConfig extends AwsAuthResolvedConfig {
1818
stsClientCtor: new (clientConfig: any) => Client<any, any, any>;
1919
}
2020

21+
export interface StsAuthConfigOptions {
22+
/**
23+
* Reference to STSClient class constructor.
24+
*/
25+
stsClientCtor: new (clientConfig: any) => Client<any, any, any>;
26+
}
27+
2128
/**
2229
* Set STS client constructor to `stsClientCtor` config parameter. It is used
2330
* for role assumers for STS client internally. See `clients/client-sts/defaultStsRoleAssumers.ts`
2431
* and `clients/client-sts/STSClient.ts`.
2532
*/
2633
export const resolveStsAuthConfig = <T>(
2734
input: T & PreviouslyResolved & StsAuthInputConfig,
28-
stsClientCtor: new (clientConfig: any) => Client<any, any, any>
29-
): T & StsAuthResolvedConfig => {
30-
return resolveAwsAuthConfig({
35+
{ stsClientCtor }: StsAuthConfigOptions
36+
): T & StsAuthResolvedConfig =>
37+
resolveAwsAuthConfig({
3138
...input,
3239
stsClientCtor,
3340
});
34-
};

0 commit comments

Comments
 (0)