diff --git a/.release-please-manifest.json b/.release-please-manifest.json index e20563e..6c17b97 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "7.14.0" + ".": "7.15.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 6ee7bef..55e2ce6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 119 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier/courier-a64bb97c3455b0689de7f6a297ba1dc1e747561ce310ddb18b9c4a5f4d3d510a.yml -openapi_spec_hash: 6a3b89f3ea7600e784902f61680f8f1a -config_hash: 822a92efc80e63cdb2d496dbd6176620 +configured_endpoints: 120 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier/courier-cf10f3428ad9b9f636939a9305e80dd49118fea2c3f86cf61bf2b95367469e0f.yml +openapi_spec_hash: a61356bb015cec773770d2b61cabaa58 +config_hash: 86b472590f1c27b5a74499744b30c2ee diff --git a/CHANGELOG.md b/CHANGELOG.md index 3387b19..75e0625 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 7.15.0 (2026-06-17) + +Full Changelog: [v7.14.0...v7.15.0](https://github.com/trycourier/courier-python/compare/v7.14.0...v7.15.0) + +### Features + +* **openapi:** add add-to-digest JourneyNode variant ([7abe0d3](https://github.com/trycourier/courier-python/commit/7abe0d346d51a31301753dc54ac0025285a14dc8)) +* **openapi:** add DELETE /users/{id}/preferences/{topicId} ([1f14fd0](https://github.com/trycourier/courier-python/commit/1f14fd06794d54d5cc6d959867561a72d660462a)) + ## 7.14.0 (2026-06-12) Full Changelog: [v7.13.0...v7.14.0](https://github.com/trycourier/courier-python/compare/v7.13.0...v7.14.0) diff --git a/api.md b/api.md index cc16218..bbf7c0c 100644 --- a/api.md +++ b/api.md @@ -604,6 +604,7 @@ from courier.types.users import ( Methods: - client.users.preferences.retrieve(user_id, \*\*params) -> PreferenceRetrieveResponse +- client.users.preferences.delete_topic(topic_id, \*, user_id, \*\*params) -> None - client.users.preferences.retrieve_topic(topic_id, \*, user_id, \*\*params) -> PreferenceRetrieveTopicResponse - client.users.preferences.update_or_create_topic(topic_id, \*, user_id, \*\*params) -> PreferenceUpdateOrCreateTopicResponse diff --git a/pyproject.toml b/pyproject.toml index 10d2fb0..fa4586e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "trycourier" -version = "7.14.0" +version = "7.15.0" description = "The official Python library for the Courier API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/courier/_version.py b/src/courier/_version.py index 070136e..8dcab68 100644 --- a/src/courier/_version.py +++ b/src/courier/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "courier" -__version__ = "7.14.0" # x-release-please-version +__version__ = "7.15.0" # x-release-please-version diff --git a/src/courier/resources/users/preferences.py b/src/courier/resources/users/preferences.py index eb7483d..3083999 100644 --- a/src/courier/resources/users/preferences.py +++ b/src/courier/resources/users/preferences.py @@ -6,7 +6,7 @@ import httpx -from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource @@ -18,6 +18,7 @@ ) from ...types.users import ( preference_retrieve_params, + preference_delete_topic_params, preference_retrieve_topic_params, preference_update_or_create_topic_params, ) @@ -89,6 +90,54 @@ def retrieve( cast_to=PreferenceRetrieveResponse, ) + def delete_topic( + self, + topic_id: str, + *, + user_id: str, + tenant_id: Optional[str] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> None: + """ + Remove a user's preferences for a specific subscription topic, resetting the + topic to its effective default. This operation is idempotent: deleting a + preference that does not exist succeeds with no error. + + Args: + tenant_id: Delete the preferences of a user for this specific tenant context. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not user_id: + raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") + if not topic_id: + raise ValueError(f"Expected a non-empty value for `topic_id` but received {topic_id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return self._delete( + path_template("/users/{user_id}/preferences/{topic_id}", user_id=user_id, topic_id=topic_id), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + {"tenant_id": tenant_id}, preference_delete_topic_params.PreferenceDeleteTopicParams + ), + ), + cast_to=NoneType, + ) + def retrieve_topic( self, topic_id: str, @@ -247,6 +296,54 @@ async def retrieve( cast_to=PreferenceRetrieveResponse, ) + async def delete_topic( + self, + topic_id: str, + *, + user_id: str, + tenant_id: Optional[str] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> None: + """ + Remove a user's preferences for a specific subscription topic, resetting the + topic to its effective default. This operation is idempotent: deleting a + preference that does not exist succeeds with no error. + + Args: + tenant_id: Delete the preferences of a user for this specific tenant context. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not user_id: + raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") + if not topic_id: + raise ValueError(f"Expected a non-empty value for `topic_id` but received {topic_id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return await self._delete( + path_template("/users/{user_id}/preferences/{topic_id}", user_id=user_id, topic_id=topic_id), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + {"tenant_id": tenant_id}, preference_delete_topic_params.PreferenceDeleteTopicParams + ), + ), + cast_to=NoneType, + ) + async def retrieve_topic( self, topic_id: str, @@ -350,6 +447,9 @@ def __init__(self, preferences: PreferencesResource) -> None: self.retrieve = to_raw_response_wrapper( preferences.retrieve, ) + self.delete_topic = to_raw_response_wrapper( + preferences.delete_topic, + ) self.retrieve_topic = to_raw_response_wrapper( preferences.retrieve_topic, ) @@ -365,6 +465,9 @@ def __init__(self, preferences: AsyncPreferencesResource) -> None: self.retrieve = async_to_raw_response_wrapper( preferences.retrieve, ) + self.delete_topic = async_to_raw_response_wrapper( + preferences.delete_topic, + ) self.retrieve_topic = async_to_raw_response_wrapper( preferences.retrieve_topic, ) @@ -380,6 +483,9 @@ def __init__(self, preferences: PreferencesResource) -> None: self.retrieve = to_streamed_response_wrapper( preferences.retrieve, ) + self.delete_topic = to_streamed_response_wrapper( + preferences.delete_topic, + ) self.retrieve_topic = to_streamed_response_wrapper( preferences.retrieve_topic, ) @@ -395,6 +501,9 @@ def __init__(self, preferences: AsyncPreferencesResource) -> None: self.retrieve = async_to_streamed_response_wrapper( preferences.retrieve, ) + self.delete_topic = async_to_streamed_response_wrapper( + preferences.delete_topic, + ) self.retrieve_topic = async_to_streamed_response_wrapper( preferences.retrieve_topic, ) diff --git a/src/courier/types/journey_node.py b/src/courier/types/journey_node.py index eee04d8..33420ba 100644 --- a/src/courier/types/journey_node.py +++ b/src/courier/types/journey_node.py @@ -23,6 +23,7 @@ "JourneyNode", "JourneyBatchNode", "JourneyBatchNodeRetain", + "JourneyAddToDigestNode", "JourneyBranchNode", "JourneyBranchNodeDefault", "JourneyBranchNodePath", @@ -94,6 +95,27 @@ class JourneyBatchNode(BaseModel): """Releases the batch once this many events have been collected.""" +class JourneyAddToDigestNode(BaseModel): + """Add the current event to a digest keyed by the given subscription topic. + + The digest accumulates events and releases them on the schedule configured for the topic. + """ + + subscription_topic_id: str + """The subscription topic that owns the digest the event is added to.""" + + type: Literal["add-to-digest"] + + id: Optional[str] = None + + conditions: Optional[JourneyConditionsField] = None + """Condition spec for a journey node. + + Accepts a single condition atom, an AND/OR group, or an AND/OR nested group. + Omit the `conditions` property entirely to express "no conditions". + """ + + class JourneyBranchNodeDefault(BaseModel): nodes: List["JourneyNode"] @@ -140,6 +162,7 @@ class JourneyBranchNode(BaseModel): JourneyThrottleStaticNode, JourneyThrottleDynamicNode, JourneyBatchNode, + JourneyAddToDigestNode, JourneyExitNode, JourneyBranchNode, ] diff --git a/src/courier/types/journey_node_param.py b/src/courier/types/journey_node_param.py index 2b32b49..65b0d1b 100644 --- a/src/courier/types/journey_node_param.py +++ b/src/courier/types/journey_node_param.py @@ -22,6 +22,7 @@ "JourneyNodeParam", "JourneyBatchNode", "JourneyBatchNodeRetain", + "JourneyAddToDigestNode", "JourneyBranchNode", "JourneyBranchNodeDefault", "JourneyBranchNodePath", @@ -93,6 +94,27 @@ class JourneyBatchNode(TypedDict, total=False): """Releases the batch once this many events have been collected.""" +class JourneyAddToDigestNode(TypedDict, total=False): + """Add the current event to a digest keyed by the given subscription topic. + + The digest accumulates events and releases them on the schedule configured for the topic. + """ + + subscription_topic_id: Required[str] + """The subscription topic that owns the digest the event is added to.""" + + type: Required[Literal["add-to-digest"]] + + id: str + + conditions: JourneyConditionsFieldParam + """Condition spec for a journey node. + + Accepts a single condition atom, an AND/OR group, or an AND/OR nested group. + Omit the `conditions` property entirely to express "no conditions". + """ + + class JourneyBranchNodeDefault(TypedDict, total=False): nodes: Required[Iterable["JourneyNodeParam"]] @@ -139,6 +161,7 @@ class JourneyBranchNode(TypedDict, total=False): JourneyThrottleStaticNodeParam, JourneyThrottleDynamicNodeParam, JourneyBatchNode, + JourneyAddToDigestNode, JourneyExitNodeParam, JourneyBranchNode, ] diff --git a/src/courier/types/users/__init__.py b/src/courier/types/users/__init__.py index 2ccd5ad..3a23aaf 100644 --- a/src/courier/types/users/__init__.py +++ b/src/courier/types/users/__init__.py @@ -14,6 +14,7 @@ from .preference_retrieve_params import PreferenceRetrieveParams as PreferenceRetrieveParams from .tenant_add_multiple_params import TenantAddMultipleParams as TenantAddMultipleParams from .preference_retrieve_response import PreferenceRetrieveResponse as PreferenceRetrieveResponse +from .preference_delete_topic_params import PreferenceDeleteTopicParams as PreferenceDeleteTopicParams from .preference_retrieve_topic_params import PreferenceRetrieveTopicParams as PreferenceRetrieveTopicParams from .preference_retrieve_topic_response import PreferenceRetrieveTopicResponse as PreferenceRetrieveTopicResponse from .preference_update_or_create_topic_params import ( diff --git a/src/courier/types/users/preference_delete_topic_params.py b/src/courier/types/users/preference_delete_topic_params.py new file mode 100644 index 0000000..517af31 --- /dev/null +++ b/src/courier/types/users/preference_delete_topic_params.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional +from typing_extensions import Required, TypedDict + +__all__ = ["PreferenceDeleteTopicParams"] + + +class PreferenceDeleteTopicParams(TypedDict, total=False): + user_id: Required[str] + + tenant_id: Optional[str] + """Delete the preferences of a user for this specific tenant context.""" diff --git a/tests/api_resources/users/test_preferences.py b/tests/api_resources/users/test_preferences.py index bc46236..a5ee71e 100644 --- a/tests/api_resources/users/test_preferences.py +++ b/tests/api_resources/users/test_preferences.py @@ -72,6 +72,68 @@ def test_path_params_retrieve(self, client: Courier) -> None: user_id="", ) + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_delete_topic(self, client: Courier) -> None: + preference = client.users.preferences.delete_topic( + topic_id="topic_id", + user_id="user_id", + ) + assert preference is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_delete_topic_with_all_params(self, client: Courier) -> None: + preference = client.users.preferences.delete_topic( + topic_id="topic_id", + user_id="user_id", + tenant_id="tenant_id", + ) + assert preference is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_delete_topic(self, client: Courier) -> None: + response = client.users.preferences.with_raw_response.delete_topic( + topic_id="topic_id", + user_id="user_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + preference = response.parse() + assert preference is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_delete_topic(self, client: Courier) -> None: + with client.users.preferences.with_streaming_response.delete_topic( + topic_id="topic_id", + user_id="user_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + preference = response.parse() + assert preference is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_delete_topic(self, client: Courier) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"): + client.users.preferences.with_raw_response.delete_topic( + topic_id="topic_id", + user_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `topic_id` but received ''"): + client.users.preferences.with_raw_response.delete_topic( + topic_id="", + user_id="user_id", + ) + @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_retrieve_topic(self, client: Courier) -> None: @@ -263,6 +325,68 @@ async def test_path_params_retrieve(self, async_client: AsyncCourier) -> None: user_id="", ) + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_delete_topic(self, async_client: AsyncCourier) -> None: + preference = await async_client.users.preferences.delete_topic( + topic_id="topic_id", + user_id="user_id", + ) + assert preference is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_delete_topic_with_all_params(self, async_client: AsyncCourier) -> None: + preference = await async_client.users.preferences.delete_topic( + topic_id="topic_id", + user_id="user_id", + tenant_id="tenant_id", + ) + assert preference is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_delete_topic(self, async_client: AsyncCourier) -> None: + response = await async_client.users.preferences.with_raw_response.delete_topic( + topic_id="topic_id", + user_id="user_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + preference = await response.parse() + assert preference is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_delete_topic(self, async_client: AsyncCourier) -> None: + async with async_client.users.preferences.with_streaming_response.delete_topic( + topic_id="topic_id", + user_id="user_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + preference = await response.parse() + assert preference is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_delete_topic(self, async_client: AsyncCourier) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"): + await async_client.users.preferences.with_raw_response.delete_topic( + topic_id="topic_id", + user_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `topic_id` but received ''"): + await async_client.users.preferences.with_raw_response.delete_topic( + topic_id="", + user_id="user_id", + ) + @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_retrieve_topic(self, async_client: AsyncCourier) -> None: