Skip to content

execute_gremlin_query async

execute_gremlin_query(
    gremlin_query: str,
    *,
    config_overrides: Optional[AsyncneptunedataClientConfig] = None,
    serializer: Optional[str] = None,
) -> ExecuteGremlinQueryOutput

This commands executes a Gremlin query. Amazon Neptune is compatible with Apache TinkerPop3 and Gremlin, so you can use the Gremlin traversal language to query the graph, as described under The Graph in the Apache TinkerPop3 documentation. More details can also be found in Accessing a Neptune graph with Gremlin.

When invoking this operation in a Neptune cluster that has IAM authentication enabled, the IAM user or role making the request must have a policy attached that enables one of the following IAM actions in that cluster, depending on the query:

Note that the neptune-db:QueryLanguage:Gremlin IAM condition key can be used in the policy document to restrict the use of Gremlin queries (see Condition keys available in Neptune IAM data-access policy statements).

Parameters:

  • gremlin_query (str) –

    Using this API, you can run Gremlin queries in string format much as you can using the HTTP endpoint. The interface is compatible with whatever Gremlin version your DB cluster is using (see the Tinkerpop client section to determine which Gremlin releases your engine version supports).

  • serializer (Optional[str], default: None ) –

    If non-null, the query results are returned in a serialized response message in the format specified by this parameter. See the GraphSON section in the TinkerPop documentation for a list of the formats that are currently supported.

Raises:

Source code in docs_src/capo_neptunedata/_services/async_neptunedata.py
async def execute_gremlin_query(
    self,
    gremlin_query: str,
    *,
    config_overrides: Optional[AsyncneptunedataClientConfig] = None,
    serializer: Optional[str] = None,
) -> (
    "capo_neptunedata.types.execute_gremlin_query_output.ExecuteGremlinQueryOutput"
):
    """<p>This commands executes a Gremlin query. Amazon Neptune is compatible with Apache TinkerPop3 and Gremlin, so you can use the Gremlin traversal language to query the graph, as described under <a href="https://tinkerpop.apache.org/docs/current/reference/#graph">The Graph</a> in the Apache TinkerPop3 documentation. More details can also be found in <a href="https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-gremlin.html">Accessing a Neptune graph with Gremlin</a>.</p> <p>When invoking this operation in a Neptune cluster that has IAM authentication enabled, the IAM user or role making the request must have a policy attached that enables one of the following IAM actions in that cluster, depending on the query:</p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/neptune/latest/userguide/iam-dp-actions.html#readdataviaquery">neptune-db:ReadDataViaQuery</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/neptune/latest/userguide/iam-dp-actions.html#writedataviaquery">neptune-db:WriteDataViaQuery</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/neptune/latest/userguide/iam-dp-actions.html#deletedataviaquery">neptune-db:DeleteDataViaQuery</a> </p> </li> </ul> <p>Note that the <a href="https://docs.aws.amazon.com/neptune/latest/userguide/iam-data-condition-keys.html#iam-neptune-condition-keys">neptune-db:QueryLanguage:Gremlin</a> IAM condition key can be used in the policy document to restrict the use of Gremlin queries (see <a href="https://docs.aws.amazon.com/neptune/latest/userguide/iam-data-condition-keys.html">Condition keys available in Neptune IAM data-access policy statements</a>).</p>

    Args:
        gremlin_query: <p>Using this API, you can run Gremlin queries in string format much as you can using the HTTP endpoint. The interface is compatible with whatever Gremlin version your DB cluster is using (see the <a href="https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-gremlin-client.html#best-practices-gremlin-java-latest">Tinkerpop client section</a> to determine which Gremlin releases your engine version supports).</p>
        serializer: <p>If non-null, the query results are returned in a serialized response message in the format specified by this parameter. See the <a href="https://tinkerpop.apache.org/docs/current/reference/#_graphson">GraphSON</a> section in the TinkerPop documentation for a list of the formats that are currently supported.</p>

    Raises:
        capo_neptunedata.errors.bad_request_exception.BadRequestException: <p>Raised when a request is submitted that cannot be processed.</p>
        capo_neptunedata.errors.cancelled_by_user_exception.CancelledByUserException: <p>Raised when a user cancelled a request.</p>
        capo_neptunedata.errors.client_timeout_exception.ClientTimeoutException: <p>Raised when a request timed out in the client.</p>
        capo_neptunedata.errors.concurrent_modification_exception.ConcurrentModificationException: <p>Raised when a request attempts to modify data that is concurrently being modified by another process.</p>
        capo_neptunedata.errors.constraint_violation_exception.ConstraintViolationException: <p>Raised when a value in a request field did not satisfy required constraints.</p>
        capo_neptunedata.errors.failure_by_query_exception.FailureByQueryException: <p>Raised when a request fails.</p>
        capo_neptunedata.errors.illegal_argument_exception.IllegalArgumentException: <p>Raised when an argument in a request is not supported.</p>
        capo_neptunedata.errors.invalid_argument_exception.InvalidArgumentException: <p>Raised when an argument in a request has an invalid value.</p>
        capo_neptunedata.errors.invalid_parameter_exception.InvalidParameterException: <p>Raised when a parameter value is not valid.</p>
        capo_neptunedata.errors.malformed_query_exception.MalformedQueryException: <p>Raised when a query is submitted that is syntactically incorrect or does not pass additional validation.</p>
        capo_neptunedata.errors.memory_limit_exceeded_exception.MemoryLimitExceededException: <p>Raised when a request fails because of insufficient memory resources. The request can be retried.</p>
        capo_neptunedata.errors.missing_parameter_exception.MissingParameterException: <p>Raised when a required parameter is missing.</p>
        capo_neptunedata.errors.parsing_exception.ParsingException: <p>Raised when a parsing issue is encountered.</p>
        capo_neptunedata.errors.preconditions_failed_exception.PreconditionsFailedException: <p>Raised when a precondition for processing a request is not satisfied.</p>
        capo_neptunedata.errors.query_limit_exceeded_exception.QueryLimitExceededException: <p>Raised when the number of active queries exceeds what the server can process. The query in question can be retried when the system is less busy.</p>
        capo_neptunedata.errors.query_limit_exception.QueryLimitException: <p>Raised when the size of a query exceeds the system limit.</p>
        capo_neptunedata.errors.query_too_large_exception.QueryTooLargeException: <p>Raised when the body of a query is too large.</p>
        capo_neptunedata.errors.time_limit_exceeded_exception.TimeLimitExceededException: <p>Raised when the an operation exceeds the time limit allowed for it.</p>
        capo_neptunedata.errors.too_many_requests_exception.TooManyRequestsException: <p>Raised when the number of requests being processed exceeds the limit.</p>
        capo_neptunedata.errors.unsupported_operation_exception.UnsupportedOperationException: <p>Raised when a request attempts to initiate an operation that is not supported.</p>
        capo_neptunedata.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_neptunedata.types.execute_gremlin_query_input.ExecuteGremlinQueryInput]",
    ) -> AsyncOperationResponse[
        "capo_neptunedata.types.execute_gremlin_query_output.ExecuteGremlinQueryOutput"
    ]:
        import capo_neptunedata._operations.amazon_neptune_dataplane.execute_gremlin_query

        (
            output,
            http_response,
        ) = await capo_neptunedata._operations.amazon_neptune_dataplane.execute_gremlin_query.async_execute_gremlin_query(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ExecuteGremlinQuery")
    )
    input_: capo_neptunedata.types.execute_gremlin_query_input.ExecuteGremlinQueryInput = {
        "gremlin_query": gremlin_query
    }
    if serializer is not None:
        input_["serializer"] = serializer

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output