Amazon Neptune Graph

2024/02/01 - Amazon Neptune Graph - 5 new api methods

Changes  Adding new APIs in SDK for Amazon Neptune Analytics. These APIs include operations to execute, cancel, list queries and get the graph summary.

CancelQuery (new) Link ¶

Cancels a specified query.

See also: AWS API Documentation

Request Syntax

client.cancel_query(
    graphIdentifier='string',
    queryId='string'
)
type graphIdentifier:

string

param graphIdentifier:

[REQUIRED]

The unique identifier of the Neptune Analytics graph.

type queryId:

string

param queryId:

[REQUIRED]

The unique identifier of the query to cancel.

returns:

None

GetGraphSummary (new) Link ¶

Gets a graph summary for a property graph.

See also: AWS API Documentation

Request Syntax

client.get_graph_summary(
    graphIdentifier='string',
    mode='BASIC'|'DETAILED'
)
type graphIdentifier:

string

param graphIdentifier:

[REQUIRED]

The unique identifier of the Neptune Analytics graph.

type mode:

string

param mode:

The summary mode can take one of two values: basic (the default), and detailed.

rtype:

dict

returns:

Response Syntax

{
    'version': 'string',
    'lastStatisticsComputationTime': datetime(2015, 1, 1),
    'graphSummary': {
        'numNodes': 123,
        'numEdges': 123,
        'numNodeLabels': 123,
        'numEdgeLabels': 123,
        'nodeLabels': [
            'string',
        ],
        'edgeLabels': [
            'string',
        ],
        'numNodeProperties': 123,
        'numEdgeProperties': 123,
        'nodeProperties': [
            {
                'string': 123
            },
        ],
        'edgeProperties': [
            {
                'string': 123
            },
        ],
        'totalNodePropertyValues': 123,
        'totalEdgePropertyValues': 123,
        'nodeStructures': [
            {
                'count': 123,
                'nodeProperties': [
                    'string',
                ],
                'distinctOutgoingEdgeLabels': [
                    'string',
                ]
            },
        ],
        'edgeStructures': [
            {
                'count': 123,
                'edgeProperties': [
                    'string',
                ]
            },
        ]
    }
}

Response Structure

  • (dict) --

    • version (string) --

      Display the version of this tool.

    • lastStatisticsComputationTime (datetime) --

      The timestamp, in ISO 8601 format, of the time at which Neptune Analytics last computed statistics.

    • graphSummary (dict) --

      The graph summary.

      • numNodes (integer) --

        The number of nodes in the graph.

      • numEdges (integer) --

        The number of edges in the graph.

      • numNodeLabels (integer) --

        The number of distinct node labels in the graph.

      • numEdgeLabels (integer) --

        The number of unique edge labels in the graph.

      • nodeLabels (list) --

        A list of distinct node labels in the graph.

        • (string) --

      • edgeLabels (list) --

        A list of the edge labels in the graph.

        • (string) --

      • numNodeProperties (integer) --

        The number of distinct node properties in the graph.

      • numEdgeProperties (integer) --

        The number of edge properties in the graph.

      • nodeProperties (list) --

        A list of the distinct node properties in the graph, along with the count of nodes where each property is used.

        • (dict) --

          • (string) --

            • (integer) --

      • edgeProperties (list) --

        A list of the distinct edge properties in the graph, along with the count of edges where each property is used.

        • (dict) --

          • (string) --

            • (integer) --

      • totalNodePropertyValues (integer) --

        The total number of usages of all node properties.

      • totalEdgePropertyValues (integer) --

        The total number of usages of all edge properties.

      • nodeStructures (list) --

        This field is only present when the requested mode is DETAILED. It contains a list of node structures.

        • (dict) --

          Information about a node.

          • count (integer) --

            The number of instances of this node.

          • nodeProperties (list) --

            Properties associated with this node.

            • (string) --

          • distinctOutgoingEdgeLabels (list) --

            The outgoing edge labels associated with this node.

            • (string) --

      • edgeStructures (list) --

        This field is only present when the requested mode is DETAILED. It contains a list of edge structures.

        • (dict) --

          Contains information about an edge in a Neptune Analytics graph.

          • count (integer) --

            The number of instances of the edge in the graph.

          • edgeProperties (list) --

            A list of the properties associated with the edge.

            • (string) --

