@@ -798,6 +798,7 @@ def set_preferences(
798
798
object_id : str ,
799
799
id : str ,
800
800
* ,
801
+ _persistence_strategy : Literal ["merge" , "replace" ] | NotGiven = NOT_GIVEN ,
801
802
categories : Optional [Dict [str , object_set_preferences_params .Categories ]] | NotGiven = NOT_GIVEN ,
802
803
channel_types : Optional [PreferenceSetChannelTypesParam ] | NotGiven = NOT_GIVEN ,
803
804
workflows : Optional [Dict [str , object_set_preferences_params .Workflows ]] | NotGiven = NOT_GIVEN ,
@@ -810,14 +811,19 @@ def set_preferences(
810
811
) -> PreferenceSet :
811
812
"""Sets preferences within the given preference set.
812
813
813
- This is a destructive
814
- operation and will replace any existing preferences with the preferences given.
815
- If no object exists in the current environment for the given `:collection` and
816
- `:object_id`, Knock will create the object as part of this request. The
817
- preference set `:id` can be either `default` or a `tenant.id`. Learn more about
814
+ By default, this is a
815
+ destructive operation and will replace any existing preferences with the
816
+ preferences given. Use '\\ __\\ __persistence_strategy': 'merge' to merge with
817
+ existing preferences instead. If no object exists in the current environment for
818
+ the given `:collection` and `:object_id`, Knock will create the object as part
819
+ of this request. The preference set `:id` can be either `default` or a
820
+ `tenant.id`. Learn more about
818
821
[per-tenant preferences](/preferences/tenant-preferences).
819
822
820
823
Args:
824
+ _persistence_strategy: Controls how the preference set is persisted. 'replace' will completely replace
825
+ the preference set, 'merge' will merge with existing preferences.
826
+
821
827
categories: An object where the key is the category and the values are the preference
822
828
settings for that category.
823
829
@@ -844,6 +850,7 @@ def set_preferences(
844
850
f"/v1/objects/{ collection } /{ object_id } /preferences/{ id } " ,
845
851
body = maybe_transform (
846
852
{
853
+ "_persistence_strategy" : _persistence_strategy ,
847
854
"categories" : categories ,
848
855
"channel_types" : channel_types ,
849
856
"workflows" : workflows ,
@@ -1638,6 +1645,7 @@ async def set_preferences(
1638
1645
object_id : str ,
1639
1646
id : str ,
1640
1647
* ,
1648
+ _persistence_strategy : Literal ["merge" , "replace" ] | NotGiven = NOT_GIVEN ,
1641
1649
categories : Optional [Dict [str , object_set_preferences_params .Categories ]] | NotGiven = NOT_GIVEN ,
1642
1650
channel_types : Optional [PreferenceSetChannelTypesParam ] | NotGiven = NOT_GIVEN ,
1643
1651
workflows : Optional [Dict [str , object_set_preferences_params .Workflows ]] | NotGiven = NOT_GIVEN ,
@@ -1650,14 +1658,19 @@ async def set_preferences(
1650
1658
) -> PreferenceSet :
1651
1659
"""Sets preferences within the given preference set.
1652
1660
1653
- This is a destructive
1654
- operation and will replace any existing preferences with the preferences given.
1655
- If no object exists in the current environment for the given `:collection` and
1656
- `:object_id`, Knock will create the object as part of this request. The
1657
- preference set `:id` can be either `default` or a `tenant.id`. Learn more about
1661
+ By default, this is a
1662
+ destructive operation and will replace any existing preferences with the
1663
+ preferences given. Use '\\ __\\ __persistence_strategy': 'merge' to merge with
1664
+ existing preferences instead. If no object exists in the current environment for
1665
+ the given `:collection` and `:object_id`, Knock will create the object as part
1666
+ of this request. The preference set `:id` can be either `default` or a
1667
+ `tenant.id`. Learn more about
1658
1668
[per-tenant preferences](/preferences/tenant-preferences).
1659
1669
1660
1670
Args:
1671
+ _persistence_strategy: Controls how the preference set is persisted. 'replace' will completely replace
1672
+ the preference set, 'merge' will merge with existing preferences.
1673
+
1661
1674
categories: An object where the key is the category and the values are the preference
1662
1675
settings for that category.
1663
1676
@@ -1684,6 +1697,7 @@ async def set_preferences(
1684
1697
f"/v1/objects/{ collection } /{ object_id } /preferences/{ id } " ,
1685
1698
body = await async_maybe_transform (
1686
1699
{
1700
+ "_persistence_strategy" : _persistence_strategy ,
1687
1701
"categories" : categories ,
1688
1702
"channel_types" : channel_types ,
1689
1703
"workflows" : workflows ,
0 commit comments