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)