Skip to content

chore: update rds-data client #616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clients/client-rds-data/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
275 changes: 143 additions & 132 deletions clients/client-rds-data/RDSData.ts

Large diffs are not rendered by default.

39 changes: 27 additions & 12 deletions clients/client-rds-data/RDSDataClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ import {
resolveRegionConfig
} from "@aws-sdk/config-resolver";
import { getContentLengthPlugin } from "@aws-sdk/middleware-content-length";
import {
HostHeaderInputConfig,
HostHeaderResolvedConfig,
getHostHeaderPlugin,
resolveHostHeaderConfig
} from "@aws-sdk/middleware-host-header";
import {
RetryInputConfig,
RetryResolvedConfig,
Expand All @@ -47,15 +53,15 @@ import {
SmithyResolvedConfiguration as __SmithyResolvedConfiguration
} from "@aws-sdk/smithy-client";
import {
RegionInfoProvider,
Credentials as __Credentials,
Decoder as __Decoder,
Encoder as __Encoder,
HashConstructor as __HashConstructor,
HttpHandlerOptions as __HttpHandlerOptions,
Provider as __Provider,
StreamCollector as __StreamCollector,
UrlParser as __UrlParser,
RegionInfoProvider
UrlParser as __UrlParser
} from "@aws-sdk/types";

export type ServiceInputTypes =
Expand Down Expand Up @@ -123,10 +129,15 @@ export interface ClientDefaults
utf8Encoder?: __Encoder;

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

/**
* The runtime environment
*/
runtime?: string;

/**
* The service name with which to sign requests.
*/
Expand All @@ -143,7 +154,7 @@ export interface ClientDefaults
regionDefaultProvider?: (input: any) => __Provider<string>;

/**
* Fetch hostname, signing name or signing region of given region
* Fetch related hostname, signing name or signing region with given region.
*/
regionInfoProvider?: RegionInfoProvider;
}
Expand All @@ -153,20 +164,22 @@ export type RDSDataClientConfig = Partial<
> &
ClientDefaults &
RegionInputConfig &
AwsAuthInputConfig &
EndpointsInputConfig &
AwsAuthInputConfig &
RetryInputConfig &
UserAgentInputConfig;
UserAgentInputConfig &
HostHeaderInputConfig;

export type RDSDataClientResolvedConfig = __SmithyResolvedConfiguration<
__HttpHandlerOptions
> &
Required<ClientDefaults> &
RegionResolvedConfig &
AwsAuthResolvedConfig &
EndpointsResolvedConfig &
AwsAuthResolvedConfig &
RetryResolvedConfig &
UserAgentResolvedConfig;
UserAgentResolvedConfig &
HostHeaderResolvedConfig;

/**
* <fullname>Amazon RDS Data Service</fullname>
Expand Down Expand Up @@ -194,16 +207,18 @@ export class RDSDataClient extends __Client<
...configuration
};
let _config_1 = resolveRegionConfig(_config_0);
let _config_2 = resolveAwsAuthConfig(_config_1);
let _config_3 = resolveEndpointsConfig(_config_2);
let _config_2 = resolveEndpointsConfig(_config_1);
let _config_3 = resolveAwsAuthConfig(_config_2);
let _config_4 = resolveRetryConfig(_config_3);
let _config_5 = resolveUserAgentConfig(_config_4);
super(_config_5);
this.config = _config_5;
let _config_6 = resolveHostHeaderConfig(_config_5);
super(_config_6);
this.config = _config_6;
this.middlewareStack.use(getAwsAuthPlugin(this.config));
this.middlewareStack.use(getRetryPlugin(this.config));
this.middlewareStack.use(getUserAgentPlugin(this.config));
this.middlewareStack.use(getContentLengthPlugin(this.config));
this.middlewareStack.use(getHostHeaderPlugin(this.config));
}

destroy(): void {}
Expand Down
131 changes: 2 additions & 129 deletions clients/client-rds-data/README.md
Original file line number Diff line number Diff line change
@@ -1,133 +1,6 @@
# @aws-sdk/client-rds-data
@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/
For SDK usage, please step to [SDK reademe](https://github.com/aws/aws-sdk-js-v3).
37 changes: 25 additions & 12 deletions clients/client-rds-data/endpoints.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types";
import {
RegionInfo,
RegionInfoProvider,
} from "@aws-sdk/types";

// Partition default templates
const AWS_TEMPLATE = "rds-data.{region}.amazonaws.com";
Expand Down Expand Up @@ -26,12 +29,22 @@ const AWS_REGIONS = new Set([
"us-east-1",
"us-east-2",
"us-west-1",
"us-west-2"
"us-west-2",
]);
const AWS_CN_REGIONS = new Set([
"cn-north-1",
"cn-northwest-1",
]);
const AWS_ISO_REGIONS = new Set([
"us-iso-east-1",
]);
const AWS_ISO_B_REGIONS = new Set([
"us-isob-east-1",
]);
const AWS_US_GOV_REGIONS = new Set([
"us-gov-west-1",
"us-gov-east-1",
]);
const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]);
const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]);
const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]);
const AWS_US_GOV_REGIONS = new Set(["us-gov-west-1", "us-gov-east-1"]);

export const defaultRegionInfoProvider: RegionInfoProvider = (
region: string,
Expand All @@ -44,33 +57,33 @@ export const defaultRegionInfoProvider: RegionInfoProvider = (
default:
if (AWS_REGIONS.has(region)) {
regionInfo = {
hostname: AWS_TEMPLATE.replace("{region}", region)
hostname: AWS_TEMPLATE.replace("{region}", region),
};
}
if (AWS_CN_REGIONS.has(region)) {
regionInfo = {
hostname: AWS_CN_TEMPLATE.replace("{region}", region)
hostname: AWS_CN_TEMPLATE.replace("{region}", region),
};
}
if (AWS_ISO_REGIONS.has(region)) {
regionInfo = {
hostname: AWS_ISO_TEMPLATE.replace("{region}", region)
hostname: AWS_ISO_TEMPLATE.replace("{region}", region),
};
}
if (AWS_ISO_B_REGIONS.has(region)) {
regionInfo = {
hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region)
hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region),
};
}
if (AWS_US_GOV_REGIONS.has(region)) {
regionInfo = {
hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region)
hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region),
};
}
// Finally, assume it's an AWS partition endpoint.
if (regionInfo === undefined) {
regionInfo = {
hostname: AWS_TEMPLATE.replace("{region}", region)
hostname: AWS_TEMPLATE.replace("{region}", region),
};
}
}
Expand Down
6 changes: 3 additions & 3 deletions clients/client-rds-data/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export * from "./RDSDataClient";
export * from "./RDSData";
export * from "./commands/BatchExecuteStatementCommand";
export * from "./commands/ExecuteStatementCommand";
export * from "./commands/CommitTransactionCommand";
export * from "./commands/RollbackTransactionCommand";
export * from "./commands/BeginTransactionCommand";
export * from "./commands/BatchExecuteStatementCommand";
export * from "./commands/RollbackTransactionCommand";
export * from "./commands/ExecuteSqlCommand";
export * from "./commands/ExecuteStatementCommand";
2 changes: 1 addition & 1 deletion clients/client-rds-data/models/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as _smithy from "../lib/smithy";
import * as _smithy from "@aws-sdk/smithy-client";
import { MetadataBearer as $MetadataBearer } from "@aws-sdk/types";

/**
Expand Down
Loading