Data Organization

Annotations (legacy)

AsyncCogniteClient.annotations.create(...)

Create annotations.

AsyncCogniteClient.annotations.delete(id)

Delete annotations.

AsyncCogniteClient.annotations.list(filter)

List annotations.

AsyncCogniteClient.annotations.retrieve(id)

Retrieve an annotation by id.

AsyncCogniteClient.annotations.retrieve_multiple(ids)

Retrieve annotations by IDs.

AsyncCogniteClient.annotations.reverse_lookup(filter)

Reverse lookup annotated resources based on having annotations matching the filter.

AsyncCogniteClient.annotations.suggest(...)

Suggest annotations.

AsyncCogniteClient.annotations.update(item)

Update annotations.

Annotations Data classes

class cognite.client.data_classes.annotations.Annotation(
id: int,
created_time: int,
last_updated_time: int,
annotation_type: str,
data: dict,
status: str,
creating_app: str,
creating_app_version: str,
creating_user: str,
annotated_resource_type: str,
annotated_resource_id: int,
)

Bases: AnnotationCore

Representation of an annotation in CDF. This is the read version of the Annotation class. It is never to be used when creating new annotations.

Parameters:
  • id (int) – A server-generated ID for the object.

  • created_time (int) – The timestamp for when the annotation was created, in milliseconds since epoch.

  • last_updated_time (int) – The timestamp for when the annotation was last updated, in milliseconds since epoch.

  • annotation_type (str) – The type of the annotation. This uniquely decides what the structure of the ‘data’ block will be.

  • data (dict) – The annotation information. The format of this object is decided by and validated against the ‘annotation_type’ attribute.

  • status (str) – The status of the annotation, e.g. “suggested”, “approved”, “rejected”.

  • creating_app (str) – The name of the app from which this annotation was created.

  • creating_app_version (str) – The version of the app that created this annotation. Must be a valid semantic versioning (SemVer) string.

  • creating_user (str) – (str, optional): A username, or email, or name. This is not checked nor enforced. If the value is None, it means the annotation was created by a service.

  • annotated_resource_type (str) – Type name of the CDF resource that is annotated, e.g. “file”.

  • annotated_resource_id (int) – The internal ID of the annotated resource.

as_write() AnnotationWrite

Returns this Annotation in its write version.

class cognite.client.data_classes.annotations.AnnotationCore(
annotation_type: str,
data: dict,
status: str,
creating_app: str,
creating_app_version: str,
creating_user: str,
annotated_resource_type: str,
annotated_resource_id: int,
)

Bases: WriteableCogniteResource[AnnotationWrite], ABC

Representation of an annotation in CDF.

Parameters:
  • annotation_type (str) – The type of the annotation. This uniquely decides what the structure of the ‘data’ block will be.

  • data (dict) – The annotation information. The format of this object is decided by and validated against the ‘annotation_type’ attribute.

  • status (str) – The status of the annotation, e.g. “suggested”, “approved”, “rejected”.

  • creating_app (str) – The name of the app from which this annotation was created.

  • creating_app_version (str) – The version of the app that created this annotation. Must be a valid semantic versioning (SemVer) string.

  • creating_user (str) – (str, optional): A username, or email, or name. This is not checked nor enforced. If the value is None, it means the annotation was created by a service.

  • annotated_resource_type (str) – Type name of the CDF resource that is annotated, e.g. “file”.

  • annotated_resource_id (int) – The internal ID of the annotated resource.

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.annotations.AnnotationFilter(
annotated_resource_type: str,
annotated_resource_ids: list[dict[str, int]],
status: str | None = None,
creating_user: str | None = '',
creating_app: str | None = None,
creating_app_version: str | None = None,
annotation_type: str | None = None,
data: dict[str, Any] | None = None,
)

Bases: AnnotationReverseLookupFilter

Filter on annotations with various criteria

