res = client.data_modeling.instances.retrieve(
nodes=("mySpace", "myNodeExternalId"),
edges=("mySpace", "myEdgeExternalId"),
sources=("mySpace", "myViewExternalId", "myViewVersion"))
from cognite.client.data_classes.data_modeling import NodeId, EdgeId, ViewId
res = client.data_modeling.instances.retrieve(
NodeId("mySpace", "myNode"),
EdgeId("mySpace", "myEdge"),
ViewId("mySpace", "myViewExternalId", "myViewVersion"))
from cognite.client.data_classes.data_modeling import NodeId, EdgeId
res = client.data_modeling.instances.retrieve(
NodeId("mySpace", "myNode"),
EdgeId("mySpace", "myEdge"),
sources=("myspace", "myView"))
from cognite.client.data_classes.data_modeling import EdgeId, TypedEdge, PropertyOptions, DirectRelationReference, ViewId
class Flow(TypedEdge):
flow_rate = PropertyOptions(identifier="flowRate")
def __init__(
self,
space: str,
external_id: str,
version: int,
type: DirectRelationReference,
last_updated_time: int,
created_time: int,
flow_rate: float,
start_node: DirectRelationReference,
end_node: DirectRelationReference,
deleted_time: int | None = None,
) -> None:
super().__init__(
space, external_id, version, type, last_updated_time, created_time, start_node, end_node, deleted_time
)
self.flow_rate = flow_rate
@classmethod
def get_source(cls) -> ViewId:
return ViewId("sp_model_space", "flow", "1")
res = client.data_modeling.instances.retrieve_edges(
EdgeId("mySpace", "theFlow"), edge_cls=Flow
)
isinstance(res, Flow)
from cognite.client.data_classes.data_modeling import NodeId, TypedNode, PropertyOptions, DirectRelationReference, ViewId
class Person(TypedNode):
birth_year = PropertyOptions(identifier="birthYear")
def __init__(
self,
space: str,
external_id: str,
version: int,
last_updated_time: int,
created_time: int,
name: str,
birth_year: int | None = None,
type: DirectRelationReference | None = None,
deleted_time: int | None = None,
):
super().__init__(
space=space,
external_id=external_id,
version=version,
last_updated_time=last_updated_time,
created_time=created_time,
type=type,
deleted_time=deleted_time
)
self.name = name
self.birth_year = birth_year
@classmethod
def get_source(cls) -> ViewId:
return ViewId("myModelSpace", "Person", "1")
res = client.data_modeling.instances.retrieve_nodes(
NodeId("myDataSpace", "myPerson"), node_cls=Person
)
isinstance(res, Person){
"items": [
{
"instanceType": "node",
"version": 123,
"space": "<string>",
"externalId": "<string>",
"createdTime": 1730204346000,
"lastUpdatedTime": 1730204346000,
"type": {
"space": "<string>",
"externalId": "<string>"
},
"deletedTime": 1730204346000,
"properties": {}
}
],
"typing": {}
}Required capabilities:
DataModelsAcl:READ
Retrieve up to 1000 nodes or edges by their external ids.
res = client.data_modeling.instances.retrieve(
nodes=("mySpace", "myNodeExternalId"),
edges=("mySpace", "myEdgeExternalId"),
sources=("mySpace", "myViewExternalId", "myViewVersion"))
from cognite.client.data_classes.data_modeling import NodeId, EdgeId, ViewId
res = client.data_modeling.instances.retrieve(
NodeId("mySpace", "myNode"),
EdgeId("mySpace", "myEdge"),
ViewId("mySpace", "myViewExternalId", "myViewVersion"))
from cognite.client.data_classes.data_modeling import NodeId, EdgeId
res = client.data_modeling.instances.retrieve(
NodeId("mySpace", "myNode"),
EdgeId("mySpace", "myEdge"),
sources=("myspace", "myView"))
from cognite.client.data_classes.data_modeling import EdgeId, TypedEdge, PropertyOptions, DirectRelationReference, ViewId
class Flow(TypedEdge):
flow_rate = PropertyOptions(identifier="flowRate")
def __init__(
self,
space: str,
external_id: str,
version: int,
type: DirectRelationReference,
last_updated_time: int,
created_time: int,
flow_rate: float,
start_node: DirectRelationReference,
end_node: DirectRelationReference,
deleted_time: int | None = None,
) -> None:
super().__init__(
space, external_id, version, type, last_updated_time, created_time, start_node, end_node, deleted_time
)
self.flow_rate = flow_rate
@classmethod
def get_source(cls) -> ViewId:
return ViewId("sp_model_space", "flow", "1")
res = client.data_modeling.instances.retrieve_edges(
EdgeId("mySpace", "theFlow"), edge_cls=Flow
)
isinstance(res, Flow)
from cognite.client.data_classes.data_modeling import NodeId, TypedNode, PropertyOptions, DirectRelationReference, ViewId
class Person(TypedNode):
birth_year = PropertyOptions(identifier="birthYear")
def __init__(
self,
space: str,
external_id: str,
version: int,
last_updated_time: int,
created_time: int,
name: str,
birth_year: int | None = None,
type: DirectRelationReference | None = None,
deleted_time: int | None = None,
):
super().__init__(
space=space,
external_id=external_id,
version=version,
last_updated_time=last_updated_time,
created_time=created_time,
type=type,
deleted_time=deleted_time
)
self.name = name
self.birth_year = birth_year
@classmethod
def get_source(cls) -> ViewId:
return ViewId("myModelSpace", "Person", "1")
res = client.data_modeling.instances.retrieve_nodes(
NodeId("myDataSpace", "myPerson"), node_cls=Person
)
isinstance(res, Person){
"items": [
{
"instanceType": "node",
"version": 123,
"space": "<string>",
"externalId": "<string>",
"createdTime": 1730204346000,
"lastUpdatedTime": 1730204346000,
"type": {
"space": "<string>",
"externalId": "<string>"
},
"deletedTime": 1730204346000,
"properties": {}
}
],
"typing": {}
}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.
List of external-ids for nodes or edges to retrieve. Properties for up to 10 unique views (in total across the external ids requested) can be retrieved in one query.
1 - 1000 elementsShow child attributes
The node/edge must have data in all the sources defined in the list
10Show child attributes
Should we return property type information as part of the result?
Was this page helpful?