Skip to content
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

feat: standardize plugins #422

Merged
merged 20 commits into from
Oct 29, 2019
Merged
Show file tree
Hide file tree
Changes from 18 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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# @aws-sdk/client-rds-data-node
# @aws-sdk/client-rds-data

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

Expand All @@ -18,29 +18,29 @@ Serverless</a> in the <i>Amazon Aurora User Guide</i>.</p>
To install the this package using NPM, simply type the following into a terminal window:

```
npm install @aws-sdk/client-rds-data-node
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(`RDSDataClient`) and the commands you need, for example `BatchExecuteStatementCommand`:
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 {
RDSDataClient
} = require("@aws-sdk/client-rds-data-node/RDSDataClient");
RdsDataServiceClient
} = require("@aws-sdk/client-rds-data/RdsDataServiceClient");
const {
BatchExecuteStatementCommand
} = require("@aws-sdk/client-rds-data-node/commands/BatchExecuteStatementCommand");
} = require("@aws-sdk/client-rds-data/commands/BatchExecuteStatementCommand");
trivikr marked this conversation as resolved.
Show resolved Hide resolved
```

```javascript
//TypeScript
import { RDSDataClient } from "@aws-sdk/client-rds-data-node/RDSDataClient";
import { BatchExecuteStatementCommand } from "@aws-sdk/client-rds-data-node/commands/BatchExecuteStatementCommand";
import { RdsDataServiceClient } from "@aws-sdk/client-rds-data/RdsDataServiceClient";
import { BatchExecuteStatementCommand } from "@aws-sdk/client-rds-data/commands/BatchExecuteStatementCommand";
trivikr marked this conversation as resolved.
Show resolved Hide resolved
```

### Usage
Expand All @@ -53,7 +53,7 @@ To send a request, you:
- If you are using a custom http handler, you may call `destroy()` to close open connections.

```javascript
const rDSData = new RDSDataClient({region: 'region'});
const rDSData = new RdsDataServiceClient({region: 'region'});
//clients can be shared by different commands
const params = {
resourceArn: /**a string value*/,
Expand Down Expand Up @@ -90,7 +90,7 @@ rDSData.send(batchExecuteStatementCommand, (err, data) => {
The SDK can also send requests using the simplified callback style from version 2 of the SDK.
trivikr marked this conversation as resolved.
Show resolved Hide resolved

```javascript
import * as AWS from "@aws-sdk/@aws-sdk/client-rds-data-node/RDSData";
import * as AWS from "@aws-sdk/@aws-sdk/client-rds-data/RDSData";
const rDSData = new AWS.RDSData({ region: "region" });
rDSData.batchExecuteStatement(params, (err, data) => {
//do something
Expand Down Expand Up @@ -131,7 +131,7 @@ Please use these community resources for getting help. We use the GitHub issues

## Contributing

This client code is generated automatically. Any modifications will be overwritten the next time the `@aws-sdk/@aws-sdk/client-rds-data-node' package is updated. To contribute to SDK you can checkout our [code generator package][].
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

Expand Down
206 changes: 206 additions & 0 deletions clients/client-rds-data/RdsDataServiceClient.ts
Original file line number Diff line number Diff line change
@@ -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;
trivikr marked this conversation as resolved.
Show resolved Hide resolved
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);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command } from "@aws-sdk/smithy-client";
import { serdePlugin } from "@aws-sdk/middleware-serde";
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
import {
HttpOptions,
Handler,
Expand All @@ -8,16 +8,17 @@ import {
MiddlewareStack,
SerdeContext
} from "@aws-sdk/types";
import { RDSDataResolvedConfiguration } from "../RDSDataConfiguration";
import { HttpRequest, HttpResponse } from "@aws-sdk/protocol-http";
import {
executeStatementAwsRestJson1_1Serialize,
executeStatementAwsRestJson1_1Deserialize
} from "../protocol/AwsRestJson1_1";
import { ExecuteStatementRequest, ExecuteStatementResponse } from "../models";

type InputTypesUnion = any;
type OutputTypesUnion = any;
import {
ServiceInputTypes,
ServiceOutputTypes,
RdsDataServiceResolvedConfig
} from "../RdsDataServiceClient";

export class ExecuteStatementCommand extends Command<
ExecuteStatementRequest,
Expand All @@ -28,15 +29,17 @@ export class ExecuteStatementCommand extends Command<
}

resolveMiddleware(
clientStack: MiddlewareStack<InputTypesUnion, OutputTypesUnion>,
configuration: RDSDataResolvedConfiguration,
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
configuration: RdsDataServiceResolvedConfig,
options?: HttpOptions
): Handler<ExecuteStatementRequest, ExecuteStatementResponse> {
const {
protocol: { handler }
} = configuration;

this.use(serdePlugin(configuration, this.serialize, this.deserialize));
this.middlewareStack.use(
getSerdePlugin(configuration, this.serialize, this.deserialize)
);

const stack = clientStack.concat(this.middlewareStack);

Expand Down
2 changes: 2 additions & 0 deletions clients/client-rds-data/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./RdsDataServiceClient";
export * from "./commands/ExecuteStatementCommand";
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@aws-sdk/client-rds-data-node",
"name": "@aws-sdk/client-rds-data",
"description": "Node SDK for AWS RDS DataService",
"version": "0.1.0-preview.3",
"scripts": {
"clean": "npm run remove-definitions && npm run remove-maps && npm run remove-js",
"build-documentation": "npm run clean && typedoc ./",
"prepublishOnly": "tsc",
"prepublishOnly": "yarn build",
"pretest": "tsc",
"remove-definitions": "rimraf *.d.ts && rimraf ./commands/*.d.ts && rimraf ./model/*.d.ts rimraf ./types/*.d.ts && rimraf ./protocol/*.d.ts",
"remove-documentation": "rimraf ./docs",
Expand Down Expand Up @@ -44,9 +44,9 @@
"@aws-sdk/node-http-handler": "^0.1.0-preview.6",
"@aws-sdk/protocol-rest-json": "^0.1.0-preview.5",
"@aws-sdk/region-provider": "^0.1.0-preview.5",
"@aws-sdk/retry-middleware": "^0.1.0-preview.5",
"@aws-sdk/middleware-retry": "^0.1.0-preview.5",
"@aws-sdk/signature-v4": "^0.1.0-preview.7",
"@aws-sdk/signing-middleware": "^0.1.0-preview.7",
"@aws-sdk/middleware-signing": "^0.1.0-preview.7",
"@aws-sdk/stream-collector-node": "^0.1.0-preview.6",
"@aws-sdk/stream-collector-browser": "^0.1.0-preview.5",
"@aws-sdk/types": "^0.1.0-preview.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser";
import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser";
import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser";
import { name, version } from "./package.json";
import { RDSDataRuntimeDependencies } from "./RDSDataConfiguration";
import { RDSDataRuntimeDependencies } from "./RdsDataServiceClient";

export const RDSRuntimeConfiguration: Required<RDSDataRuntimeDependencies> = {
protocolDefaultProvider: handler => new RestJsonProtocol(handler),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node";
import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node";
import { defaultUserAgent } from "@aws-sdk/util-user-agent-node";
import { name, version } from "./package.json";
import { RDSDataRuntimeDependencies } from "./RDSDataConfiguration";
import { RDSDataRuntimeDependencies } from "./RdsDataServiceClient";

export const RDSRuntimeConfiguration: Required<RDSDataRuntimeDependencies> = {
protocolDefaultProvider: handler => new RestJsonProtocol(handler),
Expand Down
Loading