Parameters:
  • annotated_resource_type (str) – The type of the CDF resource that is annotated, e.g. “file”.

  • annotated_resource_ids (list[dict[str, int]]) – List of ids of the annotated CDF resources to filter in. Example format: [{“id”: 1234}, {“id”: “4567”}]. Must contain at least one item.

  • status (str | None) – Status of annotations to filter for, e.g. “suggested”, “approved”, “rejected”.

  • creating_user (str | None) – Name of the user who created the annotations to filter for. Can be set explicitly to “None” to filter for annotations created by a service.

  • creating_app (str | None) – Name of the app from which the annotations to filter for where created.

  • creating_app_version (str | None) – Version of the app from which the annotations to filter for were created.

  • annotation_type (str | None) – Type name of the annotations.

  • data (dict[str, Any] | None) – The annotation data to filter by. Example format: {“label”: “cat”, “confidence”: 0.9}

class cognite.client.data_classes.annotations.AnnotationList(
resources: Sequence[T_CogniteResource],
)

Bases: WriteableCogniteResourceList[AnnotationWrite, Annotation], IdTransformerMixin

as_write() AnnotationWriteList

Returns this AnnotationList in its write version.

class cognite.client.data_classes.annotations.AnnotationReverseLookupFilter(
annotated_resource_type: str,
status: str | None = None,
creating_user: str | None = '',
creating_app: str | None = None,
creating_app_version: str | None = None,
annotation_type: str | None = None,
data: dict[str, Any] | None = None,
)

Bases: CogniteFilter

Filter on annotations with various criteria

Parameters:
  • annotated_resource_type (str) – The type of the CDF resource that is annotated, e.g. “file”.

  • status (str | None) – Status of annotations to filter for, e.g. “suggested”, “approved”, “rejected”.

  • creating_user (str | None) – Name of the user who created the annotations to filter for. Can be set explicitly to “None” to filter for annotations created by a service.

  • creating_app (str | None) – Name of the app from which the annotations to filter for where created.

  • creating_app_version (str | None) – Version of the app from which the annotations to filter for were created.

  • annotation_type (str | None) – Type name of the annotations.

  • data (dict[str, Any] | None) – The annotation data to filter by. Example format: {“label”: “cat”, “confidence”: 0.9}

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.annotations.AnnotationUpdate(id: int)

Bases: CogniteUpdate

Changes applied to annotation

Parameters:

id (int) – A server-generated ID for the object.

class cognite.client.data_classes.annotations.AnnotationWrite(
annotation_type: Literal['images.ObjectDetection', 'images.Classification', 'images.KeypointCollection', 'images.AssetLink', 'images.TextRegion', 'images.InstanceLink', 'isoplan.IsoPlanAnnotation', 'diagrams.AssetLink', 'diagrams.FileLink', 'diagrams.InstanceLink', 'diagrams.UnhandledTextObject', 'diagrams.UnhandledSymbolObject', 'documents.ExtractedText', 'diagrams.Line', 'diagrams.Junction', 'pointcloud.BoundingVolume', 'forms.Detection'],
data: dict,
status: Literal['suggested', 'approved', 'rejected'],
creating_app: str,
creating_app_version: str,
creating_user: str,
annotated_resource_type: Literal['file', 'threedmodel'],
annotated_resource_id: int,
)

Bases: AnnotationCore

Representation of an annotation in CDF. This is the write version of the Annotation class. It is used when creating new annotations.

Parameters:
  • annotation_type (AnnotationType) – The type of the annotation. This uniquely decides what the structure of the ‘data’ block will be.

  • data (dict) – The annotation information. The format of this object is decided by and validated against the ‘annotation_type’ attribute.

  • status (Literal['suggested', 'approved', 'rejected']) – The status of the annotation, e.g. “suggested”, “approved”, “rejected”.

  • creating_app (str) – The name of the app from which this annotation was created.

  • creating_app_version (str) – The version of the app that created this annotation. Must be a valid semantic versioning (SemVer) string.

  • creating_user (str) – A username, or email, or name. This is not checked nor enforced. If the value is None, it means the annotation was created by a service.

  • annotated_resource_type (Literal['file', 'threedmodel']) – Type name of the CDF resource that is annotated, e.g. “file”.

  • annotated_resource_id (int) – The internal ID of the annotated resource.

as_write() AnnotationWrite

Returns this AnnotationWrite.

class cognite.client.data_classes.annotations.AnnotationWriteList(
resources: Sequence[T_CogniteResource],
)

Bases: CogniteResourceList[AnnotationWrite]

Data sets

