Skip to content

Commit 6bf32b1

Browse files
authored
chore(codegen): move eventstream services to id-auth sra (#6340)
1 parent 56ce5e5 commit 6bf32b1

24 files changed

+814
-90
lines changed

clients/client-lex-runtime-v2/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"@aws-sdk/middleware-host-header": "*",
3030
"@aws-sdk/middleware-logger": "*",
3131
"@aws-sdk/middleware-recursion-detection": "*",
32-
"@aws-sdk/middleware-signing": "*",
3332
"@aws-sdk/middleware-user-agent": "*",
3433
"@aws-sdk/region-config-resolver": "*",
3534
"@aws-sdk/types": "*",
@@ -61,6 +60,7 @@
6160
"@smithy/util-defaults-mode-browser": "^3.0.13",
6261
"@smithy/util-defaults-mode-node": "^3.0.13",
6362
"@smithy/util-endpoints": "^2.0.5",
63+
"@smithy/util-middleware": "^3.0.3",
6464
"@smithy/util-retry": "^3.0.3",
6565
"@smithy/util-stream": "^3.1.3",
6666
"@smithy/util-utf8": "^3.0.0",

clients/client-lex-runtime-v2/src/LexRuntimeV2Client.ts

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,19 @@ import {
1212
} from "@aws-sdk/middleware-host-header";
1313
import { getLoggerPlugin } from "@aws-sdk/middleware-logger";
1414
import { getRecursionDetectionPlugin } from "@aws-sdk/middleware-recursion-detection";
15-
import {
16-
AwsAuthInputConfig,
17-
AwsAuthResolvedConfig,
18-
getAwsAuthPlugin,
19-
resolveAwsAuthConfig,
20-
} from "@aws-sdk/middleware-signing";
2115
import {
2216
getUserAgentPlugin,
2317
resolveUserAgentConfig,
2418
UserAgentInputConfig,
2519
UserAgentResolvedConfig,
2620
} from "@aws-sdk/middleware-user-agent";
27-
import {
28-
Credentials as __Credentials,
29-
EventStreamPayloadHandlerProvider as __EventStreamPayloadHandlerProvider,
30-
} from "@aws-sdk/types";
21+
import { EventStreamPayloadHandlerProvider as __EventStreamPayloadHandlerProvider } from "@aws-sdk/types";
3122
import { RegionInputConfig, RegionResolvedConfig, resolveRegionConfig } from "@smithy/config-resolver";
23+
import {
24+
DefaultIdentityProviderConfig,
25+
getHttpAuthSchemeEndpointRuleSetPlugin,
26+
getHttpSigningPlugin,
27+
} from "@smithy/core";
3228
import {
3329
EventStreamSerdeInputConfig,
3430
EventStreamSerdeResolvedConfig,
@@ -45,6 +41,7 @@ import {
4541
SmithyResolvedConfiguration as __SmithyResolvedConfiguration,
4642
} from "@smithy/smithy-client";
4743
import {
44+
AwsCredentialIdentityProvider,
4845
BodyLengthCalculator as __BodyLengthCalculator,
4946
CheckOptionalClientConfig as __CheckOptionalClientConfig,
5047
ChecksumConstructor as __ChecksumConstructor,
@@ -63,6 +60,12 @@ import {
6360
UserAgent as __UserAgent,
6461
} from "@smithy/types";
6562

63+
import {
64+
defaultLexRuntimeV2HttpAuthSchemeParametersProvider,
65+
HttpAuthSchemeInputConfig,
66+
HttpAuthSchemeResolvedConfig,
67+
resolveHttpAuthSchemeConfig,
68+
} from "./auth/httpAuthSchemeProvider";
6669
import { DeleteSessionCommandInput, DeleteSessionCommandOutput } from "./commands/DeleteSessionCommand";
6770
import { GetSessionCommandInput, GetSessionCommandOutput } from "./commands/GetSessionCommand";
6871
import { PutSessionCommandInput, PutSessionCommandOutput } from "./commands/PutSessionCommand";
@@ -201,15 +204,10 @@ export interface ClientDefaults extends Partial<__SmithyConfiguration<__HttpHand
201204

202205
/**
203206
* Default credentials provider; Not available in browser runtime.
207+
* @deprecated
204208
* @internal
205209
*/
206-
credentialDefaultProvider?: (input: any) => __Provider<__Credentials>;
207-
208-
/**
209-
* The function that provides necessary utilities for handling request event stream.
210-
* @internal
211-
*/
212-
eventStreamPayloadHandlerProvider?: __EventStreamPayloadHandlerProvider;
210+
credentialDefaultProvider?: (input: any) => AwsCredentialIdentityProvider;
213211

214212
/**
215213
* Value for how many times a request will be made at most in case of retry.
@@ -243,6 +241,12 @@ export interface ClientDefaults extends Partial<__SmithyConfiguration<__HttpHand
243241
*/
244242
defaultsMode?: __DefaultsMode | __Provider<__DefaultsMode>;
245243

244+
/**
245+
* The function that provides necessary utilities for handling request event stream.
246+
* @internal
247+
*/
248+
eventStreamPayloadHandlerProvider?: __EventStreamPayloadHandlerProvider;
249+
246250
/**
247251
* The internal function that inject utilities to runtime-specific stream to help users consume the data
248252
* @internal
@@ -260,9 +264,9 @@ export type LexRuntimeV2ClientConfigType = Partial<__SmithyConfiguration<__HttpH
260264
RegionInputConfig &
261265
HostHeaderInputConfig &
262266
EndpointInputConfig<EndpointParameters> &
263-
AwsAuthInputConfig &
264-
EventStreamInputConfig &
265267
EventStreamSerdeInputConfig &
268+
HttpAuthSchemeInputConfig &
269+
EventStreamInputConfig &
266270
ClientInputEndpointParameters;
267271
/**
268272
* @public
@@ -282,9 +286,9 @@ export type LexRuntimeV2ClientResolvedConfigType = __SmithyResolvedConfiguration
282286
RegionResolvedConfig &
283287
HostHeaderResolvedConfig &
284288
EndpointResolvedConfig<EndpointParameters> &
285-
AwsAuthResolvedConfig &
286-
EventStreamResolvedConfig &
287289
EventStreamSerdeResolvedConfig &
290+
HttpAuthSchemeResolvedConfig &
291+
EventStreamResolvedConfig &
288292
ClientResolvedEndpointParameters;
289293
/**
290294
* @public
@@ -316,9 +320,9 @@ export class LexRuntimeV2Client extends __Client<
316320
const _config_4 = resolveRegionConfig(_config_3);
317321
const _config_5 = resolveHostHeaderConfig(_config_4);
318322
const _config_6 = resolveEndpointConfig(_config_5);
319-
const _config_7 = resolveAwsAuthConfig(_config_6);
320-
const _config_8 = resolveEventStreamConfig(_config_7);
321-
const _config_9 = resolveEventStreamSerdeConfig(_config_8);
323+
const _config_7 = resolveEventStreamSerdeConfig(_config_6);
324+
const _config_8 = resolveHttpAuthSchemeConfig(_config_7);
325+
const _config_9 = resolveEventStreamConfig(_config_8);
322326
const _config_10 = resolveRuntimeExtensions(_config_9, configuration?.extensions || []);
323327
super(_config_10);
324328
this.config = _config_10;
@@ -328,7 +332,16 @@ export class LexRuntimeV2Client extends __Client<
328332
this.middlewareStack.use(getHostHeaderPlugin(this.config));
329333
this.middlewareStack.use(getLoggerPlugin(this.config));
330334
this.middlewareStack.use(getRecursionDetectionPlugin(this.config));
331-
this.middlewareStack.use(getAwsAuthPlugin(this.config));
335+
this.middlewareStack.use(
336+
getHttpAuthSchemeEndpointRuleSetPlugin(this.config, {
337+
httpAuthSchemeParametersProvider: defaultLexRuntimeV2HttpAuthSchemeParametersProvider,
338+
identityProviderConfigProvider: async (config: LexRuntimeV2ClientResolvedConfig) =>
339+
new DefaultIdentityProviderConfig({
340+
"aws.auth#sigv4": config.credentials,
341+
}),
342+
})
343+
);
344+
this.middlewareStack.use(getHttpSigningPlugin(this.config));
332345
}
333346

334347
/**
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// smithy-typescript generated code
2+
import { AwsCredentialIdentity, AwsCredentialIdentityProvider, HttpAuthScheme } from "@smithy/types";
3+
4+
import { LexRuntimeV2HttpAuthSchemeProvider } from "./httpAuthSchemeProvider";
5+
6+
/**
7+
* @internal
8+
*/
9+
export interface HttpAuthExtensionConfiguration {
10+
setHttpAuthScheme(httpAuthScheme: HttpAuthScheme): void;
11+
httpAuthSchemes(): HttpAuthScheme[];
12+
setHttpAuthSchemeProvider(httpAuthSchemeProvider: LexRuntimeV2HttpAuthSchemeProvider): void;
13+
httpAuthSchemeProvider(): LexRuntimeV2HttpAuthSchemeProvider;
14+
setCredentials(credentials: AwsCredentialIdentity | AwsCredentialIdentityProvider): void;
15+
credentials(): AwsCredentialIdentity | AwsCredentialIdentityProvider | undefined;
16+
}
17+
18+
/**
19+
* @internal
20+
*/
21+
export type HttpAuthRuntimeConfig = Partial<{
22+
httpAuthSchemes: HttpAuthScheme[];
23+
httpAuthSchemeProvider: LexRuntimeV2HttpAuthSchemeProvider;
24+
credentials: AwsCredentialIdentity | AwsCredentialIdentityProvider;
25+
}>;
26+
27+
/**
28+
* @internal
29+
*/
30+
export const getHttpAuthExtensionConfiguration = (
31+
runtimeConfig: HttpAuthRuntimeConfig
32+
): HttpAuthExtensionConfiguration => {
33+
const _httpAuthSchemes = runtimeConfig.httpAuthSchemes!;
34+
let _httpAuthSchemeProvider = runtimeConfig.httpAuthSchemeProvider!;
35+
let _credentials = runtimeConfig.credentials;
36+
return {
37+
setHttpAuthScheme(httpAuthScheme: HttpAuthScheme): void {
38+
const index = _httpAuthSchemes.findIndex((scheme) => scheme.schemeId === httpAuthScheme.schemeId);
39+
if (index === -1) {
40+
_httpAuthSchemes.push(httpAuthScheme);
41+
} else {
42+
_httpAuthSchemes.splice(index, 1, httpAuthScheme);
43+
}
44+
},
45+
httpAuthSchemes(): HttpAuthScheme[] {
46+
return _httpAuthSchemes;
47+
},
48+
setHttpAuthSchemeProvider(httpAuthSchemeProvider: LexRuntimeV2HttpAuthSchemeProvider): void {
49+
_httpAuthSchemeProvider = httpAuthSchemeProvider;
50+
},
51+
httpAuthSchemeProvider(): LexRuntimeV2HttpAuthSchemeProvider {
52+
return _httpAuthSchemeProvider;
53+
},
54+
setCredentials(credentials: AwsCredentialIdentity | AwsCredentialIdentityProvider): void {
55+
_credentials = credentials;
56+
},
57+
credentials(): AwsCredentialIdentity | AwsCredentialIdentityProvider | undefined {
58+
return _credentials;
59+
},
60+
};
61+
};
62+
63+
/**
64+
* @internal
65+
*/
66+
export const resolveHttpAuthRuntimeConfig = (config: HttpAuthExtensionConfiguration): HttpAuthRuntimeConfig => {
67+
return {
68+
httpAuthSchemes: config.httpAuthSchemes(),
69+
httpAuthSchemeProvider: config.httpAuthSchemeProvider(),
70+
credentials: config.credentials(),
71+
};
72+
};
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
// smithy-typescript generated code
2+
import {
3+
AwsSdkSigV4AuthInputConfig,
4+
AwsSdkSigV4AuthResolvedConfig,
5+
AwsSdkSigV4PreviouslyResolved,
6+
resolveAwsSdkSigV4Config,
7+
} from "@aws-sdk/core";
8+
import {
9+
HandlerExecutionContext,
10+
HttpAuthOption,
11+
HttpAuthScheme,
12+
HttpAuthSchemeParameters,
13+
HttpAuthSchemeParametersProvider,
14+
HttpAuthSchemeProvider,
15+
} from "@smithy/types";
16+
import { getSmithyContext, normalizeProvider } from "@smithy/util-middleware";
17+
18+
import { LexRuntimeV2ClientConfig, LexRuntimeV2ClientResolvedConfig } from "../LexRuntimeV2Client";
19+
20+
/**
21+
* @internal
22+
*/
23+
export interface LexRuntimeV2HttpAuthSchemeParameters extends HttpAuthSchemeParameters {
24+
region?: string;
25+
}
26+
27+
/**
28+
* @internal
29+
*/
30+
export interface LexRuntimeV2HttpAuthSchemeParametersProvider
31+
extends HttpAuthSchemeParametersProvider<
32+
LexRuntimeV2ClientResolvedConfig,
33+
HandlerExecutionContext,
34+
LexRuntimeV2HttpAuthSchemeParameters,
35+
object
36+
> {}
37+
38+
/**
39+
* @internal
40+
*/
41+
export const defaultLexRuntimeV2HttpAuthSchemeParametersProvider = async (
42+
config: LexRuntimeV2ClientResolvedConfig,
43+
context: HandlerExecutionContext,
44+
input: object
45+
): Promise<LexRuntimeV2HttpAuthSchemeParameters> => {
46+
return {
47+
operation: getSmithyContext(context).operation as string,
48+
region:
49+
(await normalizeProvider(config.region)()) ||
50+
(() => {
51+
throw new Error("expected `region` to be configured for `aws.auth#sigv4`");
52+
})(),
53+
};
54+
};
55+
56+
function createAwsAuthSigv4HttpAuthOption(authParameters: LexRuntimeV2HttpAuthSchemeParameters): HttpAuthOption {
57+
return {
58+
schemeId: "aws.auth#sigv4",
59+
signingProperties: {
60+
name: "lex",
61+
region: authParameters.region,
62+
},
63+
propertiesExtractor: (config: Partial<LexRuntimeV2ClientConfig>, context) => ({
64+
/**
65+
* @internal
66+
*/
67+
signingProperties: {
68+
config,
69+
context,
70+
},
71+
}),
72+
};
73+
}
74+
75+
/**
76+
* @internal
77+
*/
78+
export interface LexRuntimeV2HttpAuthSchemeProvider
79+
extends HttpAuthSchemeProvider<LexRuntimeV2HttpAuthSchemeParameters> {}
80+
81+
/**
82+
* @internal
83+
*/
84+
export const defaultLexRuntimeV2HttpAuthSchemeProvider: LexRuntimeV2HttpAuthSchemeProvider = (authParameters) => {
85+
const options: HttpAuthOption[] = [];
86+
switch (authParameters.operation) {
87+
default: {
88+
options.push(createAwsAuthSigv4HttpAuthOption(authParameters));
89+
}
90+
}
91+
return options;
92+
};
93+
94+
/**
95+
* @internal
96+
*/
97+
export interface HttpAuthSchemeInputConfig extends AwsSdkSigV4AuthInputConfig {
98+
/**
99+
* Configuration of HttpAuthSchemes for a client which provides default identity providers and signers per auth scheme.
100+
* @internal
101+
*/
102+
httpAuthSchemes?: HttpAuthScheme[];
103+
104+
/**
105+
* Configuration of an HttpAuthSchemeProvider for a client which resolves which HttpAuthScheme to use.
106+
* @internal
107+
*/
108+
httpAuthSchemeProvider?: LexRuntimeV2HttpAuthSchemeProvider;
109+
}
110+
111+
/**
112+
* @internal
113+
*/
114+
export interface HttpAuthSchemeResolvedConfig extends AwsSdkSigV4AuthResolvedConfig {
115+
/**
116+
* Configuration of HttpAuthSchemes for a client which provides default identity providers and signers per auth scheme.
117+
* @internal
118+
*/
119+
readonly httpAuthSchemes: HttpAuthScheme[];
120+
121+
/**
122+
* Configuration of an HttpAuthSchemeProvider for a client which resolves which HttpAuthScheme to use.
123+
* @internal
124+
*/
125+
readonly httpAuthSchemeProvider: LexRuntimeV2HttpAuthSchemeProvider;
126+
}
127+
128+
/**
129+
* @internal
130+
*/
131+
export const resolveHttpAuthSchemeConfig = <T>(
132+
config: T & HttpAuthSchemeInputConfig & AwsSdkSigV4PreviouslyResolved
133+
): T & HttpAuthSchemeResolvedConfig => {
134+
const config_0 = resolveAwsSdkSigV4Config(config);
135+
return {
136+
...config_0,
137+
} as T & HttpAuthSchemeResolvedConfig;
138+
};

clients/client-lex-runtime-v2/src/extensionConfiguration.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ import { AwsRegionExtensionConfiguration } from "@aws-sdk/types";
33
import { HttpHandlerExtensionConfiguration } from "@smithy/protocol-http";
44
import { DefaultExtensionConfiguration } from "@smithy/types";
55

6+
import { HttpAuthExtensionConfiguration } from "./auth/httpAuthExtensionConfiguration";
7+
68
/**
79
* @internal
810
*/
911
export interface LexRuntimeV2ExtensionConfiguration
1012
extends HttpHandlerExtensionConfiguration,
1113
DefaultExtensionConfiguration,
12-
AwsRegionExtensionConfiguration {}
14+
AwsRegionExtensionConfiguration,
15+
HttpAuthExtensionConfiguration {}

clients/client-lex-runtime-v2/src/models/models_0.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// smithy-typescript generated code
22
import { ExceptionOptionType as __ExceptionOptionType, SENSITIVE_STRING } from "@smithy/smithy-client";
3-
43
import { StreamingBlobTypes } from "@smithy/types";
54

65
import { LexRuntimeV2ServiceException as __BaseException } from "./LexRuntimeV2ServiceException";

0 commit comments

Comments
 (0)