Update transformations
- async AsyncCogniteClient.transformations.update(
- item: Transformation | TransformationWrite | TransformationUpdate | Sequence[Transformation | TransformationWrite | TransformationUpdate],
- mode: Literal['replace_ignore_null', 'patch', 'replace'] = 'replace_ignore_null',
Update one or more transformations.
- Parameters:
item (Transformation | TransformationWrite | TransformationUpdate | Sequence[Transformation | TransformationWrite | TransformationUpdate]) – Transformation(s) to update
mode (Literal['replace_ignore_null', 'patch', 'replace']) – How to update data when a non-update object is given (Transformation or -Write). If you use ‘replace_ignore_null’, only the fields you have set will be used to replace existing (default). Using ‘replace’ will additionally clear all the fields that are not specified by you. Last option, ‘patch’, will update only the fields you have set and for container-like fields such as metadata or labels, add the values to the existing. For more details, see Update and Upsert Mode Parameter.
- Returns:
Updated transformation(s)
- Return type:
Examples
Update a transformation that you have fetched. This will perform a full update of the transformation:
>>> from cognite.client import CogniteClient, AsyncCogniteClient >>> client = CogniteClient() >>> # async_client = AsyncCogniteClient() # another option >>> transformation = client.transformations.retrieve(id=1) >>> transformation.query = "SELECT * FROM _cdf.assets" >>> res = client.transformations.update(transformation)
Perform a partial update on a transformation, updating the query and making it private:
>>> from cognite.client.data_classes import TransformationUpdate >>> my_update = ( ... TransformationUpdate(id=1) ... .query.set("SELECT * FROM _cdf.assets") ... .is_public.set(False) ... ) >>> res = client.transformations.update(my_update)
Update the session used for reading (source) and writing (destination) when authenticating for all transformations in a given data set:
>>> from cognite.client.data_classes import NonceCredentials >>> to_update = client.transformations.list(data_set_external_ids=["foo"]) >>> new_session = client.iam.sessions.create() >>> new_nonce = NonceCredentials( ... session_id=new_session.id, ... nonce=new_session.nonce, ... cdf_project_name=client.config.project, ... ) >>> for tr in to_update: ... tr.source_nonce = new_nonce ... tr.destination_nonce = new_nonce >>> res = client.transformations.update(to_update)