AsyncCogniteClient.data_sets.aggregate_count([...])

Aggregate data sets.

AsyncCogniteClient.data_sets.create(data_set)

Create one or more data sets.

AsyncCogniteClient.data_sets.list([...])

List data sets.

AsyncCogniteClient.data_sets.retrieve([id, ...])

Retrieve a single data set by id.

AsyncCogniteClient.data_sets.retrieve_multiple([...])

Retrieve multiple data sets by id.

AsyncCogniteClient.data_sets.update(item[, mode])

Update one or more data sets.

Delete data sets

This functionality is not yet available in the API.

Data Sets Data classes

class cognite.client.data_classes.data_sets.DataSet(
id: int,
created_time: int,
last_updated_time: int,
write_protected: bool,
external_id: str | None = None,
name: str | None = None,
description: str | None = None,
metadata: dict[str, str] | None = None,
)

Bases: DataSetCore

Data sets let you document and track data lineage, ensure data integrity, and allow 3rd parties to write their insights securely back to a Cognite Data Fusion (CDF) project. This is the read version of the DataSet, which is used when retrieving from CDF.

Parameters:
  • id (int) – A server-generated ID for the object.

  • created_time (int) – The number of milliseconds since 00:00:00 Thursday, 1 January 1970, Coordinated Universal Time (UTC), minus leap seconds.

  • last_updated_time (int) – The number of milliseconds since 00:00:00 Thursday, 1 January 1970, Coordinated Universal Time (UTC), minus leap seconds.

  • write_protected (bool) – To write data to a write-protected data set, you need to be a member of a group that has the “datasets:owner” action for the data set. To learn more about write-protected data sets, follow this [guide](/cdf/data_governance/concepts/datasets/#write-protection)

  • external_id (str | None) – The external ID provided by the client. Must be unique for the resource type.

  • name (str | None) – The name of the data set.

  • description (str | None) – The description of the data set.

  • metadata (dict[str, str] | None) – Custom, application-specific metadata. String key -> String value. Limits: Maximum length of key is 128 bytes, value 10240 bytes, up to 256 key-value pairs, of total size at most 10240.

class cognite.client.data_classes.data_sets.DataSetCore(
external_id: str | None = None,
name: str | None = None,
description: str | None = None,
metadata: dict[str, str] | None = None,
write_protected: bool | None = None,
)

Bases: WriteableCogniteResource[DataSetWrite]

Data sets let you document and track data lineage, ensure data integrity, and allow 3rd parties to write their insights securely back to a Cognite Data Fusion (CDF) project. This is the read version of the DataSet, which is used when retrieving from CDF.

Parameters:
  • external_id (str | None) – The external ID provided by the client. Must be unique for the resource type.

  • name (str | None) – The name of the data set.

  • description (str | None) – The description of the data set.

  • metadata (dict[str, str] | None) – Custom, application-specific metadata. String key -> String value. Limits: Maximum length of key is 128 bytes, value 10240 bytes, up to 256 key-value pairs, of total size at most 10240.

  • write_protected (bool | None) – To write data to a write-protected data set, you need to be a member of a group that has the “datasets:owner” action for the data set. To learn more about write-protected data sets, follow this [guide](/cdf/data_governance/concepts/datasets/#write-protection)

class cognite.client.data_classes.data_sets.DataSetFilter(
metadata: dict[str, str] | None = None,
created_time: dict[str, Any] | TimestampRange | None = None,
last_updated_time: dict[str, Any] | TimestampRange | None = None,
external_id_prefix: str | None = None,
write_protected: bool | None = None,
)

Bases: CogniteFilter

Filter on data sets with strict matching.

Parameters:
  • metadata (dict[str, str] | None) – Custom, application specific metadata. String key -> String value. Limits: Maximum length of key is 128 bytes, value 10240 bytes, up to 256 key-value pairs, of total size at most 10240.

  • created_time (dict[str, Any] | TimestampRange | None) – Range between two timestamps.

  • last_updated_time (dict[str, Any] | TimestampRange | None) – Range between two timestamps.

  • external_id_prefix (str | None) – Filter by this (case-sensitive) prefix for the external ID.

  • write_protected (bool | None) – No description.

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_sets.DataSetList(
resources: Sequence[T_CogniteResource],
)

Bases: WriteableCogniteResourceList[DataSetWrite, DataSet], IdTransformerMixin

class cognite.client.data_classes.data_sets.DataSetUpdate(id: int | None = None, external_id: str | None = None)

Bases: CogniteUpdate

Update applied to single data set

Parameters:
  • id (int) – A server-generated ID for the object.

  • external_id (str) – The external ID provided by the client. Must be unique for the resource type.

class cognite.client.data_classes.data_sets.DataSetWrite(
external_id: str | None = None,
name: str | None = None,
description: str | None = None,
metadata: dict[str, str] | None = None,
write_protected: bool | None = None,
)

Bases: DataSetCore

Data sets let you document and track data lineage, ensure data integrity, and allow 3rd parties to write their insights securely back to a Cognite Data Fusion (CDF) project. This is the read version of the DataSet, which is used when retrieving from CDF.

Parameters:
  • external_id (str | None) – The external ID provided by the client. Must be unique for the resource type.

  • name (str | None) – The name of the data set.

  • description (str | None) – The description of the data set.

  • metadata (dict[str, str] | None) – Custom, application-specific metadata. String key -> String value. Limits: Maximum length of key is 128 bytes, value 10240 bytes, up to 256 key-value pairs, of total size at most 10240.

  • write_protected (bool | None) – To write data to a write-protected data set, you need to be a member of a group that has the “datasets:owner” action for the data set. To learn more about write-protected data sets, follow this [guide](/cdf/data_governance/concepts/datasets/#write-protection)

as_write() DataSetWrite

Returns this DataSetWrite instance.

class cognite.client.data_classes.data_sets.DataSetWriteList(
resources: Sequence[T_CogniteResource],
)

Bases: CogniteResourceList[DataSetWrite], ExternalIDTransformerMixin

Labels

AsyncCogniteClient.labels.create(label)

Create one or more label definitions.

AsyncCogniteClient.labels.delete([external_id])

Delete one or more label definitions.

AsyncCogniteClient.labels.list([name, ...])

List Labels.

AsyncCogniteClient.labels.retrieve(external_id)

Retrieve one or more label definitions by external id.

Labels Data classes

class cognite.client.data_classes.labels.Label(external_id: str)

Bases: CogniteResource

A label assigned to a resource.

Parameters:

external_id (str) – The external id to the attached label.

class cognite.client.data_classes.labels.LabelDefinition(
external_id: str,
name: str,
created_time: int,
description: str | None = None,
data_set_id: int | None = None,
)

Bases: LabelDefinitionCore

A label definition is a globally defined label that can later be attached to resources (e.g., assets). For example, can you define a “Pump” label definition and attach that label to your pump assets. This is the read version of the LabelDefinition class. It is used when retrieving existing label definitions.

Parameters:
  • external_id (str) – The external ID provided by the client. Must be unique for the resource type.

  • name (str) – Name of the label.

  • created_time (int) – The number of milliseconds since 00:00:00 Thursday, 1 January 1970, Coordinated Universal Time (UTC), minus leap seconds.

  • description (str | None) – Description of the label.

  • data_set_id (int | None) – The id of the dataset this label belongs to.

as_write() LabelDefinitionWrite

Returns this LabelDefinition in its write version.

class cognite.client.data_classes.labels.LabelDefinitionCore(
external_id: str,
name: str,
description: str | None,
data_set_id: int | None,
)

Bases: WriteableCogniteResource[LabelDefinitionWrite], ABC

A label definition is a globally defined label that can later be attached to resources (e.g., assets). For example, can you define a “Pump” label definition and attach that label to your pump assets. This is the parent for the reading and write versions.

Parameters:
  • external_id (str) – The external ID provided by the client. Must be unique for the resource type.

  • name (str) – Name of the label.

  • description (str | None) – Description of the label.

  • data_set_id (int | None) – The id of the dataset this label belongs to.

class cognite.client.data_classes.labels.LabelDefinitionFilter(
name: str | None = None,
external_id_prefix: str | None = None,
data_set_ids: list[dict[str, Any]] | None = None,
)

Bases: CogniteFilter

Filter on labels definitions with strict matching.

Parameters:
  • name (str | None) – Returns the label definitions matching that name.

  • external_id_prefix (str | None) – filter label definitions with external ids starting with the prefix specified

  • data_set_ids (list[dict[str, Any]] | None) – Only include labels that belong to these datasets.

class cognite.client.data_classes.labels.LabelDefinitionList(
resources: Sequence[T_CogniteResource],
)

Bases: WriteableCogniteResourceList[LabelDefinitionWrite, LabelDefinition], ExternalIDTransformerMixin

as_write() LabelDefinitionWriteList

Returns this LabelDefinitionList in its write version.

class cognite.client.data_classes.labels.LabelDefinitionWrite(
external_id: str,
name: str,
description: str | None = None,
data_set_id: int | None = None,
)

Bases: LabelDefinitionCore

A label definition is a globally defined label that can later be attached to resources (e.g., assets). For example, can you define a “Pump” label definition and attach that label to your pump assets. This is the write version of the LabelDefinition class. It is used when creating new label definitions.

Parameters:
  • external_id (str) – The external ID provided by the client. Must be unique for the resource type.

  • name (str) – Name of the label.

  • description (str | None) – Description of the label.

  • data_set_id (int | None) – The id of the dataset this label belongs to.

as_write() LabelDefinitionWrite

Returns this LabelDefinitionWrite instance.

class cognite.client.data_classes.labels.LabelDefinitionWriteList(
resources: Sequence[T_CogniteResource],
)

Bases: CogniteResourceList[LabelDefinitionWrite], ExternalIDTransformerMixin

class cognite.client.data_classes.labels.LabelFilter(
contains_any: list[str] | None = None,
contains_all: list[str] | None = None,
)

Bases: CogniteFilter

Return only the resource matching the specified label constraints.

Parameters:
  • contains_any (list[str] | None) – The resource item contains at least one of the listed labels. The labels are defined by a list of external ids.

  • contains_all (list[str] | None) – The resource item contains all the listed labels. The labels are defined by a list of external ids.

Examples

List only resources marked as a PUMP and VERIFIED:

>>> from cognite.client.data_classes import LabelFilter
>>> my_label_filter = LabelFilter(contains_all=["PUMP", "VERIFIED"])

List only resources marked as a PUMP or as a VALVE:

>>> from cognite.client.data_classes import LabelFilter
>>> my_label_filter = LabelFilter(contains_any=["PUMP", "VALVE"])
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]

Relationships (legacy)

AsyncCogniteClient.relationships.create(...)

Create one or more relationships.

AsyncCogniteClient.relationships.delete(...)

Delete one or more relationships.

AsyncCogniteClient.relationships.list([...])

Lists relationships stored in the project based on a query filter given in the payload of this request.

AsyncCogniteClient.relationships.retrieve(...)

Retrieve a single relationship by external id.

AsyncCogniteClient.relationships.retrieve_multiple(...)

Retrieve multiple relationships by external id.

AsyncCogniteClient.relationships.update(item)

Update one or more relationships.

AsyncCogniteClient.relationships.upsert(item)

Upsert relationships, i.e., update if it exists, and create if it does not exist.

Relationship Data classes

class cognite.client.data_classes.relationships.Relationship(
external_id: str,
created_time: int,
last_updated_time: int,
source_external_id: str,
source_type: str,
target_external_id: str,
target_type: str,
source: Asset | TimeSeries | FileMetadata | Sequence | Event | dict[str, Any] | None = None,
target: Asset | TimeSeries | FileMetadata | Sequence | Event | dict[str, Any] | None = None,
start_time: int | None = None,
end_time: int | None = None,
confidence: float | None = None,
data_set_id: int | None = None,
labels: SequenceNotStr[Label | str | LabelDefinition | dict] | None = None,
)

Bases: RelationshipCore

Representation of a relationship in CDF, consists of a source and a target and some additional parameters. This is the read version of the relationship class, it is used when retrieving from CDF.

Parameters:
  • external_id (str) – External id of the relationship, must be unique within the project.

  • created_time (int) – Time, in milliseconds since Jan. 1, 1970, when this relationship was created in CDF.

  • last_updated_time (int) – Time, in milliseconds since Jan. 1, 1970, when this relationship was last updated in CDF.

  • source_external_id (str) – External id of the CDF resource that constitutes the relationship source.

  • source_type (str) – The CDF resource type of the relationship source. Must be one of the specified values.

  • target_external_id (str) – External id of the CDF resource that constitutes the relationship target.

  • target_type (str) – The CDF resource type of the relationship target. Must be one of the specified values.

  • source (Asset | TimeSeries | FileMetadata | Sequence | Event | dict[str, Any] | None) – The full resource referenced by the source_external_id and source_type fields.

  • target (Asset | TimeSeries | FileMetadata | Sequence | Event | dict[str, Any] | None) – The full resource referenced by the target_external_id and target_type fields.

  • start_time (int | None) – Time, in milliseconds since Jan. 1, 1970, when the relationship became active. If there is no startTime, relationship is active from the beginning of time until endTime.

  • end_time (int | None) – Time, in milliseconds since Jan. 1, 1970, when the relationship became inactive. If there is no endTime, relationship is active from startTime until the present or any point in the future. If endTime and startTime are set, then endTime must be strictly greater than startTime.

  • confidence (float | None) – Confidence value of the existence of this relationship. Generated relationships should provide a realistic score on the likelihood of the existence of the relationship. Relationships without a confidence value can be interpreted at the discretion of each project.

  • data_set_id (int | None) – The id of the dataset this relationship belongs to.

  • labels (SequenceNotStr[Label | str | LabelDefinition | dict] | None) – A list of the labels associated with this resource item.

as_write() RelationshipWrite

Returns this Relationship in its write version.

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.relationships.RelationshipCore(
external_id: str,
source_external_id: str,
source_type: str,
target_external_id: str,
target_type: str,
start_time: int | None,
end_time: int | None,
confidence: float | None,
data_set_id: int | None,
labels: list[Label] | None,
)

Bases: WriteableCogniteResource[RelationshipWrite], ABC

Representation of a relationship in CDF, consists of a source and a target and some additional parameters.

Parameters:
  • external_id (str) – External id of the relationship, must be unique within the project.

  • source_external_id (str) – External id of the CDF resource that constitutes the relationship source.

  • source_type (str) – The CDF resource type of the relationship source. Must be one of the specified values.

  • target_external_id (str) – External id of the CDF resource that constitutes the relationship target.

  • target_type (str) – The CDF resource type of the relationship target. Must be one of the specified values.

  • start_time (int | None) – Time, in milliseconds since Jan. 1, 1970, when the relationship became active. If there is no startTime, relationship is active from the beginning of time until endTime.

  • end_time (int | None) – Time, in milliseconds since Jan. 1, 1970, when the relationship became inactive. If there is no endTime, relationship is active from startTime until the present or any point in the future. If endTime and startTime are set, then endTime must be strictly greater than startTime.

  • confidence (float | None) – Confidence value of the existence of this relationship. Generated relationships should provide a realistic score on the likelihood of the existence of the relationship. Relationships without a confidence value can be interpreted at the discretion of each project.

  • data_set_id (int | None) – The id of the dataset this relationship belongs to.

  • labels (list[Label] | None) – A list of the labels associated with this resource item.

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.relationships.RelationshipFilter(
source_external_ids: SequenceNotStr[str] | None = None,
source_types: SequenceNotStr[str] | None = None,
target_external_ids: SequenceNotStr[str] | None = None,
target_types: SequenceNotStr[str] | None = None,
data_set_ids: Sequence[dict[str, Any]] | None = None,
start_time: dict[str, int] | None = None,
end_time: dict[str, int] | None = None,
confidence: dict[str, int] | None = None,
last_updated_time: dict[str, int] | None = None,
created_time: dict[str, int] | None = None,
active_at_time: dict[str, int] | None = None,
labels: LabelFilter | None = None,
)

Bases: CogniteFilter

Filter on relationships with exact match. Multiple filter elements in one property, e.g. sourceExternalIds: [ “a”, “b” ], will return all relationships where the sourceExternalId field is either a or b. Filters in multiple properties will return the relationships that match all criteria. If the filter is not specified it default to an empty filter.

Parameters:
  • source_external_ids (SequenceNotStr[str] | None) – Include relationships that have any of these values in their sourceExternalId field

  • source_types (SequenceNotStr[str] | None) – Include relationships that have any of these values in their sourceType field

  • target_external_ids (SequenceNotStr[str] | None) – Include relationships that have any of these values in their targetExternalId field

  • target_types (SequenceNotStr[str] | None) – Include relationships that have any of these values in their targetType field

  • data_set_ids (Sequence[dict[str, Any]] | None) – Either one of internalId (int) or externalId (str)

  • start_time (dict[str, int] | None) – Range between two timestamps, minimum and maximum milliseconds (inclusive)

  • end_time (dict[str, int] | None) – Range between two timestamps, minimum and maximum milliseconds (inclusive)

  • confidence (dict[str, int] | None) – Range to filter the field for (inclusive).

  • last_updated_time (dict[str, int] | None) – Range to filter the field for (inclusive).

  • created_time (dict[str, int] | None) – Range to filter the field for (inclusive).

  • active_at_time (dict[str, int] | None) – Limits results to those active at any point within the given time range, i.e. if there is any overlap in the intervals [activeAtTime.min, activeAtTime.max] and [startTime, endTime], where both intervals are inclusive. If a relationship does not have a startTime, it is regarded as active from the beginning of time by this filter. If it does not have an endTime is will be regarded as active until the end of time. Similarly, if a min is not supplied to the filter, the min will be implicitly set to the beginning of time, and if a max is not supplied, the max will be implicitly set to the end of time.

  • labels (LabelFilter | None) – Return only the resource matching the specified label constraints.

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.relationships.RelationshipList(
resources: Sequence[T_CogniteResource],
)

Bases: WriteableCogniteResourceList[RelationshipWrite, Relationship], ExternalIDTransformerMixin

as_write() RelationshipWriteList

Returns this RelationshipList in its write version.

class cognite.client.data_classes.relationships.RelationshipUpdate(external_id: str)

Bases: CogniteUpdate

Update applied to a single relationship

Parameters:

external_id (str) – The external ID provided by the client. Must be unique for the resource type.

class cognite.client.data_classes.relationships.RelationshipWrite(
external_id: str,
source_external_id: str,
source_type: Literal['asset', 'timeseries', 'file', 'event', 'sequence'],
target_external_id: str,
target_type: Literal['asset', 'timeseries', 'file', 'event', 'sequence'],
start_time: int | None = None,
end_time: int | None = None,
confidence: float | None = None,
data_set_id: int | None = None,
labels: SequenceNotStr[Label | str | LabelDefinitionWrite | dict] | None = None,
)

Bases: RelationshipCore

Representation of a relationship in CDF, consists of a source and a target and some additional parameters. This is the write version of the relationship class, and is used when creating new relationships.

Parameters:
  • external_id (str) – External id of the relationship, must be unique within the project.

  • source_external_id (str) – External id of the CDF resource that constitutes the relationship source.

  • source_type (RelationshipType) – The CDF resource type of the relationship source. Must be one of the specified values.

  • target_external_id (str) – External id of the CDF resource that constitutes the relationship target.

  • target_type (RelationshipType) – The CDF resource type of the relationship target. Must be one of the specified values.

  • start_time (int | None) – Time, in milliseconds since Jan. 1, 1970, when the relationship became active. If there is no startTime, relationship is active from the beginning of time until endTime.

  • end_time (int | None) – Time, in milliseconds since Jan. 1, 1970, when the relationship became inactive. If there is no endTime, relationship is active from startTime until the present or any point in the future. If endTime and startTime are set, then endTime must be strictly greater than startTime.

  • confidence (float | None) – Confidence value of the existence of this relationship. Generated relationships should provide a realistic score on the likelihood of the existence of the relationship. Relationships without a confidence value can be interpreted at the discretion of each project.

  • data_set_id (int | None) – The id of the dataset this relationship belongs to.

  • labels (SequenceNotStr[Label | str | LabelDefinitionWrite | dict] | None) – A list of the labels associated with this resource item.

as_write() RelationshipWrite

Returns this RelationshipWrite instance.

class cognite.client.data_classes.relationships.RelationshipWriteList(
resources: Sequence[T_CogniteResource],
)

Bases: CogniteResourceList[RelationshipWrite], ExternalIDTransformerMixin