Skip to content

Commit ca0c783

Browse files
author
Steven Yuan
committed
chore(codegen): generate clients
1 parent 3e21108 commit ca0c783

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1738
-519
lines changed

clients/client-api-gateway/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"@aws-sdk/middleware-logger": "*",
2828
"@aws-sdk/middleware-recursion-detection": "*",
2929
"@aws-sdk/middleware-sdk-api-gateway": "*",
30-
"@aws-sdk/middleware-signing": "*",
3130
"@aws-sdk/middleware-user-agent": "*",
3231
"@aws-sdk/region-config-resolver": "*",
3332
"@aws-sdk/types": "*",
@@ -56,6 +55,7 @@
5655
"@smithy/util-defaults-mode-browser": "^2.0.24",
5756
"@smithy/util-defaults-mode-node": "^2.0.32",
5857
"@smithy/util-endpoints": "^1.0.8",
58+
"@smithy/util-middleware": "^2.0.9",
5959
"@smithy/util-retry": "^2.0.9",
6060
"@smithy/util-stream": "^2.0.24",
6161
"@smithy/util-utf8": "^2.0.2",

clients/client-api-gateway/src/APIGatewayClient.ts

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,18 @@ import {
88
import { getLoggerPlugin } from "@aws-sdk/middleware-logger";
99
import { getRecursionDetectionPlugin } from "@aws-sdk/middleware-recursion-detection";
1010
import { getAcceptHeaderPlugin } from "@aws-sdk/middleware-sdk-api-gateway";
11-
import {
12-
AwsAuthInputConfig,
13-
AwsAuthResolvedConfig,
14-
getAwsAuthPlugin,
15-
resolveAwsAuthConfig,
16-
} from "@aws-sdk/middleware-signing";
1711
import {
1812
getUserAgentPlugin,
1913
resolveUserAgentConfig,
2014
UserAgentInputConfig,
2115
UserAgentResolvedConfig,
2216
} from "@aws-sdk/middleware-user-agent";
23-
import { Credentials as __Credentials } from "@aws-sdk/types";
2417
import { RegionInputConfig, RegionResolvedConfig, resolveRegionConfig } from "@smithy/config-resolver";
18+
import {
19+
DefaultIdentityProviderConfig,
20+
getHttpAuthSchemeEndpointRuleSetPlugin,
21+
getHttpSigningPlugin,
22+
} from "@smithy/core";
2523
import { getContentLengthPlugin } from "@smithy/middleware-content-length";
2624
import { EndpointInputConfig, EndpointResolvedConfig, resolveEndpointConfig } from "@smithy/middleware-endpoint";
2725
import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry";
@@ -33,6 +31,7 @@ import {
3331
SmithyResolvedConfiguration as __SmithyResolvedConfiguration,
3432
} from "@smithy/smithy-client";
3533
import {
34+
AwsCredentialIdentityProvider,
3635
BodyLengthCalculator as __BodyLengthCalculator,
3736
CheckOptionalClientConfig as __CheckOptionalClientConfig,
3837
ChecksumConstructor as __ChecksumConstructor,
@@ -49,6 +48,12 @@ import {
4948
UserAgent as __UserAgent,
5049
} from "@smithy/types";
5150

51+
import {
52+
defaultAPIGatewayHttpAuthSchemeParametersProvider,
53+
HttpAuthSchemeInputConfig,
54+
HttpAuthSchemeResolvedConfig,
55+
resolveHttpAuthSchemeConfig,
56+
} from "./auth/httpAuthSchemeProvider";
5257
import { CreateApiKeyCommandInput, CreateApiKeyCommandOutput } from "./commands/CreateApiKeyCommand";
5358
import { CreateAuthorizerCommandInput, CreateAuthorizerCommandOutput } from "./commands/CreateAuthorizerCommand";
5459
import {
@@ -625,21 +630,22 @@ export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__
625630
useFipsEndpoint?: boolean | __Provider<boolean>;
626631

627632
/**
628-
* The AWS region to which this client will send requests
633+
* The provider populating default tracking information to be sent with `user-agent`, `x-amz-user-agent` header
634+
* @internal
629635
*/
630-
region?: string | __Provider<string>;
636+
defaultUserAgentProvider?: Provider<__UserAgent>;
631637

632638
/**
633-
* Default credentials provider; Not available in browser runtime.
634-
* @internal
639+
* The AWS region to which this client will send requests
635640
*/
636-
credentialDefaultProvider?: (input: any) => __Provider<__Credentials>;
641+
region?: string | __Provider<string>;
637642

638643
/**
639-
* The provider populating default tracking information to be sent with `user-agent`, `x-amz-user-agent` header
644+
* Default credentials provider; Not available in browser runtime.
645+
* @deprecated
640646
* @internal
641647
*/
642-
defaultUserAgentProvider?: Provider<__UserAgent>;
648+
credentialDefaultProvider?: (input: any) => AwsCredentialIdentityProvider;
643649

644650
/**
645651
* Value for how many times a request will be made at most in case of retry.
@@ -678,8 +684,8 @@ export type APIGatewayClientConfigType = Partial<__SmithyConfiguration<__HttpHan
678684
EndpointInputConfig<EndpointParameters> &
679685
RetryInputConfig &
680686
HostHeaderInputConfig &
681-
AwsAuthInputConfig &
682687
UserAgentInputConfig &
688+
HttpAuthSchemeInputConfig &
683689
ClientInputEndpointParameters;
684690
/**
685691
* @public
@@ -698,8 +704,8 @@ export type APIGatewayClientResolvedConfigType = __SmithyResolvedConfiguration<_
698704
EndpointResolvedConfig<EndpointParameters> &
699705
RetryResolvedConfig &
700706
HostHeaderResolvedConfig &
701-
AwsAuthResolvedConfig &
702707
UserAgentResolvedConfig &
708+
HttpAuthSchemeResolvedConfig &
703709
ClientResolvedEndpointParameters;
704710
/**
705711
* @public
@@ -731,8 +737,8 @@ export class APIGatewayClient extends __Client<
731737
const _config_3 = resolveEndpointConfig(_config_2);
732738
const _config_4 = resolveRetryConfig(_config_3);
733739
const _config_5 = resolveHostHeaderConfig(_config_4);
734-
const _config_6 = resolveAwsAuthConfig(_config_5);
735-
const _config_7 = resolveUserAgentConfig(_config_6);
740+
const _config_6 = resolveUserAgentConfig(_config_5);
741+
const _config_7 = resolveHttpAuthSchemeConfig(_config_6);
736742
const _config_8 = resolveRuntimeExtensions(_config_7, configuration?.extensions || []);
737743
super(_config_8);
738744
this.config = _config_8;
@@ -742,8 +748,14 @@ export class APIGatewayClient extends __Client<
742748
this.middlewareStack.use(getHostHeaderPlugin(this.config));
743749
this.middlewareStack.use(getLoggerPlugin(this.config));
744750
this.middlewareStack.use(getRecursionDetectionPlugin(this.config));
745-
this.middlewareStack.use(getAwsAuthPlugin(this.config));
746751
this.middlewareStack.use(getUserAgentPlugin(this.config));
752+
this.middlewareStack.use(
753+
getHttpAuthSchemeEndpointRuleSetPlugin(this.config, {
754+
httpAuthSchemeParametersProvider: this.getDefaultHttpAuthSchemeParametersProvider(),
755+
identityProviderConfigProvider: this.getIdentityProviderConfigProvider(),
756+
})
757+
);
758+
this.middlewareStack.use(getHttpSigningPlugin(this.config));
747759
}
748760

749761
/**
@@ -754,4 +766,13 @@ export class APIGatewayClient extends __Client<
754766
destroy(): void {
755767
super.destroy();
756768
}
769+
private getDefaultHttpAuthSchemeParametersProvider() {
770+
return defaultAPIGatewayHttpAuthSchemeParametersProvider;
771+
}
772+
private getIdentityProviderConfigProvider() {
773+
return async (config: APIGatewayClientResolvedConfig) =>
774+
new DefaultIdentityProviderConfig({
775+
"aws.auth#sigv4": config.credentials,
776+
});
777+
}
757778
}
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 { APIGatewayHttpAuthSchemeProvider } from "./httpAuthSchemeProvider";
5+
6+
/**
7+
* @internal
8+
*/
9+
export interface HttpAuthExtensionConfiguration {
10+
setHttpAuthScheme(httpAuthScheme: HttpAuthScheme): void;
11+
httpAuthSchemes(): HttpAuthScheme[];
12+
setHttpAuthSchemeProvider(httpAuthSchemeProvider: APIGatewayHttpAuthSchemeProvider): void;
13+
httpAuthSchemeProvider(): APIGatewayHttpAuthSchemeProvider;
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: APIGatewayHttpAuthSchemeProvider;
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: APIGatewayHttpAuthSchemeProvider): void {
49+
_httpAuthSchemeProvider = httpAuthSchemeProvider;
50+
},
51+
httpAuthSchemeProvider(): APIGatewayHttpAuthSchemeProvider {
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: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
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 { APIGatewayClientConfig, APIGatewayClientResolvedConfig } from "../APIGatewayClient";
19+
20+
/**
21+
* @internal
22+
*/
23+
export interface APIGatewayHttpAuthSchemeParameters extends HttpAuthSchemeParameters {
24+
region?: string;
25+
}
26+
27+
/**
28+
* @internal
29+
*/
30+
export interface APIGatewayHttpAuthSchemeParametersProvider
31+
extends HttpAuthSchemeParametersProvider<
32+
APIGatewayClientResolvedConfig,
33+
HandlerExecutionContext,
34+
APIGatewayHttpAuthSchemeParameters,
35+
object
36+
> {}
37+
38+
/**
39+
* @internal
40+
*/
41+
export const defaultAPIGatewayHttpAuthSchemeParametersProvider = async (
42+
config: APIGatewayClientResolvedConfig,
43+
context: HandlerExecutionContext,
44+
input: object
45+
): Promise<APIGatewayHttpAuthSchemeParameters> => {
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: APIGatewayHttpAuthSchemeParameters): HttpAuthOption {
57+
return {
58+
schemeId: "aws.auth#sigv4",
59+
signingProperties: {
60+
name: "apigateway",
61+
region: authParameters.region,
62+
},
63+
propertiesExtractor: (config: APIGatewayClientConfig, context) => ({
64+
/**
65+
* @internal
66+
*/
67+
signingProperties: {
68+
config,
69+
context,
70+
},
71+
}),
72+
};
73+
}
74+
75+
/**
76+
* @internal
77+
*/
78+
export interface APIGatewayHttpAuthSchemeProvider extends HttpAuthSchemeProvider<APIGatewayHttpAuthSchemeParameters> {}
79+
80+
/**
81+
* @internal
82+
*/
83+
export const defaultAPIGatewayHttpAuthSchemeProvider: APIGatewayHttpAuthSchemeProvider = (authParameters) => {
84+
const options: HttpAuthOption[] = [];
85+
switch (authParameters.operation) {
86+
default: {
87+
options.push(createAwsAuthSigv4HttpAuthOption(authParameters));
88+
}
89+
}
90+
return options;
91+
};
92+
93+
/**
94+
* @internal
95+
*/
96+
export interface HttpAuthSchemeInputConfig extends AwsSdkSigV4AuthInputConfig {
97+
/**
98+
* experimentalIdentityAndAuth: Configuration of HttpAuthSchemes for a client which provides default identity providers and signers per auth scheme.
99+
* @internal
100+
*/
101+
httpAuthSchemes?: HttpAuthScheme[];
102+
103+
/**
104+
* experimentalIdentityAndAuth: Configuration of an HttpAuthSchemeProvider for a client which resolves which HttpAuthScheme to use.
105+
* @internal
106+
*/
107+
httpAuthSchemeProvider?: APIGatewayHttpAuthSchemeProvider;
108+
}
109+
110+
/**
111+
* @internal
112+
*/
113+
export interface HttpAuthSchemeResolvedConfig extends AwsSdkSigV4AuthResolvedConfig {
114+
/**
115+
* experimentalIdentityAndAuth: Configuration of HttpAuthSchemes for a client which provides default identity providers and signers per auth scheme.
116+
* @internal
117+
*/
118+
readonly httpAuthSchemes: HttpAuthScheme[];
119+
120+
/**
121+
* experimentalIdentityAndAuth: Configuration of an HttpAuthSchemeProvider for a client which resolves which HttpAuthScheme to use.
122+
* @internal
123+
*/
124+
readonly httpAuthSchemeProvider: APIGatewayHttpAuthSchemeProvider;
125+
}
126+
127+
/**
128+
* @internal
129+
*/
130+
export const resolveHttpAuthSchemeConfig = <T>(
131+
config: T & HttpAuthSchemeInputConfig & AwsSdkSigV4PreviouslyResolved
132+
): T & HttpAuthSchemeResolvedConfig => {
133+
const config_0 = resolveAwsSdkSigV4Config(config);
134+
return {
135+
...config_0,
136+
} as T & HttpAuthSchemeResolvedConfig;
137+
};

clients/client-api-gateway/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 APIGatewayExtensionConfiguration
1012
extends HttpHandlerExtensionConfiguration,
1113
DefaultExtensionConfiguration,
12-
AwsRegionExtensionConfiguration {}
14+
AwsRegionExtensionConfiguration,
15+
HttpAuthExtensionConfiguration {}

0 commit comments

Comments
 (0)