GetQuery (new) Link ¶

Retrieves the status of a specified query.

See also: AWS API Documentation

Request Syntax

client.get_query(
    graphIdentifier='string',
    queryId='string'
)
type graphIdentifier:

string

param graphIdentifier:

[REQUIRED]

The unique identifier of the Neptune Analytics graph.

type queryId:

string

param queryId:

[REQUIRED]

The ID of the query in question.

rtype:

dict

returns:

Response Syntax

{
    'id': 'string',
    'queryString': 'string',
    'waited': 123,
    'elapsed': 123,
    'state': 'RUNNING'|'WAITING'|'CANCELLING'
}

Response Structure

  • (dict) --

    • id (string) --

      The ID of the query in question.

    • queryString (string) --

      The query in question.

    • waited (integer) --

      Indicates how long the query waited, in milliseconds.

    • elapsed (integer) --

      The number of milliseconds the query has been running.

    • state (string) --

      State of the query.

ExecuteQuery (new) Link ¶

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.

See also: AWS API Documentation

Request Syntax

client.execute_query(
    graphIdentifier='string',
    queryString='string',
    language='OPEN_CYPHER',
    planCache='ENABLED'|'DISABLED'|'AUTO',
    explainMode='STATIC'|'DETAILS',
    queryTimeoutMilliseconds=123
)
type graphIdentifier:

string

param graphIdentifier:

[REQUIRED]

The unique identifier of the Neptune Analytics graph.

type queryString:

string

param queryString:

[REQUIRED]

The query string to be executed.

type language:

string

param language:

[REQUIRED]

The query language the query is written in. Currently only openCypher is supported.

type planCache:

string

param planCache:

Query plan cache is a feature that saves the query plan and reuses it on successive executions of the same query. This reduces query latency, and works for both READ and UPDATE queries. The plan cache is an LRU cache with a 5 minute TTL and a capacity of 1000.

type explainMode:

string

param explainMode:

The explain mode parameter returns a query explain instead of the actual query results. A query explain can be used to gather insights about the query execution such as planning decisions, time spent on each operator, solutions flowing etc.

type queryTimeoutMilliseconds:

integer

param queryTimeoutMilliseconds:

Specifies the query timeout duration, in milliseconds. (optional)

rtype:

dict

returns:

Response Syntax

{
    'payload': StreamingBody()
}

Response Structure

  • (dict) --

    • payload (:class:`.StreamingBody`) --

      The query results.

ListQueries (new) Link ¶

Lists active openCypher queries.

See also: AWS API Documentation

Request Syntax

client.list_queries(
    graphIdentifier='string',
    maxResults=123,
    state='ALL'|'RUNNING'|'WAITING'|'CANCELLING'
)
type graphIdentifier:

string

param graphIdentifier:

[REQUIRED]

The unique identifier of the Neptune Analytics graph.

type maxResults:

integer

param maxResults:

[REQUIRED]

The maximum number of results to be fetched by the API.

type state:

string

param state:

Filtered list of queries based on state.

rtype:

dict

returns:

Response Syntax

{
    'queries': [
        {
            'id': 'string',
            'queryString': 'string',
            'waited': 123,
            'elapsed': 123,
            'state': 'RUNNING'|'WAITING'|'CANCELLING'
        },
    ]
}

Response Structure

  • (dict) --

    • queries (list) --

      A list of current openCypher queries.

      • (dict) --

        Details of the query listed.

        • id (string) --

          A string representation of the id of the query.

        • queryString (string) --

          The actual query text. The queryString may be truncated if the actual query string is too long.

        • waited (integer) --

          The amount of time, in milliseconds, the query has waited in the queue before being picked up by a worker thread.

        • elapsed (integer) --

          The running time of the query, in milliseconds.

        • state (string) --

          State of the query.