Skip to content

Commit

Permalink
feat: standardize plugins (#422)
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanZhengYP authored and trivikr committed Jan 3, 2020
1 parent 92f290b commit 09112e5
Show file tree
Hide file tree
Showing 76 changed files with 804 additions and 505 deletions.
File renamed without changes.
File renamed without changes.
26 changes: 26 additions & 0 deletions clients/client-rds-data/CHANGELOG.md
@@ -0,0 +1,26 @@
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# 0.1.0-preview.3 (2019-09-19)



# 0.3.0 (2019-09-09)


### Features

* 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))





# 0.1.0-preview.2 (2019-09-09)


### Features

* 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.
133 changes: 133 additions & 0 deletions clients/client-rds-data/README.md
@@ -0,0 +1,133 @@
# @aws-sdk/client-rds-data

[![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)
[![NPM downloads](https://img.shields.io/npm/dm/@aws-sdk/client-rds-data.svg)](https://www.npmjs.com/package/@aws-sdk/client-rds-data)

## Description

<fullname>Amazon RDS Data Service</fullname>

<p>Amazon RDS provides an HTTP endpoint to run SQL statements on an Amazon Aurora
Serverless DB cluster. To run these statements, you work with the Data Service
API.</p>
<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
Serverless</a> in the <i>Amazon Aurora User Guide</i>.</p>

## Installing

To install the this package using NPM, simply type the following into a terminal window:

```
npm install @aws-sdk/client-rds-data
```

## Getting Started

### Import

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`:

```javascript
//JavaScript
const {
RdsDataServiceClient,
BatchExecuteStatementCommand
} = require("@aws-sdk/client-rds-data");
```

```javascript
//TypeScript
import {
RdsDataServiceClient,
BatchExecuteStatementCommand
} from "@aws-sdk/client-rds-data";
```

### Usage

To send a request, you:

- Initiate client with configuration (e.g. credentials, region). For more information you can refer to the [API reference][].
- Initiate command with input parameters.
- Call `send` operation on client with command object as input.
- If you are using a custom http handler, you may call `destroy()` to close open connections.

```javascript
const rDSData = new RdsDataServiceClient({region: 'region'});
//clients can be shared by different commands
const params = {
resourceArn: /**a string value*/,
secretArn: /**a string value*/,
sql: /**a string value*/,
};
const batchExecuteStatementCommand = new BatchExecuteStatementCommand(params);
rDSData.send(batchExecuteStatementCommand).then(data => {
// do something
}).catch(error => {
// error handling
})
```

In addition to using promises, there are 2 other ways to send a request:

```javascript
// async/await
try {
const data = await rDSData.send(batchExecuteStatementCommand);
// do something
} catch (error) {
// error handling
}
```

```javascript
// callback
rDSData.send(batchExecuteStatementCommand, (err, data) => {
//do something
});
```

### Troubleshooting

When the service returns an exception, the error will include the exception information, as well as response metadata (e.g. request id).

```javascript
try {
const data = await rDSData.send(batchExecuteStatementCommand);
// do something
} catch (error) {
const metadata = error.$metadata;
console.log(
`requestId: ${metadata.requestId}
cfId: ${metadata.cfId}
extendedRequestId: ${metadata.extendedRequestId}`
);
/*
The keys within exceptions are also parsed. You can access them by specifying exception names:
if(error.name === 'SomeServiceException') {
const value = error.specialKeyInException;
}
*/
}
```

## Getting Help

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.

- Ask a question on [StackOverflow](https://stackoverflow.com/questions/tagged/aws-sdk-js) and tag it with `aws-sdk-js`
- Come join the AWS JavaScript community on [gitter](https://gitter.im/aws/aws-sdk-js-v3)
- If it turns out that you may have found a bug, please [open an issue](https://github.com/aws/aws-sdk-js-v3/issues)

## Contributing

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][].

## License

This SDK is distributed under the
[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0),
see LICENSE for more information.

[code generator package]: https://github.com/aws/aws-sdk-js-v3/tree/master/packages/service-types-generator
[api reference]: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/
206 changes: 206 additions & 0 deletions clients/client-rds-data/RdsDataServiceClient.ts
@@ -0,0 +1,206 @@
import {
BatchExecuteStatementRequest,
BatchExecuteStatementResponse,
BeginTransactionRequest,
BeginTransactionResponse,
CommitTransactionRequest,
CommitTransactionResponse,
ExecuteSqlRequest,
ExecuteSqlResponse,
ExecuteStatementRequest,
ExecuteStatementResponse,
RollbackTransactionRequest,
RollbackTransactionResponse
} from "./models/index";
import { RDSRuntimeConfiguration } from "./runtimeConfig";
import {
Credentials,
Provider,
HashConstructor,
UrlParser,
Protocol,
StreamCollector,
Decoder,
Encoder
} from "@aws-sdk/types";
import {
EndpointsConfigInput,
EndpointsConfigResolved,
resolveEndpointsConfig,
ClientProtocolConfigInput,
ClientProtocolConfigResolved,
resolveClientProtocolConfig,
destroyClientProtocolConfig,
RegionConfigInput,
RegionConfigResolved,
resolveRegionConfig
} from "@aws-sdk/config-resolver";
import { getContentLengthPlugin } from "@aws-sdk/middleware-content-length";
import {
UserAgentConfigInput,
UserAgentConfigResolved,
resolveUserAgentConfig,
getUserAgentPlugin
} from "@aws-sdk/middleware-user-agent";
import {
RetryConfigInput,
RetryConfigResolved,
resolveRetryConfig,
getRetryPlugin
} from "@aws-sdk/middleware-retry";
import {
AwsAuthConfigInput,
AwsAuthConfigResolved,
resolveAwsAuthConfig,
getAwsAuthPlugin
} from "@aws-sdk/middleware-signing";
import { HttpHandler, HttpRequest, HttpResponse } from "@aws-sdk/protocol-http";
import {
Client as SmithyClient,
SmithyResolvedConfiguration
} from "@aws-sdk/smithy-client";
import { HttpOptions as __HttpOptions } from "@aws-sdk/types";

export type ServiceInputTypes =
| RollbackTransactionRequest
| CommitTransactionRequest
| ExecuteSqlRequest
| BeginTransactionRequest
| ExecuteStatementRequest
| BatchExecuteStatementRequest;

export type ServiceOutputTypes =
| RollbackTransactionResponse
| CommitTransactionResponse
| ExecuteSqlResponse
| BeginTransactionResponse
| ExecuteStatementResponse
| BatchExecuteStatementResponse;

export interface RDSDataRuntimeDependencies {
/**
* The HTTP handler to use. Fetch in browser and Https in Nodejs
*/
httpHandler?: HttpHandler;

/**
* 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
*/
sha256?: HashConstructor;

/**
* Default credentials provider; Not available in browser runtime
*/
credentialDefaultProvider?: (input: any) => Provider<Credentials>;

/**
* Provider function that return promise of a region string
*/
regionDefaultProvider?: (input: any) => Provider<string>;

/**
* The function that will be used to convert strings into HTTP endpoints
*/
urlParser?: UrlParser;

/**
* A function that can calculate the length of a request body.
*/
bodyLengthChecker?: (body: any) => number | undefined;

/**
* A function that converts a stream into an array of bytes.
*/
streamCollector?: StreamCollector;

/**
* The function that will be used to convert a base64-encoded string to a byte array
*/
base64Decoder?: Decoder;

/**
* The function that will be used to convert binary data to a base64-encoded string
*/
base64Encoder?: Encoder;

/**
* The function that will be used to convert a UTF8-encoded string to a byte array
*/
utf8Decoder?: Decoder;

/**
* The function that will be used to convert binary data to a UTF-8 encoded string
*/
utf8Encoder?: Encoder;

/**
* The function that will be used to populate default value in 'User-Agent' header
*/
defaultUserAgent?: string;

/**
* The function that will be used to populate serializing protocol
*/
protocolDefaultProvider?: (
handler: HttpHandler
) => Protocol<HttpRequest, HttpResponse>;

/**
* The service name with which to sign requests.
*/
signingName?: string;

/**
* The service name with which to construct endpoints.
*/
service?: string;
}

export type RdsDataServiceConfig = RDSDataRuntimeDependencies &
AwsAuthConfigInput &
RegionConfigInput &
RetryConfigInput &
EndpointsConfigInput &
ClientProtocolConfigInput &
UserAgentConfigInput;

export type RdsDataServiceResolvedConfig = SmithyResolvedConfiguration<
__HttpOptions
> &
Required<RDSDataRuntimeDependencies> &
AwsAuthConfigResolved &
RegionConfigResolved &
RetryConfigResolved &
EndpointsConfigResolved &
ClientProtocolConfigResolved &
UserAgentConfigResolved;

export class RdsDataService extends SmithyClient<
__HttpOptions,
ServiceInputTypes,
ServiceOutputTypes
> {
readonly config: RdsDataServiceResolvedConfig;

constructor(configuration: RdsDataServiceConfig) {
const _config_0 = resolveClientProtocolConfig({
...RDSRuntimeConfiguration,
...configuration
});
let _config_1 = resolveRegionConfig(_config_0);
let _config_2 = resolveAwsAuthConfig(_config_1);
let _config_3 = resolveEndpointsConfig(_config_2);
let _config_4 = resolveRetryConfig(_config_3);
let _config_5 = resolveUserAgentConfig(_config_4);
super(_config_5);
this.config = _config_5;
this.middlewareStack.use(getContentLengthPlugin(this.config));
this.middlewareStack.use(getAwsAuthPlugin(this.config));
this.middlewareStack.use(getRetryPlugin(this.config));
this.middlewareStack.use(getUserAgentPlugin(this.config));
}

destroy(): void {
destroyClientProtocolConfig(this.config);
}
}

0 comments on commit 09112e5

Please sign in to comment.