Skip to content

Commit 7b173c3

Browse files
author
awstools
committed
feat(client-rds-data): Support to receive SQL query results in the form of a simplified JSON string. This enables developers using the new JSON string format to more easily convert it to an object using popular JSON string parsing libraries.
1 parent 0abb527 commit 7b173c3

File tree

7 files changed

+257
-58
lines changed

7 files changed

+257
-58
lines changed

clients/client-rds-data/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ AWS SDK for JavaScript RDSData Client for Node.js, Browser and React Native.
1212
<p>Amazon RDS provides an HTTP endpoint to run SQL statements on an Amazon Aurora
1313
Serverless DB cluster. To run these statements, you work with the Data Service
1414
API.</p>
15-
<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
16-
Serverless</a> in the <i>Amazon Aurora User Guide</i>.</p>
15+
<p>For more information about the Data Service API, see
16+
<a href="https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html">Using the Data API</a>
17+
in the <i>Amazon Aurora User Guide</i>.</p>
1718

1819
## Installing
1920

clients/client-rds-data/src/RDSData.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ import { RDSDataClient } from "./RDSDataClient";
3333
* <p>Amazon RDS provides an HTTP endpoint to run SQL statements on an Amazon Aurora
3434
* Serverless DB cluster. To run these statements, you work with the Data Service
3535
* API.</p>
36-
* <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
37-
* Serverless</a> in the <i>Amazon Aurora User Guide</i>.</p>
36+
* <p>For more information about the Data Service API, see
37+
* <a href="https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html">Using the Data API</a>
38+
* in the <i>Amazon Aurora User Guide</i>.</p>
3839
*/
3940
export class RDSData extends RDSDataClient {
4041
/**
@@ -192,7 +193,7 @@ export class RDSData extends RDSDataClient {
192193
* <code>transactionID</code> parameter, changes that result from the call are
193194
* committed automatically.</p>
194195
* </important>
195-
* <p>The response size limit is 1 MB. If the call returns more than 1 MB of response data, the call is terminated.</p>
196+
* <p>If the binary response data from the database is more than 1 MB, the call is terminated.</p>
196197
*/
197198
public executeStatement(
198199
args: ExecuteStatementCommandInput,

clients/client-rds-data/src/RDSDataClient.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,9 @@ export interface RDSDataClientResolvedConfig extends RDSDataClientResolvedConfig
239239
* <p>Amazon RDS provides an HTTP endpoint to run SQL statements on an Amazon Aurora
240240
* Serverless DB cluster. To run these statements, you work with the Data Service
241241
* API.</p>
242-
* <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
243-
* Serverless</a> in the <i>Amazon Aurora User Guide</i>.</p>
242+
* <p>For more information about the Data Service API, see
243+
* <a href="https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html">Using the Data API</a>
244+
* in the <i>Amazon Aurora User Guide</i>.</p>
244245
*/
245246
export class RDSDataClient extends __Client<
246247
__HttpHandlerOptions,

clients/client-rds-data/src/commands/ExecuteStatementCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export interface ExecuteStatementCommandOutput extends ExecuteStatementResponse,
2828
* <code>transactionID</code> parameter, changes that result from the call are
2929
* committed automatically.</p>
3030
* </important>
31-
* <p>The response size limit is 1 MB. If the call returns more than 1 MB of response data, the call is terminated.</p>
31+
* <p>If the binary response data from the database is more than 1 MB, the call is terminated.</p>
3232
* @example
3333
* Use a bare-bones client and the command you need to make an API call.
3434
* ```javascript

clients/client-rds-data/src/models/models_0.ts

Lines changed: 81 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,25 @@ import { MetadataBearer as $MetadataBearer } from "@aws-sdk/types";
33

44
import { RDSDataServiceException as __BaseException } from "./RDSDataServiceException";
55

6+
/**
7+
* <p>You do not have sufficient access to perform this action.</p>
8+
*/
9+
export class AccessDeniedException extends __BaseException {
10+
readonly name: "AccessDeniedException" = "AccessDeniedException";
11+
readonly $fault: "client" = "client";
12+
/**
13+
* @internal
14+
*/
15+
constructor(opts: __ExceptionOptionType<AccessDeniedException, __BaseException>) {
16+
super({
17+
name: "AccessDeniedException",
18+
$fault: "client",
19+
...opts,
20+
});
21+
Object.setPrototypeOf(this, AccessDeniedException.prototype);
22+
}
23+
}
24+
625
/**
726
* <p>There is an error in the call or in a SQL statement.</p>
827
*/
@@ -392,6 +411,16 @@ export namespace ResultSetMetadata {
392411
});
393412
}
394413

414+
export enum RecordsFormatType {
415+
JSON = "JSON",
416+
NONE = "NONE",
417+
}
418+
419+
export enum LongReturnType {
420+
LONG = "LONG",
421+
STRING = "STRING",
422+
}
423+
395424
/**
396425
* <p>Options that control how the result set is returned.</p>
397426
*/
@@ -408,6 +437,15 @@ export interface ResultSetOptions {
408437
* </important>
409438
*/
410439
decimalReturnType?: DecimalReturnType | string;
440+
441+
/**
442+
* <p>A value that indicates how a field of <code>LONG</code> type is represented.
443+
* Allowed values are <code>LONG</code> and <code>STRING</code>. The default
444+
* is <code>LONG</code>. Specify <code>STRING</code> if the length or
445+
* precision of numeric values might cause truncation or rounding errors.
446+
* </p>
447+
*/
448+
longReturnType?: LongReturnType | string;
411449
}
412450

413451
export namespace ResultSetOptions {
@@ -494,7 +532,7 @@ export namespace ArrayValue {
494532
}
495533

496534
/**
497-
* <p>An array of floating point numbers.</p>
535+
* <p>An array of integers.</p>
498536
*/
499537
export interface LongValuesMember {
500538
booleanValues?: never;
@@ -506,7 +544,7 @@ export namespace ArrayValue {
506544
}
507545

508546
/**
509-
* <p>An array of integers.</p>
547+
* <p>An array of floating-point numbers.</p>
510548
*/
511549
export interface DoubleValuesMember {
512550
booleanValues?: never;
@@ -830,7 +868,8 @@ export namespace UpdateResult {
830868
* <p>Contains the value of a column.</p>
831869
*
832870
* <important>
833-
* <p>This data type is deprecated.</p>
871+
* <p>This data structure is only used with the deprecated <code>ExecuteSql</code> operation.
872+
* Use the <code>BatchExecuteStatement</code> or <code>ExecuteStatement</code> operation instead.</p>
834873
* </important>
835874
*/
836875
export type Value =
@@ -1148,6 +1187,17 @@ export interface ExecuteStatementRequest {
11481187
* <p>Options that control how the result set is returned.</p>
11491188
*/
11501189
resultSetOptions?: ResultSetOptions;
1190+
1191+
/**
1192+
* <p>A value that indicates whether to format the result set as a single JSON string.
1193+
* This parameter only applies to <code>SELECT</code> statements and is ignored for
1194+
* other types of statements. Allowed values are <code>NONE</code> and <code>JSON</code>.
1195+
* The default value is <code>NONE</code>. The result is returned in the <code>formattedRecords</code> field.</p>
1196+
* <p>For usage information about the JSON format for result sets, see
1197+
* <a href="https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html">Using the Data API</a>
1198+
* in the <i>Amazon Aurora User Guide</i>.</p>
1199+
*/
1200+
formatRecordsAs?: RecordsFormatType | string;
11511201
}
11521202

11531203
export namespace ExecuteStatementRequest {
@@ -1162,6 +1212,10 @@ export namespace ExecuteStatementRequest {
11621212

11631213
/**
11641214
* <p>A structure value returned by a call.</p>
1215+
* <important>
1216+
* <p>This data structure is only used with the deprecated <code>ExecuteSql</code> operation.
1217+
* Use the <code>BatchExecuteStatement</code> or <code>ExecuteStatement</code> operation instead.</p>
1218+
* </important>
11651219
*/
11661220
export interface StructValue {
11671221
/**
@@ -1273,6 +1327,10 @@ export namespace BatchExecuteStatementResponse {
12731327

12741328
/**
12751329
* <p>A record returned by a call.</p>
1330+
* <important>
1331+
* <p>This data structure is only used with the deprecated <code>ExecuteSql</code> operation.
1332+
* Use the <code>BatchExecuteStatement</code> or <code>ExecuteStatement</code> operation instead.</p>
1333+
* </important>
12761334
*/
12771335
export interface _Record {
12781336
/**
@@ -1297,12 +1355,14 @@ export namespace _Record {
12971355
*/
12981356
export interface ExecuteStatementResponse {
12991357
/**
1300-
* <p>The records returned by the SQL statement.</p>
1358+
* <p>The records returned by the SQL statement. This field is blank if the
1359+
* <code>formatRecordsAs</code> parameter is set to <code>JSON</code>.</p>
13011360
*/
13021361
records?: Field[][];
13031362

13041363
/**
1305-
* <p>Metadata for the columns included in the results.</p>
1364+
* <p>Metadata for the columns included in the results. This field is blank if the
1365+
* <code>formatRecordsAs</code> parameter is set to <code>JSON</code>.</p>
13061366
*/
13071367
columnMetadata?: ColumnMetadata[];
13081368

@@ -1312,7 +1372,7 @@ export interface ExecuteStatementResponse {
13121372
numberOfRecordsUpdated?: number;
13131373

13141374
/**
1315-
* <p>Values for fields generated during the request.</p>
1375+
* <p>Values for fields generated during a DML request.</p>
13161376
*
13171377
* <note>
13181378
* <p>The <code>generatedFields</code> data isn't supported by Aurora PostgreSQL.
@@ -1322,6 +1382,15 @@ export interface ExecuteStatementResponse {
13221382
* </note>
13231383
*/
13241384
generatedFields?: Field[];
1385+
1386+
/**
1387+
* <p>A string value that represents the result set of a <code>SELECT</code> statement
1388+
* in JSON format. This value is only present when the <code>formatRecordsAs</code>
1389+
* parameter is set to <code>JSON</code>.</p>
1390+
* <p>The size limit for this field is currently 10 MB. If the JSON-formatted string representing the
1391+
* result set requires more than 10 MB, the call returns an error.</p>
1392+
*/
1393+
formattedRecords?: string;
13251394
}
13261395

13271396
export namespace ExecuteStatementResponse {
@@ -1337,6 +1406,10 @@ export namespace ExecuteStatementResponse {
13371406

13381407
/**
13391408
* <p>The result set returned by a SQL statement.</p>
1409+
* <important>
1410+
* <p>This data structure is only used with the deprecated <code>ExecuteSql</code> operation.
1411+
* Use the <code>BatchExecuteStatement</code> or <code>ExecuteStatement</code> operation instead.</p>
1412+
* </important>
13401413
*/
13411414
export interface ResultFrame {
13421415
/**
@@ -1364,7 +1437,8 @@ export namespace ResultFrame {
13641437
* <p>The result of a SQL statement.</p>
13651438
*
13661439
* <important>
1367-
* <p>This data type is deprecated.</p>
1440+
* <p>This data structure is only used with the deprecated <code>ExecuteSql</code> operation.
1441+
* Use the <code>BatchExecuteStatement</code> or <code>ExecuteStatement</code> operation instead.</p>
13681442
* </important>
13691443
*/
13701444
export interface SqlStatementResult {

clients/client-rds-data/src/protocols/Aws_restJson1.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
} from "../commands/RollbackTransactionCommand";
3333
import {
3434
_Record,
35+
AccessDeniedException,
3536
ArrayValue,
3637
BadRequestException,
3738
ColumnMetadata,
@@ -182,6 +183,8 @@ export const serializeAws_restJson1ExecuteStatementCommand = async (
182183
...(input.continueAfterTimeout !== undefined &&
183184
input.continueAfterTimeout !== null && { continueAfterTimeout: input.continueAfterTimeout }),
184185
...(input.database !== undefined && input.database !== null && { database: input.database }),
186+
...(input.formatRecordsAs !== undefined &&
187+
input.formatRecordsAs !== null && { formatRecordsAs: input.formatRecordsAs }),
185188
...(input.includeResultMetadata !== undefined &&
186189
input.includeResultMetadata !== null && { includeResultMetadata: input.includeResultMetadata }),
187190
...(input.parameters !== undefined &&
@@ -263,6 +266,9 @@ const deserializeAws_restJson1BatchExecuteStatementCommandError = async (
263266
let errorCode = "UnknownError";
264267
errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
265268
switch (errorCode) {
269+
case "AccessDeniedException":
270+
case "com.amazonaws.rdsdata#AccessDeniedException":
271+
throw await deserializeAws_restJson1AccessDeniedExceptionResponse(parsedOutput, context);
266272
case "BadRequestException":
267273
case "com.amazonaws.rdsdata#BadRequestException":
268274
throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context);
@@ -319,6 +325,9 @@ const deserializeAws_restJson1BeginTransactionCommandError = async (
319325
let errorCode = "UnknownError";
320326
errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
321327
switch (errorCode) {
328+
case "AccessDeniedException":
329+
case "com.amazonaws.rdsdata#AccessDeniedException":
330+
throw await deserializeAws_restJson1AccessDeniedExceptionResponse(parsedOutput, context);
322331
case "BadRequestException":
323332
case "com.amazonaws.rdsdata#BadRequestException":
324333
throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context);
@@ -375,6 +384,9 @@ const deserializeAws_restJson1CommitTransactionCommandError = async (
375384
let errorCode = "UnknownError";
376385
errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
377386
switch (errorCode) {
387+
case "AccessDeniedException":
388+
case "com.amazonaws.rdsdata#AccessDeniedException":
389+
throw await deserializeAws_restJson1AccessDeniedExceptionResponse(parsedOutput, context);
378390
case "BadRequestException":
379391
case "com.amazonaws.rdsdata#BadRequestException":
380392
throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context);
@@ -434,6 +446,9 @@ const deserializeAws_restJson1ExecuteSqlCommandError = async (
434446
let errorCode = "UnknownError";
435447
errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
436448
switch (errorCode) {
449+
case "AccessDeniedException":
450+
case "com.amazonaws.rdsdata#AccessDeniedException":
451+
throw await deserializeAws_restJson1AccessDeniedExceptionResponse(parsedOutput, context);
437452
case "BadRequestException":
438453
case "com.amazonaws.rdsdata#BadRequestException":
439454
throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context);
@@ -467,6 +482,7 @@ export const deserializeAws_restJson1ExecuteStatementCommand = async (
467482
const contents: ExecuteStatementCommandOutput = {
468483
$metadata: deserializeMetadata(output),
469484
columnMetadata: undefined,
485+
formattedRecords: undefined,
470486
generatedFields: undefined,
471487
numberOfRecordsUpdated: undefined,
472488
records: undefined,
@@ -475,6 +491,9 @@ export const deserializeAws_restJson1ExecuteStatementCommand = async (
475491
if (data.columnMetadata !== undefined && data.columnMetadata !== null) {
476492
contents.columnMetadata = deserializeAws_restJson1Metadata(data.columnMetadata, context);
477493
}
494+
if (data.formattedRecords !== undefined && data.formattedRecords !== null) {
495+
contents.formattedRecords = __expectString(data.formattedRecords);
496+
}
478497
if (data.generatedFields !== undefined && data.generatedFields !== null) {
479498
contents.generatedFields = deserializeAws_restJson1FieldList(data.generatedFields, context);
480499
}
@@ -499,6 +518,9 @@ const deserializeAws_restJson1ExecuteStatementCommandError = async (
499518
let errorCode = "UnknownError";
500519
errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
501520
switch (errorCode) {
521+
case "AccessDeniedException":
522+
case "com.amazonaws.rdsdata#AccessDeniedException":
523+
throw await deserializeAws_restJson1AccessDeniedExceptionResponse(parsedOutput, context);
502524
case "BadRequestException":
503525
case "com.amazonaws.rdsdata#BadRequestException":
504526
throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context);
@@ -555,6 +577,9 @@ const deserializeAws_restJson1RollbackTransactionCommandError = async (
555577
let errorCode = "UnknownError";
556578
errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
557579
switch (errorCode) {
580+
case "AccessDeniedException":
581+
case "com.amazonaws.rdsdata#AccessDeniedException":
582+
throw await deserializeAws_restJson1AccessDeniedExceptionResponse(parsedOutput, context);
558583
case "BadRequestException":
559584
case "com.amazonaws.rdsdata#BadRequestException":
560585
throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context);
@@ -584,6 +609,22 @@ const deserializeAws_restJson1RollbackTransactionCommandError = async (
584609
}
585610
};
586611

612+
const deserializeAws_restJson1AccessDeniedExceptionResponse = async (
613+
parsedOutput: any,
614+
context: __SerdeContext
615+
): Promise<AccessDeniedException> => {
616+
const contents: any = {};
617+
const data: any = parsedOutput.body;
618+
if (data.message !== undefined && data.message !== null) {
619+
contents.message = __expectString(data.message);
620+
}
621+
const exception = new AccessDeniedException({
622+
$metadata: deserializeMetadata(parsedOutput),
623+
...contents,
624+
});
625+
return __decorateServiceException(exception, parsedOutput.body);
626+
};
627+
587628
const deserializeAws_restJson1BadRequestExceptionResponse = async (
588629
parsedOutput: any,
589630
context: __SerdeContext
@@ -749,6 +790,8 @@ const serializeAws_restJson1ResultSetOptions = (input: ResultSetOptions, context
749790
return {
750791
...(input.decimalReturnType !== undefined &&
751792
input.decimalReturnType !== null && { decimalReturnType: input.decimalReturnType }),
793+
...(input.longReturnType !== undefined &&
794+
input.longReturnType !== null && { longReturnType: input.longReturnType }),
752795
};
753796
};
754797

0 commit comments

Comments
 (0)