Records

AsyncCogniteClient.data_modeling.records.delete(...)

Delete records from a stream.

AsyncCogniteClient.data_modeling.records.filter(...)

Filter records in a stream.

AsyncCogniteClient.data_modeling.records.ingest(...)

Ingest records into a stream.

AsyncCogniteClient.data_modeling.records.sync(...)

Sync records from a stream.

AsyncCogniteClient.data_modeling.records.sync_resume(...)

Resume syncing records from a stream using a cursor from sync() or sync_resume().

AsyncCogniteClient.data_modeling.records.upsert(...)

Upsert records into a stream.

Records data classes

class cognite.client.data_classes.data_modeling.records.Record(
space: str,
external_id: str,
created_time: int,
last_updated_time: int,
properties: dict[str, dict[str, dict[str, Any]]] | None = None,
)

Bases: WriteableCogniteResource[RecordWrite]

A record returned from the stream records API.

This is the read version of RecordWrite.

Parameters:
  • space (str) – Space the record belongs to.

  • external_id (str) – External ID of the record.

  • created_time (int) – Creation time in milliseconds since epoch.

  • last_updated_time (int) – Last updated time in milliseconds since epoch.

  • properties (dict[str, dict[str, dict[str, Any]]] | None) – Property values keyed by {space: {container_external_id: {property_id: value}}}.

as_write() RecordWrite

Reconstruct the RecordWrite by grouping read properties back into sources.

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

class cognite.client.data_classes.data_modeling.records.RecordContainerId(*args: Any, **kwargs: Any)

Bases: ContainerId

Container reference used as a source in a record write.

Parameters:
  • space (str) – Space that contains the container.

  • external_id (str) – External ID of the container.

class cognite.client.data_classes.data_modeling.records.RecordId(space: 'str', external_id: 'str')

Bases: InstanceId

class cognite.client.data_classes.data_modeling.records.RecordIdSequence(
identifiers: list[T_Identifier],
is_singleton: bool,
)

Bases: IdentifierSequenceCore[RecordId]

class cognite.client.data_classes.data_modeling.records.RecordList(
resources: Sequence[Record],
typing: TypeInformation | None = None,
)

Bases: WriteableCogniteResourceList[RecordWrite, Record]

A list of Record objects.

Parameters:
  • resources (Sequence[Record]) – The records.

  • typing (TypeInformation | None) – Property type information, present when the request was made with include_typing=True.

class cognite.client.data_classes.data_modeling.records.RecordSource(
source: RecordContainerId,
properties: dict[str, Any],
)

Bases: CogniteResource

Container source with property values for a record write.

Parameters:
  • source (RecordContainerId) – Reference to the container.

  • properties (dict[str, Any]) – The data to write to the source container.

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

class cognite.client.data_classes.data_modeling.records.RecordSourceSelector(
source: RecordContainerId,
properties: list[str],
)

Bases: CogniteResource

Selects which container properties to return for a record.

Parameters:
  • source (RecordContainerId) – The container to select properties from.

  • properties (list[str]) – Property identifiers to return; use ["*"] to return all.

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

class cognite.client.data_classes.data_modeling.records.RecordTargetUnit(
property: list[str],
unit: UnitReference | UnitSystemReference,
)

Bases: CogniteResource

A target unit conversion for one Records container property.

Parameters:
  • property (list[str]) – Fully qualified container property path: [space, container_external_id, property_id].

  • unit (UnitReference | UnitSystemReference) – Target unit or target unit system.

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

class cognite.client.data_classes.data_modeling.records.RecordTargetUnits(
properties: list[RecordTargetUnit] | None = None,
unit_system_name: str | None = None,
)

Bases: CogniteResource

Target unit conversions for a Records filter, sync, or aggregate request.

Parameters:
  • properties (list[RecordTargetUnit] | None) – Property-specific target unit conversions.

  • unit_system_name (str | None) – Convert all convertible properties to a target unit system.

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

class cognite.client.data_classes.data_modeling.records.RecordWrite(
space: str,
external_id: str,
sources: list[RecordSource],
)

Bases: WriteableCogniteResource[RecordWrite]

Write representation of a record, used for ingest and upsert.

This is the write version of Record.

Parameters:
  • space (str) – Space the record belongs to.

  • external_id (str) – External ID of the record (1-256 chars, no null bytes).

  • sources (list[RecordSource]) – Container property values to write (1-100 sources).

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

class cognite.client.data_classes.data_modeling.records.RecordWriteList(
resources: Sequence[T_CogniteResource],
)

Bases: CogniteResourceList[RecordWrite]

A list of RecordWrite objects.

class cognite.client.data_classes.data_modeling.records.SyncRecord(
space: str,
external_id: str,
created_time: int,
last_updated_time: int,
status: Literal['created', 'updated', 'deleted'],
properties: dict[str, dict[str, dict[str, Any]]] | None = None,
)

Bases: Record

A record returned by the sync endpoint, annotated with a change status.

For status="deleted" tombstones (mutable streams), properties is None.

Parameters:
  • space (str) – Space the record belongs to.

  • external_id (str) – External ID of the record.

  • created_time (int) – Creation time in milliseconds since epoch.

  • last_updated_time (int) – Last updated time in milliseconds since epoch.

  • status (Literal['created', 'updated', 'deleted']) – The record’s change status.

  • properties (dict[str, dict[str, dict[str, Any]]] | None) – Property values (absent for deleted tombstones).

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

class cognite.client.data_classes.data_modeling.records.SyncRecordList(
resources: Sequence[SyncRecord],
cursor: str | None = None,
has_next: bool = False,
typing: TypeInformation | None = None,
)

Bases: CogniteResourceList[SyncRecord]

A page of SyncRecord objects from the sync endpoint.

Parameters:
  • resources (Sequence[SyncRecord]) – The records in this page.

  • cursor (str | None) – Cursor to pass as cursor to the next sync_resume call to resume from this position.

  • has_next (bool) – Whether more changes are available beyond this page.

  • typing (TypeInformation | None) – Property type information, present when the request was made with include_typing=True.

class cognite.client.data_classes.data_modeling.records.TimeRange(
gte: int | str | None = None,
gt: int | str | None = None,
lte: int | str | None = None,
lt: int | str | None = None,
)

Bases: CogniteResource

A time range filter on lastUpdatedTime.

Bounds are either milliseconds since the Unix epoch (int) or an ISO-8601 string. At least a lower bound (gte or gt) is required for immutable streams; specifying two lower or two upper bounds is not allowed.

Parameters:
  • gte (int | str | None) – Greater than or equal to.

  • gt (int | str | None) – Greater than.

  • lte (int | str | None) – Less than or equal to.

  • lt (int | str | None) – Less than.

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]