From 0ca71d15d095865e9a531254efeabf5db2e8cdb9 Mon Sep 17 00:00:00 2001 From: anders-albert Date: Wed, 19 Jul 2023 16:40:21 +0200 Subject: [PATCH] docs: ref appendix in upsert methods --- cognite/client/_api/assets.py | 13 +------------ cognite/client/_api/events.py | 2 ++ cognite/client/_api/relationships.py | 2 ++ cognite/client/_api/sequences.py | 2 ++ cognite/client/_api/time_series.py | 2 ++ 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/cognite/client/_api/assets.py b/cognite/client/_api/assets.py index 50743c2d1c..ed6ab5a7e6 100644 --- a/cognite/client/_api/assets.py +++ b/cognite/client/_api/assets.py @@ -684,18 +684,7 @@ def upsert(self, item: Asset | Sequence[Asset], mode: Literal["patch", "replace" 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. - Warning: - This is not an atomic operation. It performs multiple calls to the update and create endpoints, depending - on whether the assets exist from before or not. This means that if one of the calls fail, it is possible - that some of the assets have been updated/created while others have not been created/updated. - - Note: - The mode parameter controls how the update is performed. If you set 'patch', the call will only update - the fields in the Asset object that are not None. This means that if the asset exists from before, the - fields that are not specified will not be changed. If you set 'replace', all the fields that are not - specified, i.e., set to None and support being set to null, will be nulled out. See the API - documentation for the update endpoint for more information. - + For more details, see :ref:`appendix-upsert`. Args: item (Asset | Sequence[Asset]): Asset or list of assets to upsert. diff --git a/cognite/client/_api/events.py b/cognite/client/_api/events.py index 1068bb8bbf..0c99478318 100644 --- a/cognite/client/_api/events.py +++ b/cognite/client/_api/events.py @@ -459,6 +459,8 @@ def upsert(self, item: Event | Sequence[Event], mode: Literal["patch", "replace" 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 :ref:`appendix-upsert`. + Args: item (Event | Sequence[Event]): Event or list of events to upsert. mode (Literal["patch", "replace"])): Whether to patch or replace in the case the events are existing. If diff --git a/cognite/client/_api/relationships.py b/cognite/client/_api/relationships.py index 75d5422580..65c157acb0 100644 --- a/cognite/client/_api/relationships.py +++ b/cognite/client/_api/relationships.py @@ -436,6 +436,8 @@ def upsert( 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 :ref:`appendix-upsert`. + Args: item (Relationship | Sequence[Relationship]): Relationship or list of relationships to upsert. mode (Literal["patch", "replace"])): Whether to patch or replace in the case the relationships are existing. If diff --git a/cognite/client/_api/sequences.py b/cognite/client/_api/sequences.py index 04a8253662..008b9752b5 100644 --- a/cognite/client/_api/sequences.py +++ b/cognite/client/_api/sequences.py @@ -462,6 +462,8 @@ def upsert( 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 :ref:`appendix-upsert`. + Args: item (Sequence | Sequence[Sequence]): Sequence or list of sequences to upsert. mode (Literal["patch", "replace"])): Whether to patch or replace in the case the sequences are existing. If diff --git a/cognite/client/_api/time_series.py b/cognite/client/_api/time_series.py index 51a25ed3c3..0b644f354c 100644 --- a/cognite/client/_api/time_series.py +++ b/cognite/client/_api/time_series.py @@ -402,6 +402,8 @@ def upsert( 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 :ref:`appendix-upsert`. + Args: item (TimeSeries | Sequence[TimeSeries]): TimeSeries or list of TimeSeries to upsert. mode (Literal["patch", "replace"])): Whether to patch or replace in the case the time series are existing. If