from cognite.client.data_classes.data_modeling.instances import InstanceSort
from cognite.client.data_classes.data_modeling.query import Query, Select, NodeResultSetExpression, EdgeResultSetExpression, SourceSelector
from cognite.client.data_classes.filters import Range, Equals
from cognite.client.data_classes.data_modeling.ids import ViewId
movie_id = ViewId("mySpace", "MovieView", "v1")
actor_id = ViewId("mySpace", "ActorView", "v1")
query = Query(
with_ = {
"movies": NodeResultSetExpression(filter=Range(movie_id.as_property_ref("releaseYear"), lt=2000)),
"actors_in_movie": EdgeResultSetExpression(from_="movies", filter=Equals(["edge", "type"], {"space": movie_id.space, "externalId": "Movie.actors"})),
"actors": NodeResultSetExpression(from_="actors_in_movie"),
},
select = {
"actors": Select(
[SourceSelector(actor_id, ["name"])], sort=[InstanceSort(actor_id.as_property_ref("name"))]),
},
)
res = client.data_modeling.instances.sync(query)
query.cursors = res.cursors
res_new = client.data_modeling.instances.sync(query)
{
"items": {},
"nextCursor": {},
"typing": {},
"debug": {
"notices": [
{
"code": "excessiveTimeout",
"category": "invalidDebugOptions",
"level": "warning",
"hint": "<string>",
"timeout": 123
}
]
}
}Required capabilities:
DataModelsAcl:READ
Subscribe to changes for nodes and edges in a project, matching a supplied filter. This endpoint will always return a NextCursor. The sync specification mirrors the query interface, but sorting is not currently supported. For more information, see Query language.
from cognite.client.data_classes.data_modeling.instances import InstanceSort
from cognite.client.data_classes.data_modeling.query import Query, Select, NodeResultSetExpression, EdgeResultSetExpression, SourceSelector
from cognite.client.data_classes.filters import Range, Equals
from cognite.client.data_classes.data_modeling.ids import ViewId
movie_id = ViewId("mySpace", "MovieView", "v1")
actor_id = ViewId("mySpace", "ActorView", "v1")
query = Query(
with_ = {
"movies": NodeResultSetExpression(filter=Range(movie_id.as_property_ref("releaseYear"), lt=2000)),
"actors_in_movie": EdgeResultSetExpression(from_="movies", filter=Equals(["edge", "type"], {"space": movie_id.space, "externalId": "Movie.actors"})),
"actors": NodeResultSetExpression(from_="actors_in_movie"),
},
select = {
"actors": Select(
[SourceSelector(actor_id, ["name"])], sort=[InstanceSort(actor_id.as_property_ref("name"))]),
},
)
res = client.data_modeling.instances.sync(query)
query.cursors = res.cursors
res_new = client.data_modeling.instances.sync(query)
{
"items": {},
"nextCursor": {},
"typing": {},
"debug": {
"notices": [
{
"code": "excessiveTimeout",
"category": "invalidDebugOptions",
"level": "warning",
"hint": "<string>",
"timeout": 123
}
]
}
}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.
Change filter specification
Show child attributes
Show child attributes
Cursors returned from the previous sync request. These cursors match the result set expressions you specified in the with clause for the sync.
Show child attributes
Parameters to return
Show child attributes
Should we return property type information as part of the result?
Sync cursors will expire after 3 days. This is because soft-deleted instances are cleaned up after this grace period, so a client using a cursor older than that risks missing deletes. If this option is set to true, the API will allow the use of expired cursors.
Return query debug notices.
Show child attributes
Matching nodes and edges
Was this page helpful?