Create transformations

async AsyncCogniteClient.transformations.create(
transformation: Transformation | TransformationWrite | Sequence[Transformation] | Sequence[TransformationWrite],
) Transformation | TransformationList

Create one or more transformations.

Parameters:

transformation (Transformation | TransformationWrite | Sequence[Transformation] | Sequence[TransformationWrite]) – Transformation or list of transformations to create.

Returns:

Created transformation(s)

Return type:

Transformation | TransformationList

Examples

Create new transformations:

>>> from cognite.client import CogniteClient
>>> from cognite.client.data_classes import (
...     TransformationWrite,
...     TransformationDestination,
... )
>>> from cognite.client.data_classes.transformations.common import (
...     ViewInfo,
...     EdgeType,
...     DataModelInfo,
... )
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>> transformations = [
>>>     TransformationWrite(
>>>         external_id="transformation1",
>>>         name="transformation1",
>>>         ignore_null_fields=False,
>>>         destination=TransformationDestination.assets()
>>>     ),
>>>     TransformationWrite(
>>>         external_id="transformation2",
>>>         name="transformation2",
>>>         ignore_null_fields=False,
>>>         destination=TransformationDestination.raw("myDatabase", "myTable")
>>>     ),
>>>      TransformationWrite(
>>>          external_id="transformation3",
>>>          name="transformation3",
>>>          ignore_null_fields=False,
>>>          view = ViewInfo(space="TypeSpace", external_id="TypeExtId", version="version"),
>>>          destination=TransformationDestination.nodes(view, "InstanceSpace")
>>>      ),
>>>      TransformationWrite(
>>>          external_id="transformation4",
>>>          name="transformation4",
>>>          ignore_null_fields=False,
>>>          view = ViewInfo(space="TypeSpace", external_id="TypeExtId", version="version"),
>>>          destination=TransformationDestination.edges(view, "InstanceSpace")
>>>      ),
>>>      TransformationWrite(
>>>          external_id="transformation5",
>>>          name="transformation5",
>>>          ignore_null_fields=False,
>>>          edge_type = EdgeType(space="TypeSpace", external_id="TypeExtId"),
>>>          destination=TransformationDestination.edges(edge_type,"InstanceSpace")
>>>      ),
>>>      TransformationWrite(
>>>          external_id="transformation6",
>>>          name="transformation6",
>>>          ignore_null_fields=False,
>>>          data_model = DataModelInfo(space="modelSpace", external_id="modelExternalId",version="modelVersion",destination_type="viewExternalId"),
>>>          destination=TransformationDestination.instances(data_model,"InstanceSpace")
>>>      ),
>>>      TransformationWrite(
>>>          external_id="transformation7",
>>>          name="transformation7",
>>>          ignore_null_fields=False,
>>>          data_model = DataModelInfo(space="modelSpace", external_id="modelExternalId",version="modelVersion",destination_type="viewExternalId", destination_relationship_from_type="connectionPropertyName"),
>>>          destination=TransformationDestination.instances(data_model,"InstanceSpace")
>>>      ),
>>> ]
>>> res = client.transformations.create(transformations)