Skip to content

get_sparql_stream

get_sparql_stream(
    *,
    config_overrides: Optional[neptunedataClientConfig] = None,
    limit: Optional[int] = None,
    iterator_type: Optional[IteratorType] = None,
    commit_num: Optional[int] = None,
    op_num: Optional[int] = None,
    encoding: Optional[Encoding] = None,
) -> GetSparqlStreamOutput

Gets a stream for an RDF graph.

With the Neptune Streams feature, you can generate a complete sequence of change-log entries that record every change made to your graph data as it happens. GetSparqlStream lets you collect these change-log entries for an RDF graph.

The Neptune streams feature needs to be enabled on your Neptune DBcluster. To enable streams, set the neptune_streams DB cluster parameter to 1.

See Capturing graph changes in real time using Neptune streams.

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 allows the neptune-db:GetStreamRecords IAM action in that cluster.

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

Parameters:

  • limit (Optional[int], default: None ) –

    Specifies the maximum number of records to return. There is also a size limit of 10 MB on the response that can't be modified and that takes precedence over the number of records specified in the limit parameter. The response does include a threshold-breaching record if the 10 MB limit was reached.

    The range for limit is 1 to 100,000, with a default of 10.

  • iterator_type (Optional[IteratorType], default: None ) –

    Can be one of:

    • AT_SEQUENCE_NUMBER - Indicates that reading should start from the event sequence number specified jointly by the commitNum and opNum parameters.

    • AFTER_SEQUENCE_NUMBER - Indicates that reading should start right after the event sequence number specified jointly by the commitNum and opNum parameters.

    • TRIM_HORIZON - Indicates that reading should start at the last untrimmed record in the system, which is the oldest unexpired (not yet deleted) record in the change-log stream.

    • LATEST - Indicates that reading should start at the most recent record in the system, which is the latest unexpired (not yet deleted) record in the change-log stream.

  • commit_num (Optional[int], default: None ) –

    The commit number of the starting record to read from the change-log stream. This parameter is required when iteratorType isAT_SEQUENCE_NUMBER or AFTER_SEQUENCE_NUMBER, and ignored when iteratorType is TRIM_HORIZON or LATEST.

  • op_num (Optional[int], default: None ) –

    The operation sequence number within the specified commit to start reading from in the change-log stream data. The default is 1.

  • encoding (Optional[Encoding], default: None ) –

    If set to TRUE, Neptune compresses the response using gzip encoding.

Raises:

Source code in docs_src/capo_neptunedata/_services/neptunedata.py
def get_sparql_stream(
    self,
    *,
    config_overrides: Optional[neptunedataClientConfig] = None,
    limit: Optional[int] = None,
    iterator_type: Optional[
        "capo_neptunedata.types.iterator_type.IteratorType"
    ] = None,
    commit_num: Optional[int] = None,
    op_num: Optional[int] = None,
    encoding: Optional["capo_neptunedata.types.encoding.Encoding"] = None,
) -> "capo_neptunedata.types.get_sparql_stream_output.GetSparqlStreamOutput":
    """<p>Gets a stream for an RDF graph.</p> <p>With the Neptune Streams feature, you can generate a complete sequence of change-log entries that record every change made to your graph data as it happens. <code>GetSparqlStream</code> lets you collect these change-log entries for an RDF graph.</p> <p>The Neptune streams feature needs to be enabled on your Neptune DBcluster. To enable streams, set the <a href="https://docs.aws.amazon.com/neptune/latest/userguide/parameters.html#parameters-db-cluster-parameters-neptune_streams">neptune_streams</a> DB cluster parameter to <code>1</code>.</p> <p>See <a href="https://docs.aws.amazon.com/neptune/latest/userguide/streams.html">Capturing graph changes in real time using Neptune streams</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 allows the <a href="https://docs.aws.amazon.com/neptune/latest/userguide/iam-dp-actions.html#getstreamrecords">neptune-db:GetStreamRecords</a> IAM action in that cluster.</p> <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:Sparql</a> IAM condition key can be used in the policy document to restrict the use of SPARQL 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:
        limit: <p>Specifies the maximum number of records to return. There is also a size limit of 10 MB on the response that can't be modified and that takes precedence over the number of records specified in the <code>limit</code> parameter. The response does include a threshold-breaching record if the 10 MB limit was reached.</p> <p>The range for <code>limit</code> is 1 to 100,000, with a default of 10.</p>
        iterator_type: <p>Can be one of:</p> <ul> <li> <p> <code>AT_SEQUENCE_NUMBER</code> - Indicates that reading should start from the event sequence number specified jointly by the <code>commitNum</code> and <code>opNum</code> parameters.</p> </li> <li> <p> <code>AFTER_SEQUENCE_NUMBER</code> - Indicates that reading should start right after the event sequence number specified jointly by the <code>commitNum</code> and <code>opNum</code> parameters.</p> </li> <li> <p> <code>TRIM_HORIZON</code> - Indicates that reading should start at the last untrimmed record in the system, which is the oldest unexpired (not yet deleted) record in the change-log stream.</p> </li> <li> <p> <code>LATEST</code> - Indicates that reading should start at the most recent record in the system, which is the latest unexpired (not yet deleted) record in the change-log stream.</p> </li> </ul>
        commit_num: <p>The commit number of the starting record to read from the change-log stream. This parameter is required when <code>iteratorType</code> is<code>AT_SEQUENCE_NUMBER</code> or <code>AFTER_SEQUENCE_NUMBER</code>, and ignored when <code>iteratorType</code> is <code>TRIM_HORIZON</code> or <code>LATEST</code>.</p>
        op_num: <p>The operation sequence number within the specified commit to start reading from in the change-log stream data. The default is <code>1</code>.</p>
        encoding: <p>If set to TRUE, Neptune compresses the response using gzip encoding.</p>

    Raises:
        capo_neptunedata.errors.client_timeout_exception.ClientTimeoutException: <p>Raised when a request timed out in the client.</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.expired_stream_exception.ExpiredStreamException: <p>Raised when a request attempts to access an stream that has expired.</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.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.preconditions_failed_exception.PreconditionsFailedException: <p>Raised when a precondition for processing a request is not satisfied.</p>
        capo_neptunedata.errors.stream_records_not_found_exception.StreamRecordsNotFoundException: <p>Raised when stream records requested by a query cannot be found.</p>
        capo_neptunedata.errors.throttling_exception.ThrottlingException: <p>Raised when the rate of requests exceeds the maximum throughput. Requests can be retried after encountering this exception.</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.
    """

    def _handler(
        req: "OperationRequest[capo_neptunedata.types.get_sparql_stream_input.GetSparqlStreamInput]",
    ) -> OperationResponse[
        "capo_neptunedata.types.get_sparql_stream_output.GetSparqlStreamOutput"
    ]:
        import capo_neptunedata._operations.amazon_neptune_dataplane.get_sparql_stream

        output, http_response = (
            capo_neptunedata._operations.amazon_neptune_dataplane.get_sparql_stream.get_sparql_stream(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetSparqlStream")
    )
    input_: capo_neptunedata.types.get_sparql_stream_input.GetSparqlStreamInput = {}
    if limit is not None:
        input_["limit"] = limit
    if iterator_type is not None:
        input_["iterator_type"] = iterator_type
    if commit_num is not None:
        input_["commit_num"] = commit_num
    if op_num is not None:
        input_["op_num"] = op_num
    if encoding is not None:
        input_["encoding"] = encoding

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output