Skip to content

Commit

Permalink
feat(client-neptune-graph): Adding a new option "parameters" for data…
Browse files Browse the repository at this point in the history
… plane api ExecuteQuery to support running parameterized query via SDK.
  • Loading branch information
awstools committed Feb 12, 2024
1 parent d085306 commit 9d13d68
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 13 deletions.
18 changes: 18 additions & 0 deletions clients/client-neptune-graph/src/commands/ExecuteQueryCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ export interface ExecuteQueryCommandOutput extends Omit<ExecuteQueryOutput, "pay
* @public
* <p>Execute an openCypher query. Currently, the SDK does not support parameterized queries. If you want to make a
* parameterized query call, you can use an HTTP request. </p>
* <p>
* When invoking this operation in a Neptune Analytics cluster, the IAM user or role making the request must have a policy attached
* that allows one of the following IAM actions in that cluster, depending on the query:
* </p>
* <ul>
* <li>
* <p>neptune-graph:ReadDataViaQuery</p>
* </li>
* <li>
* <p>neptune-graph:WriteDataViaQuery</p>
* </li>
* <li>
* <p>neptune-graph:DeleteDataViaQuery</p>
* </li>
* </ul>
* <note>
* <p>
* Non-parametrized queries are not considered for plan caching. You can force plan caching with
Expand All @@ -49,6 +64,9 @@ export interface ExecuteQueryCommandOutput extends Omit<ExecuteQueryOutput, "pay
* graphIdentifier: "STRING_VALUE", // required
* queryString: "STRING_VALUE", // required
* language: "OPEN_CYPHER", // required
* parameters: { // DocumentValuedMap
* "<keys>": "DOCUMENT_VALUE",
* },
* planCache: "ENABLED" || "DISABLED" || "AUTO",
* explainMode: "STATIC" || "DETAILS",
* queryTimeoutMilliseconds: Number("int"),
Expand Down
6 changes: 6 additions & 0 deletions clients/client-neptune-graph/src/commands/GetQueryCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ export interface GetQueryCommandOutput extends GetQueryOutput, __MetadataBearer
/**
* @public
* <p>Retrieves the status of a specified query.</p>
* <note>
* <p>
* When invoking this operation in a Neptune Analytics cluster, the IAM user or role making the request must have the
* <code>neptune-graph:GetQueryStatus</code> IAM action attached.
* </p>
* </note>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
Expand Down
18 changes: 12 additions & 6 deletions clients/client-neptune-graph/src/models/models_0.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// smithy-typescript generated code
import { ExceptionOptionType as __ExceptionOptionType } from "@smithy/smithy-client";

import { StreamingBlobTypes } from "@smithy/types";
import { DocumentType as __DocumentType, StreamingBlobTypes } from "@smithy/types";

import { NeptuneGraphServiceException as __BaseException } from "./NeptuneGraphServiceException";

Expand Down Expand Up @@ -256,6 +256,12 @@ export interface ExecuteQueryInput {
*/
language: QueryLanguage | undefined;

/**
* @public
* <p>The data parameters the query can use in JSON format. For example: \{"name": "john", "age": 20\}. (optional) </p>
*/
parameters?: Record<string, __DocumentType>;

