Update events
- async AsyncCogniteClient.events.update(
- item: Event | EventWrite | EventUpdate | Sequence[Event | EventWrite | EventUpdate],
- mode: Literal['replace_ignore_null', 'patch', 'replace'] = 'replace_ignore_null',
-
Deprecated since version 8.23.0: The Events API is deprecated and is scheduled for removal on 2027-12-31. Move events to records, CogniteActivity or CogniteMaintenanceOrder in the core data model. See https://docs.cognite.com/cdf/deprecated for details and migration guidance.
- Parameters:
item (Event | EventWrite | EventUpdate | Sequence[Event | EventWrite | EventUpdate]) – Event(s) to update
mode (Literal['replace_ignore_null', 'patch', 'replace']) – How to update data when a non-update object is given (Event 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 event(s)
- Return type:
Examples
Update an event that you have fetched. This will perform a full update of the event:
>>> from cognite.client import CogniteClient, AsyncCogniteClient >>> client = CogniteClient() >>> # async_client = AsyncCogniteClient() # another option >>> event = client.events.retrieve(id=1) >>> event.description = "New description" >>> res = client.events.update(event)
Perform a partial update on a event, updating the description and adding a new field to metadata:
>>> from cognite.client.data_classes import EventUpdate >>> my_update = ( ... EventUpdate(id=1) ... .description.set("New description") ... .metadata.add({"key": "value"}) ... ) >>> res = client.events.update(my_update)