Upsert sequences
- async AsyncCogniteClient.sequences.upsert(
- item: Sequence | SequenceWrite | Sequence[Sequence | SequenceWrite],
- mode: Literal['patch', 'replace'] = 'patch',
Upsert sequences, i.e., update if it exists, and create if it does not exist.
Note this is a convenience method that handles the upserting for you by first calling update on all items, and if any of them fail because they do not exist, it will create them instead.
For more details, see Upsert.
- Parameters:
item (Sequence | SequenceWrite | Sequence[Sequence | SequenceWrite]) – Sequence or list of sequences to upsert.
mode (Literal['patch', 'replace']) – Whether to patch or replace in the case the sequences are existing. If you set ‘patch’, the call will only update fields with non-null values (default). Setting ‘replace’ will unset any fields that are not specified.
- Returns:
The upserted sequence(s).
- Return type:
Sequence | SequenceList
Examples
Upsert for sequences:
>>> from cognite.client import CogniteClient >>> from cognite.client.data_classes import SequenceWrite, SequenceColumnWrite >>> client = CogniteClient() >>> # async_client = AsyncCogniteClient() # another option >>> existing_sequence = client.sequences.retrieve(id=1) >>> existing_sequence.description = "New description" >>> new_sequence = SequenceWrite( ... external_id="new_sequence", ... description="New sequence", ... columns=[SequenceColumnWrite(external_id="col1", value_type="STRING")], ... ) >>> res = client.sequences.upsert([existing_sequence, new_sequence], mode="replace")