Skip to content

Commit 52a77f5

Browse files
author
awstools
committed
feat(client-athena): This feature introduces the API support for Athena's parameterized query and BatchGetPreparedStatement API.
1 parent debff58 commit 52a77f5

File tree

8 files changed

+605
-43
lines changed

8 files changed

+605
-43
lines changed

clients/client-athena/src/Athena.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ import {
77
BatchGetNamedQueryCommandInput,
88
BatchGetNamedQueryCommandOutput,
99
} from "./commands/BatchGetNamedQueryCommand";
10+
import {
11+
BatchGetPreparedStatementCommand,
12+
BatchGetPreparedStatementCommandInput,
13+
BatchGetPreparedStatementCommandOutput,
14+
} from "./commands/BatchGetPreparedStatementCommand";
1015
import {
1116
BatchGetQueryExecutionCommand,
1217
BatchGetQueryExecutionCommandInput,
@@ -227,6 +232,38 @@ export class Athena extends AthenaClient {
227232
}
228233
}
229234

235+
/**
236+
* <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>
237+
*/
238+
public batchGetPreparedStatement(
239+
args: BatchGetPreparedStatementCommandInput,
240+
options?: __HttpHandlerOptions
241+
): Promise<BatchGetPreparedStatementCommandOutput>;
242+
public batchGetPreparedStatement(
243+
args: BatchGetPreparedStatementCommandInput,
244+
cb: (err: any, data?: BatchGetPreparedStatementCommandOutput) => void
245+
): void;
246+
public batchGetPreparedStatement(
247+
args: BatchGetPreparedStatementCommandInput,
248+
options: __HttpHandlerOptions,
249+
cb: (err: any, data?: BatchGetPreparedStatementCommandOutput) => void
250+
): void;
251+
public batchGetPreparedStatement(
252+
args: BatchGetPreparedStatementCommandInput,
253+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: BatchGetPreparedStatementCommandOutput) => void),
254+
cb?: (err: any, data?: BatchGetPreparedStatementCommandOutput) => void
255+
): Promise<BatchGetPreparedStatementCommandOutput> | void {
256+
const command = new BatchGetPreparedStatementCommand(args);
257+
if (typeof optionsOrCb === "function") {
258+
this.send(command, optionsOrCb);
259+
} else if (typeof cb === "function") {
260+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
261+
this.send(command, optionsOrCb || {}, cb);
262+
} else {
263+
return this.send(command, optionsOrCb);
264+
}
265+
}
266+
230267
/**
231268
* <p>Returns the details of a single query execution or a list of up to 50 query
232269
* executions, which you provide as an array of query execution ID strings. Requires you to
@@ -931,7 +968,7 @@ export class Athena extends AthenaClient {
931968
}
932969

933970
/**
934-
* <p>Lists the prepared statements in the specfied workgroup.</p>
971+
* <p>Lists the prepared statements in the specified workgroup.</p>
935972
*/
936973
public listPreparedStatements(
937974
args: ListPreparedStatementsCommandInput,

clients/client-athena/src/AthenaClient.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ import {
5454
} from "@aws-sdk/types";
5555

5656
import { BatchGetNamedQueryCommandInput, BatchGetNamedQueryCommandOutput } from "./commands/BatchGetNamedQueryCommand";
57+
import {
58+
BatchGetPreparedStatementCommandInput,
59+
BatchGetPreparedStatementCommandOutput,
60+
} from "./commands/BatchGetPreparedStatementCommand";
5761
import {
5862
BatchGetQueryExecutionCommandInput,
5963
BatchGetQueryExecutionCommandOutput,
@@ -119,6 +123,7 @@ import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig";
119123

120124
export type ServiceInputTypes =
121125
| BatchGetNamedQueryCommandInput
126+
| BatchGetPreparedStatementCommandInput
122127
| BatchGetQueryExecutionCommandInput
123128
| CreateDataCatalogCommandInput
124129
| CreateNamedQueryCommandInput
@@ -156,6 +161,7 @@ export type ServiceInputTypes =
156161

157162
export type ServiceOutputTypes =
158163
| BatchGetNamedQueryCommandOutput
164+
| BatchGetPreparedStatementCommandOutput
159165
| BatchGetQueryExecutionCommandOutput
160166
| CreateDataCatalogCommandOutput
161167
| CreateNamedQueryCommandOutput
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// smithy-typescript generated code
2+
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
3+
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
4+
import { Command as $Command } from "@aws-sdk/smithy-client";
5+
import {
6+
FinalizeHandlerArguments,
7+
Handler,
8+
HandlerExecutionContext,
9+
HttpHandlerOptions as __HttpHandlerOptions,
10+
MetadataBearer as __MetadataBearer,
11+
MiddlewareStack,
12+
SerdeContext as __SerdeContext,
13+
} from "@aws-sdk/types";
14+
15+
import { AthenaClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../AthenaClient";
16+
import { BatchGetPreparedStatementInput, BatchGetPreparedStatementOutput } from "../models/models_0";
17+
import {
18+
deserializeAws_json1_1BatchGetPreparedStatementCommand,
19+
serializeAws_json1_1BatchGetPreparedStatementCommand,
20+
} from "../protocols/Aws_json1_1";
21+
22+
export interface BatchGetPreparedStatementCommandInput extends BatchGetPreparedStatementInput {}
23+
export interface BatchGetPreparedStatementCommandOutput extends BatchGetPreparedStatementOutput, __MetadataBearer {}
24+
25+
/**
26+
* <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>
27+
* @example
28+
* Use a bare-bones client and the command you need to make an API call.
29+
* ```javascript
30+
* import { AthenaClient, BatchGetPreparedStatementCommand } from "@aws-sdk/client-athena"; // ES Modules import
31+
* // const { AthenaClient, BatchGetPreparedStatementCommand } = require("@aws-sdk/client-athena"); // CommonJS import
32+
* const client = new AthenaClient(config);
33+
* const command = new BatchGetPreparedStatementCommand(input);
34+
* const response = await client.send(command);
35+
* ```
36+
*
37+
* @see {@link BatchGetPreparedStatementCommandInput} for command's `input` shape.
38+
* @see {@link BatchGetPreparedStatementCommandOutput} for command's `response` shape.
39+
* @see {@link AthenaClientResolvedConfig | config} for AthenaClient's `config` shape.
40+
*
41+
*/
42+
export class BatchGetPreparedStatementCommand extends $Command<
43+
BatchGetPreparedStatementCommandInput,
44+
BatchGetPreparedStatementCommandOutput,
45+
AthenaClientResolvedConfig
46+
> {
47+
// Start section: command_properties
48+
// End section: command_properties
49+
50+
constructor(readonly input: BatchGetPreparedStatementCommandInput) {
51+
// Start section: command_constructor
52+
super();
53+
// End section: command_constructor
54+
}
55+
56+
/**
57+
* @internal
58+
*/
59+
resolveMiddleware(
60+
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
61+
configuration: AthenaClientResolvedConfig,
62+
options?: __HttpHandlerOptions
63+
): Handler<BatchGetPreparedStatementCommandInput, BatchGetPreparedStatementCommandOutput> {
64+
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
65+
66+
const stack = clientStack.concat(this.middlewareStack);
67+
68+
const { logger } = configuration;
69+
const clientName = "AthenaClient";
70+
const commandName = "BatchGetPreparedStatementCommand";
71+
const handlerExecutionContext: HandlerExecutionContext = {
72+
logger,
73+
clientName,
74+
commandName,
75+
inputFilterSensitiveLog: BatchGetPreparedStatementInput.filterSensitiveLog,
76+
outputFilterSensitiveLog: BatchGetPreparedStatementOutput.filterSensitiveLog,
77+
};
78+
const { requestHandler } = configuration;
79+
return stack.resolve(
80+
(request: FinalizeHandlerArguments<any>) =>
81+
requestHandler.handle(request.request as __HttpRequest, options || {}),
82+
handlerExecutionContext
83+
);
84+
}
85+
86+
private serialize(input: BatchGetPreparedStatementCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
87+
return serializeAws_json1_1BatchGetPreparedStatementCommand(input, context);
88+
}
89+
90+
private deserialize(
91+
output: __HttpResponse,
92+
context: __SerdeContext
93+
): Promise<BatchGetPreparedStatementCommandOutput> {
94+
return deserializeAws_json1_1BatchGetPreparedStatementCommand(output, context);
95+
}
96+
97+
// Start section: command_body_extra
98+
// End section: command_body_extra
99+
}

clients/client-athena/src/commands/ListPreparedStatementsCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export interface ListPreparedStatementsCommandInput extends ListPreparedStatemen
2323
export interface ListPreparedStatementsCommandOutput extends ListPreparedStatementsOutput, __MetadataBearer {}
2424

2525
/**
26-
* <p>Lists the prepared statements in the specfied workgroup.</p>
26+
* <p>Lists the prepared statements in the specified workgroup.</p>
2727
* @example
2828
* Use a bare-bones client and the command you need to make an API call.
2929
* ```javascript

clients/client-athena/src/commands/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// smithy-typescript generated code
22
export * from "./BatchGetNamedQueryCommand";
3+
export * from "./BatchGetPreparedStatementCommand";
34
export * from "./BatchGetQueryExecutionCommand";
45
export * from "./CreateDataCatalogCommand";
56
export * from "./CreateNamedQueryCommand";

0 commit comments

Comments
 (0)