Skip to content

Commit

Permalink
feat(client-athena): This feature introduces the API support for Athe…
Browse files Browse the repository at this point in the history
…na's parameterized query and BatchGetPreparedStatement API.
  • Loading branch information
awstools committed Jun 30, 2022
1 parent debff58 commit 52a77f5
Show file tree
Hide file tree
Showing 8 changed files with 605 additions and 43 deletions.
39 changes: 38 additions & 1 deletion clients/client-athena/src/Athena.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import {
BatchGetNamedQueryCommandInput,
BatchGetNamedQueryCommandOutput,
} from "./commands/BatchGetNamedQueryCommand";
import {
BatchGetPreparedStatementCommand,
BatchGetPreparedStatementCommandInput,
BatchGetPreparedStatementCommandOutput,
} from "./commands/BatchGetPreparedStatementCommand";
import {
BatchGetQueryExecutionCommand,
BatchGetQueryExecutionCommandInput,
Expand Down Expand Up @@ -227,6 +232,38 @@ export class Athena extends AthenaClient {
}
}

/**
* <p>Returns the details of a single prepared statement or a list of up to 256 prepared statements for the array of prepared statement names that you provide. Requires you to have access to the workgroup to which the prepared statements belong. If a prepared statement cannot be retrieved for the name specified, the statement is listed in <code>UnprocessedPreparedStatementNames</code>.</p>
*/
public batchGetPreparedStatement(
args: BatchGetPreparedStatementCommandInput,
options?: __HttpHandlerOptions
): Promise<BatchGetPreparedStatementCommandOutput>;
public batchGetPreparedStatement(
args: BatchGetPreparedStatementCommandInput,
cb: (err: any, data?: BatchGetPreparedStatementCommandOutput) => void
): void;
public batchGetPreparedStatement(
args: BatchGetPreparedStatementCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: BatchGetPreparedStatementCommandOutput) => void
): void;
public batchGetPreparedStatement(
args: BatchGetPreparedStatementCommandInput,
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: BatchGetPreparedStatementCommandOutput) => void),
cb?: (err: any, data?: BatchGetPreparedStatementCommandOutput) => void
): Promise<BatchGetPreparedStatementCommandOutput> | void {
const command = new BatchGetPreparedStatementCommand(args);
if (typeof optionsOrCb === "function") {
this.send(command, optionsOrCb);
} else if (typeof cb === "function") {
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
this.send(command, optionsOrCb || {}, cb);
} else {
return this.send(command, optionsOrCb);
}
}