/**
* @public
* <p>Query plan cache is a feature that saves the query plan and reuses it on successive executions of the same query.
Expand Down Expand Up @@ -624,7 +630,7 @@ export interface CreateGraphInput {

/**
* @public
* <p>Specifies whether or not the graph can be reachable over the internet. All access to graphs IAM authenticated.
* <p>Specifies whether or not the graph can be reachable over the internet. All access to graphs is IAM authenticated.
* (<code>true</code> to enable, or <code>false</code> to disable.</p>
*/
publicConnectivity?: boolean;
Expand Down Expand Up @@ -738,7 +744,7 @@ export interface CreateGraphOutput {

/**
* @public
* <p>Specifies whether or not the graph can be reachable over the internet. All access to graphs IAM authenticated.</p>
* <p>Specifies whether or not the graph can be reachable over the internet. All access to graphs is IAM authenticated.</p>
*/
publicConnectivity?: boolean;

Expand Down Expand Up @@ -1321,7 +1327,7 @@ export interface RestoreGraphFromSnapshotInput {

/**
* @public
* <p>Specifies whether or not the graph can be reachable over the internet. All access to graphs IAM authenticated.
* <p>Specifies whether or not the graph can be reachable over the internet. All access to graphs is IAM authenticated.
* (<code>true</code> to enable, or <code>false</code> to disable).</p>
*/
publicConnectivity?: boolean;
Expand Down Expand Up @@ -1434,7 +1440,7 @@ export interface UpdateGraphInput {

/**
* @public
* <p>Specifies whether or not the graph can be reachable over the internet. All access to graphs IAM authenticated.
* <p>Specifies whether or not the graph can be reachable over the internet. All access to graphs is IAM authenticated.
* (<code>true</code> to enable, or <code>false</code> to disable.</p>
*/
publicConnectivity?: boolean;
Expand Down Expand Up @@ -2443,7 +2449,7 @@ export interface CreateGraphUsingImportTaskInput {

/**
* @public
* <p>Specifies whether or not the graph can be reachable over the internet. All access to graphs IAM authenticated.
* <p>Specifies whether or not the graph can be reachable over the internet. All access to graphs is IAM authenticated.
* (<code>true</code> to enable, or <code>false</code> to disable).</p>
*/
publicConnectivity?: boolean;
Expand Down
22 changes: 22 additions & 0 deletions clients/client-neptune-graph/src/protocols/Aws_restJson1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
withBaseException,
} from "@smithy/smithy-client";
import {
DocumentType as __DocumentType,
Endpoint as __Endpoint,
ResponseMetadata as __ResponseMetadata,
SdkStreamSerdeContext as __SdkStreamSerdeContext,
Expand Down Expand Up @@ -332,6 +333,7 @@ export const se_ExecuteQueryCommand = async (
take(input, {
explain: [, , `explainMode`],
language: [],
parameters: (_) => se_DocumentValuedMap(_, context),
planCache: [],
query: [, , `queryString`],
queryTimeoutMilliseconds: [],
Expand Down Expand Up @@ -1625,6 +1627,19 @@ const de_ValidationExceptionRes = async (parsedOutput: any, context: __SerdeCont
return __decorateServiceException(exception, parsedOutput.body);
};

/**
* serializeAws_restJson1DocumentValuedMap
*/
const se_DocumentValuedMap = (input: Record<string, __DocumentType>, context: __SerdeContext): any => {
return Object.entries(input).reduce((acc: Record<string, any>, [key, value]: [string, any]) => {
if (value === null) {
return acc;
}
acc[key] = se_Document(value, context);
return acc;
}, {});
};

// se_ImportOptions omitted.

// se_NeptuneImportOptions omitted.
Expand All @@ -1637,6 +1652,13 @@ const de_ValidationExceptionRes = async (parsedOutput: any, context: __SerdeCont

// se_VectorSearchConfiguration omitted.

/**
* serializeAws_restJson1Document
*/
const se_Document = (input: __DocumentType, context: __SerdeContext): any => {
return input;
};

// de_EdgeLabels omitted.

// de_EdgeProperties omitted.
Expand Down
29 changes: 22 additions & 7 deletions codegen/sdk-codegen/aws-models/neptune-graph.json
Original file line number Diff line number Diff line change
Expand Up @@ -1800,7 +1800,7 @@
"publicConnectivity": {
"target": "smithy.api#Boolean",
"traits": {
"smithy.api#documentation": "<p>Specifies whether or not the graph can be reachable over the internet. All access to graphs IAM authenticated.\n (<code>true</code> to enable, or <code>false</code> to disable.</p>"
"smithy.api#documentation": "<p>Specifies whether or not the graph can be reachable over the internet. All access to graphs is IAM authenticated.\n (<code>true</code> to enable, or <code>false</code> to disable.</p>"
}
},
"kmsKeyIdentifier": {
Expand Down Expand Up @@ -1896,7 +1896,7 @@
"publicConnectivity": {
"target": "smithy.api#Boolean",
"traits": {
"smithy.api#documentation": "<p>Specifies whether or not the graph can be reachable over the internet. All access to graphs IAM authenticated.</p>"
"smithy.api#documentation": "<p>Specifies whether or not the graph can be reachable over the internet. All access to graphs is IAM authenticated.</p>"
}
},
"vectorSearchConfiguration": {
Expand Down Expand Up @@ -2123,7 +2123,7 @@
"publicConnectivity": {
"target": "smithy.api#Boolean",
"traits": {
"smithy.api#documentation": "<p>Specifies whether or not the graph can be reachable over the internet. All access to graphs IAM authenticated.\n (<code>true</code> to enable, or <code>false</code> to disable).</p>"
"smithy.api#documentation": "<p>Specifies whether or not the graph can be reachable over the internet. All access to graphs is IAM authenticated.\n (<code>true</code> to enable, or <code>false</code> to disable).</p>"
}
},
"kmsKeyIdentifier": {
Expand Down Expand Up @@ -2735,6 +2735,15 @@
"smithy.api#output": {}
}
},
"com.amazonaws.neptunegraph#DocumentValuedMap": {
"type": "map",
"key": {
"target": "smithy.api#String"
},
"value": {
"target": "smithy.api#Document"
}
},
"com.amazonaws.neptunegraph#EdgeLabels": {
"type": "list",
"member": {
Expand Down Expand Up @@ -2803,7 +2812,7 @@
],
"traits": {
"aws.api#dataPlane": {},
"smithy.api#documentation": "<p>Execute an openCypher query. Currently, the SDK does not support parameterized queries. If you want to make a \n parameterized query call, you can use an HTTP request. </p>\n <note>\n <p>\n Non-parametrized queries are not considered for plan caching. You can force plan caching with \n <code>planCache=enabled</code>. The plan cache will be reused only for the same exact query. Slight variations \n in the query will not be able to reuse the query plan cache.\n </p>\n </note>",
"smithy.api#documentation": "<p>Execute an openCypher query. Currently, the SDK does not support parameterized queries. If you want to make a \n parameterized query call, you can use an HTTP request. </p>\n <p>\n When invoking this operation in a Neptune Analytics cluster, the IAM user or role making the request must have a policy attached \n that allows one of the following IAM actions in that cluster, depending on the query:\n </p>\n <ul>\n <li>\n <p>neptune-graph:ReadDataViaQuery</p>\n </li>\n <li>\n <p>neptune-graph:WriteDataViaQuery</p>\n </li>\n <li>\n <p>neptune-graph:DeleteDataViaQuery</p>\n </li>\n </ul>\n <note>\n <p>\n Non-parametrized queries are not considered for plan caching. You can force plan caching with \n <code>planCache=enabled</code>. The plan cache will be reused only for the same exact query. Slight variations \n in the query will not be able to reuse the query plan cache.\n </p>\n </note>",
"smithy.api#endpoint": {
"hostPrefix": "{graphIdentifier}."
},
Expand Down Expand Up @@ -2846,6 +2855,12 @@
"smithy.api#required": {}
}
},
"parameters": {
"target": "com.amazonaws.neptunegraph#DocumentValuedMap",
"traits": {
"smithy.api#documentation": "<p>The data parameters the query can use in JSON format. For example: {\"name\": \"john\", \"age\": 20}. (optional) </p>"
}
},
"planCache": {
"target": "com.amazonaws.neptunegraph#PlanCacheType",
"traits": {
Expand Down Expand Up @@ -3796,7 +3811,7 @@
],
"traits": {
"aws.api#dataPlane": {},
"smithy.api#documentation": "<p>Retrieves the status of a specified query.</p>",
"smithy.api#documentation": "<p>Retrieves the status of a specified query.</p>\n <note>\n <p>\n When invoking this operation in a Neptune Analytics cluster, the IAM user or role making the request must have the \n <code>neptune-graph:GetQueryStatus</code> IAM action attached.\n </p>\n </note>",
"smithy.api#endpoint": {
"hostPrefix": "{graphIdentifier}."
},
Expand Down Expand Up @@ -5587,7 +5602,7 @@
"publicConnectivity": {
"target": "smithy.api#Boolean",
"traits": {
"smithy.api#documentation": "<p>Specifies whether or not the graph can be reachable over the internet. All access to graphs IAM authenticated.\n (<code>true</code> to enable, or <code>false</code> to disable).</p>"
"smithy.api#documentation": "<p>Specifies whether or not the graph can be reachable over the internet. All access to graphs is IAM authenticated.\n (<code>true</code> to enable, or <code>false</code> to disable).</p>"
}
}
},
Expand Down Expand Up @@ -6181,7 +6196,7 @@
"publicConnectivity": {
"target": "smithy.api#Boolean",
"traits": {
"smithy.api#documentation": "<p>Specifies whether or not the graph can be reachable over the internet. All access to graphs IAM authenticated.\n (<code>true</code> to enable, or <code>false</code> to disable.</p>"
"smithy.api#documentation": "<p>Specifies whether or not the graph can be reachable over the internet. All access to graphs is IAM authenticated.\n (<code>true</code> to enable, or <code>false</code> to disable.</p>"
}
},
"provisionedMemory": {
Expand Down

0 comments on commit 9d13d68

Please sign in to comment.