Update events

async AsyncCogniteClient.events.update(
item: Event | EventWrite | EventUpdate | Sequence[Event | EventWrite | EventUpdate],
mode: Literal['replace_ignore_null', 'patch', 'replace'] = 'replace_ignore_null',
) Event | EventList

Update one or more events.

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:

Event | EventList

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)