Skip to content

Commit

Permalink
feat(client-redshift-data): This release adds a new --client-token fi…
Browse files Browse the repository at this point in the history
…eld to ExecuteStatement and BatchExecuteStatement operations. Customers can now run queries with the additional client token parameter to ensures idempotency.
  • Loading branch information
awstools committed Dec 14, 2022
1 parent 09e09ff commit e54654e
Show file tree
Hide file tree
Showing 17 changed files with 162 additions and 63 deletions.
2 changes: 1 addition & 1 deletion clients/client-redshift-data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ AWS SDK for JavaScript RedshiftData Client for Node.js, Browser and React Native
can run SQL statements, which are committed if the statement succeeds. </p>
<p>For more information about the Amazon Redshift Data API and CLI usage examples, see
<a href="https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html">Using the Amazon Redshift Data API</a> in the
<i>Amazon Redshift Cluster Management Guide</i>. </p>
<i>Amazon Redshift Management Guide</i>. </p>

## Installing

Expand Down
4 changes: 3 additions & 1 deletion clients/client-redshift-data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@
"@aws-sdk/util-user-agent-node": "*",
"@aws-sdk/util-utf8-browser": "*",
"@aws-sdk/util-utf8-node": "*",
"tslib": "^2.3.1"
"tslib": "^2.3.1",
"uuid": "^8.3.2"
},
"devDependencies": {
"@aws-sdk/service-client-documentation-generator": "*",
"@tsconfig/node14": "1.0.3",
"@types/node": "^14.14.31",
"@types/uuid": "^8.3.0",
"concurrently": "7.0.0",
"downlevel-dts": "0.10.1",
"rimraf": "3.0.2",
Expand Down
32 changes: 31 additions & 1 deletion clients/client-redshift-data/src/RedshiftData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import { RedshiftDataClient } from "./RedshiftDataClient";
* can run SQL statements, which are committed if the statement succeeds. </p>
* <p>For more information about the Amazon Redshift Data API and CLI usage examples, see
* <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html">Using the Amazon Redshift Data API</a> in the
* <i>Amazon Redshift Cluster Management Guide</i>. </p>
* <i>Amazon Redshift Management Guide</i>. </p>
*/
export class RedshiftData extends RedshiftDataClient {
/**
Expand All @@ -69,6 +69,9 @@ export class RedshiftData extends RedshiftDataClient {
* When connecting to a serverless workgroup, specify the workgroup name and database name. Also, permission to call the <code>redshift-serverless:GetCredentials</code> operation is required. </p>
* </li>
* </ul>
* <p>For more information about the Amazon Redshift Data API and CLI usage examples, see
* <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html">Using the Amazon Redshift Data API</a> in the
* <i>Amazon Redshift Management Guide</i>. </p>
*/
public batchExecuteStatement(
args: BatchExecuteStatementCommandInput,
Expand Down Expand Up @@ -101,6 +104,9 @@ export class RedshiftData extends RedshiftDataClient {

/**
* <p>Cancels a running query. To be canceled, a query must be running. </p>
* <p>For more information about the Amazon Redshift Data API and CLI usage examples, see
* <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html">Using the Amazon Redshift Data API</a> in the
* <i>Amazon Redshift Management Guide</i>. </p>
*/
public cancelStatement(
args: CancelStatementCommandInput,
Expand Down Expand Up @@ -135,6 +141,9 @@ export class RedshiftData extends RedshiftDataClient {
* <p>Describes the details about a specific instance when a query was run by the Amazon Redshift Data API. The information
* includes when the query started, when it finished, the query status, the number of rows returned, and the SQL
* statement. </p>
* <p>For more information about the Amazon Redshift Data API and CLI usage examples, see
* <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html">Using the Amazon Redshift Data API</a> in the
* <i>Amazon Redshift Management Guide</i>. </p>
*/
public describeStatement(
args: DescribeStatementCommandInput,
Expand Down Expand Up @@ -182,6 +191,9 @@ export class RedshiftData extends RedshiftDataClient {
* When connecting to a serverless workgroup, specify the workgroup name and database name. Also, permission to call the <code>redshift-serverless:GetCredentials</code> operation is required. </p>
* </li>
* </ul>
* <p>For more information about the Amazon Redshift Data API and CLI usage examples, see
* <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html">Using the Amazon Redshift Data API</a> in the
* <i>Amazon Redshift Management Guide</i>. </p>
*/
public describeTable(
args: DescribeTableCommandInput,
Expand Down Expand Up @@ -228,6 +240,9 @@ export class RedshiftData extends RedshiftDataClient {
* When connecting to a serverless workgroup, specify the workgroup name and database name. Also, permission to call the <code>redshift-serverless:GetCredentials</code> operation is required. </p>
* </li>
* </ul>
* <p>For more information about the Amazon Redshift Data API and CLI usage examples, see
* <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html">Using the Amazon Redshift Data API</a> in the
* <i>Amazon Redshift Management Guide</i>. </p>
*/
public executeStatement(
args: ExecuteStatementCommandInput,
Expand Down Expand Up @@ -261,6 +276,9 @@ export class RedshiftData extends RedshiftDataClient {
/**
* <p>Fetches the temporarily cached result of an SQL statement.
* A token is returned to page through the statement results. </p>
* <p>For more information about the Amazon Redshift Data API and CLI usage examples, see
* <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html">Using the Amazon Redshift Data API</a> in the
* <i>Amazon Redshift Management Guide</i>. </p>
*/
public getStatementResult(
args: GetStatementResultCommandInput,
Expand Down Expand Up @@ -307,6 +325,9 @@ export class RedshiftData extends RedshiftDataClient {
* When connecting to a serverless workgroup, specify the workgroup name and database name. Also, permission to call the <code>redshift-serverless:GetCredentials</code> operation is required. </p>
* </li>
* </ul>
* <p>For more information about the Amazon Redshift Data API and CLI usage examples, see
* <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html">Using the Amazon Redshift Data API</a> in the
* <i>Amazon Redshift Management Guide</i>. </p>
*/
public listDatabases(
args: ListDatabasesCommandInput,
Expand Down Expand Up @@ -353,6 +374,9 @@ export class RedshiftData extends RedshiftDataClient {
* When connecting to a serverless workgroup, specify the workgroup name and database name. Also, permission to call the <code>redshift-serverless:GetCredentials</code> operation is required. </p>
* </li>
* </ul>
* <p>For more information about the Amazon Redshift Data API and CLI usage examples, see
* <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html">Using the Amazon Redshift Data API</a> in the
* <i>Amazon Redshift Management Guide</i>. </p>
*/
public listSchemas(args: ListSchemasCommandInput, options?: __HttpHandlerOptions): Promise<ListSchemasCommandOutput>;
public listSchemas(args: ListSchemasCommandInput, cb: (err: any, data?: ListSchemasCommandOutput) => void): void;
Expand Down Expand Up @@ -380,6 +404,9 @@ export class RedshiftData extends RedshiftDataClient {
/**
* <p>List of SQL statements. By default, only finished statements are shown.
* A token is returned to page through the statement list. </p>
* <p>For more information about the Amazon Redshift Data API and CLI usage examples, see
* <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html">Using the Amazon Redshift Data API</a> in the
* <i>Amazon Redshift Management Guide</i>. </p>
*/
public listStatements(
args: ListStatementsCommandInput,
Expand Down Expand Up @@ -427,6 +454,9 @@ export class RedshiftData extends RedshiftDataClient {
* When connecting to a serverless workgroup, specify the workgroup name and database name. Also, permission to call the <code>redshift-serverless:GetCredentials</code> operation is required. </p>
* </li>
* </ul>
* <p>For more information about the Amazon Redshift Data API and CLI usage examples, see
* <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html">Using the Amazon Redshift Data API</a> in the
* <i>Amazon Redshift Management Guide</i>. </p>
*/
public listTables(args: ListTablesCommandInput, options?: __HttpHandlerOptions): Promise<ListTablesCommandOutput>;
public listTables(args: ListTablesCommandInput, cb: (err: any, data?: ListTablesCommandOutput) => void): void;
Expand Down
2 changes: 1 addition & 1 deletion clients/client-redshift-data/src/RedshiftDataClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export interface RedshiftDataClientResolvedConfig extends RedshiftDataClientReso
* can run SQL statements, which are committed if the statement succeeds. </p>
* <p>For more information about the Amazon Redshift Data API and CLI usage examples, see
* <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html">Using the Amazon Redshift Data API</a> in the
* <i>Amazon Redshift Cluster Management Guide</i>. </p>
* <i>Amazon Redshift Management Guide</i>. </p>
*/
export class RedshiftDataClient extends __Client<
__HttpHandlerOptions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export interface BatchExecuteStatementCommandOutput extends BatchExecuteStatemen
* When connecting to a serverless workgroup, specify the workgroup name and database name. Also, permission to call the <code>redshift-serverless:GetCredentials</code> operation is required. </p>
* </li>
* </ul>
* <p>For more information about the Amazon Redshift Data API and CLI usage examples, see
* <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html">Using the Amazon Redshift Data API</a> in the
* <i>Amazon Redshift Management Guide</i>. </p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export interface CancelStatementCommandOutput extends CancelStatementResponse, _

/**
* <p>Cancels a running query. To be canceled, a query must be running. </p>
* <p>For more information about the Amazon Redshift Data API and CLI usage examples, see
* <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html">Using the Amazon Redshift Data API</a> in the
* <i>Amazon Redshift Management Guide</i>. </p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export interface DescribeStatementCommandOutput extends DescribeStatementRespons
* <p>Describes the details about a specific instance when a query was run by the Amazon Redshift Data API. The information
* includes when the query started, when it finished, the query status, the number of rows returned, and the SQL
* statement. </p>
* <p>For more information about the Amazon Redshift Data API and CLI usage examples, see
* <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html">Using the Amazon Redshift Data API</a> in the
* <i>Amazon Redshift Management Guide</i>. </p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export interface DescribeTableCommandOutput extends DescribeTableResponse, __Met
* When connecting to a serverless workgroup, specify the workgroup name and database name. Also, permission to call the <code>redshift-serverless:GetCredentials</code> operation is required. </p>
* </li>
* </ul>
* <p>For more information about the Amazon Redshift Data API and CLI usage examples, see
* <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html">Using the Amazon Redshift Data API</a> in the
* <i>Amazon Redshift Management Guide</i>. </p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export interface ExecuteStatementCommandOutput extends ExecuteStatementOutput, _
* When connecting to a serverless workgroup, specify the workgroup name and database name. Also, permission to call the <code>redshift-serverless:GetCredentials</code> operation is required. </p>
* </li>
* </ul>
* <p>For more information about the Amazon Redshift Data API and CLI usage examples, see
* <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html">Using the Amazon Redshift Data API</a> in the
* <i>Amazon Redshift Management Guide</i>. </p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export interface GetStatementResultCommandOutput extends GetStatementResultRespo
/**
* <p>Fetches the temporarily cached result of an SQL statement.
* A token is returned to page through the statement results. </p>
* <p>For more information about the Amazon Redshift Data API and CLI usage examples, see
* <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html">Using the Amazon Redshift Data API</a> in the
* <i>Amazon Redshift Management Guide</i>. </p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export interface ListDatabasesCommandOutput extends ListDatabasesResponse, __Met
* When connecting to a serverless workgroup, specify the workgroup name and database name. Also, permission to call the <code>redshift-serverless:GetCredentials</code> operation is required. </p>
* </li>
* </ul>
* <p>For more information about the Amazon Redshift Data API and CLI usage examples, see
* <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html">Using the Amazon Redshift Data API</a> in the
* <i>Amazon Redshift Management Guide</i>. </p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export interface ListSchemasCommandOutput extends ListSchemasResponse, __Metadat
* When connecting to a serverless workgroup, specify the workgroup name and database name. Also, permission to call the <code>redshift-serverless:GetCredentials</code> operation is required. </p>
* </li>
* </ul>
* <p>For more information about the Amazon Redshift Data API and CLI usage examples, see
* <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html">Using the Amazon Redshift Data API</a> in the
* <i>Amazon Redshift Management Guide</i>. </p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export interface ListStatementsCommandOutput extends ListStatementsResponse, __M
/**
* <p>List of SQL statements. By default, only finished statements are shown.
* A token is returned to page through the statement list. </p>
* <p>For more information about the Amazon Redshift Data API and CLI usage examples, see
* <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html">Using the Amazon Redshift Data API</a> in the
* <i>Amazon Redshift Management Guide</i>. </p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export interface ListTablesCommandOutput extends ListTablesResponse, __MetadataB
* When connecting to a serverless workgroup, specify the workgroup name and database name. Also, permission to call the <code>redshift-serverless:GetCredentials</code> operation is required. </p>
* </li>
* </ul>
* <p>For more information about the Amazon Redshift Data API and CLI usage examples, see
* <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html">Using the Amazon Redshift Data API</a> in the
* <i>Amazon Redshift Management Guide</i>. </p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
Expand Down
18 changes: 16 additions & 2 deletions clients/client-redshift-data/src/models/models_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ export class BatchExecuteStatementException extends __BaseException {

export interface BatchExecuteStatementInput {
/**
* <p>One or more SQL statements to run. </p>
* <p>One or more SQL statements to run.
*
* The SQL statements are run as a single transaction. They run serially in the order of the array.
* Subsequent SQL statements don't start until the previous statement in the array completes.
* If any SQL statement fails, then because they are run as one transaction, all work is rolled back.</p>
*/
Sqls: string[] | undefined;

Expand Down Expand Up @@ -90,6 +94,11 @@ export interface BatchExecuteStatementInput {
* <p>The serverless workgroup name. This parameter is required when connecting to a serverless workgroup and authenticating using either Secrets Manager or temporary credentials.</p>
*/
WorkgroupName?: string;

/**
* <p>A unique, case-sensitive identifier that you provide to ensure the idempotency of the request.</p>
*/
ClientToken?: string;
}

export interface BatchExecuteStatementOutput {
Expand Down Expand Up @@ -335,7 +344,7 @@ export interface SqlParameter {

/**
* <p>The value of the parameter.
* Amazon Redshift implicitly converts to the proper data type. For more inforation, see
* Amazon Redshift implicitly converts to the proper data type. For more information, see
* <a href="https://docs.aws.amazon.com/redshift/latest/dg/c_Supported_data_types.html">Data types</a> in the
* <i>Amazon Redshift Database Developer Guide</i>. </p>
*/
Expand Down Expand Up @@ -699,6 +708,11 @@ export interface ExecuteStatementInput {
* <p>The serverless workgroup name. This parameter is required when connecting to a serverless workgroup and authenticating using either Secrets Manager or temporary credentials.</p>
*/
WorkgroupName?: string;

/**
* <p>A unique, case-sensitive identifier that you provide to ensure the idempotency of the request.</p>
*/
ClientToken?: string;
}

export interface ExecuteStatementOutput {
Expand Down
3 changes: 3 additions & 0 deletions clients/client-redshift-data/src/protocols/Aws_json1_1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
ResponseMetadata as __ResponseMetadata,
SerdeContext as __SerdeContext,
} from "@aws-sdk/types";
import { v4 as generateIdempotencyToken } from "uuid";

import {
BatchExecuteStatementCommandInput,
Expand Down Expand Up @@ -766,6 +767,7 @@ const serializeAws_json1_1BatchExecuteStatementInput = (
context: __SerdeContext
): any => {
return {
ClientToken: input.ClientToken ?? generateIdempotencyToken(),
...(input.ClusterIdentifier != null && { ClusterIdentifier: input.ClusterIdentifier }),
...(input.Database != null && { Database: input.Database }),
...(input.DbUser != null && { DbUser: input.DbUser }),
Expand Down Expand Up @@ -809,6 +811,7 @@ const serializeAws_json1_1DescribeTableRequest = (input: DescribeTableRequest, c

const serializeAws_json1_1ExecuteStatementInput = (input: ExecuteStatementInput, context: __SerdeContext): any => {
return {
ClientToken: input.ClientToken ?? generateIdempotencyToken(),
...(input.ClusterIdentifier != null && { ClusterIdentifier: input.ClusterIdentifier }),
...(input.Database != null && { Database: input.Database }),
...(input.DbUser != null && { DbUser: input.DbUser }),
Expand Down
Loading

0 comments on commit e54654e

Please sign in to comment.