|
1 |
| -import * as __aws_sdk_config_resolver from "@aws-sdk/config-resolver"; |
2 |
| -import * as __aws_sdk_middleware_content_length from "@aws-sdk/middleware-content-length"; |
3 |
| -import * as __aws_sdk_middleware_header_default from "@aws-sdk/middleware-header-default"; |
4 |
| -import * as __aws_sdk_middleware_stack from "@aws-sdk/middleware-stack"; |
5 |
| -import * as __aws_sdk_retry_middleware from "@aws-sdk/retry-middleware"; |
6 |
| -import * as __aws_sdk_signing_middleware from "@aws-sdk/signing-middleware"; |
7 |
| -import * as __aws_sdk_types from "@aws-sdk/types"; |
8 |
| -import * as __aws_sdk_util_user_agent_node from "@aws-sdk/util-user-agent-node"; |
| 1 | +import { contentLengthPlugin } from "@aws-sdk/middleware-content-length"; |
| 2 | +import { UserAgentPlugin, UserAgentConfig } from "@aws-sdk/middleware-user-agent"; |
| 3 | +import { retryPlugin, RetryConfig } from "@aws-sdk/retry-middleware"; |
| 4 | +import { signingPlugin, AwsAuthConfiguration } from "@aws-sdk/signing-middleware"; |
9 | 5 | import {
|
10 | 6 | RDSDataConfiguration,
|
11 | 7 | RDSDataResolvedConfiguration,
|
12 |
| - configurationProperties |
| 8 | + RDSRuntimeConfiguration |
13 | 9 | } from "./RDSDataConfiguration";
|
14 |
| -import {version as clientVersion} from './package.json' |
15 |
| -import {HttpOptions} from '@aws-sdk/types' |
16 |
| - |
17 |
| -/** |
18 |
| - * To remove this when move to Smithy model |
19 |
| - */ |
20 |
| -const ServiceMetadata = { |
21 |
| - endpointPrefix: "rds-data", |
22 |
| - serviceId: "RDS Data" |
23 |
| -}; |
| 10 | +import { RegionConfiguration, EndpointsConfig, ProtocolConfig } from '@aws-sdk/config-resolver'; |
| 11 | +import { HttpOptions, MetadataBearer } from '@aws-sdk/types'; |
| 12 | +import { Client as SmithyClient } from "@aws-sdk/smithy-client"; |
24 | 13 |
|
25 | 14 | type InputTypesUnion = any;
|
26 |
| -type OutputTypesUnion = any; |
| 15 | +type OutputTypesUnion = MetadataBearer; |
27 | 16 |
|
28 |
| -export class RDSDataClient { |
| 17 | +export class RDSDataClient extends SmithyClient<HttpOptions, InputTypesUnion, OutputTypesUnion> { |
29 | 18 | readonly config: RDSDataResolvedConfiguration;
|
30 | 19 |
|
31 |
| - readonly middlewareStack = new __aws_sdk_middleware_stack.MiddlewareStack< |
32 |
| - InputTypesUnion, |
33 |
| - OutputTypesUnion |
34 |
| - >(); |
35 |
| - |
36 | 20 | constructor(configuration: RDSDataConfiguration) {
|
37 |
| - this.config = __aws_sdk_config_resolver.resolveConfiguration( |
38 |
| - configuration, |
39 |
| - configurationProperties, |
40 |
| - this.middlewareStack |
41 |
| - ); |
42 |
| - this.middlewareStack.add( |
43 |
| - __aws_sdk_middleware_content_length.contentLengthMiddleware( |
44 |
| - this.config.bodyLengthChecker |
45 |
| - ), |
46 |
| - { |
47 |
| - step: "build", |
48 |
| - priority: -80, |
49 |
| - tags: { SET_CONTENT_LENGTH: true } |
50 |
| - } |
51 |
| - ); |
| 21 | + const intermediaConfig_0 = ProtocolConfig.resolve({ |
| 22 | + ...RDSRuntimeConfiguration, |
| 23 | + ...configuration |
| 24 | + }); |
| 25 | + super(intermediaConfig_0); |
| 26 | + let intermediaConfig_1 = RegionConfiguration.resolve(intermediaConfig_0); |
| 27 | + let intermediaConfig_2 = AwsAuthConfiguration.resolve(intermediaConfig_1); |
| 28 | + let intermediaConfig_3 = EndpointsConfig.resolve(intermediaConfig_2); |
| 29 | + let intermediaConfig_4 = RetryConfig.resolve(intermediaConfig_3); |
| 30 | + let intermediaConfig_5 = UserAgentConfig.resolve(intermediaConfig_4); |
| 31 | + this.config = intermediaConfig_5; |
| 32 | + super.use(contentLengthPlugin(this.config)); |
52 | 33 | if (this.config.maxRetries > 0) {
|
53 |
| - this.middlewareStack.add( |
54 |
| - __aws_sdk_retry_middleware.retryMiddleware( |
55 |
| - this.config.maxRetries, |
56 |
| - this.config.retryDecider, |
57 |
| - this.config.delayDecider |
58 |
| - ), |
59 |
| - { |
60 |
| - step: "finalize", |
61 |
| - priority: Infinity, |
62 |
| - tags: { RETRY: true } |
63 |
| - } |
64 |
| - ); |
| 34 | + super.use(retryPlugin(this.config)); |
65 | 35 | }
|
66 |
| - this.middlewareStack.add( |
67 |
| - __aws_sdk_signing_middleware.signingMiddleware< |
68 |
| - InputTypesUnion, |
69 |
| - OutputTypesUnion |
70 |
| - >(this.config.signer), |
71 |
| - { |
72 |
| - step: "finalize", |
73 |
| - priority: 0, |
74 |
| - tags: { SIGNATURE: true } |
75 |
| - } |
76 |
| - ); |
77 |
| - this.middlewareStack.add( |
78 |
| - __aws_sdk_middleware_header_default.headerDefault({ |
79 |
| - "User-Agent": __aws_sdk_util_user_agent_node.defaultUserAgent( |
80 |
| - ServiceMetadata.serviceId || ServiceMetadata.endpointPrefix, |
81 |
| - clientVersion |
82 |
| - ) |
83 |
| - }), |
84 |
| - { |
85 |
| - step: "build", |
86 |
| - priority: 0, |
87 |
| - tags: { SET_USER_AGENT: true } |
88 |
| - } |
89 |
| - ); |
| 36 | + super.use(signingPlugin(this.config)); |
| 37 | + super.use(UserAgentPlugin(this.config)); |
90 | 38 | }
|
91 | 39 |
|
92 | 40 | destroy(): void {
|
93 | 41 | if (
|
94 |
| - !this.config._user_injected_http_handler && |
95 | 42 | typeof this.config.httpHandler.destroy === 'function'
|
96 | 43 | ) {
|
97 | 44 | this.config.httpHandler.destroy();
|
98 | 45 | }
|
99 | 46 | }
|
100 |
| - |
101 |
| - /** |
102 |
| - * This will need to be revised when the command interface lands. |
103 |
| - */ |
104 |
| - send<InputType extends InputTypesUnion, OutputType extends OutputTypesUnion>( |
105 |
| - command: __aws_sdk_types.Command< |
106 |
| - InputTypesUnion, |
107 |
| - InputType, |
108 |
| - OutputTypesUnion, |
109 |
| - OutputType, |
110 |
| - RDSDataResolvedConfiguration |
111 |
| - >, |
112 |
| - options?: HttpOptions |
113 |
| - ): Promise<OutputType>; |
114 |
| - send<InputType extends InputTypesUnion, OutputType extends OutputTypesUnion>( |
115 |
| - command: __aws_sdk_types.Command< |
116 |
| - InputTypesUnion, |
117 |
| - InputType, |
118 |
| - OutputTypesUnion, |
119 |
| - OutputType, |
120 |
| - RDSDataResolvedConfiguration |
121 |
| - >, |
122 |
| - options: HttpOptions, |
123 |
| - cb: (err: any, data?: OutputType) => void |
124 |
| - ): void; |
125 |
| - send<InputType extends InputTypesUnion, OutputType extends OutputTypesUnion>( |
126 |
| - command: __aws_sdk_types.Command< |
127 |
| - InputTypesUnion, |
128 |
| - InputType, |
129 |
| - OutputTypesUnion, |
130 |
| - OutputType, |
131 |
| - RDSDataResolvedConfiguration |
132 |
| - >, |
133 |
| - options?: HttpOptions, |
134 |
| - cb?: (err: any, data?: OutputType) => void |
135 |
| - ): Promise<OutputType> | void { |
136 |
| - const handler = command.resolveMiddleware( |
137 |
| - this.middlewareStack, |
138 |
| - this.config, |
139 |
| - options |
140 |
| - ); |
141 |
| - if (cb) { |
142 |
| - handler(command) |
143 |
| - .then(result => cb(null, result.output), (err: any) => cb(err)) |
144 |
| - .catch( |
145 |
| - // prevent any errors thrown in the callback from triggering an |
146 |
| - // unhandled promise rejection |
147 |
| - () => {} |
148 |
| - ); |
149 |
| - } else { |
150 |
| - return handler(command).then(result => result.output); |
151 |
| - } |
152 |
| - } |
153 | 47 | }
|
0 commit comments