Retrieve

async AsyncCogniteClient.data_modeling.files.retrieve(
node_ids: NodeId | tuple[str, str] | Sequence[NodeId] | Sequence[tuple[str, str]],
*,
source: View | ViewId | tuple[str, str, str] = ViewId(space='cdf_cdm', external_id='CogniteFile', version='v1'),
) Node | NodeList[Node] | None

Retrieve one or more files by instance ID.

Only nodes that are files (i.e. have data in the CogniteFile view) will be returned. If a single instance ID is requested and it is not found, None is returned.

Parameters:
  • node_ids (NodeId | tuple[str, str] | Sequence[NodeId] | Sequence[tuple[str, str]]) – Single instance ID or a list of instance IDs.

  • source (View | ViewId | tuple[str, str, str]) – The view to fetch properties from. Defaults to CogniteFile.

Returns:

A single Node (or None if not found) when given a single identifier, or a NodeList when given a sequence.

Return type:

Node | NodeList[Node] | None

Examples

Retrieve a single file by instance ID:

>>> from cognite.client import CogniteClient
>>> from cognite.client.data_classes.data_modeling import NodeId
>>> client = CogniteClient()
>>> res = client.data_modeling.files.retrieve(NodeId("my-space", "my-file"))

Using a tuple shorthand:

>>> res = client.data_modeling.files.retrieve(("my-space", "my-file"))

Retrieve multiple file nodes:

>>> res = client.data_modeling.files.retrieve(
...     [("my-space", "file-1"), ("my-space", "file-2")]
... )

Fetch properties from a custom view (note, only files will be returned):

>>> from cognite.client.data_classes.data_modeling import ViewId
>>> res = client.data_modeling.files.retrieve(
...     NodeId("my-space", "my-file"),
...     source=ViewId("my-space", "MyFileExtension", "v1"),
... )