diff --git a/.release-please-manifest.json b/.release-please-manifest.json index aa06f86..de44c40 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.18.1" + ".": "1.19.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 637d217..84e29ab 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 89 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/knock%2Fknock-1584eaacf779edacf947595928550c8914bd5f39e68c9ef7d8af8dd65e36187a.yml -openapi_spec_hash: 1e56a42e6985e71dfe1a58ff352b57cd -config_hash: 1470ae08f436e4d00dd096cb585b41fd +configured_endpoints: 90 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/knock%2Fknock-ce72fff9b44a47ab7e0425e496f09c61cde5b4258feb20cb5dbef6fa615a57e4.yml +openapi_spec_hash: 3054ea299cf43dc89b68266818fecfe4 +config_hash: 2b42d138d85c524e65fa7e205d36cc4a diff --git a/CHANGELOG.md b/CHANGELOG.md index cee8504..8228415 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## 1.19.0 (2025-11-20) + +Full Changelog: [v1.18.1...v1.19.0](https://github.com/knocklabs/knock-python/compare/v1.18.1...v1.19.0) + +### Features + +* **api:** Add bulk delete subscriptions ([19e98c2](https://github.com/knocklabs/knock-python/commit/19e98c23c849f558c931993cf4b4b51c8aa6cba9)) +* **api:** api update ([fd69af2](https://github.com/knocklabs/knock-python/commit/fd69af2d0bceb8268ffe5332d27f164ba8d9cc40)) +* **api:** api update ([73a3ba3](https://github.com/knocklabs/knock-python/commit/73a3ba3c1d5e370f31d781f13b211c18c0ba2b25)) + + +### Bug Fixes + +* **compat:** update signatures of `model_dump` and `model_dump_json` for Pydantic v1 ([8800c2d](https://github.com/knocklabs/knock-python/commit/8800c2da8a3bd29950d784f87c60d9725a5657b6)) + ## 1.18.1 (2025-11-10) Full Changelog: [v1.18.0...v1.18.1](https://github.com/knocklabs/knock-python/compare/v1.18.0...v1.18.1) diff --git a/api.md b/api.md index 547f993..139f276 100644 --- a/api.md +++ b/api.md @@ -164,6 +164,7 @@ Methods: - client.objects.bulk.delete(collection, \*\*params) -> BulkOperation - client.objects.bulk.add_subscriptions(collection, \*\*params) -> BulkOperation +- client.objects.bulk.delete_subscriptions(collection, \*\*params) -> BulkOperation - client.objects.bulk.set(collection, \*\*params) -> BulkOperation # Tenants @@ -178,7 +179,7 @@ Methods: - client.tenants.list(\*\*params) -> SyncEntriesCursor[Tenant] - client.tenants.delete(id) -> None -- client.tenants.get(id) -> Tenant +- client.tenants.get(id, \*\*params) -> Tenant - client.tenants.set(id, \*\*params) -> Tenant ## Bulk diff --git a/pyproject.toml b/pyproject.toml index a14ef0f..ba8f9b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "knockapi" -version = "1.18.1" +version = "1.19.0" description = "The official Python library for the knock API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/knockapi/_models.py b/src/knockapi/_models.py index fcec2cf..ca9500b 100644 --- a/src/knockapi/_models.py +++ b/src/knockapi/_models.py @@ -257,15 +257,16 @@ def model_dump( mode: Literal["json", "python"] | str = "python", include: IncEx | None = None, exclude: IncEx | None = None, + context: Any | None = None, by_alias: bool | None = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, + exclude_computed_fields: bool = False, round_trip: bool = False, warnings: bool | Literal["none", "warn", "error"] = True, - context: dict[str, Any] | None = None, - serialize_as_any: bool = False, fallback: Callable[[Any], Any] | None = None, + serialize_as_any: bool = False, ) -> dict[str, Any]: """Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump @@ -273,16 +274,24 @@ def model_dump( Args: mode: The mode in which `to_python` should run. - If mode is 'json', the dictionary will only contain JSON serializable types. - If mode is 'python', the dictionary may contain any Python objects. - include: A list of fields to include in the output. - exclude: A list of fields to exclude from the output. + If mode is 'json', the output will only contain JSON serializable types. + If mode is 'python', the output may contain non-JSON-serializable Python objects. + include: A set of fields to include in the output. + exclude: A set of fields to exclude from the output. + context: Additional context to pass to the serializer. by_alias: Whether to use the field's alias in the dictionary key if defined. - exclude_unset: Whether to exclude fields that are unset or None from the output. - exclude_defaults: Whether to exclude fields that are set to their default value from the output. - exclude_none: Whether to exclude fields that have a value of `None` from the output. - round_trip: Whether to enable serialization and deserialization round-trip support. - warnings: Whether to log warnings when invalid fields are encountered. + exclude_unset: Whether to exclude fields that have not been explicitly set. + exclude_defaults: Whether to exclude fields that are set to their default value. + exclude_none: Whether to exclude fields that have a value of `None`. + exclude_computed_fields: Whether to exclude computed fields. + While this can be useful for round-tripping, it is usually recommended to use the dedicated + `round_trip` parameter instead. + round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. + warnings: How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors, + "error" raises a [`PydanticSerializationError`][pydantic_core.PydanticSerializationError]. + fallback: A function to call when an unknown value is encountered. If not provided, + a [`PydanticSerializationError`][pydantic_core.PydanticSerializationError] error is raised. + serialize_as_any: Whether to serialize fields with duck-typing serialization behavior. Returns: A dictionary representation of the model. @@ -299,6 +308,8 @@ def model_dump( raise ValueError("serialize_as_any is only supported in Pydantic v2") if fallback is not None: raise ValueError("fallback is only supported in Pydantic v2") + if exclude_computed_fields != False: + raise ValueError("exclude_computed_fields is only supported in Pydantic v2") dumped = super().dict( # pyright: ignore[reportDeprecated] include=include, exclude=exclude, @@ -315,15 +326,17 @@ def model_dump_json( self, *, indent: int | None = None, + ensure_ascii: bool = False, include: IncEx | None = None, exclude: IncEx | None = None, + context: Any | None = None, by_alias: bool | None = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, + exclude_computed_fields: bool = False, round_trip: bool = False, warnings: bool | Literal["none", "warn", "error"] = True, - context: dict[str, Any] | None = None, fallback: Callable[[Any], Any] | None = None, serialize_as_any: bool = False, ) -> str: @@ -355,6 +368,10 @@ def model_dump_json( raise ValueError("serialize_as_any is only supported in Pydantic v2") if fallback is not None: raise ValueError("fallback is only supported in Pydantic v2") + if ensure_ascii != False: + raise ValueError("ensure_ascii is only supported in Pydantic v2") + if exclude_computed_fields != False: + raise ValueError("exclude_computed_fields is only supported in Pydantic v2") return super().json( # type: ignore[reportDeprecated] indent=indent, include=include, diff --git a/src/knockapi/_version.py b/src/knockapi/_version.py index d274ff9..0abf59d 100644 --- a/src/knockapi/_version.py +++ b/src/knockapi/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "knockapi" -__version__ = "1.18.1" # x-release-please-version +__version__ = "1.19.0" # x-release-please-version diff --git a/src/knockapi/resources/objects/bulk.py b/src/knockapi/resources/objects/bulk.py index d875c2b..a84b55f 100644 --- a/src/knockapi/resources/objects/bulk.py +++ b/src/knockapi/resources/objects/bulk.py @@ -17,7 +17,12 @@ async_to_streamed_response_wrapper, ) from ..._base_client import make_request_options -from ...types.objects import bulk_set_params, bulk_delete_params, bulk_add_subscriptions_params +from ...types.objects import ( + bulk_set_params, + bulk_delete_params, + bulk_add_subscriptions_params, + bulk_delete_subscriptions_params, +) from ...types.bulk_operation import BulkOperation __all__ = ["BulkResource", "AsyncBulkResource"] @@ -109,7 +114,7 @@ def add_subscriptions( for the `recipient` field. Args: - subscriptions: A list of subscriptions. + subscriptions: A nested list of subscriptions. extra_headers: Send extra headers @@ -138,6 +143,54 @@ def add_subscriptions( cast_to=BulkOperation, ) + def delete_subscriptions( + self, + collection: str, + *, + subscriptions: Iterable[bulk_delete_subscriptions_params.Subscription], + # 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, + idempotency_key: str | None = None, + ) -> BulkOperation: + """Delete subscriptions for many objects in a single collection type. + + If a + subscription for an object in the collection doesn't exist, it will be skipped. + + Args: + subscriptions: A nested list of subscriptions. + + 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 + + idempotency_key: Specify a custom idempotency key for this request + """ + if not collection: + raise ValueError(f"Expected a non-empty value for `collection` but received {collection!r}") + return self._post( + f"/v1/objects/{collection}/bulk/subscriptions/delete", + body=maybe_transform( + {"subscriptions": subscriptions}, bulk_delete_subscriptions_params.BulkDeleteSubscriptionsParams + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + idempotency_key=idempotency_key, + ), + cast_to=BulkOperation, + ) + def set( self, collection: str, @@ -269,7 +322,7 @@ async def add_subscriptions( for the `recipient` field. Args: - subscriptions: A list of subscriptions. + subscriptions: A nested list of subscriptions. extra_headers: Send extra headers @@ -298,6 +351,54 @@ async def add_subscriptions( cast_to=BulkOperation, ) + async def delete_subscriptions( + self, + collection: str, + *, + subscriptions: Iterable[bulk_delete_subscriptions_params.Subscription], + # 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, + idempotency_key: str | None = None, + ) -> BulkOperation: + """Delete subscriptions for many objects in a single collection type. + + If a + subscription for an object in the collection doesn't exist, it will be skipped. + + Args: + subscriptions: A nested list of subscriptions. + + 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 + + idempotency_key: Specify a custom idempotency key for this request + """ + if not collection: + raise ValueError(f"Expected a non-empty value for `collection` but received {collection!r}") + return await self._post( + f"/v1/objects/{collection}/bulk/subscriptions/delete", + body=await async_maybe_transform( + {"subscriptions": subscriptions}, bulk_delete_subscriptions_params.BulkDeleteSubscriptionsParams + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + idempotency_key=idempotency_key, + ), + cast_to=BulkOperation, + ) + async def set( self, collection: str, @@ -353,6 +454,9 @@ def __init__(self, bulk: BulkResource) -> None: self.add_subscriptions = to_raw_response_wrapper( bulk.add_subscriptions, ) + self.delete_subscriptions = to_raw_response_wrapper( + bulk.delete_subscriptions, + ) self.set = to_raw_response_wrapper( bulk.set, ) @@ -368,6 +472,9 @@ def __init__(self, bulk: AsyncBulkResource) -> None: self.add_subscriptions = async_to_raw_response_wrapper( bulk.add_subscriptions, ) + self.delete_subscriptions = async_to_raw_response_wrapper( + bulk.delete_subscriptions, + ) self.set = async_to_raw_response_wrapper( bulk.set, ) @@ -383,6 +490,9 @@ def __init__(self, bulk: BulkResource) -> None: self.add_subscriptions = to_streamed_response_wrapper( bulk.add_subscriptions, ) + self.delete_subscriptions = to_streamed_response_wrapper( + bulk.delete_subscriptions, + ) self.set = to_streamed_response_wrapper( bulk.set, ) @@ -398,6 +508,9 @@ def __init__(self, bulk: AsyncBulkResource) -> None: self.add_subscriptions = async_to_streamed_response_wrapper( bulk.add_subscriptions, ) + self.delete_subscriptions = async_to_streamed_response_wrapper( + bulk.delete_subscriptions, + ) self.set = async_to_streamed_response_wrapper( bulk.set, ) diff --git a/src/knockapi/resources/tenants/tenants.py b/src/knockapi/resources/tenants/tenants.py index 2692a9b..492f541 100644 --- a/src/knockapi/resources/tenants/tenants.py +++ b/src/knockapi/resources/tenants/tenants.py @@ -14,7 +14,7 @@ BulkResourceWithStreamingResponse, AsyncBulkResourceWithStreamingResponse, ) -from ...types import tenant_set_params, tenant_list_params +from ...types import tenant_get_params, tenant_set_params, tenant_list_params from ..._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given from ..._utils import maybe_transform, async_maybe_transform from ..._compat import cached_property @@ -162,6 +162,7 @@ def get( self, id: str, *, + resolve_full_preference_settings: bool | 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, @@ -173,6 +174,10 @@ def get( Get a tenant by ID. Args: + resolve_full_preference_settings: When true, merges environment-level default preferences into the tenant's + `settings.preference_set` field before returning the response. Defaults to + false. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -186,7 +191,14 @@ def get( return self._get( f"/v1/tenants/{id}", options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + {"resolve_full_preference_settings": resolve_full_preference_settings}, + tenant_get_params.TenantGetParams, + ), ), cast_to=Tenant, ) @@ -195,6 +207,7 @@ def set( self, id: str, *, + resolve_full_preference_settings: bool | Omit = omit, channel_data: Optional[InlineChannelDataRequestParam] | Omit = omit, name: Optional[str] | Omit = omit, settings: tenant_set_params.Settings | Omit = omit, @@ -212,6 +225,10 @@ def set( existing properties will be merged with the incoming properties. Args: + resolve_full_preference_settings: When true, merges environment-level default preferences into the tenant's + `settings.preference_set` field before returning the response. Defaults to + false. + channel_data: A request to set channel data for a type of channel inline. name: An optional name for the tenant. @@ -246,6 +263,10 @@ def set( extra_body=extra_body, timeout=timeout, idempotency_key=idempotency_key, + query=maybe_transform( + {"resolve_full_preference_settings": resolve_full_preference_settings}, + tenant_set_params.TenantSetParams, + ), ), cast_to=Tenant, ) @@ -380,6 +401,7 @@ async def get( self, id: str, *, + resolve_full_preference_settings: bool | 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, @@ -391,6 +413,10 @@ async def get( Get a tenant by ID. Args: + resolve_full_preference_settings: When true, merges environment-level default preferences into the tenant's + `settings.preference_set` field before returning the response. Defaults to + false. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -404,7 +430,14 @@ async def get( return await self._get( f"/v1/tenants/{id}", options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + {"resolve_full_preference_settings": resolve_full_preference_settings}, + tenant_get_params.TenantGetParams, + ), ), cast_to=Tenant, ) @@ -413,6 +446,7 @@ async def set( self, id: str, *, + resolve_full_preference_settings: bool | Omit = omit, channel_data: Optional[InlineChannelDataRequestParam] | Omit = omit, name: Optional[str] | Omit = omit, settings: tenant_set_params.Settings | Omit = omit, @@ -430,6 +464,10 @@ async def set( existing properties will be merged with the incoming properties. Args: + resolve_full_preference_settings: When true, merges environment-level default preferences into the tenant's + `settings.preference_set` field before returning the response. Defaults to + false. + channel_data: A request to set channel data for a type of channel inline. name: An optional name for the tenant. @@ -464,6 +502,10 @@ async def set( extra_body=extra_body, timeout=timeout, idempotency_key=idempotency_key, + query=await async_maybe_transform( + {"resolve_full_preference_settings": resolve_full_preference_settings}, + tenant_set_params.TenantSetParams, + ), ), cast_to=Tenant, ) diff --git a/src/knockapi/types/__init__.py b/src/knockapi/types/__init__.py index e8daf53..c0b735d 100644 --- a/src/knockapi/types/__init__.py +++ b/src/knockapi/types/__init__.py @@ -15,6 +15,7 @@ from .audience_member import AudienceMember as AudienceMember from .user_list_params import UserListParams as UserListParams from .object_set_params import ObjectSetParams as ObjectSetParams +from .tenant_get_params import TenantGetParams as TenantGetParams from .tenant_set_params import TenantSetParams as TenantSetParams from .user_merge_params import UserMergeParams as UserMergeParams from .object_list_params import ObjectListParams as ObjectListParams diff --git a/src/knockapi/types/objects/__init__.py b/src/knockapi/types/objects/__init__.py index f8f9979..827d8b6 100644 --- a/src/knockapi/types/objects/__init__.py +++ b/src/knockapi/types/objects/__init__.py @@ -5,3 +5,4 @@ from .bulk_set_params import BulkSetParams as BulkSetParams from .bulk_delete_params import BulkDeleteParams as BulkDeleteParams from .bulk_add_subscriptions_params import BulkAddSubscriptionsParams as BulkAddSubscriptionsParams +from .bulk_delete_subscriptions_params import BulkDeleteSubscriptionsParams as BulkDeleteSubscriptionsParams diff --git a/src/knockapi/types/objects/bulk_add_subscriptions_params.py b/src/knockapi/types/objects/bulk_add_subscriptions_params.py index 6198b30..cb4584e 100644 --- a/src/knockapi/types/objects/bulk_add_subscriptions_params.py +++ b/src/knockapi/types/objects/bulk_add_subscriptions_params.py @@ -13,10 +13,13 @@ class BulkAddSubscriptionsParams(TypedDict, total=False): subscriptions: Required[Iterable[Subscription]] - """A list of subscriptions.""" + """A nested list of subscriptions.""" class Subscription(TypedDict, total=False): + id: Required[str] + """Unique identifier for the object.""" + recipients: Required[SequenceNotStr[RecipientRequestParam]] """The recipients of the subscription. diff --git a/src/knockapi/types/objects/bulk_delete_subscriptions_params.py b/src/knockapi/types/objects/bulk_delete_subscriptions_params.py new file mode 100644 index 0000000..ab33214 --- /dev/null +++ b/src/knockapi/types/objects/bulk_delete_subscriptions_params.py @@ -0,0 +1,27 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Iterable +from typing_extensions import Required, TypedDict + +from ..._types import SequenceNotStr +from ..recipient_reference_param import RecipientReferenceParam + +__all__ = ["BulkDeleteSubscriptionsParams", "Subscription"] + + +class BulkDeleteSubscriptionsParams(TypedDict, total=False): + subscriptions: Required[Iterable[Subscription]] + """A nested list of subscriptions.""" + + +class Subscription(TypedDict, total=False): + id: Required[str] + """Unique identifier for the object.""" + + recipients: Required[SequenceNotStr[RecipientReferenceParam]] + """The recipients of the subscription. + + You can subscribe up to 100 recipients to an object at a time. + """ diff --git a/src/knockapi/types/tenant_get_params.py b/src/knockapi/types/tenant_get_params.py new file mode 100644 index 0000000..80bf42a --- /dev/null +++ b/src/knockapi/types/tenant_get_params.py @@ -0,0 +1,16 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import TypedDict + +__all__ = ["TenantGetParams"] + + +class TenantGetParams(TypedDict, total=False): + resolve_full_preference_settings: bool + """ + When true, merges environment-level default preferences into the tenant's + `settings.preference_set` field before returning the response. Defaults to + false. + """ diff --git a/src/knockapi/types/tenant_set_params.py b/src/knockapi/types/tenant_set_params.py index e2a9b11..760794d 100644 --- a/src/knockapi/types/tenant_set_params.py +++ b/src/knockapi/types/tenant_set_params.py @@ -12,6 +12,13 @@ class TenantSetParams(TypedDict, total=False): + resolve_full_preference_settings: bool + """ + When true, merges environment-level default preferences into the tenant's + `settings.preference_set` field before returning the response. Defaults to + false. + """ + channel_data: Optional[InlineChannelDataRequestParam] """A request to set channel data for a type of channel inline.""" diff --git a/tests/api_resources/objects/test_bulk.py b/tests/api_resources/objects/test_bulk.py index ae3b397..9043d3d 100644 --- a/tests/api_resources/objects/test_bulk.py +++ b/tests/api_resources/objects/test_bulk.py @@ -68,7 +68,12 @@ def test_path_params_delete(self, client: Knock) -> None: def test_method_add_subscriptions(self, client: Knock) -> None: bulk = client.objects.bulk.add_subscriptions( collection="projects", - subscriptions=[{"recipients": [{"id": "user_1"}]}], + subscriptions=[ + { + "id": "project-1", + "recipients": [{"id": "user_1"}], + } + ], ) assert_matches_type(BulkOperation, bulk, path=["response"]) @@ -77,7 +82,12 @@ def test_method_add_subscriptions(self, client: Knock) -> None: def test_raw_response_add_subscriptions(self, client: Knock) -> None: response = client.objects.bulk.with_raw_response.add_subscriptions( collection="projects", - subscriptions=[{"recipients": [{"id": "user_1"}]}], + subscriptions=[ + { + "id": "project-1", + "recipients": [{"id": "user_1"}], + } + ], ) assert response.is_closed is True @@ -90,7 +100,12 @@ def test_raw_response_add_subscriptions(self, client: Knock) -> None: def test_streaming_response_add_subscriptions(self, client: Knock) -> None: with client.objects.bulk.with_streaming_response.add_subscriptions( collection="projects", - subscriptions=[{"recipients": [{"id": "user_1"}]}], + subscriptions=[ + { + "id": "project-1", + "recipients": [{"id": "user_1"}], + } + ], ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -106,7 +121,94 @@ def test_path_params_add_subscriptions(self, client: Knock) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `collection` but received ''"): client.objects.bulk.with_raw_response.add_subscriptions( collection="", - subscriptions=[{"recipients": [{"id": "user_1"}]}], + subscriptions=[ + { + "id": "project-1", + "recipients": [{"id": "user_1"}], + } + ], + ) + + @pytest.mark.skip(reason="Prism doesn't support callbacks yet") + @parametrize + def test_method_delete_subscriptions(self, client: Knock) -> None: + bulk = client.objects.bulk.delete_subscriptions( + collection="projects", + subscriptions=[ + { + "id": "subscribed-to-object-1", + "recipients": [{}, "subscriber-user-1"], + }, + { + "id": "subscribed-to-object-2", + "recipients": ["subscriber-user-2"], + }, + ], + ) + assert_matches_type(BulkOperation, bulk, path=["response"]) + + @pytest.mark.skip(reason="Prism doesn't support callbacks yet") + @parametrize + def test_raw_response_delete_subscriptions(self, client: Knock) -> None: + response = client.objects.bulk.with_raw_response.delete_subscriptions( + collection="projects", + subscriptions=[ + { + "id": "subscribed-to-object-1", + "recipients": [{}, "subscriber-user-1"], + }, + { + "id": "subscribed-to-object-2", + "recipients": ["subscriber-user-2"], + }, + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + bulk = response.parse() + assert_matches_type(BulkOperation, bulk, path=["response"]) + + @pytest.mark.skip(reason="Prism doesn't support callbacks yet") + @parametrize + def test_streaming_response_delete_subscriptions(self, client: Knock) -> None: + with client.objects.bulk.with_streaming_response.delete_subscriptions( + collection="projects", + subscriptions=[ + { + "id": "subscribed-to-object-1", + "recipients": [{}, "subscriber-user-1"], + }, + { + "id": "subscribed-to-object-2", + "recipients": ["subscriber-user-2"], + }, + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + bulk = response.parse() + assert_matches_type(BulkOperation, bulk, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism doesn't support callbacks yet") + @parametrize + def test_path_params_delete_subscriptions(self, client: Knock) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `collection` but received ''"): + client.objects.bulk.with_raw_response.delete_subscriptions( + collection="", + subscriptions=[ + { + "id": "subscribed-to-object-1", + "recipients": [{}, "subscriber-user-1"], + }, + { + "id": "subscribed-to-object-2", + "recipients": ["subscriber-user-2"], + }, + ], ) @pytest.mark.skip(reason="Prism doesn't support callbacks yet") @@ -212,7 +314,12 @@ async def test_path_params_delete(self, async_client: AsyncKnock) -> None: async def test_method_add_subscriptions(self, async_client: AsyncKnock) -> None: bulk = await async_client.objects.bulk.add_subscriptions( collection="projects", - subscriptions=[{"recipients": [{"id": "user_1"}]}], + subscriptions=[ + { + "id": "project-1", + "recipients": [{"id": "user_1"}], + } + ], ) assert_matches_type(BulkOperation, bulk, path=["response"]) @@ -221,7 +328,12 @@ async def test_method_add_subscriptions(self, async_client: AsyncKnock) -> None: async def test_raw_response_add_subscriptions(self, async_client: AsyncKnock) -> None: response = await async_client.objects.bulk.with_raw_response.add_subscriptions( collection="projects", - subscriptions=[{"recipients": [{"id": "user_1"}]}], + subscriptions=[ + { + "id": "project-1", + "recipients": [{"id": "user_1"}], + } + ], ) assert response.is_closed is True @@ -234,7 +346,12 @@ async def test_raw_response_add_subscriptions(self, async_client: AsyncKnock) -> async def test_streaming_response_add_subscriptions(self, async_client: AsyncKnock) -> None: async with async_client.objects.bulk.with_streaming_response.add_subscriptions( collection="projects", - subscriptions=[{"recipients": [{"id": "user_1"}]}], + subscriptions=[ + { + "id": "project-1", + "recipients": [{"id": "user_1"}], + } + ], ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -250,7 +367,94 @@ async def test_path_params_add_subscriptions(self, async_client: AsyncKnock) -> with pytest.raises(ValueError, match=r"Expected a non-empty value for `collection` but received ''"): await async_client.objects.bulk.with_raw_response.add_subscriptions( collection="", - subscriptions=[{"recipients": [{"id": "user_1"}]}], + subscriptions=[ + { + "id": "project-1", + "recipients": [{"id": "user_1"}], + } + ], + ) + + @pytest.mark.skip(reason="Prism doesn't support callbacks yet") + @parametrize + async def test_method_delete_subscriptions(self, async_client: AsyncKnock) -> None: + bulk = await async_client.objects.bulk.delete_subscriptions( + collection="projects", + subscriptions=[ + { + "id": "subscribed-to-object-1", + "recipients": [{}, "subscriber-user-1"], + }, + { + "id": "subscribed-to-object-2", + "recipients": ["subscriber-user-2"], + }, + ], + ) + assert_matches_type(BulkOperation, bulk, path=["response"]) + + @pytest.mark.skip(reason="Prism doesn't support callbacks yet") + @parametrize + async def test_raw_response_delete_subscriptions(self, async_client: AsyncKnock) -> None: + response = await async_client.objects.bulk.with_raw_response.delete_subscriptions( + collection="projects", + subscriptions=[ + { + "id": "subscribed-to-object-1", + "recipients": [{}, "subscriber-user-1"], + }, + { + "id": "subscribed-to-object-2", + "recipients": ["subscriber-user-2"], + }, + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + bulk = await response.parse() + assert_matches_type(BulkOperation, bulk, path=["response"]) + + @pytest.mark.skip(reason="Prism doesn't support callbacks yet") + @parametrize + async def test_streaming_response_delete_subscriptions(self, async_client: AsyncKnock) -> None: + async with async_client.objects.bulk.with_streaming_response.delete_subscriptions( + collection="projects", + subscriptions=[ + { + "id": "subscribed-to-object-1", + "recipients": [{}, "subscriber-user-1"], + }, + { + "id": "subscribed-to-object-2", + "recipients": ["subscriber-user-2"], + }, + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + bulk = await response.parse() + assert_matches_type(BulkOperation, bulk, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism doesn't support callbacks yet") + @parametrize + async def test_path_params_delete_subscriptions(self, async_client: AsyncKnock) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `collection` but received ''"): + await async_client.objects.bulk.with_raw_response.delete_subscriptions( + collection="", + subscriptions=[ + { + "id": "subscribed-to-object-1", + "recipients": [{}, "subscriber-user-1"], + }, + { + "id": "subscribed-to-object-2", + "recipients": ["subscriber-user-2"], + }, + ], ) @pytest.mark.skip(reason="Prism doesn't support callbacks yet") diff --git a/tests/api_resources/test_tenants.py b/tests/api_resources/test_tenants.py index 46fc5c4..a9febeb 100644 --- a/tests/api_resources/test_tenants.py +++ b/tests/api_resources/test_tenants.py @@ -104,7 +104,16 @@ def test_path_params_delete(self, client: Knock) -> None: @parametrize def test_method_get(self, client: Knock) -> None: tenant = client.tenants.get( - "id", + id="id", + ) + assert_matches_type(Tenant, tenant, path=["response"]) + + @pytest.mark.skip(reason="Prism doesn't support callbacks yet") + @parametrize + def test_method_get_with_all_params(self, client: Knock) -> None: + tenant = client.tenants.get( + id="id", + resolve_full_preference_settings=True, ) assert_matches_type(Tenant, tenant, path=["response"]) @@ -112,7 +121,7 @@ def test_method_get(self, client: Knock) -> None: @parametrize def test_raw_response_get(self, client: Knock) -> None: response = client.tenants.with_raw_response.get( - "id", + id="id", ) assert response.is_closed is True @@ -124,7 +133,7 @@ def test_raw_response_get(self, client: Knock) -> None: @parametrize def test_streaming_response_get(self, client: Knock) -> None: with client.tenants.with_streaming_response.get( - "id", + id="id", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -139,7 +148,7 @@ def test_streaming_response_get(self, client: Knock) -> None: def test_path_params_get(self, client: Knock) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): client.tenants.with_raw_response.get( - "", + id="", ) @pytest.mark.skip(reason="Prism doesn't support callbacks yet") @@ -155,6 +164,7 @@ def test_method_set(self, client: Knock) -> None: def test_method_set_with_all_params(self, client: Knock) -> None: tenant = client.tenants.set( id="id", + resolve_full_preference_settings=True, channel_data={"97c5837d-c65c-4d54-aa39-080eeb81c69d": {"tokens": ["push_token_xxx"]}}, name="Jurassic Park", settings={ @@ -383,7 +393,16 @@ async def test_path_params_delete(self, async_client: AsyncKnock) -> None: @parametrize async def test_method_get(self, async_client: AsyncKnock) -> None: tenant = await async_client.tenants.get( - "id", + id="id", + ) + assert_matches_type(Tenant, tenant, path=["response"]) + + @pytest.mark.skip(reason="Prism doesn't support callbacks yet") + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncKnock) -> None: + tenant = await async_client.tenants.get( + id="id", + resolve_full_preference_settings=True, ) assert_matches_type(Tenant, tenant, path=["response"]) @@ -391,7 +410,7 @@ async def test_method_get(self, async_client: AsyncKnock) -> None: @parametrize async def test_raw_response_get(self, async_client: AsyncKnock) -> None: response = await async_client.tenants.with_raw_response.get( - "id", + id="id", ) assert response.is_closed is True @@ -403,7 +422,7 @@ async def test_raw_response_get(self, async_client: AsyncKnock) -> None: @parametrize async def test_streaming_response_get(self, async_client: AsyncKnock) -> None: async with async_client.tenants.with_streaming_response.get( - "id", + id="id", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -418,7 +437,7 @@ async def test_streaming_response_get(self, async_client: AsyncKnock) -> None: async def test_path_params_get(self, async_client: AsyncKnock) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): await async_client.tenants.with_raw_response.get( - "", + id="", ) @pytest.mark.skip(reason="Prism doesn't support callbacks yet") @@ -434,6 +453,7 @@ async def test_method_set(self, async_client: AsyncKnock) -> None: async def test_method_set_with_all_params(self, async_client: AsyncKnock) -> None: tenant = await async_client.tenants.set( id="id", + resolve_full_preference_settings=True, channel_data={"97c5837d-c65c-4d54-aa39-080eeb81c69d": {"tokens": ["push_token_xxx"]}}, name="Jurassic Park", settings={