/**
* <p>Returns the details of a single query execution or a list of up to 50 query
* executions, which you provide as an array of query execution ID strings. Requires you to
Expand Down Expand Up @@ -931,7 +968,7 @@ export class Athena extends AthenaClient {
}

/**
* <p>Lists the prepared statements in the specfied workgroup.</p>
* <p>Lists the prepared statements in the specified workgroup.</p>
*/
public listPreparedStatements(
args: ListPreparedStatementsCommandInput,
Expand Down
6 changes: 6 additions & 0 deletions clients/client-athena/src/AthenaClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ import {
} from "@aws-sdk/types";

import { BatchGetNamedQueryCommandInput, BatchGetNamedQueryCommandOutput } from "./commands/BatchGetNamedQueryCommand";
import {
BatchGetPreparedStatementCommandInput,
BatchGetPreparedStatementCommandOutput,
} from "./commands/BatchGetPreparedStatementCommand";
import {
BatchGetQueryExecutionCommandInput,
BatchGetQueryExecutionCommandOutput,
Expand Down Expand Up @@ -119,6 +123,7 @@ import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig";

export type ServiceInputTypes =
| BatchGetNamedQueryCommandInput
| BatchGetPreparedStatementCommandInput
| BatchGetQueryExecutionCommandInput
| CreateDataCatalogCommandInput
| CreateNamedQueryCommandInput
Expand Down Expand Up @@ -156,6 +161,7 @@ export type ServiceInputTypes =

export type ServiceOutputTypes =
| BatchGetNamedQueryCommandOutput
| BatchGetPreparedStatementCommandOutput
| BatchGetQueryExecutionCommandOutput
| CreateDataCatalogCommandOutput
| CreateNamedQueryCommandOutput
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// smithy-typescript generated code
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
import { Command as $Command } from "@aws-sdk/smithy-client";
import {
FinalizeHandlerArguments,
Handler,
HandlerExecutionContext,
HttpHandlerOptions as __HttpHandlerOptions,
MetadataBearer as __MetadataBearer,
MiddlewareStack,
SerdeContext as __SerdeContext,
} from "@aws-sdk/types";

import { AthenaClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../AthenaClient";
import { BatchGetPreparedStatementInput, BatchGetPreparedStatementOutput } from "../models/models_0";
import {
deserializeAws_json1_1BatchGetPreparedStatementCommand,
serializeAws_json1_1BatchGetPreparedStatementCommand,
} from "../protocols/Aws_json1_1";

export interface BatchGetPreparedStatementCommandInput extends BatchGetPreparedStatementInput {}
export interface BatchGetPreparedStatementCommandOutput extends BatchGetPreparedStatementOutput, __MetadataBearer {}

/**
* <p>Returns the details of a single prepared statement or a list of up to 256 prepared statements for the array of prepared statement names that you provide. Requires you to have access to the workgroup to which the prepared statements belong. If a prepared statement cannot be retrieved for the name specified, the statement is listed in <code>UnprocessedPreparedStatementNames</code>.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { AthenaClient, BatchGetPreparedStatementCommand } from "@aws-sdk/client-athena"; // ES Modules import
* // const { AthenaClient, BatchGetPreparedStatementCommand } = require("@aws-sdk/client-athena"); // CommonJS import
* const client = new AthenaClient(config);
* const command = new BatchGetPreparedStatementCommand(input);
* const response = await client.send(command);
* ```
*
* @see {@link BatchGetPreparedStatementCommandInput} for command's `input` shape.
* @see {@link BatchGetPreparedStatementCommandOutput} for command's `response` shape.
* @see {@link AthenaClientResolvedConfig | config} for AthenaClient's `config` shape.
*
*/
export class BatchGetPreparedStatementCommand extends $Command<
BatchGetPreparedStatementCommandInput,
BatchGetPreparedStatementCommandOutput,
AthenaClientResolvedConfig
> {
// Start section: command_properties
// End section: command_properties

constructor(readonly input: BatchGetPreparedStatementCommandInput) {
// Start section: command_constructor
super();
// End section: command_constructor
}

/**
* @internal
*/
resolveMiddleware(
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
configuration: AthenaClientResolvedConfig,
options?: __HttpHandlerOptions
): Handler<BatchGetPreparedStatementCommandInput, BatchGetPreparedStatementCommandOutput> {
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));

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

const { logger } = configuration;
const clientName = "AthenaClient";
const commandName = "BatchGetPreparedStatementCommand";
const handlerExecutionContext: HandlerExecutionContext = {
logger,
clientName,
commandName,
inputFilterSensitiveLog: BatchGetPreparedStatementInput.filterSensitiveLog,
outputFilterSensitiveLog: BatchGetPreparedStatementOutput.filterSensitiveLog,
};
const { requestHandler } = configuration;
return stack.resolve(
(request: FinalizeHandlerArguments<any>) =>
requestHandler.handle(request.request as __HttpRequest, options || {}),
handlerExecutionContext
);
}

private serialize(input: BatchGetPreparedStatementCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
return serializeAws_json1_1BatchGetPreparedStatementCommand(input, context);
}

private deserialize(
output: __HttpResponse,
context: __SerdeContext
): Promise<BatchGetPreparedStatementCommandOutput> {
return deserializeAws_json1_1BatchGetPreparedStatementCommand(output, context);
}

// Start section: command_body_extra
// End section: command_body_extra
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface ListPreparedStatementsCommandInput extends ListPreparedStatemen
export interface ListPreparedStatementsCommandOutput extends ListPreparedStatementsOutput, __MetadataBearer {}

/**
* <p>Lists the prepared statements in the specfied workgroup.</p>
* <p>Lists the prepared statements in the specified workgroup.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
Expand Down
1 change: 1 addition & 0 deletions clients/client-athena/src/commands/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// smithy-typescript generated code
export * from "./BatchGetNamedQueryCommand";
export * from "./BatchGetPreparedStatementCommand";
export * from "./BatchGetQueryExecutionCommand";
export * from "./CreateDataCatalogCommand";
export * from "./CreateNamedQueryCommand";
Expand Down
Loading

0 comments on commit 52a77f5

Please sign in to comment.