for batch in client.time_series.subscriptions.iterate_data("my_subscription"):
# Changes to the subscription itself:
print(f"Added {len(batch.subscription_changes.added)} timeseries")
print(f"Removed {len(batch.subscription_changes.removed)} timeseries")
print(f"Changed timeseries data in {len(batch.updates)} updates")
# Changes to datapoints for time series in the subscription:
for update in batch.updates:
upserts.time_series # The time series the update belongs to
upserts.upserts # The upserted datapoints, if any
upserts.deletes # Ranges of deleted periods, if any
if not batch.has_next:
break
for batch in client.time_series.subscriptions.iterate_data("my_subscription", "3d-ago"):
pass # do something{
"updates": [
{
"timeSeries": {
"id": 4503599627370496,
"isString": true,
"type": "<string>",
"externalId": "my.known.id",
"instanceId": {
"space": "<string>",
"externalId": "<string>"
}
},
"upserts": [
{
"timestamp": 946727999999.5,
"value": 123,
"status": {
"code": 123,
"symbol": "<string>"
}
}
],
"deletes": [
{
"inclusiveBegin": 1638795554528,
"exclusiveEnd": 1638795554528
}
]
}
],
"partitions": [
{
"index": 123,
"nextCursor": "<string>"
}
],
"hasNext": true,
"subscriptionChanges": {
"added": [
{
"id": 4503599627370496,
"isString": true,
"type": "<string>",
"externalId": "my.known.id",
"instanceId": {
"space": "<string>",
"externalId": "<string>"
}
}
],
"removed": [
{
"id": 4503599627370496,
"isString": true,
"type": "<string>",
"externalId": "my.known.id",
"instanceId": {
"space": "<string>",
"externalId": "<string>"
}
}
]
}
}Required capabilities:
timeSeriesSubscriptionsAcl:READ
Fetch the next batch of data from a given subscription and partition(s). Data can be ingested datapoints and time ranges where data is deleted. This endpoint will also return changes to the subscription itself, that is, if time series are added or removed from the subscription.
The data can be returned multiple times, there is no mechanism to acknowledge or delete data. Use cursors to paginate through the results.
for batch in client.time_series.subscriptions.iterate_data("my_subscription"):
# Changes to the subscription itself:
print(f"Added {len(batch.subscription_changes.added)} timeseries")
print(f"Removed {len(batch.subscription_changes.removed)} timeseries")
print(f"Changed timeseries data in {len(batch.updates)} updates")
# Changes to datapoints for time series in the subscription:
for update in batch.updates:
upserts.time_series # The time series the update belongs to
upserts.upserts # The upserted datapoints, if any
upserts.deletes # Ranges of deleted periods, if any
if not batch.has_next:
break
for batch in client.time_series.subscriptions.iterate_data("my_subscription", "3d-ago"):
pass # do something{
"updates": [
{
"timeSeries": {
"id": 4503599627370496,
"isString": true,
"type": "<string>",
"externalId": "my.known.id",
"instanceId": {
"space": "<string>",
"externalId": "<string>"
}
},
"upserts": [
{
"timestamp": 946727999999.5,
"value": 123,
"status": {
"code": 123,
"symbol": "<string>"
}
}
],
"deletes": [
{
"inclusiveBegin": 1638795554528,
"exclusiveEnd": 1638795554528
}
]
}
],
"partitions": [
{
"index": 123,
"nextCursor": "<string>"
}
],
"hasNext": true,
"subscriptionChanges": {
"added": [
{
"id": 4503599627370496,
"isString": true,
"type": "<string>",
"externalId": "my.known.id",
"instanceId": {
"space": "<string>",
"externalId": "<string>"
}
}
],
"removed": [
{
"id": 4503599627370496,
"isString": true,
"type": "<string>",
"externalId": "my.known.id",
"instanceId": {
"space": "<string>",
"externalId": "<string>"
}
}
]
}
}Access token issued by the CDF project's configured identity provider. Access token must be an OpenID Connect token, and the project must be configured to accept OpenID Connect tokens. Use a header key of 'Authorization' with a value of 'Bearer $accesstoken'. The token can be obtained through any flow supported by the identity provider.
Pairs of (partition, cursor) to fetch from.
Show child attributes
The external ID provided by the client. Must be unique for the resource type.
255"my.known.id"
Approximate number of results to return across all partitions. We will batch together groups of updates, where each group come from the same ingestion request. Thus, if a single group is large, it may exceed limit, otherwise we will return up to limit results. To check whether you have reached the end, do not rely on the count. Instead, check the hasNext field.
1 <= x <= 100000If partitions.cursor is not set, the default behaviour is to start from the beginning of the stream.
initializeCursors can be used to override this behaviour.
The format is "N[timeunit]-ago", where timeunit is w,d,h,m (week, day, hour, minute). For instance, "2d-ago" will give a stream of changes ingested up to 2 days ago. You can also use "now" to jump straight to the end of the stream.
Note that initializeCursors is not exact; a deviation of some seconds can occur.
The maximum time to wait for data to arrive, in seconds. As soon as data is available, the request will return immediately with the data. If the timeout is reached while waiting for data, the request will return an empty data response.
0 <= x <= 5Show the status code for each data point in the response. Good (code = 0) status codes are always omitted.
Treat data points with a Bad status code as if they do not exist. Set to false to include all data points.
Treat data points with Uncertain status codes as Bad. Set to false to include uncertain data points.
A batch of data from the subscription.
Subscription data along with cursors.
List of updates from the subscription, sorted by point in time they were applied to the time series. Every update contains a time series along with a set of changes to that time series.
Show child attributes
List of partition/cursor pairs to use for the next request.
Show child attributes
Whether there is more data available at the time of the query. In rare cases, we may return true, even if there is no data available. If that is the case, just continue to query with the updated cursors, and it will eventually return false.
If present, this object represents changes to the subscription definition. The subscription will now start/stop listening to changes from the time series listed here.
These changes can be triggered by explicit changes through the Update subscriptions endpoint, or they can be caused by changes in time series, in that they start/stop matching the filter for the subscription.
Time series are added to these lists when the change takes effect, which may be later than the actual trigger.
The object is partitioned - it will only be present in the response for the relevant partition, from which the time series was added/removed.
Show child attributes
Was this page helpful?