Skip to content

Commit 09112e5

Browse files
AllanZhengYPtrivikr
authored andcommitted
feat: standardize plugins (#422)
1 parent 92f290b commit 09112e5

Some content is hidden

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

76 files changed

+804
-505
lines changed
File renamed without changes.
File renamed without changes.

Diff for: clients/client-rds-data/CHANGELOG.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Change Log
2+
3+
All notable changes to this project will be documented in this file.
4+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5+
6+
# 0.1.0-preview.3 (2019-09-19)
7+
8+
9+
10+
# 0.3.0 (2019-09-09)
11+
12+
13+
### Features
14+
15+
* commit all clients ([#324](https://github.com/aws/aws-sdk-js-v3/issues/324)) ([cb268ed](https://github.com/aws/aws-sdk-js-v3/commit/cb268ed))
16+
17+
18+
19+
20+
21+
# 0.1.0-preview.2 (2019-09-09)
22+
23+
24+
### Features
25+
26+
* commit all clients ([#324](https://github.com/aws/aws-sdk-js-v3/issues/324)) ([cb268ed](https://github.com/aws/aws-sdk-js-v3/commit/cb268ed))
File renamed without changes.

Diff for: clients/client-rds-data/README.md

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# @aws-sdk/client-rds-data
2+
3+
[![NPM version](https://img.shields.io/npm/v/@aws-sdk/client-rds-data/preview.svg)](https://www.npmjs.com/package/@aws-sdk/client-rds-data)
4+
[![NPM downloads](https://img.shields.io/npm/dm/@aws-sdk/client-rds-data.svg)](https://www.npmjs.com/package/@aws-sdk/client-rds-data)
5+
6+
## Description
7+
8+
<fullname>Amazon RDS Data Service</fullname>
9+
10+
<p>Amazon RDS provides an HTTP endpoint to run SQL statements on an Amazon Aurora
11+
Serverless DB cluster. To run these statements, you work with the Data Service
12+
API.</p>
13+
<p>For more information about the Data Service API, see <a href="https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html">Using the Data API for Aurora
14+
Serverless</a> in the <i>Amazon Aurora User Guide</i>.</p>
15+
16+
## Installing
17+
18+
To install the this package using NPM, simply type the following into a terminal window:
19+
20+
```
21+
npm install @aws-sdk/client-rds-data
22+
```
23+
24+
## Getting Started
25+
26+
### Import
27+
28+
The AWS SDK is modulized by clients and commands in CommonJS modules. To send a request, you only need to import the client(`RdsDataServiceClient`) and the commands you need, for example `BatchExecuteStatementCommand`:
29+
30+
```javascript
31+
//JavaScript
32+
const {
33+
RdsDataServiceClient,
34+
BatchExecuteStatementCommand
35+
} = require("@aws-sdk/client-rds-data");
36+
```
37+
38+
```javascript
39+
//TypeScript
40+
import {
41+
RdsDataServiceClient,
42+
BatchExecuteStatementCommand
43+
} from "@aws-sdk/client-rds-data";
44+
```
45+
46+
### Usage
47+
48+
To send a request, you:
49+
50+
- Initiate client with configuration (e.g. credentials, region). For more information you can refer to the [API reference][].
51+
- Initiate command with input parameters.
52+
- Call `send` operation on client with command object as input.
53+
- If you are using a custom http handler, you may call `destroy()` to close open connections.
54+
55+
```javascript
56+
const rDSData = new RdsDataServiceClient({region: 'region'});
57+
//clients can be shared by different commands
58+
const params = {
59+
resourceArn: /**a string value*/,
60+
secretArn: /**a string value*/,
61+
sql: /**a string value*/,
62+
};
63+
const batchExecuteStatementCommand = new BatchExecuteStatementCommand(params);
64+
rDSData.send(batchExecuteStatementCommand).then(data => {
65+
// do something
66+
}).catch(error => {
67+
// error handling
68+
})
69+
```
70+
71+
In addition to using promises, there are 2 other ways to send a request:
72+
73+
```javascript
74+
// async/await
75+
try {
76+
const data = await rDSData.send(batchExecuteStatementCommand);
77+
// do something
78+
} catch (error) {
79+
// error handling
80+
}
81+
```
82+
83+
```javascript
84+
// callback
85+
rDSData.send(batchExecuteStatementCommand, (err, data) => {
86+
//do something
87+
});
88+
```
89+
90+
### Troubleshooting
91+
92+
When the service returns an exception, the error will include the exception information, as well as response metadata (e.g. request id).
93+
94+
```javascript
95+
try {
96+
const data = await rDSData.send(batchExecuteStatementCommand);
97+
// do something
98+
} catch (error) {
99+
const metadata = error.$metadata;
100+
console.log(
101+
`requestId: ${metadata.requestId}
102+
cfId: ${metadata.cfId}
103+
extendedRequestId: ${metadata.extendedRequestId}`
104+
);
105+
/*
106+
The keys within exceptions are also parsed. You can access them by specifying exception names:
107+
if(error.name === 'SomeServiceException') {
108+
const value = error.specialKeyInException;
109+
}
110+
*/
111+
}
112+
```
113+
114+
## Getting Help
115+
116+
Please use these community resources for getting help. We use the GitHub issues for tracking bugs and feature requests and have limited bandwidth to address them.
117+
118+
- Ask a question on [StackOverflow](https://stackoverflow.com/questions/tagged/aws-sdk-js) and tag it with `aws-sdk-js`
119+
- Come join the AWS JavaScript community on [gitter](https://gitter.im/aws/aws-sdk-js-v3)
120+
- If it turns out that you may have found a bug, please [open an issue](https://github.com/aws/aws-sdk-js-v3/issues)
121+
122+
## Contributing
123+
124+
This client code is generated automatically. Any modifications will be overwritten the next time the `@aws-sdk/@aws-sdk/client-rds-data' package is updated. To contribute to SDK you can checkout our [code generator package][].
125+
126+
## License
127+
128+
This SDK is distributed under the
129+
[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0),
130+
see LICENSE for more information.
131+
132+
[code generator package]: https://github.com/aws/aws-sdk-js-v3/tree/master/packages/service-types-generator
133+
[api reference]: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/

Diff for: clients/client-rds-data/RdsDataServiceClient.ts

+206
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
import {
2+
BatchExecuteStatementRequest,
3+
BatchExecuteStatementResponse,
4+
BeginTransactionRequest,
5+
BeginTransactionResponse,
6+
CommitTransactionRequest,
7+
CommitTransactionResponse,
8+
ExecuteSqlRequest,
9+
ExecuteSqlResponse,
10+
ExecuteStatementRequest,
11+
ExecuteStatementResponse,
12+
RollbackTransactionRequest,
13+
RollbackTransactionResponse
14+
} from "./models/index";
15+
import { RDSRuntimeConfiguration } from "./runtimeConfig";
16+
import {
17+
Credentials,
18+
Provider,
19+
HashConstructor,
20+
UrlParser,
21+
Protocol,
22+
StreamCollector,
23+
Decoder,
24+
Encoder
25+
} from "@aws-sdk/types";
26+
import {
27+
EndpointsConfigInput,
28+
EndpointsConfigResolved,
29+
resolveEndpointsConfig,
30+
ClientProtocolConfigInput,
31+
ClientProtocolConfigResolved,
32+
resolveClientProtocolConfig,
33+
destroyClientProtocolConfig,
34+
RegionConfigInput,
35+
RegionConfigResolved,
36+
resolveRegionConfig
37+
} from "@aws-sdk/config-resolver";
38+
import { getContentLengthPlugin } from "@aws-sdk/middleware-content-length";
39+
import {
40+
UserAgentConfigInput,
41+
UserAgentConfigResolved,
42+
resolveUserAgentConfig,
43+
getUserAgentPlugin
44+
} from "@aws-sdk/middleware-user-agent";
45+
import {
46+
RetryConfigInput,
47+
RetryConfigResolved,
48+
resolveRetryConfig,
49+
getRetryPlugin
50+
} from "@aws-sdk/middleware-retry";
51+
import {
52+
AwsAuthConfigInput,
53+
AwsAuthConfigResolved,
54+
resolveAwsAuthConfig,
55+
getAwsAuthPlugin
56+
} from "@aws-sdk/middleware-signing";
57+
import { HttpHandler, HttpRequest, HttpResponse } from "@aws-sdk/protocol-http";
58+
import {
59+
Client as SmithyClient,
60+
SmithyResolvedConfiguration
61+
} from "@aws-sdk/smithy-client";
62+
import { HttpOptions as __HttpOptions } from "@aws-sdk/types";
63+
64+
export type ServiceInputTypes =
65+
| RollbackTransactionRequest
66+
| CommitTransactionRequest
67+
| ExecuteSqlRequest
68+
| BeginTransactionRequest
69+
| ExecuteStatementRequest
70+
| BatchExecuteStatementRequest;
71+
72+
export type ServiceOutputTypes =
73+
| RollbackTransactionResponse
74+
| CommitTransactionResponse
75+
| ExecuteSqlResponse
76+
| BeginTransactionResponse
77+
| ExecuteStatementResponse
78+
| BatchExecuteStatementResponse;
79+
80+
export interface RDSDataRuntimeDependencies {
81+
/**
82+
* The HTTP handler to use. Fetch in browser and Https in Nodejs
83+
*/
84+
httpHandler?: HttpHandler;
85+
86+
/**
87+
* A constructor for a class implementing the @aws-sdk/types.Hash interface that computes the SHA-256 HMAC or checksum of a string or binary buffer
88+
*/
89+
sha256?: HashConstructor;
90+
91+
/**
92+
* Default credentials provider; Not available in browser runtime
93+
*/
94+
credentialDefaultProvider?: (input: any) => Provider<Credentials>;
95+
96+
/**
97+
* Provider function that return promise of a region string
98+
*/
99+
regionDefaultProvider?: (input: any) => Provider<string>;
100+
101+
/**
102+
* The function that will be used to convert strings into HTTP endpoints
103+
*/
104+
urlParser?: UrlParser;
105+
106+
/**
107+
* A function that can calculate the length of a request body.
108+
*/
109+
bodyLengthChecker?: (body: any) => number | undefined;
110+
111+
/**
112+
* A function that converts a stream into an array of bytes.
113+
*/
114+
streamCollector?: StreamCollector;
115+
116+
/**
117+
* The function that will be used to convert a base64-encoded string to a byte array
118+
*/
119+
base64Decoder?: Decoder;
120+
121+
/**
122+
* The function that will be used to convert binary data to a base64-encoded string
123+
*/
124+
base64Encoder?: Encoder;
125+
126+
/**
127+
* The function that will be used to convert a UTF8-encoded string to a byte array
128+
*/
129+
utf8Decoder?: Decoder;
130+
131+
/**
132+
* The function that will be used to convert binary data to a UTF-8 encoded string
133+
*/
134+
utf8Encoder?: Encoder;
135+
136+
/**
137+
* The function that will be used to populate default value in 'User-Agent' header
138+
*/
139+
defaultUserAgent?: string;
140+
141+
/**
142+
* The function that will be used to populate serializing protocol
143+
*/
144+
protocolDefaultProvider?: (
145+
handler: HttpHandler
146+
) => Protocol<HttpRequest, HttpResponse>;
147+
148+
/**
149+
* The service name with which to sign requests.
150+
*/
151+
signingName?: string;
152+
153+
/**
154+
* The service name with which to construct endpoints.
155+
*/
156+
service?: string;
157+
}
158+
159+
export type RdsDataServiceConfig = RDSDataRuntimeDependencies &
160+
AwsAuthConfigInput &
161+
RegionConfigInput &
162+
RetryConfigInput &
163+
EndpointsConfigInput &
164+
ClientProtocolConfigInput &
165+
UserAgentConfigInput;
166+
167+
export type RdsDataServiceResolvedConfig = SmithyResolvedConfiguration<
168+
__HttpOptions
169+
> &
170+
Required<RDSDataRuntimeDependencies> &
171+
AwsAuthConfigResolved &
172+
RegionConfigResolved &
173+
RetryConfigResolved &
174+
EndpointsConfigResolved &
175+
ClientProtocolConfigResolved &
176+
UserAgentConfigResolved;
177+
178+
export class RdsDataService extends SmithyClient<
179+
__HttpOptions,
180+
ServiceInputTypes,
181+
ServiceOutputTypes
182+
> {
183+
readonly config: RdsDataServiceResolvedConfig;
184+
185+
constructor(configuration: RdsDataServiceConfig) {
186+
const _config_0 = resolveClientProtocolConfig({
187+
...RDSRuntimeConfiguration,
188+
...configuration
189+
});
190+
let _config_1 = resolveRegionConfig(_config_0);
191+
let _config_2 = resolveAwsAuthConfig(_config_1);
192+
let _config_3 = resolveEndpointsConfig(_config_2);
193+
let _config_4 = resolveRetryConfig(_config_3);
194+
let _config_5 = resolveUserAgentConfig(_config_4);
195+
super(_config_5);
196+
this.config = _config_5;
197+
this.middlewareStack.use(getContentLengthPlugin(this.config));
198+
this.middlewareStack.use(getAwsAuthPlugin(this.config));
199+
this.middlewareStack.use(getRetryPlugin(this.config));
200+
this.middlewareStack.use(getUserAgentPlugin(this.config));
201+
}
202+
203+
destroy(): void {
204+
destroyClientProtocolConfig(this.config);
205+
}
206+
}

0 commit comments

Comments
 (0)