From eeeb684d28965f37db55f32c46939442f88611a7 Mon Sep 17 00:00:00 2001 From: stainless-bot Date: Thu, 28 Nov 2024 01:18:13 +0000 Subject: [PATCH] feat(internal): update path placeholders --- .stats.yml | 4 +- api.md | 56 +- .../resources/ai_gateway/ai_gateway.py | 8 - src/cloudflare/resources/dnssec.py | 52 +- .../settings/trusted_domains.py | 341 +++++++- .../resources/resource_sharing/__init__.py | 28 + .../resources/resource_sharing/recipients.py | 571 ++++++++++++++ .../resource_sharing/resource_sharing.py | 387 +++++++++- .../resources/resource_sharing/resources.py | 725 ++++++++++++++++++ .../ai_gateway/ai_gateway_list_params.py | 3 - .../types/dnssec/dnssec_delete_response.py | 3 +- .../types/email_security/settings/__init__.py | 4 + .../trusted_domain_delete_response.py | 11 + .../settings/trusted_domain_edit_params.py | 31 + .../settings/trusted_domain_edit_response.py | 35 + .../settings/trusted_domain_get_response.py | 35 + .../types/resource_sharing/__init__.py | 18 + .../recipient_create_params.py | 20 + .../recipient_create_response.py | 28 + .../recipient_delete_response.py | 28 + .../recipient_get_response.py | 28 + .../resource_sharing/recipient_list_params.py | 18 + .../recipient_list_response.py | 28 + .../resource_create_params.py | 24 + .../resource_create_response.py | 37 + .../resource_delete_response.py | 37 + .../resource_sharing/resource_get_response.py | 37 + .../resource_sharing/resource_list_params.py | 24 + .../resource_list_response.py | 37 + .../resource_sharing_delete_response.py | 38 + .../resource_sharing_get_response.py | 38 + .../resource_sharing_update_params.py | 15 + .../resource_sharing_update_response.py | 38 + .../resource_update_params.py | 18 + .../resource_update_response.py | 37 + .../settings/test_trusted_domains.py | 281 +++++++ .../resource_sharing/test_recipients.py | 502 ++++++++++++ .../resource_sharing/test_resources.py | 657 ++++++++++++++++ tests/api_resources/test_ai_gateway.py | 2 - tests/api_resources/test_dnssec.py | 14 +- tests/api_resources/test_resource_sharing.py | 301 ++++++++ 41 files changed, 4551 insertions(+), 48 deletions(-) create mode 100644 src/cloudflare/resources/resource_sharing/recipients.py create mode 100644 src/cloudflare/resources/resource_sharing/resources.py create mode 100644 src/cloudflare/types/email_security/settings/trusted_domain_delete_response.py create mode 100644 src/cloudflare/types/email_security/settings/trusted_domain_edit_params.py create mode 100644 src/cloudflare/types/email_security/settings/trusted_domain_edit_response.py create mode 100644 src/cloudflare/types/email_security/settings/trusted_domain_get_response.py create mode 100644 src/cloudflare/types/resource_sharing/recipient_create_params.py create mode 100644 src/cloudflare/types/resource_sharing/recipient_create_response.py create mode 100644 src/cloudflare/types/resource_sharing/recipient_delete_response.py create mode 100644 src/cloudflare/types/resource_sharing/recipient_get_response.py create mode 100644 src/cloudflare/types/resource_sharing/recipient_list_params.py create mode 100644 src/cloudflare/types/resource_sharing/recipient_list_response.py create mode 100644 src/cloudflare/types/resource_sharing/resource_create_params.py create mode 100644 src/cloudflare/types/resource_sharing/resource_create_response.py create mode 100644 src/cloudflare/types/resource_sharing/resource_delete_response.py create mode 100644 src/cloudflare/types/resource_sharing/resource_get_response.py create mode 100644 src/cloudflare/types/resource_sharing/resource_list_params.py create mode 100644 src/cloudflare/types/resource_sharing/resource_list_response.py create mode 100644 src/cloudflare/types/resource_sharing/resource_sharing_delete_response.py create mode 100644 src/cloudflare/types/resource_sharing/resource_sharing_get_response.py create mode 100644 src/cloudflare/types/resource_sharing/resource_sharing_update_params.py create mode 100644 src/cloudflare/types/resource_sharing/resource_sharing_update_response.py create mode 100644 src/cloudflare/types/resource_sharing/resource_update_params.py create mode 100644 src/cloudflare/types/resource_sharing/resource_update_response.py create mode 100644 tests/api_resources/resource_sharing/test_recipients.py create mode 100644 tests/api_resources/resource_sharing/test_resources.py diff --git a/.stats.yml b/.stats.yml index 4695a258720..970d709d9c6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1436 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8c1088ba96368f5f19f6d33654ae76942cfd4f0e3b7f418add2c67b01a6085dc.yml +configured_endpoints: 1451 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c5682a28c312411d32f5a8447e4c50880eabf7d71415128758e7924dc434c4da.yml diff --git a/api.md b/api.md index 1aa6be1054b..8a4b3ca8632 100644 --- a/api.md +++ b/api.md @@ -1164,7 +1164,7 @@ from cloudflare.types.dnssec import DNSSEC, DNSSECDeleteResponse Methods: -- client.dnssec.delete(\*, zone_id) -> str +- client.dnssec.delete(\*, zone_id) -> Optional[DNSSECDeleteResponse] - client.dnssec.edit(\*, zone_id, \*\*params) -> Optional[DNSSEC] - client.dnssec.get(\*, zone_id) -> Optional[DNSSEC] @@ -1367,6 +1367,9 @@ Types: from cloudflare.types.email_security.settings import ( TrustedDomainCreateResponse, TrustedDomainListResponse, + TrustedDomainDeleteResponse, + TrustedDomainEditResponse, + TrustedDomainGetResponse, ) ``` @@ -1374,6 +1377,9 @@ Methods: - client.email_security.settings.trusted_domains.create(\*, account_id, \*\*params) -> TrustedDomainCreateResponse - client.email_security.settings.trusted_domains.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[TrustedDomainListResponse] +- client.email_security.settings.trusted_domains.delete(trusted_domain_id, \*, account_id) -> TrustedDomainDeleteResponse +- client.email_security.settings.trusted_domains.edit(trusted_domain_id, \*, account_id, \*\*params) -> TrustedDomainEditResponse +- client.email_security.settings.trusted_domains.get(trusted_domain_id, \*, account_id) -> TrustedDomainGetResponse ## Submissions @@ -8274,14 +8280,62 @@ Types: ```python from cloudflare.types.resource_sharing import ( ResourceSharingCreateResponse, + ResourceSharingUpdateResponse, ResourceSharingListResponse, + ResourceSharingDeleteResponse, + ResourceSharingGetResponse, ) ``` Methods: - client.resource_sharing.create(\*, account_id, \*\*params) -> Optional[ResourceSharingCreateResponse] +- client.resource_sharing.update(share_id, \*, account_id, \*\*params) -> Optional[ResourceSharingUpdateResponse] - client.resource_sharing.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[ResourceSharingListResponse] +- client.resource_sharing.delete(share_id, \*, account_id) -> Optional[ResourceSharingDeleteResponse] +- client.resource_sharing.get(share_id, \*, account_id) -> Optional[ResourceSharingGetResponse] + +## Recipients + +Types: + +```python +from cloudflare.types.resource_sharing import ( + RecipientCreateResponse, + RecipientListResponse, + RecipientDeleteResponse, + RecipientGetResponse, +) +``` + +Methods: + +- client.resource_sharing.recipients.create(share_id, \*, path_account_id, \*\*params) -> Optional[RecipientCreateResponse] +- client.resource_sharing.recipients.list(share_id, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[RecipientListResponse] +- client.resource_sharing.recipients.delete(recipient_id, \*, account_id, share_id) -> Optional[RecipientDeleteResponse] +- client.resource_sharing.recipients.get(recipient_id, \*, account_id, share_id) -> Optional[RecipientGetResponse] + +## Resources + +Types: + +```python +from cloudflare.types.resource_sharing import ( + ResourceCreateResponse, + ResourceUpdateResponse, + ResourceListResponse, + ResourceDeleteResponse, + ResourceGetResponse, +) +``` + +Methods: + +- client.resource_sharing.resources.create(share_id, \*, account_id, \*\*params) -> Optional[ResourceCreateResponse] +- client.resource_sharing.resources.update(resource_id, \*, account_id, share_id, \*\*params) -> Optional[ResourceUpdateResponse] +- client.resource_sharing.resources.list(share_id, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[ResourceListResponse] +- client.resource_sharing.resources.delete(resource_id, \*, account_id, share_id) -> Optional[ResourceDeleteResponse] +- client.resource_sharing.resources.get(resource_id, \*, account_id, share_id) -> Optional[ResourceGetResponse] # LeakedCredentialChecks diff --git a/src/cloudflare/resources/ai_gateway/ai_gateway.py b/src/cloudflare/resources/ai_gateway/ai_gateway.py index c10d86e5d9c..a6611f20caa 100644 --- a/src/cloudflare/resources/ai_gateway/ai_gateway.py +++ b/src/cloudflare/resources/ai_gateway/ai_gateway.py @@ -234,7 +234,6 @@ def list( order_by_direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN, page: int | NotGiven = NOT_GIVEN, per_page: int | NotGiven = NOT_GIVEN, - search: str | NotGiven = NOT_GIVEN, # 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, @@ -250,8 +249,6 @@ def list( order_by_direction: Order By Direction - search: Search by id - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -276,7 +273,6 @@ def list( "order_by_direction": order_by_direction, "page": page, "per_page": per_page, - "search": search, }, ai_gateway_list_params.AIGatewayListParams, ), @@ -538,7 +534,6 @@ def list( order_by_direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN, page: int | NotGiven = NOT_GIVEN, per_page: int | NotGiven = NOT_GIVEN, - search: str | NotGiven = NOT_GIVEN, # 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, @@ -554,8 +549,6 @@ def list( order_by_direction: Order By Direction - search: Search by id - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -580,7 +573,6 @@ def list( "order_by_direction": order_by_direction, "page": page, "per_page": per_page, - "search": search, }, ai_gateway_list_params.AIGatewayListParams, ), diff --git a/src/cloudflare/resources/dnssec.py b/src/cloudflare/resources/dnssec.py index 456af0fed2c..ee2c708afda 100644 --- a/src/cloudflare/resources/dnssec.py +++ b/src/cloudflare/resources/dnssec.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Any, Type, Optional, cast from typing_extensions import Literal import httpx @@ -59,7 +59,7 @@ def delete( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> str: + ) -> Optional[DNSSECDeleteResponse]: """ Delete DNSSEC. @@ -76,16 +76,21 @@ def delete( """ if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - return self._delete( - f"/zones/{zone_id}/dnssec", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[DNSSECDeleteResponse]]._unwrapper, + return cast( + Optional[DNSSECDeleteResponse], + self._delete( + f"/zones/{zone_id}/dnssec", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[DNSSECDeleteResponse]]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[DNSSECDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=cast(Type[str], ResultWrapper[str]), ) def edit( @@ -227,7 +232,7 @@ async def delete( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> str: + ) -> Optional[DNSSECDeleteResponse]: """ Delete DNSSEC. @@ -244,16 +249,21 @@ async def delete( """ if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - return await self._delete( - f"/zones/{zone_id}/dnssec", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[DNSSECDeleteResponse]]._unwrapper, + return cast( + Optional[DNSSECDeleteResponse], + await self._delete( + f"/zones/{zone_id}/dnssec", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[DNSSECDeleteResponse]]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[DNSSECDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=cast(Type[str], ResultWrapper[str]), ) async def edit( diff --git a/src/cloudflare/resources/email_security/settings/trusted_domains.py b/src/cloudflare/resources/email_security/settings/trusted_domains.py index c563a78885b..9677f9db7f7 100644 --- a/src/cloudflare/resources/email_security/settings/trusted_domains.py +++ b/src/cloudflare/resources/email_security/settings/trusted_domains.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Iterable, Optional, cast +from typing import Any, Type, Iterable, Optional, cast from typing_extensions import Literal, overload import httpx @@ -24,9 +24,16 @@ from ...._wrappers import ResultWrapper from ....pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray from ...._base_client import AsyncPaginator, make_request_options -from ....types.email_security.settings import trusted_domain_list_params, trusted_domain_create_params +from ....types.email_security.settings import ( + trusted_domain_edit_params, + trusted_domain_list_params, + trusted_domain_create_params, +) +from ....types.email_security.settings.trusted_domain_get_response import TrustedDomainGetResponse +from ....types.email_security.settings.trusted_domain_edit_response import TrustedDomainEditResponse from ....types.email_security.settings.trusted_domain_list_response import TrustedDomainListResponse from ....types.email_security.settings.trusted_domain_create_response import TrustedDomainCreateResponse +from ....types.email_security.settings.trusted_domain_delete_response import TrustedDomainDeleteResponse __all__ = ["TrustedDomainsResource", "AsyncTrustedDomainsResource"] @@ -237,6 +244,153 @@ def list( model=TrustedDomainListResponse, ) + def delete( + self, + trusted_domain_id: int, + *, + account_id: str, + # 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, + ) -> TrustedDomainDeleteResponse: + """ + Delete a trusted email domain + + Args: + account_id: Account Identifier + + trusted_domain_id: The unique identifier for the trusted domain. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._delete( + f"/accounts/{account_id}/email-security/settings/trusted_domains/{trusted_domain_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[TrustedDomainDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[TrustedDomainDeleteResponse], ResultWrapper[TrustedDomainDeleteResponse]), + ) + + def edit( + self, + trusted_domain_id: int, + *, + account_id: str, + comments: Optional[str] | NotGiven = NOT_GIVEN, + is_recent: Optional[bool] | NotGiven = NOT_GIVEN, + is_regex: Optional[bool] | NotGiven = NOT_GIVEN, + is_similarity: Optional[bool] | NotGiven = NOT_GIVEN, + pattern: Optional[str] | NotGiven = NOT_GIVEN, + # 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, + ) -> TrustedDomainEditResponse: + """ + Update a trusted email domain + + Args: + account_id: Account Identifier + + trusted_domain_id: The unique identifier for the trusted domain. + + is_recent: Select to prevent recently registered domains from triggering a Suspicious or + Malicious disposition. + + is_similarity: Select for partner or other approved domains that have similar spelling to your + connected domains. Prevents listed domains from triggering a Spoof disposition. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._patch( + f"/accounts/{account_id}/email-security/settings/trusted_domains/{trusted_domain_id}", + body=maybe_transform( + { + "comments": comments, + "is_recent": is_recent, + "is_regex": is_regex, + "is_similarity": is_similarity, + "pattern": pattern, + }, + trusted_domain_edit_params.TrustedDomainEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[TrustedDomainEditResponse]._unwrapper, + ), + cast_to=cast(Type[TrustedDomainEditResponse], ResultWrapper[TrustedDomainEditResponse]), + ) + + def get( + self, + trusted_domain_id: int, + *, + account_id: str, + # 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, + ) -> TrustedDomainGetResponse: + """ + Get a trusted email domain + + Args: + account_id: Account Identifier + + trusted_domain_id: The unique identifier for the trusted domain. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + f"/accounts/{account_id}/email-security/settings/trusted_domains/{trusted_domain_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[TrustedDomainGetResponse]._unwrapper, + ), + cast_to=cast(Type[TrustedDomainGetResponse], ResultWrapper[TrustedDomainGetResponse]), + ) + class AsyncTrustedDomainsResource(AsyncAPIResource): @cached_property @@ -444,6 +598,153 @@ def list( model=TrustedDomainListResponse, ) + async def delete( + self, + trusted_domain_id: int, + *, + account_id: str, + # 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, + ) -> TrustedDomainDeleteResponse: + """ + Delete a trusted email domain + + Args: + account_id: Account Identifier + + trusted_domain_id: The unique identifier for the trusted domain. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._delete( + f"/accounts/{account_id}/email-security/settings/trusted_domains/{trusted_domain_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[TrustedDomainDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[TrustedDomainDeleteResponse], ResultWrapper[TrustedDomainDeleteResponse]), + ) + + async def edit( + self, + trusted_domain_id: int, + *, + account_id: str, + comments: Optional[str] | NotGiven = NOT_GIVEN, + is_recent: Optional[bool] | NotGiven = NOT_GIVEN, + is_regex: Optional[bool] | NotGiven = NOT_GIVEN, + is_similarity: Optional[bool] | NotGiven = NOT_GIVEN, + pattern: Optional[str] | NotGiven = NOT_GIVEN, + # 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, + ) -> TrustedDomainEditResponse: + """ + Update a trusted email domain + + Args: + account_id: Account Identifier + + trusted_domain_id: The unique identifier for the trusted domain. + + is_recent: Select to prevent recently registered domains from triggering a Suspicious or + Malicious disposition. + + is_similarity: Select for partner or other approved domains that have similar spelling to your + connected domains. Prevents listed domains from triggering a Spoof disposition. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._patch( + f"/accounts/{account_id}/email-security/settings/trusted_domains/{trusted_domain_id}", + body=await async_maybe_transform( + { + "comments": comments, + "is_recent": is_recent, + "is_regex": is_regex, + "is_similarity": is_similarity, + "pattern": pattern, + }, + trusted_domain_edit_params.TrustedDomainEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[TrustedDomainEditResponse]._unwrapper, + ), + cast_to=cast(Type[TrustedDomainEditResponse], ResultWrapper[TrustedDomainEditResponse]), + ) + + async def get( + self, + trusted_domain_id: int, + *, + account_id: str, + # 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, + ) -> TrustedDomainGetResponse: + """ + Get a trusted email domain + + Args: + account_id: Account Identifier + + trusted_domain_id: The unique identifier for the trusted domain. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + f"/accounts/{account_id}/email-security/settings/trusted_domains/{trusted_domain_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[TrustedDomainGetResponse]._unwrapper, + ), + cast_to=cast(Type[TrustedDomainGetResponse], ResultWrapper[TrustedDomainGetResponse]), + ) + class TrustedDomainsResourceWithRawResponse: def __init__(self, trusted_domains: TrustedDomainsResource) -> None: @@ -455,6 +756,15 @@ def __init__(self, trusted_domains: TrustedDomainsResource) -> None: self.list = to_raw_response_wrapper( trusted_domains.list, ) + self.delete = to_raw_response_wrapper( + trusted_domains.delete, + ) + self.edit = to_raw_response_wrapper( + trusted_domains.edit, + ) + self.get = to_raw_response_wrapper( + trusted_domains.get, + ) class AsyncTrustedDomainsResourceWithRawResponse: @@ -467,6 +777,15 @@ def __init__(self, trusted_domains: AsyncTrustedDomainsResource) -> None: self.list = async_to_raw_response_wrapper( trusted_domains.list, ) + self.delete = async_to_raw_response_wrapper( + trusted_domains.delete, + ) + self.edit = async_to_raw_response_wrapper( + trusted_domains.edit, + ) + self.get = async_to_raw_response_wrapper( + trusted_domains.get, + ) class TrustedDomainsResourceWithStreamingResponse: @@ -479,6 +798,15 @@ def __init__(self, trusted_domains: TrustedDomainsResource) -> None: self.list = to_streamed_response_wrapper( trusted_domains.list, ) + self.delete = to_streamed_response_wrapper( + trusted_domains.delete, + ) + self.edit = to_streamed_response_wrapper( + trusted_domains.edit, + ) + self.get = to_streamed_response_wrapper( + trusted_domains.get, + ) class AsyncTrustedDomainsResourceWithStreamingResponse: @@ -491,3 +819,12 @@ def __init__(self, trusted_domains: AsyncTrustedDomainsResource) -> None: self.list = async_to_streamed_response_wrapper( trusted_domains.list, ) + self.delete = async_to_streamed_response_wrapper( + trusted_domains.delete, + ) + self.edit = async_to_streamed_response_wrapper( + trusted_domains.edit, + ) + self.get = async_to_streamed_response_wrapper( + trusted_domains.get, + ) diff --git a/src/cloudflare/resources/resource_sharing/__init__.py b/src/cloudflare/resources/resource_sharing/__init__.py index ecae72f2f38..3f72b0bc713 100644 --- a/src/cloudflare/resources/resource_sharing/__init__.py +++ b/src/cloudflare/resources/resource_sharing/__init__.py @@ -1,5 +1,21 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +from .resources import ( + ResourcesResource, + AsyncResourcesResource, + ResourcesResourceWithRawResponse, + AsyncResourcesResourceWithRawResponse, + ResourcesResourceWithStreamingResponse, + AsyncResourcesResourceWithStreamingResponse, +) +from .recipients import ( + RecipientsResource, + AsyncRecipientsResource, + RecipientsResourceWithRawResponse, + AsyncRecipientsResourceWithRawResponse, + RecipientsResourceWithStreamingResponse, + AsyncRecipientsResourceWithStreamingResponse, +) from .resource_sharing import ( ResourceSharingResource, AsyncResourceSharingResource, @@ -10,6 +26,18 @@ ) __all__ = [ + "RecipientsResource", + "AsyncRecipientsResource", + "RecipientsResourceWithRawResponse", + "AsyncRecipientsResourceWithRawResponse", + "RecipientsResourceWithStreamingResponse", + "AsyncRecipientsResourceWithStreamingResponse", + "ResourcesResource", + "AsyncResourcesResource", + "ResourcesResourceWithRawResponse", + "AsyncResourcesResourceWithRawResponse", + "ResourcesResourceWithStreamingResponse", + "AsyncResourcesResourceWithStreamingResponse", "ResourceSharingResource", "AsyncResourceSharingResource", "ResourceSharingResourceWithRawResponse", diff --git a/src/cloudflare/resources/resource_sharing/recipients.py b/src/cloudflare/resources/resource_sharing/recipients.py new file mode 100644 index 00000000000..396111d8ca4 --- /dev/null +++ b/src/cloudflare/resources/resource_sharing/recipients.py @@ -0,0 +1,571 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Optional, cast + +import httpx + +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._utils import ( + maybe_transform, + async_maybe_transform, +) +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from ..._base_client import AsyncPaginator, make_request_options +from ...types.resource_sharing import recipient_list_params, recipient_create_params +from ...types.resource_sharing.recipient_get_response import RecipientGetResponse +from ...types.resource_sharing.recipient_list_response import RecipientListResponse +from ...types.resource_sharing.recipient_create_response import RecipientCreateResponse +from ...types.resource_sharing.recipient_delete_response import RecipientDeleteResponse + +__all__ = ["RecipientsResource", "AsyncRecipientsResource"] + + +class RecipientsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> RecipientsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return the + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return RecipientsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> RecipientsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return RecipientsResourceWithStreamingResponse(self) + + def create( + self, + share_id: str, + *, + path_account_id: str, + body_account_id: str | NotGiven = NOT_GIVEN, + organization_id: str | NotGiven = NOT_GIVEN, + # 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, + ) -> Optional[RecipientCreateResponse]: + """ + Create a new share recipient + + Args: + path_account_id: Account identifier. + + share_id: Share identifier tag. + + body_account_id: Account identifier. + + organization_id: Organization identifier. + + 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 path_account_id: + raise ValueError(f"Expected a non-empty value for `path_account_id` but received {path_account_id!r}") + if not share_id: + raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") + return self._post( + f"/accounts/{path_account_id}/shares/{share_id}/recipients", + body=maybe_transform( + { + "body_account_id": body_account_id, + "organization_id": organization_id, + }, + recipient_create_params.RecipientCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[RecipientCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[RecipientCreateResponse]], ResultWrapper[RecipientCreateResponse]), + ) + + def list( + self, + share_id: str, + *, + account_id: str, + page: int | NotGiven = NOT_GIVEN, + per_page: int | NotGiven = NOT_GIVEN, + # 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, + ) -> SyncV4PagePaginationArray[RecipientListResponse]: + """ + List share recipients by share ID. + + Args: + account_id: Account identifier. + + share_id: Share identifier tag. + + page: Page number. + + per_page: Number of objects to return per page. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not share_id: + raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/shares/{share_id}/recipients", + page=SyncV4PagePaginationArray[RecipientListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "page": page, + "per_page": per_page, + }, + recipient_list_params.RecipientListParams, + ), + ), + model=RecipientListResponse, + ) + + def delete( + self, + recipient_id: str, + *, + account_id: str, + share_id: str, + # 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, + ) -> Optional[RecipientDeleteResponse]: + """ + Deletion is not immediate, an updated share recipient object with a new status + will be returned. + + Args: + account_id: Account identifier. + + share_id: Share identifier tag. + + recipient_id: Share Recipient identifier tag. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not share_id: + raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") + if not recipient_id: + raise ValueError(f"Expected a non-empty value for `recipient_id` but received {recipient_id!r}") + return self._delete( + f"/accounts/{account_id}/shares/{share_id}/recipients/{recipient_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[RecipientDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[RecipientDeleteResponse]], ResultWrapper[RecipientDeleteResponse]), + ) + + def get( + self, + recipient_id: str, + *, + account_id: str, + share_id: str, + # 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, + ) -> Optional[RecipientGetResponse]: + """ + Get share recipient by ID. + + Args: + account_id: Account identifier. + + share_id: Share identifier tag. + + recipient_id: Share Recipient identifier tag. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not share_id: + raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") + if not recipient_id: + raise ValueError(f"Expected a non-empty value for `recipient_id` but received {recipient_id!r}") + return self._get( + f"/accounts/{account_id}/shares/{share_id}/recipients/{recipient_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[RecipientGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[RecipientGetResponse]], ResultWrapper[RecipientGetResponse]), + ) + + +class AsyncRecipientsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncRecipientsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return the + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncRecipientsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncRecipientsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncRecipientsResourceWithStreamingResponse(self) + + async def create( + self, + share_id: str, + *, + path_account_id: str, + body_account_id: str | NotGiven = NOT_GIVEN, + organization_id: str | NotGiven = NOT_GIVEN, + # 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, + ) -> Optional[RecipientCreateResponse]: + """ + Create a new share recipient + + Args: + path_account_id: Account identifier. + + share_id: Share identifier tag. + + body_account_id: Account identifier. + + organization_id: Organization identifier. + + 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 path_account_id: + raise ValueError(f"Expected a non-empty value for `path_account_id` but received {path_account_id!r}") + if not share_id: + raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") + return await self._post( + f"/accounts/{path_account_id}/shares/{share_id}/recipients", + body=await async_maybe_transform( + { + "body_account_id": body_account_id, + "organization_id": organization_id, + }, + recipient_create_params.RecipientCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[RecipientCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[RecipientCreateResponse]], ResultWrapper[RecipientCreateResponse]), + ) + + def list( + self, + share_id: str, + *, + account_id: str, + page: int | NotGiven = NOT_GIVEN, + per_page: int | NotGiven = NOT_GIVEN, + # 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, + ) -> AsyncPaginator[RecipientListResponse, AsyncV4PagePaginationArray[RecipientListResponse]]: + """ + List share recipients by share ID. + + Args: + account_id: Account identifier. + + share_id: Share identifier tag. + + page: Page number. + + per_page: Number of objects to return per page. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not share_id: + raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/shares/{share_id}/recipients", + page=AsyncV4PagePaginationArray[RecipientListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "page": page, + "per_page": per_page, + }, + recipient_list_params.RecipientListParams, + ), + ), + model=RecipientListResponse, + ) + + async def delete( + self, + recipient_id: str, + *, + account_id: str, + share_id: str, + # 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, + ) -> Optional[RecipientDeleteResponse]: + """ + Deletion is not immediate, an updated share recipient object with a new status + will be returned. + + Args: + account_id: Account identifier. + + share_id: Share identifier tag. + + recipient_id: Share Recipient identifier tag. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not share_id: + raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") + if not recipient_id: + raise ValueError(f"Expected a non-empty value for `recipient_id` but received {recipient_id!r}") + return await self._delete( + f"/accounts/{account_id}/shares/{share_id}/recipients/{recipient_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[RecipientDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[RecipientDeleteResponse]], ResultWrapper[RecipientDeleteResponse]), + ) + + async def get( + self, + recipient_id: str, + *, + account_id: str, + share_id: str, + # 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, + ) -> Optional[RecipientGetResponse]: + """ + Get share recipient by ID. + + Args: + account_id: Account identifier. + + share_id: Share identifier tag. + + recipient_id: Share Recipient identifier tag. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not share_id: + raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") + if not recipient_id: + raise ValueError(f"Expected a non-empty value for `recipient_id` but received {recipient_id!r}") + return await self._get( + f"/accounts/{account_id}/shares/{share_id}/recipients/{recipient_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[RecipientGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[RecipientGetResponse]], ResultWrapper[RecipientGetResponse]), + ) + + +class RecipientsResourceWithRawResponse: + def __init__(self, recipients: RecipientsResource) -> None: + self._recipients = recipients + + self.create = to_raw_response_wrapper( + recipients.create, + ) + self.list = to_raw_response_wrapper( + recipients.list, + ) + self.delete = to_raw_response_wrapper( + recipients.delete, + ) + self.get = to_raw_response_wrapper( + recipients.get, + ) + + +class AsyncRecipientsResourceWithRawResponse: + def __init__(self, recipients: AsyncRecipientsResource) -> None: + self._recipients = recipients + + self.create = async_to_raw_response_wrapper( + recipients.create, + ) + self.list = async_to_raw_response_wrapper( + recipients.list, + ) + self.delete = async_to_raw_response_wrapper( + recipients.delete, + ) + self.get = async_to_raw_response_wrapper( + recipients.get, + ) + + +class RecipientsResourceWithStreamingResponse: + def __init__(self, recipients: RecipientsResource) -> None: + self._recipients = recipients + + self.create = to_streamed_response_wrapper( + recipients.create, + ) + self.list = to_streamed_response_wrapper( + recipients.list, + ) + self.delete = to_streamed_response_wrapper( + recipients.delete, + ) + self.get = to_streamed_response_wrapper( + recipients.get, + ) + + +class AsyncRecipientsResourceWithStreamingResponse: + def __init__(self, recipients: AsyncRecipientsResource) -> None: + self._recipients = recipients + + self.create = async_to_streamed_response_wrapper( + recipients.create, + ) + self.list = async_to_streamed_response_wrapper( + recipients.list, + ) + self.delete = async_to_streamed_response_wrapper( + recipients.delete, + ) + self.get = async_to_streamed_response_wrapper( + recipients.get, + ) diff --git a/src/cloudflare/resources/resource_sharing/resource_sharing.py b/src/cloudflare/resources/resource_sharing/resource_sharing.py index 0267bb390f0..68a7946efd5 100644 --- a/src/cloudflare/resources/resource_sharing/resource_sharing.py +++ b/src/cloudflare/resources/resource_sharing/resource_sharing.py @@ -13,6 +13,22 @@ async_maybe_transform, ) from ..._compat import cached_property +from .resources import ( + ResourcesResource, + AsyncResourcesResource, + ResourcesResourceWithRawResponse, + AsyncResourcesResourceWithRawResponse, + ResourcesResourceWithStreamingResponse, + AsyncResourcesResourceWithStreamingResponse, +) +from .recipients import ( + RecipientsResource, + AsyncRecipientsResource, + RecipientsResourceWithRawResponse, + AsyncRecipientsResourceWithRawResponse, + RecipientsResourceWithStreamingResponse, + AsyncRecipientsResourceWithStreamingResponse, +) from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( to_raw_response_wrapper, @@ -23,14 +39,29 @@ from ..._wrappers import ResultWrapper from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray from ..._base_client import AsyncPaginator, make_request_options -from ...types.resource_sharing import resource_sharing_list_params, resource_sharing_create_params +from ...types.resource_sharing import ( + resource_sharing_list_params, + resource_sharing_create_params, + resource_sharing_update_params, +) +from ...types.resource_sharing.resource_sharing_get_response import ResourceSharingGetResponse from ...types.resource_sharing.resource_sharing_list_response import ResourceSharingListResponse from ...types.resource_sharing.resource_sharing_create_response import ResourceSharingCreateResponse +from ...types.resource_sharing.resource_sharing_delete_response import ResourceSharingDeleteResponse +from ...types.resource_sharing.resource_sharing_update_response import ResourceSharingUpdateResponse __all__ = ["ResourceSharingResource", "AsyncResourceSharingResource"] class ResourceSharingResource(SyncAPIResource): + @cached_property + def recipients(self) -> RecipientsResource: + return RecipientsResource(self._client) + + @cached_property + def resources(self) -> ResourcesResource: + return ResourcesResource(self._client) + @cached_property def with_raw_response(self) -> ResourceSharingResourceWithRawResponse: """ @@ -102,6 +133,55 @@ def create( cast_to=cast(Type[Optional[ResourceSharingCreateResponse]], ResultWrapper[ResourceSharingCreateResponse]), ) + def update( + self, + share_id: str, + *, + account_id: str, + name: str, + # 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, + ) -> Optional[ResourceSharingUpdateResponse]: + """ + Updating is not immediate, an updated share object with a new status will be + returned. + + Args: + account_id: Account identifier. + + share_id: Share identifier tag. + + name: The name of the share. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not share_id: + raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") + return self._put( + f"/accounts/{account_id}/shares/{share_id}", + body=maybe_transform({"name": name}, resource_sharing_update_params.ResourceSharingUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ResourceSharingUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ResourceSharingUpdateResponse]], ResultWrapper[ResourceSharingUpdateResponse]), + ) + def list( self, *, @@ -174,8 +254,105 @@ def list( model=ResourceSharingListResponse, ) + def delete( + self, + share_id: str, + *, + account_id: str, + # 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, + ) -> Optional[ResourceSharingDeleteResponse]: + """ + Deletion is not immediate, an updated share object with a new status will be + returned. + + Args: + account_id: Account identifier. + + share_id: Share identifier tag. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not share_id: + raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") + return self._delete( + f"/accounts/{account_id}/shares/{share_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ResourceSharingDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ResourceSharingDeleteResponse]], ResultWrapper[ResourceSharingDeleteResponse]), + ) + + def get( + self, + share_id: str, + *, + account_id: str, + # 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, + ) -> Optional[ResourceSharingGetResponse]: + """ + Fetches share by ID. + + Args: + account_id: Account identifier. + + share_id: Share identifier tag. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not share_id: + raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") + return self._get( + f"/accounts/{account_id}/shares/{share_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ResourceSharingGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ResourceSharingGetResponse]], ResultWrapper[ResourceSharingGetResponse]), + ) + class AsyncResourceSharingResource(AsyncAPIResource): + @cached_property + def recipients(self) -> AsyncRecipientsResource: + return AsyncRecipientsResource(self._client) + + @cached_property + def resources(self) -> AsyncResourcesResource: + return AsyncResourcesResource(self._client) + @cached_property def with_raw_response(self) -> AsyncResourceSharingResourceWithRawResponse: """ @@ -247,6 +424,57 @@ async def create( cast_to=cast(Type[Optional[ResourceSharingCreateResponse]], ResultWrapper[ResourceSharingCreateResponse]), ) + async def update( + self, + share_id: str, + *, + account_id: str, + name: str, + # 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, + ) -> Optional[ResourceSharingUpdateResponse]: + """ + Updating is not immediate, an updated share object with a new status will be + returned. + + Args: + account_id: Account identifier. + + share_id: Share identifier tag. + + name: The name of the share. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not share_id: + raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") + return await self._put( + f"/accounts/{account_id}/shares/{share_id}", + body=await async_maybe_transform( + {"name": name}, resource_sharing_update_params.ResourceSharingUpdateParams + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ResourceSharingUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ResourceSharingUpdateResponse]], ResultWrapper[ResourceSharingUpdateResponse]), + ) + def list( self, *, @@ -319,6 +547,95 @@ def list( model=ResourceSharingListResponse, ) + async def delete( + self, + share_id: str, + *, + account_id: str, + # 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, + ) -> Optional[ResourceSharingDeleteResponse]: + """ + Deletion is not immediate, an updated share object with a new status will be + returned. + + Args: + account_id: Account identifier. + + share_id: Share identifier tag. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not share_id: + raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") + return await self._delete( + f"/accounts/{account_id}/shares/{share_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ResourceSharingDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ResourceSharingDeleteResponse]], ResultWrapper[ResourceSharingDeleteResponse]), + ) + + async def get( + self, + share_id: str, + *, + account_id: str, + # 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, + ) -> Optional[ResourceSharingGetResponse]: + """ + Fetches share by ID. + + Args: + account_id: Account identifier. + + share_id: Share identifier tag. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not share_id: + raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") + return await self._get( + f"/accounts/{account_id}/shares/{share_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ResourceSharingGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ResourceSharingGetResponse]], ResultWrapper[ResourceSharingGetResponse]), + ) + class ResourceSharingResourceWithRawResponse: def __init__(self, resource_sharing: ResourceSharingResource) -> None: @@ -327,9 +644,26 @@ def __init__(self, resource_sharing: ResourceSharingResource) -> None: self.create = to_raw_response_wrapper( resource_sharing.create, ) + self.update = to_raw_response_wrapper( + resource_sharing.update, + ) self.list = to_raw_response_wrapper( resource_sharing.list, ) + self.delete = to_raw_response_wrapper( + resource_sharing.delete, + ) + self.get = to_raw_response_wrapper( + resource_sharing.get, + ) + + @cached_property + def recipients(self) -> RecipientsResourceWithRawResponse: + return RecipientsResourceWithRawResponse(self._resource_sharing.recipients) + + @cached_property + def resources(self) -> ResourcesResourceWithRawResponse: + return ResourcesResourceWithRawResponse(self._resource_sharing.resources) class AsyncResourceSharingResourceWithRawResponse: @@ -339,9 +673,26 @@ def __init__(self, resource_sharing: AsyncResourceSharingResource) -> None: self.create = async_to_raw_response_wrapper( resource_sharing.create, ) + self.update = async_to_raw_response_wrapper( + resource_sharing.update, + ) self.list = async_to_raw_response_wrapper( resource_sharing.list, ) + self.delete = async_to_raw_response_wrapper( + resource_sharing.delete, + ) + self.get = async_to_raw_response_wrapper( + resource_sharing.get, + ) + + @cached_property + def recipients(self) -> AsyncRecipientsResourceWithRawResponse: + return AsyncRecipientsResourceWithRawResponse(self._resource_sharing.recipients) + + @cached_property + def resources(self) -> AsyncResourcesResourceWithRawResponse: + return AsyncResourcesResourceWithRawResponse(self._resource_sharing.resources) class ResourceSharingResourceWithStreamingResponse: @@ -351,9 +702,26 @@ def __init__(self, resource_sharing: ResourceSharingResource) -> None: self.create = to_streamed_response_wrapper( resource_sharing.create, ) + self.update = to_streamed_response_wrapper( + resource_sharing.update, + ) self.list = to_streamed_response_wrapper( resource_sharing.list, ) + self.delete = to_streamed_response_wrapper( + resource_sharing.delete, + ) + self.get = to_streamed_response_wrapper( + resource_sharing.get, + ) + + @cached_property + def recipients(self) -> RecipientsResourceWithStreamingResponse: + return RecipientsResourceWithStreamingResponse(self._resource_sharing.recipients) + + @cached_property + def resources(self) -> ResourcesResourceWithStreamingResponse: + return ResourcesResourceWithStreamingResponse(self._resource_sharing.resources) class AsyncResourceSharingResourceWithStreamingResponse: @@ -363,6 +731,23 @@ def __init__(self, resource_sharing: AsyncResourceSharingResource) -> None: self.create = async_to_streamed_response_wrapper( resource_sharing.create, ) + self.update = async_to_streamed_response_wrapper( + resource_sharing.update, + ) self.list = async_to_streamed_response_wrapper( resource_sharing.list, ) + self.delete = async_to_streamed_response_wrapper( + resource_sharing.delete, + ) + self.get = async_to_streamed_response_wrapper( + resource_sharing.get, + ) + + @cached_property + def recipients(self) -> AsyncRecipientsResourceWithStreamingResponse: + return AsyncRecipientsResourceWithStreamingResponse(self._resource_sharing.recipients) + + @cached_property + def resources(self) -> AsyncResourcesResourceWithStreamingResponse: + return AsyncResourcesResourceWithStreamingResponse(self._resource_sharing.resources) diff --git a/src/cloudflare/resources/resource_sharing/resources.py b/src/cloudflare/resources/resource_sharing/resources.py new file mode 100644 index 00000000000..b1e08158019 --- /dev/null +++ b/src/cloudflare/resources/resource_sharing/resources.py @@ -0,0 +1,725 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Optional, cast +from typing_extensions import Literal + +import httpx + +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._utils import ( + maybe_transform, + async_maybe_transform, +) +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from ..._base_client import AsyncPaginator, make_request_options +from ...types.resource_sharing import resource_list_params, resource_create_params, resource_update_params +from ...types.resource_sharing.resource_get_response import ResourceGetResponse +from ...types.resource_sharing.resource_list_response import ResourceListResponse +from ...types.resource_sharing.resource_create_response import ResourceCreateResponse +from ...types.resource_sharing.resource_delete_response import ResourceDeleteResponse +from ...types.resource_sharing.resource_update_response import ResourceUpdateResponse + +__all__ = ["ResourcesResource", "AsyncResourcesResource"] + + +class ResourcesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ResourcesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return the + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return ResourcesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ResourcesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return ResourcesResourceWithStreamingResponse(self) + + def create( + self, + share_id: str, + *, + account_id: str, + meta: object, + resource_account_id: str, + resource_id: str, + resource_type: Literal["custom-ruleset", "widget"], + # 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, + ) -> Optional[ResourceCreateResponse]: + """ + Create a new share resource + + Args: + account_id: Account identifier. + + share_id: Share identifier tag. + + meta: Resource Metadata. + + resource_account_id: Account identifier. + + resource_id: Share Resource identifier. + + resource_type: Resource Type. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not share_id: + raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") + return self._post( + f"/accounts/{account_id}/shares/{share_id}/resources", + body=maybe_transform( + { + "meta": meta, + "resource_account_id": resource_account_id, + "resource_id": resource_id, + "resource_type": resource_type, + }, + resource_create_params.ResourceCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ResourceCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ResourceCreateResponse]], ResultWrapper[ResourceCreateResponse]), + ) + + def update( + self, + resource_id: str, + *, + account_id: str, + share_id: str, + meta: object, + # 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, + ) -> Optional[ResourceUpdateResponse]: + """ + Update is not immediate, an updated share resource object with a new status will + be returned. + + Args: + account_id: Account identifier. + + share_id: Share identifier tag. + + resource_id: Share Resource identifier. + + meta: Resource Metadata. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not share_id: + raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") + if not resource_id: + raise ValueError(f"Expected a non-empty value for `resource_id` but received {resource_id!r}") + return self._put( + f"/accounts/{account_id}/shares/{share_id}/resources/{resource_id}", + body=maybe_transform({"meta": meta}, resource_update_params.ResourceUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ResourceUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ResourceUpdateResponse]], ResultWrapper[ResourceUpdateResponse]), + ) + + def list( + self, + share_id: str, + *, + account_id: str, + page: int | NotGiven = NOT_GIVEN, + per_page: int | NotGiven = NOT_GIVEN, + resource_type: Literal["custom-ruleset", "widget"] | NotGiven = NOT_GIVEN, + status: Literal["active", "deleting", "deleted"] | NotGiven = NOT_GIVEN, + # 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, + ) -> SyncV4PagePaginationArray[ResourceListResponse]: + """ + List share resources by share ID. + + Args: + account_id: Account identifier. + + share_id: Share identifier tag. + + page: Page number. + + per_page: Number of objects to return per page. + + resource_type: Filter share resources by resource_type. + + status: Filter share resources by status. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not share_id: + raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/shares/{share_id}/resources", + page=SyncV4PagePaginationArray[ResourceListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "page": page, + "per_page": per_page, + "resource_type": resource_type, + "status": status, + }, + resource_list_params.ResourceListParams, + ), + ), + model=ResourceListResponse, + ) + + def delete( + self, + resource_id: str, + *, + account_id: str, + share_id: str, + # 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, + ) -> Optional[ResourceDeleteResponse]: + """ + Deletion is not immediate, an updated share resource object with a new status + will be returned. + + Args: + account_id: Account identifier. + + share_id: Share identifier tag. + + resource_id: Share Resource identifier. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not share_id: + raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") + if not resource_id: + raise ValueError(f"Expected a non-empty value for `resource_id` but received {resource_id!r}") + return self._delete( + f"/accounts/{account_id}/shares/{share_id}/resources/{resource_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ResourceDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ResourceDeleteResponse]], ResultWrapper[ResourceDeleteResponse]), + ) + + def get( + self, + resource_id: str, + *, + account_id: str, + share_id: str, + # 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, + ) -> Optional[ResourceGetResponse]: + """ + Get share resource by ID. + + Args: + account_id: Account identifier. + + share_id: Share identifier tag. + + resource_id: Share Resource identifier. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not share_id: + raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") + if not resource_id: + raise ValueError(f"Expected a non-empty value for `resource_id` but received {resource_id!r}") + return self._get( + f"/accounts/{account_id}/shares/{share_id}/resources/{resource_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ResourceGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ResourceGetResponse]], ResultWrapper[ResourceGetResponse]), + ) + + +class AsyncResourcesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncResourcesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return the + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncResourcesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncResourcesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncResourcesResourceWithStreamingResponse(self) + + async def create( + self, + share_id: str, + *, + account_id: str, + meta: object, + resource_account_id: str, + resource_id: str, + resource_type: Literal["custom-ruleset", "widget"], + # 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, + ) -> Optional[ResourceCreateResponse]: + """ + Create a new share resource + + Args: + account_id: Account identifier. + + share_id: Share identifier tag. + + meta: Resource Metadata. + + resource_account_id: Account identifier. + + resource_id: Share Resource identifier. + + resource_type: Resource Type. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not share_id: + raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") + return await self._post( + f"/accounts/{account_id}/shares/{share_id}/resources", + body=await async_maybe_transform( + { + "meta": meta, + "resource_account_id": resource_account_id, + "resource_id": resource_id, + "resource_type": resource_type, + }, + resource_create_params.ResourceCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ResourceCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ResourceCreateResponse]], ResultWrapper[ResourceCreateResponse]), + ) + + async def update( + self, + resource_id: str, + *, + account_id: str, + share_id: str, + meta: object, + # 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, + ) -> Optional[ResourceUpdateResponse]: + """ + Update is not immediate, an updated share resource object with a new status will + be returned. + + Args: + account_id: Account identifier. + + share_id: Share identifier tag. + + resource_id: Share Resource identifier. + + meta: Resource Metadata. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not share_id: + raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") + if not resource_id: + raise ValueError(f"Expected a non-empty value for `resource_id` but received {resource_id!r}") + return await self._put( + f"/accounts/{account_id}/shares/{share_id}/resources/{resource_id}", + body=await async_maybe_transform({"meta": meta}, resource_update_params.ResourceUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ResourceUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ResourceUpdateResponse]], ResultWrapper[ResourceUpdateResponse]), + ) + + def list( + self, + share_id: str, + *, + account_id: str, + page: int | NotGiven = NOT_GIVEN, + per_page: int | NotGiven = NOT_GIVEN, + resource_type: Literal["custom-ruleset", "widget"] | NotGiven = NOT_GIVEN, + status: Literal["active", "deleting", "deleted"] | NotGiven = NOT_GIVEN, + # 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, + ) -> AsyncPaginator[ResourceListResponse, AsyncV4PagePaginationArray[ResourceListResponse]]: + """ + List share resources by share ID. + + Args: + account_id: Account identifier. + + share_id: Share identifier tag. + + page: Page number. + + per_page: Number of objects to return per page. + + resource_type: Filter share resources by resource_type. + + status: Filter share resources by status. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not share_id: + raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/shares/{share_id}/resources", + page=AsyncV4PagePaginationArray[ResourceListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "page": page, + "per_page": per_page, + "resource_type": resource_type, + "status": status, + }, + resource_list_params.ResourceListParams, + ), + ), + model=ResourceListResponse, + ) + + async def delete( + self, + resource_id: str, + *, + account_id: str, + share_id: str, + # 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, + ) -> Optional[ResourceDeleteResponse]: + """ + Deletion is not immediate, an updated share resource object with a new status + will be returned. + + Args: + account_id: Account identifier. + + share_id: Share identifier tag. + + resource_id: Share Resource identifier. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not share_id: + raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") + if not resource_id: + raise ValueError(f"Expected a non-empty value for `resource_id` but received {resource_id!r}") + return await self._delete( + f"/accounts/{account_id}/shares/{share_id}/resources/{resource_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ResourceDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ResourceDeleteResponse]], ResultWrapper[ResourceDeleteResponse]), + ) + + async def get( + self, + resource_id: str, + *, + account_id: str, + share_id: str, + # 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, + ) -> Optional[ResourceGetResponse]: + """ + Get share resource by ID. + + Args: + account_id: Account identifier. + + share_id: Share identifier tag. + + resource_id: Share Resource identifier. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not share_id: + raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") + if not resource_id: + raise ValueError(f"Expected a non-empty value for `resource_id` but received {resource_id!r}") + return await self._get( + f"/accounts/{account_id}/shares/{share_id}/resources/{resource_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ResourceGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ResourceGetResponse]], ResultWrapper[ResourceGetResponse]), + ) + + +class ResourcesResourceWithRawResponse: + def __init__(self, resources: ResourcesResource) -> None: + self._resources = resources + + self.create = to_raw_response_wrapper( + resources.create, + ) + self.update = to_raw_response_wrapper( + resources.update, + ) + self.list = to_raw_response_wrapper( + resources.list, + ) + self.delete = to_raw_response_wrapper( + resources.delete, + ) + self.get = to_raw_response_wrapper( + resources.get, + ) + + +class AsyncResourcesResourceWithRawResponse: + def __init__(self, resources: AsyncResourcesResource) -> None: + self._resources = resources + + self.create = async_to_raw_response_wrapper( + resources.create, + ) + self.update = async_to_raw_response_wrapper( + resources.update, + ) + self.list = async_to_raw_response_wrapper( + resources.list, + ) + self.delete = async_to_raw_response_wrapper( + resources.delete, + ) + self.get = async_to_raw_response_wrapper( + resources.get, + ) + + +class ResourcesResourceWithStreamingResponse: + def __init__(self, resources: ResourcesResource) -> None: + self._resources = resources + + self.create = to_streamed_response_wrapper( + resources.create, + ) + self.update = to_streamed_response_wrapper( + resources.update, + ) + self.list = to_streamed_response_wrapper( + resources.list, + ) + self.delete = to_streamed_response_wrapper( + resources.delete, + ) + self.get = to_streamed_response_wrapper( + resources.get, + ) + + +class AsyncResourcesResourceWithStreamingResponse: + def __init__(self, resources: AsyncResourcesResource) -> None: + self._resources = resources + + self.create = async_to_streamed_response_wrapper( + resources.create, + ) + self.update = async_to_streamed_response_wrapper( + resources.update, + ) + self.list = async_to_streamed_response_wrapper( + resources.list, + ) + self.delete = async_to_streamed_response_wrapper( + resources.delete, + ) + self.get = async_to_streamed_response_wrapper( + resources.get, + ) diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_list_params.py b/src/cloudflare/types/ai_gateway/ai_gateway_list_params.py index a363b567a3f..4210334aa47 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_list_params.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_list_params.py @@ -19,6 +19,3 @@ class AIGatewayListParams(TypedDict, total=False): page: int per_page: int - - search: str - """Search by id""" diff --git a/src/cloudflare/types/dnssec/dnssec_delete_response.py b/src/cloudflare/types/dnssec/dnssec_delete_response.py index 895a6c00234..98446b72cf8 100644 --- a/src/cloudflare/types/dnssec/dnssec_delete_response.py +++ b/src/cloudflare/types/dnssec/dnssec_delete_response.py @@ -1,7 +1,8 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +from typing import Union from typing_extensions import TypeAlias __all__ = ["DNSSECDeleteResponse"] -DNSSECDeleteResponse: TypeAlias = str +DNSSECDeleteResponse: TypeAlias = Union[str, object] diff --git a/src/cloudflare/types/email_security/settings/__init__.py b/src/cloudflare/types/email_security/settings/__init__.py index f549ba0d676..26c5fc41f06 100644 --- a/src/cloudflare/types/email_security/settings/__init__.py +++ b/src/cloudflare/types/email_security/settings/__init__.py @@ -20,15 +20,19 @@ from .block_sender_create_params import BlockSenderCreateParams as BlockSenderCreateParams from .block_sender_edit_response import BlockSenderEditResponse as BlockSenderEditResponse from .block_sender_list_response import BlockSenderListResponse as BlockSenderListResponse +from .trusted_domain_edit_params import TrustedDomainEditParams as TrustedDomainEditParams from .trusted_domain_list_params import TrustedDomainListParams as TrustedDomainListParams from .domain_bulk_delete_response import DomainBulkDeleteResponse as DomainBulkDeleteResponse +from .trusted_domain_get_response import TrustedDomainGetResponse as TrustedDomainGetResponse from .allow_policy_create_response import AllowPolicyCreateResponse as AllowPolicyCreateResponse from .allow_policy_delete_response import AllowPolicyDeleteResponse as AllowPolicyDeleteResponse from .block_sender_create_response import BlockSenderCreateResponse as BlockSenderCreateResponse from .block_sender_delete_response import BlockSenderDeleteResponse as BlockSenderDeleteResponse from .trusted_domain_create_params import TrustedDomainCreateParams as TrustedDomainCreateParams +from .trusted_domain_edit_response import TrustedDomainEditResponse as TrustedDomainEditResponse from .trusted_domain_list_response import TrustedDomainListResponse as TrustedDomainListResponse from .trusted_domain_create_response import TrustedDomainCreateResponse as TrustedDomainCreateResponse +from .trusted_domain_delete_response import TrustedDomainDeleteResponse as TrustedDomainDeleteResponse from .impersonation_registry_edit_params import ImpersonationRegistryEditParams as ImpersonationRegistryEditParams from .impersonation_registry_list_params import ImpersonationRegistryListParams as ImpersonationRegistryListParams from .impersonation_registry_get_response import ImpersonationRegistryGetResponse as ImpersonationRegistryGetResponse diff --git a/src/cloudflare/types/email_security/settings/trusted_domain_delete_response.py b/src/cloudflare/types/email_security/settings/trusted_domain_delete_response.py new file mode 100644 index 00000000000..9a4f06ca83f --- /dev/null +++ b/src/cloudflare/types/email_security/settings/trusted_domain_delete_response.py @@ -0,0 +1,11 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +from ...._models import BaseModel + +__all__ = ["TrustedDomainDeleteResponse"] + + +class TrustedDomainDeleteResponse(BaseModel): + id: int + """The unique identifier for the trusted domain.""" diff --git a/src/cloudflare/types/email_security/settings/trusted_domain_edit_params.py b/src/cloudflare/types/email_security/settings/trusted_domain_edit_params.py new file mode 100644 index 00000000000..0dcdda7c0ef --- /dev/null +++ b/src/cloudflare/types/email_security/settings/trusted_domain_edit_params.py @@ -0,0 +1,31 @@ +# 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__ = ["TrustedDomainEditParams"] + + +class TrustedDomainEditParams(TypedDict, total=False): + account_id: Required[str] + """Account Identifier""" + + comments: Optional[str] + + is_recent: Optional[bool] + """ + Select to prevent recently registered domains from triggering a Suspicious or + Malicious disposition. + """ + + is_regex: Optional[bool] + + is_similarity: Optional[bool] + """ + Select for partner or other approved domains that have similar spelling to your + connected domains. Prevents listed domains from triggering a Spoof disposition. + """ + + pattern: Optional[str] diff --git a/src/cloudflare/types/email_security/settings/trusted_domain_edit_response.py b/src/cloudflare/types/email_security/settings/trusted_domain_edit_response.py new file mode 100644 index 00000000000..eb86a0bfebc --- /dev/null +++ b/src/cloudflare/types/email_security/settings/trusted_domain_edit_response.py @@ -0,0 +1,35 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime + +from ...._models import BaseModel + +__all__ = ["TrustedDomainEditResponse"] + + +class TrustedDomainEditResponse(BaseModel): + id: int + """The unique identifier for the trusted domain.""" + + created_at: datetime + + is_recent: bool + """ + Select to prevent recently registered domains from triggering a Suspicious or + Malicious disposition. + """ + + is_regex: bool + + is_similarity: bool + """ + Select for partner or other approved domains that have similar spelling to your + connected domains. Prevents listed domains from triggering a Spoof disposition. + """ + + last_modified: datetime + + pattern: str + + comments: Optional[str] = None diff --git a/src/cloudflare/types/email_security/settings/trusted_domain_get_response.py b/src/cloudflare/types/email_security/settings/trusted_domain_get_response.py new file mode 100644 index 00000000000..23b217fa8d7 --- /dev/null +++ b/src/cloudflare/types/email_security/settings/trusted_domain_get_response.py @@ -0,0 +1,35 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime + +from ...._models import BaseModel + +__all__ = ["TrustedDomainGetResponse"] + + +class TrustedDomainGetResponse(BaseModel): + id: int + """The unique identifier for the trusted domain.""" + + created_at: datetime + + is_recent: bool + """ + Select to prevent recently registered domains from triggering a Suspicious or + Malicious disposition. + """ + + is_regex: bool + + is_similarity: bool + """ + Select for partner or other approved domains that have similar spelling to your + connected domains. Prevents listed domains from triggering a Spoof disposition. + """ + + last_modified: datetime + + pattern: str + + comments: Optional[str] = None diff --git a/src/cloudflare/types/resource_sharing/__init__.py b/src/cloudflare/types/resource_sharing/__init__.py index bddc9f8c12f..7fcb1c45e77 100644 --- a/src/cloudflare/types/resource_sharing/__init__.py +++ b/src/cloudflare/types/resource_sharing/__init__.py @@ -2,7 +2,25 @@ from __future__ import annotations +from .resource_list_params import ResourceListParams as ResourceListParams +from .recipient_list_params import RecipientListParams as RecipientListParams +from .resource_get_response import ResourceGetResponse as ResourceGetResponse +from .recipient_get_response import RecipientGetResponse as RecipientGetResponse +from .resource_create_params import ResourceCreateParams as ResourceCreateParams +from .resource_list_response import ResourceListResponse as ResourceListResponse +from .resource_update_params import ResourceUpdateParams as ResourceUpdateParams +from .recipient_create_params import RecipientCreateParams as RecipientCreateParams +from .recipient_list_response import RecipientListResponse as RecipientListResponse +from .resource_create_response import ResourceCreateResponse as ResourceCreateResponse +from .resource_delete_response import ResourceDeleteResponse as ResourceDeleteResponse +from .resource_update_response import ResourceUpdateResponse as ResourceUpdateResponse +from .recipient_create_response import RecipientCreateResponse as RecipientCreateResponse +from .recipient_delete_response import RecipientDeleteResponse as RecipientDeleteResponse from .resource_sharing_list_params import ResourceSharingListParams as ResourceSharingListParams +from .resource_sharing_get_response import ResourceSharingGetResponse as ResourceSharingGetResponse from .resource_sharing_create_params import ResourceSharingCreateParams as ResourceSharingCreateParams from .resource_sharing_list_response import ResourceSharingListResponse as ResourceSharingListResponse +from .resource_sharing_update_params import ResourceSharingUpdateParams as ResourceSharingUpdateParams from .resource_sharing_create_response import ResourceSharingCreateResponse as ResourceSharingCreateResponse +from .resource_sharing_delete_response import ResourceSharingDeleteResponse as ResourceSharingDeleteResponse +from .resource_sharing_update_response import ResourceSharingUpdateResponse as ResourceSharingUpdateResponse diff --git a/src/cloudflare/types/resource_sharing/recipient_create_params.py b/src/cloudflare/types/resource_sharing/recipient_create_params.py new file mode 100644 index 00000000000..58b143bcada --- /dev/null +++ b/src/cloudflare/types/resource_sharing/recipient_create_params.py @@ -0,0 +1,20 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, Annotated, TypedDict + +from ..._utils import PropertyInfo + +__all__ = ["RecipientCreateParams"] + + +class RecipientCreateParams(TypedDict, total=False): + path_account_id: Required[Annotated[str, PropertyInfo(alias="account_id")]] + """Account identifier.""" + + body_account_id: Annotated[str, PropertyInfo(alias="account_id")] + """Account identifier.""" + + organization_id: str + """Organization identifier.""" diff --git a/src/cloudflare/types/resource_sharing/recipient_create_response.py b/src/cloudflare/types/resource_sharing/recipient_create_response.py new file mode 100644 index 00000000000..8bc8a37b309 --- /dev/null +++ b/src/cloudflare/types/resource_sharing/recipient_create_response.py @@ -0,0 +1,28 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["RecipientCreateResponse"] + + +class RecipientCreateResponse(BaseModel): + id: str + """Share Recipient identifier tag.""" + + account_id: str + """Account identifier.""" + + association_status: Literal["associating", "associated", "disassociating", "disassociated"] + """Share Recipient association status.""" + + created: datetime + """When the share was created.""" + + modified: datetime + """When the share was modified.""" + + status_message: str + """Share Recipient status message.""" diff --git a/src/cloudflare/types/resource_sharing/recipient_delete_response.py b/src/cloudflare/types/resource_sharing/recipient_delete_response.py new file mode 100644 index 00000000000..cb979d49054 --- /dev/null +++ b/src/cloudflare/types/resource_sharing/recipient_delete_response.py @@ -0,0 +1,28 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["RecipientDeleteResponse"] + + +class RecipientDeleteResponse(BaseModel): + id: str + """Share Recipient identifier tag.""" + + account_id: str + """Account identifier.""" + + association_status: Literal["associating", "associated", "disassociating", "disassociated"] + """Share Recipient association status.""" + + created: datetime + """When the share was created.""" + + modified: datetime + """When the share was modified.""" + + status_message: str + """Share Recipient status message.""" diff --git a/src/cloudflare/types/resource_sharing/recipient_get_response.py b/src/cloudflare/types/resource_sharing/recipient_get_response.py new file mode 100644 index 00000000000..19f64200d47 --- /dev/null +++ b/src/cloudflare/types/resource_sharing/recipient_get_response.py @@ -0,0 +1,28 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["RecipientGetResponse"] + + +class RecipientGetResponse(BaseModel): + id: str + """Share Recipient identifier tag.""" + + account_id: str + """Account identifier.""" + + association_status: Literal["associating", "associated", "disassociating", "disassociated"] + """Share Recipient association status.""" + + created: datetime + """When the share was created.""" + + modified: datetime + """When the share was modified.""" + + status_message: str + """Share Recipient status message.""" diff --git a/src/cloudflare/types/resource_sharing/recipient_list_params.py b/src/cloudflare/types/resource_sharing/recipient_list_params.py new file mode 100644 index 00000000000..baafcde07b0 --- /dev/null +++ b/src/cloudflare/types/resource_sharing/recipient_list_params.py @@ -0,0 +1,18 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["RecipientListParams"] + + +class RecipientListParams(TypedDict, total=False): + account_id: Required[str] + """Account identifier.""" + + page: int + """Page number.""" + + per_page: int + """Number of objects to return per page.""" diff --git a/src/cloudflare/types/resource_sharing/recipient_list_response.py b/src/cloudflare/types/resource_sharing/recipient_list_response.py new file mode 100644 index 00000000000..7fe67f036d0 --- /dev/null +++ b/src/cloudflare/types/resource_sharing/recipient_list_response.py @@ -0,0 +1,28 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["RecipientListResponse"] + + +class RecipientListResponse(BaseModel): + id: str + """Share Recipient identifier tag.""" + + account_id: str + """Account identifier.""" + + association_status: Literal["associating", "associated", "disassociating", "disassociated"] + """Share Recipient association status.""" + + created: datetime + """When the share was created.""" + + modified: datetime + """When the share was modified.""" + + status_message: str + """Share Recipient status message.""" diff --git a/src/cloudflare/types/resource_sharing/resource_create_params.py b/src/cloudflare/types/resource_sharing/resource_create_params.py new file mode 100644 index 00000000000..c3a1d6aa3b7 --- /dev/null +++ b/src/cloudflare/types/resource_sharing/resource_create_params.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["ResourceCreateParams"] + + +class ResourceCreateParams(TypedDict, total=False): + account_id: Required[str] + """Account identifier.""" + + meta: Required[object] + """Resource Metadata.""" + + resource_account_id: Required[str] + """Account identifier.""" + + resource_id: Required[str] + """Share Resource identifier.""" + + resource_type: Required[Literal["custom-ruleset", "widget"]] + """Resource Type.""" diff --git a/src/cloudflare/types/resource_sharing/resource_create_response.py b/src/cloudflare/types/resource_sharing/resource_create_response.py new file mode 100644 index 00000000000..29019fa9a6e --- /dev/null +++ b/src/cloudflare/types/resource_sharing/resource_create_response.py @@ -0,0 +1,37 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["ResourceCreateResponse"] + + +class ResourceCreateResponse(BaseModel): + id: str + """Share Resource identifier.""" + + created: datetime + """When the share was created.""" + + meta: object + """Resource Metadata.""" + + modified: datetime + """When the share was modified.""" + + resource_account_id: str + """Account identifier.""" + + resource_id: str + """Share Resource identifier.""" + + resource_type: Literal["custom-ruleset", "widget"] + """Resource Type.""" + + resource_version: int + """Resource Version.""" + + status: Literal["active", "deleting", "deleted"] + """Resource Status.""" diff --git a/src/cloudflare/types/resource_sharing/resource_delete_response.py b/src/cloudflare/types/resource_sharing/resource_delete_response.py new file mode 100644 index 00000000000..f9fd171cb7a --- /dev/null +++ b/src/cloudflare/types/resource_sharing/resource_delete_response.py @@ -0,0 +1,37 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["ResourceDeleteResponse"] + + +class ResourceDeleteResponse(BaseModel): + id: str + """Share Resource identifier.""" + + created: datetime + """When the share was created.""" + + meta: object + """Resource Metadata.""" + + modified: datetime + """When the share was modified.""" + + resource_account_id: str + """Account identifier.""" + + resource_id: str + """Share Resource identifier.""" + + resource_type: Literal["custom-ruleset", "widget"] + """Resource Type.""" + + resource_version: int + """Resource Version.""" + + status: Literal["active", "deleting", "deleted"] + """Resource Status.""" diff --git a/src/cloudflare/types/resource_sharing/resource_get_response.py b/src/cloudflare/types/resource_sharing/resource_get_response.py new file mode 100644 index 00000000000..87ba5e73b00 --- /dev/null +++ b/src/cloudflare/types/resource_sharing/resource_get_response.py @@ -0,0 +1,37 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["ResourceGetResponse"] + + +class ResourceGetResponse(BaseModel): + id: str + """Share Resource identifier.""" + + created: datetime + """When the share was created.""" + + meta: object + """Resource Metadata.""" + + modified: datetime + """When the share was modified.""" + + resource_account_id: str + """Account identifier.""" + + resource_id: str + """Share Resource identifier.""" + + resource_type: Literal["custom-ruleset", "widget"] + """Resource Type.""" + + resource_version: int + """Resource Version.""" + + status: Literal["active", "deleting", "deleted"] + """Resource Status.""" diff --git a/src/cloudflare/types/resource_sharing/resource_list_params.py b/src/cloudflare/types/resource_sharing/resource_list_params.py new file mode 100644 index 00000000000..baa6d687883 --- /dev/null +++ b/src/cloudflare/types/resource_sharing/resource_list_params.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["ResourceListParams"] + + +class ResourceListParams(TypedDict, total=False): + account_id: Required[str] + """Account identifier.""" + + page: int + """Page number.""" + + per_page: int + """Number of objects to return per page.""" + + resource_type: Literal["custom-ruleset", "widget"] + """Filter share resources by resource_type.""" + + status: Literal["active", "deleting", "deleted"] + """Filter share resources by status.""" diff --git a/src/cloudflare/types/resource_sharing/resource_list_response.py b/src/cloudflare/types/resource_sharing/resource_list_response.py new file mode 100644 index 00000000000..4672fbfd727 --- /dev/null +++ b/src/cloudflare/types/resource_sharing/resource_list_response.py @@ -0,0 +1,37 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["ResourceListResponse"] + + +class ResourceListResponse(BaseModel): + id: str + """Share Resource identifier.""" + + created: datetime + """When the share was created.""" + + meta: object + """Resource Metadata.""" + + modified: datetime + """When the share was modified.""" + + resource_account_id: str + """Account identifier.""" + + resource_id: str + """Share Resource identifier.""" + + resource_type: Literal["custom-ruleset", "widget"] + """Resource Type.""" + + resource_version: int + """Resource Version.""" + + status: Literal["active", "deleting", "deleted"] + """Resource Status.""" diff --git a/src/cloudflare/types/resource_sharing/resource_sharing_delete_response.py b/src/cloudflare/types/resource_sharing/resource_sharing_delete_response.py new file mode 100644 index 00000000000..655a9a6e364 --- /dev/null +++ b/src/cloudflare/types/resource_sharing/resource_sharing_delete_response.py @@ -0,0 +1,38 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["ResourceSharingDeleteResponse"] + + +class ResourceSharingDeleteResponse(BaseModel): + id: str + """Share identifier tag.""" + + account_id: str + """Account identifier.""" + + account_name: str + """The display name of an account.""" + + created: datetime + """When the share was created.""" + + modified: datetime + """When the share was modified.""" + + name: str + """The name of the share.""" + + organization_id: str + """Organization identifier.""" + + status: Literal["active", "deleting", "deleted"] + + target_type: Literal["account", "organization"] + + kind: Optional[Literal["sent", "received"]] = None diff --git a/src/cloudflare/types/resource_sharing/resource_sharing_get_response.py b/src/cloudflare/types/resource_sharing/resource_sharing_get_response.py new file mode 100644 index 00000000000..b7bc736b975 --- /dev/null +++ b/src/cloudflare/types/resource_sharing/resource_sharing_get_response.py @@ -0,0 +1,38 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["ResourceSharingGetResponse"] + + +class ResourceSharingGetResponse(BaseModel): + id: str + """Share identifier tag.""" + + account_id: str + """Account identifier.""" + + account_name: str + """The display name of an account.""" + + created: datetime + """When the share was created.""" + + modified: datetime + """When the share was modified.""" + + name: str + """The name of the share.""" + + organization_id: str + """Organization identifier.""" + + status: Literal["active", "deleting", "deleted"] + + target_type: Literal["account", "organization"] + + kind: Optional[Literal["sent", "received"]] = None diff --git a/src/cloudflare/types/resource_sharing/resource_sharing_update_params.py b/src/cloudflare/types/resource_sharing/resource_sharing_update_params.py new file mode 100644 index 00000000000..6d796532f5a --- /dev/null +++ b/src/cloudflare/types/resource_sharing/resource_sharing_update_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_extensions import Required, TypedDict + +__all__ = ["ResourceSharingUpdateParams"] + + +class ResourceSharingUpdateParams(TypedDict, total=False): + account_id: Required[str] + """Account identifier.""" + + name: Required[str] + """The name of the share.""" diff --git a/src/cloudflare/types/resource_sharing/resource_sharing_update_response.py b/src/cloudflare/types/resource_sharing/resource_sharing_update_response.py new file mode 100644 index 00000000000..f4d087b6fc1 --- /dev/null +++ b/src/cloudflare/types/resource_sharing/resource_sharing_update_response.py @@ -0,0 +1,38 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["ResourceSharingUpdateResponse"] + + +class ResourceSharingUpdateResponse(BaseModel): + id: str + """Share identifier tag.""" + + account_id: str + """Account identifier.""" + + account_name: str + """The display name of an account.""" + + created: datetime + """When the share was created.""" + + modified: datetime + """When the share was modified.""" + + name: str + """The name of the share.""" + + organization_id: str + """Organization identifier.""" + + status: Literal["active", "deleting", "deleted"] + + target_type: Literal["account", "organization"] + + kind: Optional[Literal["sent", "received"]] = None diff --git a/src/cloudflare/types/resource_sharing/resource_update_params.py b/src/cloudflare/types/resource_sharing/resource_update_params.py new file mode 100644 index 00000000000..d69bbdc0eb0 --- /dev/null +++ b/src/cloudflare/types/resource_sharing/resource_update_params.py @@ -0,0 +1,18 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["ResourceUpdateParams"] + + +class ResourceUpdateParams(TypedDict, total=False): + account_id: Required[str] + """Account identifier.""" + + share_id: Required[str] + """Share identifier tag.""" + + meta: Required[object] + """Resource Metadata.""" diff --git a/src/cloudflare/types/resource_sharing/resource_update_response.py b/src/cloudflare/types/resource_sharing/resource_update_response.py new file mode 100644 index 00000000000..c1bfeec14dc --- /dev/null +++ b/src/cloudflare/types/resource_sharing/resource_update_response.py @@ -0,0 +1,37 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["ResourceUpdateResponse"] + + +class ResourceUpdateResponse(BaseModel): + id: str + """Share Resource identifier.""" + + created: datetime + """When the share was created.""" + + meta: object + """Resource Metadata.""" + + modified: datetime + """When the share was modified.""" + + resource_account_id: str + """Account identifier.""" + + resource_id: str + """Share Resource identifier.""" + + resource_type: Literal["custom-ruleset", "widget"] + """Resource Type.""" + + resource_version: int + """Resource Version.""" + + status: Literal["active", "deleting", "deleted"] + """Resource Status.""" diff --git a/tests/api_resources/email_security/settings/test_trusted_domains.py b/tests/api_resources/email_security/settings/test_trusted_domains.py index ebd849f1118..643f33b595d 100644 --- a/tests/api_resources/email_security/settings/test_trusted_domains.py +++ b/tests/api_resources/email_security/settings/test_trusted_domains.py @@ -11,8 +11,11 @@ from tests.utils import assert_matches_type from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray from cloudflare.types.email_security.settings import ( + TrustedDomainGetResponse, + TrustedDomainEditResponse, TrustedDomainListResponse, TrustedDomainCreateResponse, + TrustedDomainDeleteResponse, ) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -209,6 +212,145 @@ def test_path_params_list(self, client: Cloudflare) -> None: account_id="", ) + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + trusted_domain = client.email_security.settings.trusted_domains.delete( + trusted_domain_id=2401, + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(TrustedDomainDeleteResponse, trusted_domain, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.email_security.settings.trusted_domains.with_raw_response.delete( + trusted_domain_id=2401, + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + trusted_domain = response.parse() + assert_matches_type(TrustedDomainDeleteResponse, trusted_domain, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.email_security.settings.trusted_domains.with_streaming_response.delete( + trusted_domain_id=2401, + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + trusted_domain = response.parse() + assert_matches_type(TrustedDomainDeleteResponse, trusted_domain, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.email_security.settings.trusted_domains.with_raw_response.delete( + trusted_domain_id=2401, + account_id="", + ) + + @parametrize + def test_method_edit(self, client: Cloudflare) -> None: + trusted_domain = client.email_security.settings.trusted_domains.edit( + trusted_domain_id=2401, + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(TrustedDomainEditResponse, trusted_domain, path=["response"]) + + @parametrize + def test_method_edit_with_all_params(self, client: Cloudflare) -> None: + trusted_domain = client.email_security.settings.trusted_domains.edit( + trusted_domain_id=2401, + account_id="023e105f4ecef8ad9ca31a8372d0c353", + comments="comments", + is_recent=True, + is_regex=True, + is_similarity=True, + pattern="x", + ) + assert_matches_type(TrustedDomainEditResponse, trusted_domain, path=["response"]) + + @parametrize + def test_raw_response_edit(self, client: Cloudflare) -> None: + response = client.email_security.settings.trusted_domains.with_raw_response.edit( + trusted_domain_id=2401, + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + trusted_domain = response.parse() + assert_matches_type(TrustedDomainEditResponse, trusted_domain, path=["response"]) + + @parametrize + def test_streaming_response_edit(self, client: Cloudflare) -> None: + with client.email_security.settings.trusted_domains.with_streaming_response.edit( + trusted_domain_id=2401, + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + trusted_domain = response.parse() + assert_matches_type(TrustedDomainEditResponse, trusted_domain, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_edit(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.email_security.settings.trusted_domains.with_raw_response.edit( + trusted_domain_id=2401, + account_id="", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + trusted_domain = client.email_security.settings.trusted_domains.get( + trusted_domain_id=2401, + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(TrustedDomainGetResponse, trusted_domain, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.email_security.settings.trusted_domains.with_raw_response.get( + trusted_domain_id=2401, + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + trusted_domain = response.parse() + assert_matches_type(TrustedDomainGetResponse, trusted_domain, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.email_security.settings.trusted_domains.with_streaming_response.get( + trusted_domain_id=2401, + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + trusted_domain = response.parse() + assert_matches_type(TrustedDomainGetResponse, trusted_domain, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.email_security.settings.trusted_domains.with_raw_response.get( + trusted_domain_id=2401, + account_id="", + ) + class TestAsyncTrustedDomains: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -402,3 +544,142 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: await async_client.email_security.settings.trusted_domains.with_raw_response.list( account_id="", ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + trusted_domain = await async_client.email_security.settings.trusted_domains.delete( + trusted_domain_id=2401, + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(TrustedDomainDeleteResponse, trusted_domain, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.email_security.settings.trusted_domains.with_raw_response.delete( + trusted_domain_id=2401, + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + trusted_domain = await response.parse() + assert_matches_type(TrustedDomainDeleteResponse, trusted_domain, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.email_security.settings.trusted_domains.with_streaming_response.delete( + trusted_domain_id=2401, + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + trusted_domain = await response.parse() + assert_matches_type(TrustedDomainDeleteResponse, trusted_domain, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.email_security.settings.trusted_domains.with_raw_response.delete( + trusted_domain_id=2401, + account_id="", + ) + + @parametrize + async def test_method_edit(self, async_client: AsyncCloudflare) -> None: + trusted_domain = await async_client.email_security.settings.trusted_domains.edit( + trusted_domain_id=2401, + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(TrustedDomainEditResponse, trusted_domain, path=["response"]) + + @parametrize + async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: + trusted_domain = await async_client.email_security.settings.trusted_domains.edit( + trusted_domain_id=2401, + account_id="023e105f4ecef8ad9ca31a8372d0c353", + comments="comments", + is_recent=True, + is_regex=True, + is_similarity=True, + pattern="x", + ) + assert_matches_type(TrustedDomainEditResponse, trusted_domain, path=["response"]) + + @parametrize + async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: + response = await async_client.email_security.settings.trusted_domains.with_raw_response.edit( + trusted_domain_id=2401, + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + trusted_domain = await response.parse() + assert_matches_type(TrustedDomainEditResponse, trusted_domain, path=["response"]) + + @parametrize + async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: + async with async_client.email_security.settings.trusted_domains.with_streaming_response.edit( + trusted_domain_id=2401, + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + trusted_domain = await response.parse() + assert_matches_type(TrustedDomainEditResponse, trusted_domain, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.email_security.settings.trusted_domains.with_raw_response.edit( + trusted_domain_id=2401, + account_id="", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + trusted_domain = await async_client.email_security.settings.trusted_domains.get( + trusted_domain_id=2401, + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(TrustedDomainGetResponse, trusted_domain, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.email_security.settings.trusted_domains.with_raw_response.get( + trusted_domain_id=2401, + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + trusted_domain = await response.parse() + assert_matches_type(TrustedDomainGetResponse, trusted_domain, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.email_security.settings.trusted_domains.with_streaming_response.get( + trusted_domain_id=2401, + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + trusted_domain = await response.parse() + assert_matches_type(TrustedDomainGetResponse, trusted_domain, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.email_security.settings.trusted_domains.with_raw_response.get( + trusted_domain_id=2401, + account_id="", + ) diff --git a/tests/api_resources/resource_sharing/test_recipients.py b/tests/api_resources/resource_sharing/test_recipients.py new file mode 100644 index 00000000000..15de2199620 --- /dev/null +++ b/tests/api_resources/resource_sharing/test_recipients.py @@ -0,0 +1,502 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from cloudflare.types.resource_sharing import ( + RecipientGetResponse, + RecipientListResponse, + RecipientCreateResponse, + RecipientDeleteResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestRecipients: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + recipient = client.resource_sharing.recipients.create( + share_id="3fd85f74b32742f1bff64a85009dda07", + path_account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[RecipientCreateResponse], recipient, path=["response"]) + + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + recipient = client.resource_sharing.recipients.create( + share_id="3fd85f74b32742f1bff64a85009dda07", + path_account_id="023e105f4ecef8ad9ca31a8372d0c353", + body_account_id="023e105f4ecef8ad9ca31a8372d0c353", + organization_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[RecipientCreateResponse], recipient, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.resource_sharing.recipients.with_raw_response.create( + share_id="3fd85f74b32742f1bff64a85009dda07", + path_account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + recipient = response.parse() + assert_matches_type(Optional[RecipientCreateResponse], recipient, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.resource_sharing.recipients.with_streaming_response.create( + share_id="3fd85f74b32742f1bff64a85009dda07", + path_account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + recipient = response.parse() + assert_matches_type(Optional[RecipientCreateResponse], recipient, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_create(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `path_account_id` but received ''"): + client.resource_sharing.recipients.with_raw_response.create( + share_id="3fd85f74b32742f1bff64a85009dda07", + path_account_id="", + body_account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_id` but received ''"): + client.resource_sharing.recipients.with_raw_response.create( + share_id="", + path_account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + recipient = client.resource_sharing.recipients.list( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncV4PagePaginationArray[RecipientListResponse], recipient, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + recipient = client.resource_sharing.recipients.list( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + page=2, + per_page=20, + ) + assert_matches_type(SyncV4PagePaginationArray[RecipientListResponse], recipient, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.resource_sharing.recipients.with_raw_response.list( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + recipient = response.parse() + assert_matches_type(SyncV4PagePaginationArray[RecipientListResponse], recipient, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.resource_sharing.recipients.with_streaming_response.list( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + recipient = response.parse() + assert_matches_type(SyncV4PagePaginationArray[RecipientListResponse], recipient, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.resource_sharing.recipients.with_raw_response.list( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_id` but received ''"): + client.resource_sharing.recipients.with_raw_response.list( + share_id="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + recipient = client.resource_sharing.recipients.delete( + recipient_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + assert_matches_type(Optional[RecipientDeleteResponse], recipient, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.resource_sharing.recipients.with_raw_response.delete( + recipient_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + recipient = response.parse() + assert_matches_type(Optional[RecipientDeleteResponse], recipient, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.resource_sharing.recipients.with_streaming_response.delete( + recipient_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + recipient = response.parse() + assert_matches_type(Optional[RecipientDeleteResponse], recipient, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.resource_sharing.recipients.with_raw_response.delete( + recipient_id="3fd85f74b32742f1bff64a85009dda07", + account_id="", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_id` but received ''"): + client.resource_sharing.recipients.with_raw_response.delete( + recipient_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `recipient_id` but received ''"): + client.resource_sharing.recipients.with_raw_response.delete( + recipient_id="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + recipient = client.resource_sharing.recipients.get( + recipient_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + assert_matches_type(Optional[RecipientGetResponse], recipient, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.resource_sharing.recipients.with_raw_response.get( + recipient_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + recipient = response.parse() + assert_matches_type(Optional[RecipientGetResponse], recipient, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.resource_sharing.recipients.with_streaming_response.get( + recipient_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + recipient = response.parse() + assert_matches_type(Optional[RecipientGetResponse], recipient, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.resource_sharing.recipients.with_raw_response.get( + recipient_id="3fd85f74b32742f1bff64a85009dda07", + account_id="", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_id` but received ''"): + client.resource_sharing.recipients.with_raw_response.get( + recipient_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `recipient_id` but received ''"): + client.resource_sharing.recipients.with_raw_response.get( + recipient_id="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + + +class TestAsyncRecipients: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + recipient = await async_client.resource_sharing.recipients.create( + share_id="3fd85f74b32742f1bff64a85009dda07", + path_account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[RecipientCreateResponse], recipient, path=["response"]) + + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + recipient = await async_client.resource_sharing.recipients.create( + share_id="3fd85f74b32742f1bff64a85009dda07", + path_account_id="023e105f4ecef8ad9ca31a8372d0c353", + body_account_id="023e105f4ecef8ad9ca31a8372d0c353", + organization_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[RecipientCreateResponse], recipient, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.resource_sharing.recipients.with_raw_response.create( + share_id="3fd85f74b32742f1bff64a85009dda07", + path_account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + recipient = await response.parse() + assert_matches_type(Optional[RecipientCreateResponse], recipient, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.resource_sharing.recipients.with_streaming_response.create( + share_id="3fd85f74b32742f1bff64a85009dda07", + path_account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + recipient = await response.parse() + assert_matches_type(Optional[RecipientCreateResponse], recipient, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `path_account_id` but received ''"): + await async_client.resource_sharing.recipients.with_raw_response.create( + share_id="3fd85f74b32742f1bff64a85009dda07", + path_account_id="", + body_account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_id` but received ''"): + await async_client.resource_sharing.recipients.with_raw_response.create( + share_id="", + path_account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + recipient = await async_client.resource_sharing.recipients.list( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncV4PagePaginationArray[RecipientListResponse], recipient, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + recipient = await async_client.resource_sharing.recipients.list( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + page=2, + per_page=20, + ) + assert_matches_type(AsyncV4PagePaginationArray[RecipientListResponse], recipient, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.resource_sharing.recipients.with_raw_response.list( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + recipient = await response.parse() + assert_matches_type(AsyncV4PagePaginationArray[RecipientListResponse], recipient, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.resource_sharing.recipients.with_streaming_response.list( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + recipient = await response.parse() + assert_matches_type(AsyncV4PagePaginationArray[RecipientListResponse], recipient, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.resource_sharing.recipients.with_raw_response.list( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_id` but received ''"): + await async_client.resource_sharing.recipients.with_raw_response.list( + share_id="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + recipient = await async_client.resource_sharing.recipients.delete( + recipient_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + assert_matches_type(Optional[RecipientDeleteResponse], recipient, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.resource_sharing.recipients.with_raw_response.delete( + recipient_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + recipient = await response.parse() + assert_matches_type(Optional[RecipientDeleteResponse], recipient, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.resource_sharing.recipients.with_streaming_response.delete( + recipient_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + recipient = await response.parse() + assert_matches_type(Optional[RecipientDeleteResponse], recipient, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.resource_sharing.recipients.with_raw_response.delete( + recipient_id="3fd85f74b32742f1bff64a85009dda07", + account_id="", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_id` but received ''"): + await async_client.resource_sharing.recipients.with_raw_response.delete( + recipient_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `recipient_id` but received ''"): + await async_client.resource_sharing.recipients.with_raw_response.delete( + recipient_id="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + recipient = await async_client.resource_sharing.recipients.get( + recipient_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + assert_matches_type(Optional[RecipientGetResponse], recipient, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.resource_sharing.recipients.with_raw_response.get( + recipient_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + recipient = await response.parse() + assert_matches_type(Optional[RecipientGetResponse], recipient, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.resource_sharing.recipients.with_streaming_response.get( + recipient_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + recipient = await response.parse() + assert_matches_type(Optional[RecipientGetResponse], recipient, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.resource_sharing.recipients.with_raw_response.get( + recipient_id="3fd85f74b32742f1bff64a85009dda07", + account_id="", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_id` but received ''"): + await async_client.resource_sharing.recipients.with_raw_response.get( + recipient_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `recipient_id` but received ''"): + await async_client.resource_sharing.recipients.with_raw_response.get( + recipient_id="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) diff --git a/tests/api_resources/resource_sharing/test_resources.py b/tests/api_resources/resource_sharing/test_resources.py new file mode 100644 index 00000000000..967e5dcbfca --- /dev/null +++ b/tests/api_resources/resource_sharing/test_resources.py @@ -0,0 +1,657 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from cloudflare.types.resource_sharing import ( + ResourceGetResponse, + ResourceListResponse, + ResourceCreateResponse, + ResourceDeleteResponse, + ResourceUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestResources: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + resource = client.resource_sharing.resources.create( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + meta={}, + resource_account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="custom-ruleset", + ) + assert_matches_type(Optional[ResourceCreateResponse], resource, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.resource_sharing.resources.with_raw_response.create( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + meta={}, + resource_account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="custom-ruleset", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resource = response.parse() + assert_matches_type(Optional[ResourceCreateResponse], resource, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.resource_sharing.resources.with_streaming_response.create( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + meta={}, + resource_account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="custom-ruleset", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resource = response.parse() + assert_matches_type(Optional[ResourceCreateResponse], resource, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_create(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.resource_sharing.resources.with_raw_response.create( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="", + meta={}, + resource_account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="custom-ruleset", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_id` but received ''"): + client.resource_sharing.resources.with_raw_response.create( + share_id="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + meta={}, + resource_account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="custom-ruleset", + ) + + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + resource = client.resource_sharing.resources.update( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + meta={}, + ) + assert_matches_type(Optional[ResourceUpdateResponse], resource, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.resource_sharing.resources.with_raw_response.update( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + meta={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resource = response.parse() + assert_matches_type(Optional[ResourceUpdateResponse], resource, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.resource_sharing.resources.with_streaming_response.update( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + meta={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resource = response.parse() + assert_matches_type(Optional[ResourceUpdateResponse], resource, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.resource_sharing.resources.with_raw_response.update( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + share_id="3fd85f74b32742f1bff64a85009dda07", + meta={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_id` but received ''"): + client.resource_sharing.resources.with_raw_response.update( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="", + meta={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `resource_id` but received ''"): + client.resource_sharing.resources.with_raw_response.update( + resource_id="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + meta={}, + ) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + resource = client.resource_sharing.resources.list( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncV4PagePaginationArray[ResourceListResponse], resource, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + resource = client.resource_sharing.resources.list( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + page=2, + per_page=20, + resource_type="custom-ruleset", + status="active", + ) + assert_matches_type(SyncV4PagePaginationArray[ResourceListResponse], resource, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.resource_sharing.resources.with_raw_response.list( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resource = response.parse() + assert_matches_type(SyncV4PagePaginationArray[ResourceListResponse], resource, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.resource_sharing.resources.with_streaming_response.list( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resource = response.parse() + assert_matches_type(SyncV4PagePaginationArray[ResourceListResponse], resource, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.resource_sharing.resources.with_raw_response.list( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_id` but received ''"): + client.resource_sharing.resources.with_raw_response.list( + share_id="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + resource = client.resource_sharing.resources.delete( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + assert_matches_type(Optional[ResourceDeleteResponse], resource, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.resource_sharing.resources.with_raw_response.delete( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resource = response.parse() + assert_matches_type(Optional[ResourceDeleteResponse], resource, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.resource_sharing.resources.with_streaming_response.delete( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resource = response.parse() + assert_matches_type(Optional[ResourceDeleteResponse], resource, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.resource_sharing.resources.with_raw_response.delete( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_id` but received ''"): + client.resource_sharing.resources.with_raw_response.delete( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `resource_id` but received ''"): + client.resource_sharing.resources.with_raw_response.delete( + resource_id="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + resource = client.resource_sharing.resources.get( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + assert_matches_type(Optional[ResourceGetResponse], resource, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.resource_sharing.resources.with_raw_response.get( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resource = response.parse() + assert_matches_type(Optional[ResourceGetResponse], resource, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.resource_sharing.resources.with_streaming_response.get( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resource = response.parse() + assert_matches_type(Optional[ResourceGetResponse], resource, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.resource_sharing.resources.with_raw_response.get( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_id` but received ''"): + client.resource_sharing.resources.with_raw_response.get( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `resource_id` but received ''"): + client.resource_sharing.resources.with_raw_response.get( + resource_id="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + + +class TestAsyncResources: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + resource = await async_client.resource_sharing.resources.create( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + meta={}, + resource_account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="custom-ruleset", + ) + assert_matches_type(Optional[ResourceCreateResponse], resource, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.resource_sharing.resources.with_raw_response.create( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + meta={}, + resource_account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="custom-ruleset", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resource = await response.parse() + assert_matches_type(Optional[ResourceCreateResponse], resource, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.resource_sharing.resources.with_streaming_response.create( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + meta={}, + resource_account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="custom-ruleset", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resource = await response.parse() + assert_matches_type(Optional[ResourceCreateResponse], resource, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.resource_sharing.resources.with_raw_response.create( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="", + meta={}, + resource_account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="custom-ruleset", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_id` but received ''"): + await async_client.resource_sharing.resources.with_raw_response.create( + share_id="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + meta={}, + resource_account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="custom-ruleset", + ) + + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + resource = await async_client.resource_sharing.resources.update( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + meta={}, + ) + assert_matches_type(Optional[ResourceUpdateResponse], resource, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.resource_sharing.resources.with_raw_response.update( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + meta={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resource = await response.parse() + assert_matches_type(Optional[ResourceUpdateResponse], resource, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.resource_sharing.resources.with_streaming_response.update( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + meta={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resource = await response.parse() + assert_matches_type(Optional[ResourceUpdateResponse], resource, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.resource_sharing.resources.with_raw_response.update( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + share_id="3fd85f74b32742f1bff64a85009dda07", + meta={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_id` but received ''"): + await async_client.resource_sharing.resources.with_raw_response.update( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="", + meta={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `resource_id` but received ''"): + await async_client.resource_sharing.resources.with_raw_response.update( + resource_id="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + meta={}, + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + resource = await async_client.resource_sharing.resources.list( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncV4PagePaginationArray[ResourceListResponse], resource, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + resource = await async_client.resource_sharing.resources.list( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + page=2, + per_page=20, + resource_type="custom-ruleset", + status="active", + ) + assert_matches_type(AsyncV4PagePaginationArray[ResourceListResponse], resource, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.resource_sharing.resources.with_raw_response.list( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resource = await response.parse() + assert_matches_type(AsyncV4PagePaginationArray[ResourceListResponse], resource, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.resource_sharing.resources.with_streaming_response.list( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resource = await response.parse() + assert_matches_type(AsyncV4PagePaginationArray[ResourceListResponse], resource, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.resource_sharing.resources.with_raw_response.list( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_id` but received ''"): + await async_client.resource_sharing.resources.with_raw_response.list( + share_id="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + resource = await async_client.resource_sharing.resources.delete( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + assert_matches_type(Optional[ResourceDeleteResponse], resource, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.resource_sharing.resources.with_raw_response.delete( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resource = await response.parse() + assert_matches_type(Optional[ResourceDeleteResponse], resource, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.resource_sharing.resources.with_streaming_response.delete( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resource = await response.parse() + assert_matches_type(Optional[ResourceDeleteResponse], resource, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.resource_sharing.resources.with_raw_response.delete( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_id` but received ''"): + await async_client.resource_sharing.resources.with_raw_response.delete( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `resource_id` but received ''"): + await async_client.resource_sharing.resources.with_raw_response.delete( + resource_id="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + resource = await async_client.resource_sharing.resources.get( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + assert_matches_type(Optional[ResourceGetResponse], resource, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.resource_sharing.resources.with_raw_response.get( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resource = await response.parse() + assert_matches_type(Optional[ResourceGetResponse], resource, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.resource_sharing.resources.with_streaming_response.get( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resource = await response.parse() + assert_matches_type(Optional[ResourceGetResponse], resource, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.resource_sharing.resources.with_raw_response.get( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_id` but received ''"): + await async_client.resource_sharing.resources.with_raw_response.get( + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `resource_id` but received ''"): + await async_client.resource_sharing.resources.with_raw_response.get( + resource_id="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + share_id="3fd85f74b32742f1bff64a85009dda07", + ) diff --git a/tests/api_resources/test_ai_gateway.py b/tests/api_resources/test_ai_gateway.py index 8c33ce4e9fa..e3a0e1a20b0 100644 --- a/tests/api_resources/test_ai_gateway.py +++ b/tests/api_resources/test_ai_gateway.py @@ -215,7 +215,6 @@ def test_method_list_with_all_params(self, client: Cloudflare) -> None: order_by_direction="asc", page=1, per_page=1, - search="search", ) assert_matches_type(SyncV4PagePaginationArray[AIGatewayListResponse], ai_gateway, path=["response"]) @@ -541,7 +540,6 @@ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) order_by_direction="asc", page=1, per_page=1, - search="search", ) assert_matches_type(AsyncV4PagePaginationArray[AIGatewayListResponse], ai_gateway, path=["response"]) diff --git a/tests/api_resources/test_dnssec.py b/tests/api_resources/test_dnssec.py index 4337b194683..8b083f578d3 100644 --- a/tests/api_resources/test_dnssec.py +++ b/tests/api_resources/test_dnssec.py @@ -9,7 +9,7 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type -from cloudflare.types.dnssec import DNSSEC +from cloudflare.types.dnssec import DNSSEC, DNSSECDeleteResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -22,7 +22,7 @@ def test_method_delete(self, client: Cloudflare) -> None: dnssec = client.dnssec.delete( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(str, dnssec, path=["response"]) + assert_matches_type(Optional[DNSSECDeleteResponse], dnssec, path=["response"]) @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: @@ -33,7 +33,7 @@ def test_raw_response_delete(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" dnssec = response.parse() - assert_matches_type(str, dnssec, path=["response"]) + assert_matches_type(Optional[DNSSECDeleteResponse], dnssec, path=["response"]) @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: @@ -44,7 +44,7 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" dnssec = response.parse() - assert_matches_type(str, dnssec, path=["response"]) + assert_matches_type(Optional[DNSSECDeleteResponse], dnssec, path=["response"]) assert cast(Any, response.is_closed) is True @@ -150,7 +150,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None: dnssec = await async_client.dnssec.delete( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(str, dnssec, path=["response"]) + assert_matches_type(Optional[DNSSECDeleteResponse], dnssec, path=["response"]) @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: @@ -161,7 +161,7 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" dnssec = await response.parse() - assert_matches_type(str, dnssec, path=["response"]) + assert_matches_type(Optional[DNSSECDeleteResponse], dnssec, path=["response"]) @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: @@ -172,7 +172,7 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" dnssec = await response.parse() - assert_matches_type(str, dnssec, path=["response"]) + assert_matches_type(Optional[DNSSECDeleteResponse], dnssec, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_resource_sharing.py b/tests/api_resources/test_resource_sharing.py index 0f6acec60bc..04448a2d72f 100644 --- a/tests/api_resources/test_resource_sharing.py +++ b/tests/api_resources/test_resource_sharing.py @@ -11,8 +11,11 @@ from tests.utils import assert_matches_type from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray from cloudflare.types.resource_sharing import ( + ResourceSharingGetResponse, ResourceSharingListResponse, ResourceSharingCreateResponse, + ResourceSharingDeleteResponse, + ResourceSharingUpdateResponse, ) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -99,6 +102,59 @@ def test_path_params_create(self, client: Cloudflare) -> None: ], ) + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + resource_sharing = client.resource_sharing.update( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + name="My Shared WAF Managed Rule", + ) + assert_matches_type(Optional[ResourceSharingUpdateResponse], resource_sharing, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.resource_sharing.with_raw_response.update( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + name="My Shared WAF Managed Rule", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resource_sharing = response.parse() + assert_matches_type(Optional[ResourceSharingUpdateResponse], resource_sharing, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.resource_sharing.with_streaming_response.update( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + name="My Shared WAF Managed Rule", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resource_sharing = response.parse() + assert_matches_type(Optional[ResourceSharingUpdateResponse], resource_sharing, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.resource_sharing.with_raw_response.update( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="", + name="My Shared WAF Managed Rule", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_id` but received ''"): + client.resource_sharing.with_raw_response.update( + share_id="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + name="My Shared WAF Managed Rule", + ) + @parametrize def test_method_list(self, client: Cloudflare) -> None: resource_sharing = client.resource_sharing.list( @@ -153,6 +209,102 @@ def test_path_params_list(self, client: Cloudflare) -> None: account_id="", ) + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + resource_sharing = client.resource_sharing.delete( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[ResourceSharingDeleteResponse], resource_sharing, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.resource_sharing.with_raw_response.delete( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resource_sharing = response.parse() + assert_matches_type(Optional[ResourceSharingDeleteResponse], resource_sharing, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.resource_sharing.with_streaming_response.delete( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resource_sharing = response.parse() + assert_matches_type(Optional[ResourceSharingDeleteResponse], resource_sharing, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.resource_sharing.with_raw_response.delete( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_id` but received ''"): + client.resource_sharing.with_raw_response.delete( + share_id="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + resource_sharing = client.resource_sharing.get( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[ResourceSharingGetResponse], resource_sharing, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.resource_sharing.with_raw_response.get( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resource_sharing = response.parse() + assert_matches_type(Optional[ResourceSharingGetResponse], resource_sharing, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.resource_sharing.with_streaming_response.get( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resource_sharing = response.parse() + assert_matches_type(Optional[ResourceSharingGetResponse], resource_sharing, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.resource_sharing.with_raw_response.get( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_id` but received ''"): + client.resource_sharing.with_raw_response.get( + share_id="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + class TestAsyncResourceSharing: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -235,6 +387,59 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: ], ) + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + resource_sharing = await async_client.resource_sharing.update( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + name="My Shared WAF Managed Rule", + ) + assert_matches_type(Optional[ResourceSharingUpdateResponse], resource_sharing, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.resource_sharing.with_raw_response.update( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + name="My Shared WAF Managed Rule", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resource_sharing = await response.parse() + assert_matches_type(Optional[ResourceSharingUpdateResponse], resource_sharing, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.resource_sharing.with_streaming_response.update( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + name="My Shared WAF Managed Rule", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resource_sharing = await response.parse() + assert_matches_type(Optional[ResourceSharingUpdateResponse], resource_sharing, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.resource_sharing.with_raw_response.update( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="", + name="My Shared WAF Managed Rule", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_id` but received ''"): + await async_client.resource_sharing.with_raw_response.update( + share_id="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + name="My Shared WAF Managed Rule", + ) + @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: resource_sharing = await async_client.resource_sharing.list( @@ -294,3 +499,99 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: await async_client.resource_sharing.with_raw_response.list( account_id="", ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + resource_sharing = await async_client.resource_sharing.delete( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[ResourceSharingDeleteResponse], resource_sharing, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.resource_sharing.with_raw_response.delete( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resource_sharing = await response.parse() + assert_matches_type(Optional[ResourceSharingDeleteResponse], resource_sharing, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.resource_sharing.with_streaming_response.delete( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resource_sharing = await response.parse() + assert_matches_type(Optional[ResourceSharingDeleteResponse], resource_sharing, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.resource_sharing.with_raw_response.delete( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_id` but received ''"): + await async_client.resource_sharing.with_raw_response.delete( + share_id="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + resource_sharing = await async_client.resource_sharing.get( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[ResourceSharingGetResponse], resource_sharing, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.resource_sharing.with_raw_response.get( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resource_sharing = await response.parse() + assert_matches_type(Optional[ResourceSharingGetResponse], resource_sharing, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.resource_sharing.with_streaming_response.get( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resource_sharing = await response.parse() + assert_matches_type(Optional[ResourceSharingGetResponse], resource_sharing, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.resource_sharing.with_raw_response.get( + share_id="3fd85f74b32742f1bff64a85009dda07", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_id` but received ''"): + await async_client.resource_sharing.with_raw_response.get( + share_id="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + )