From e51ae76cb5230e3c28f24e47ab3fa7139dc6f23c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 04:30:33 +0000 Subject: [PATCH] feat(api): update via SDK Studio (#963) --- .stats.yml | 2 +- api.md | 45 +- src/cloudflare/resources/accounts/members.py | 425 ++++-- src/cloudflare/resources/accounts/roles.py | 8 + .../resources/kv/namespaces/bulk.py | 106 +- .../resources/kv/namespaces/metadata.py | 15 +- .../resources/kv/namespaces/namespaces.py | 130 +- .../resources/kv/namespaces/values.py | 160 ++- src/cloudflare/resources/memberships.py | 90 +- src/cloudflare/resources/storage/analytics.py | 26 +- .../user/tokens/permission_groups.py | 4 +- .../resources/workers/scripts/versions.py | 56 +- src/cloudflare/types/accounts/__init__.py | 1 + .../types/accounts/member_create_params.py | 51 +- .../types/accounts/member_create_response.py | 109 +- .../types/accounts/member_get_response.py | 109 +- .../types/accounts/member_list_params.py | 1 + .../types/accounts/member_list_response.py | 112 ++ .../types/accounts/member_update_params.py | 53 +- .../types/accounts/member_update_response.py | 109 +- .../addressing/address_map_create_params.py | 8 +- .../types/kv/namespace_delete_response.py | 8 +- .../types/kv/namespace_update_response.py | 8 +- .../types/kv/namespaces/__init__.py | 2 +- .../kv/namespaces/bulk_delete_response.py | 8 +- .../types/kv/namespaces/bulk_update_params.py | 4 +- .../kv/namespaces/bulk_update_response.py | 8 +- src/cloudflare/types/kv/namespaces/key.py | 4 +- .../kv/namespaces/metadata_get_response.py | 7 + .../kv/namespaces/value_delete_response.py | 8 +- .../types/kv/namespaces/value_get_response.py | 6 - .../kv/namespaces/value_update_response.py | 8 +- .../memberships/membership_get_response.py | 125 +- .../memberships/membership_update_response.py | 125 +- .../types/user/token_create_params.py | 3 +- .../types/user/token_update_params.py | 3 +- .../types/workers/scripts/__init__.py | 1 + .../workers/scripts/version_list_params.py | 21 + .../workers/scripts/version_list_response.py | 10 +- tests/api_resources/accounts/test_members.py | 1152 +++++++++++++++-- tests/api_resources/accounts/test_roles.py | 24 +- .../addressing/test_address_maps.py | 7 + .../api_resources/kv/namespaces/test_bulk.py | 26 +- .../kv/namespaces/test_metadata.py | 15 +- .../kv/namespaces/test_values.py | 133 +- tests/api_resources/kv/test_namespaces.py | 50 +- tests/api_resources/storage/test_analytics.py | 34 +- tests/api_resources/test_memberships.py | 24 +- tests/api_resources/user/test_tokens.py | 180 ++- .../workers/scripts/test_versions.py | 35 +- 50 files changed, 2928 insertions(+), 731 deletions(-) create mode 100644 src/cloudflare/types/accounts/member_list_response.py create mode 100644 src/cloudflare/types/kv/namespaces/metadata_get_response.py delete mode 100644 src/cloudflare/types/kv/namespaces/value_get_response.py create mode 100644 src/cloudflare/types/workers/scripts/version_list_params.py diff --git a/.stats.yml b/.stats.yml index c4ad890aa36..cf68beefb0d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-006fe70343aa3ef4a560a2cd1a8d68653d4f838c85aeab7106e1fbb79999d3d4.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-af1ecaabf305033e1f88b63fa9ff708149d2e8f79c0050c0e046d010c668038c.yml diff --git a/api.md b/api.md index 5d3170fce1e..8caf9c9dae6 100644 --- a/api.md +++ b/api.md @@ -50,6 +50,7 @@ from cloudflare.types.accounts import ( UserWithInviteCode, MemberCreateResponse, MemberUpdateResponse, + MemberListResponse, MemberDeleteResponse, MemberGetResponse, ) @@ -57,11 +58,11 @@ from cloudflare.types.accounts import ( Methods: -- client.accounts.members.create(\*, account_id, \*\*params) -> MemberCreateResponse -- client.accounts.members.update(member_id, \*, account_id, \*\*params) -> MemberUpdateResponse -- client.accounts.members.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Member] +- client.accounts.members.create(\*, account_id, \*\*params) -> Optional +- client.accounts.members.update(member_id, \*, account_id, \*\*params) -> Optional +- client.accounts.members.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[MemberListResponse] - client.accounts.members.delete(member_id, \*, account_id) -> Optional -- client.accounts.members.get(member_id, \*, account_id) -> MemberGetResponse +- client.accounts.members.get(member_id, \*, account_id) -> Optional ## Roles @@ -123,10 +124,10 @@ from cloudflare.types.memberships import ( Methods: -- client.memberships.update(membership_id, \*\*params) -> MembershipUpdateResponse +- client.memberships.update(membership_id, \*\*params) -> Optional - client.memberships.list(\*\*params) -> SyncV4PagePaginationArray[Membership] - client.memberships.delete(membership_id) -> Optional -- client.memberships.get(membership_id) -> MembershipGetResponse +- client.memberships.get(membership_id) -> Optional # User @@ -2765,7 +2766,7 @@ from cloudflare.types.workers.scripts import ( Methods: - client.workers.scripts.versions.create(script_name, \*, account_id, \*\*params) -> Optional -- client.workers.scripts.versions.list(script_name, \*, account_id) -> Optional +- client.workers.scripts.versions.list(script_name, \*, account_id, \*\*params) -> SyncV4PagePagination[VersionListResponse] - client.workers.scripts.versions.get(version_id, \*, account_id, script_name) -> Optional ## AccountSettings @@ -2821,11 +2822,11 @@ from cloudflare.types.kv import Namespace, NamespaceUpdateResponse, NamespaceDel Methods: -- client.kv.namespaces.create(\*, account_id, \*\*params) -> Namespace -- client.kv.namespaces.update(namespace_id, \*, account_id, \*\*params) -> NamespaceUpdateResponse +- client.kv.namespaces.create(\*, account_id, \*\*params) -> Optional +- client.kv.namespaces.update(namespace_id, \*, account_id, \*\*params) -> Optional - client.kv.namespaces.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Namespace] -- client.kv.namespaces.delete(namespace_id, \*, account_id) -> NamespaceDeleteResponse -- client.kv.namespaces.get(namespace_id, \*, account_id) -> Namespace +- client.kv.namespaces.delete(namespace_id, \*, account_id) -> Optional +- client.kv.namespaces.get(namespace_id, \*, account_id) -> Optional ### Bulk @@ -2837,8 +2838,8 @@ from cloudflare.types.kv.namespaces import BulkUpdateResponse, BulkDeleteRespons Methods: -- client.kv.namespaces.bulk.update(namespace_id, \*, account_id, \*\*params) -> BulkUpdateResponse -- client.kv.namespaces.bulk.delete(namespace_id, \*, account_id) -> BulkDeleteResponse +- client.kv.namespaces.bulk.update(namespace_id, \*, account_id, \*\*params) -> Optional +- client.kv.namespaces.bulk.delete(namespace_id, \*, account_id) -> Optional ### Keys @@ -2862,25 +2863,21 @@ from cloudflare.types.kv.namespaces import MetadataGetResponse Methods: -- client.kv.namespaces.metadata.get(key_name, \*, account_id, namespace_id) -> object +- client.kv.namespaces.metadata.get(key_name, \*, account_id, namespace_id) -> Optional ### Values Types: ```python -from cloudflare.types.kv.namespaces import ( - ValueUpdateResponse, - ValueDeleteResponse, - ValueGetResponse, -) +from cloudflare.types.kv.namespaces import ValueUpdateResponse, ValueDeleteResponse ``` Methods: -- client.kv.namespaces.values.update(key_name, \*, account_id, namespace_id, \*\*params) -> ValueUpdateResponse -- client.kv.namespaces.values.delete(key_name, \*, account_id, namespace_id) -> ValueDeleteResponse -- client.kv.namespaces.values.get(key_name, \*, account_id, namespace_id) -> str +- client.kv.namespaces.values.update(key_name, \*, account_id, namespace_id, \*\*params) -> Optional +- client.kv.namespaces.values.delete(key_name, \*, account_id, namespace_id) -> Optional +- client.kv.namespaces.values.get(key_name, \*, account_id, namespace_id) -> BinaryAPIResponse # DurableObjects @@ -4474,8 +4471,8 @@ from cloudflare.types.storage import Components, Schema Methods: -- client.storage.analytics.list(\*, account_id, \*\*params) -> Schema -- client.storage.analytics.stored(\*, account_id, \*\*params) -> Components +- client.storage.analytics.list(\*, account_id, \*\*params) -> Optional +- client.storage.analytics.stored(\*, account_id, \*\*params) -> Optional # Stream diff --git a/src/cloudflare/resources/accounts/members.py b/src/cloudflare/resources/accounts/members.py index 642cb60d058..36ae1a8926f 100644 --- a/src/cloudflare/resources/accounts/members.py +++ b/src/cloudflare/resources/accounts/members.py @@ -2,13 +2,14 @@ from __future__ import annotations -from typing import Any, List, Type, Iterable, Optional, cast +from typing import List, Type, Iterable, Optional, cast, overload from typing_extensions import Literal import httpx from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven from ..._utils import ( + required_args, maybe_transform, async_maybe_transform, ) @@ -27,8 +28,8 @@ make_request_options, ) from ...types.accounts import member_list_params, member_create_params, member_update_params -from ...types.shared.member import Member from ...types.accounts.member_get_response import MemberGetResponse +from ...types.accounts.member_list_response import MemberListResponse from ...types.accounts.member_create_response import MemberCreateResponse from ...types.accounts.member_delete_response import MemberDeleteResponse from ...types.accounts.member_update_response import MemberUpdateResponse @@ -45,6 +46,7 @@ def with_raw_response(self) -> MembersResourceWithRawResponse: def with_streaming_response(self) -> MembersResourceWithStreamingResponse: return MembersResourceWithStreamingResponse(self) + @overload def create( self, *, @@ -58,11 +60,13 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MemberCreateResponse: + ) -> Optional[MemberCreateResponse]: """ Add a user to the list of members for this account. Args: + account_id: Account identifier tag. + email: The contact email address of the user. roles: Array of roles associated with this member. @@ -75,46 +79,102 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + ... + + @overload + def create( + self, + *, + account_id: str, + email: str, + policies: Iterable[member_create_params.IamCreateMemberWithPoliciesPolicy], + status: Literal["accepted", "pending"] | 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[MemberCreateResponse]: + """ + Add a user to the list of members for this account. + + Args: + account_id: Account identifier tag. + + email: The contact email address of the user. + + policies: Array of policies associated with this member. + + 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 + """ + ... + + @required_args(["account_id", "email", "roles"], ["account_id", "email", "policies"]) + def create( + self, + *, + account_id: str, + email: str, + roles: List[str] | NotGiven = NOT_GIVEN, + status: Literal["accepted", "pending"] | NotGiven = NOT_GIVEN, + policies: Iterable[member_create_params.IamCreateMemberWithPoliciesPolicy] | 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[MemberCreateResponse]: if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return cast( - MemberCreateResponse, - self._post( - f"/accounts/{account_id}/members", - body=maybe_transform( - { - "email": email, - "roles": roles, - "status": status, - }, - member_create_params.MemberCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=cast( - Any, MemberCreateResponse - ), # Union types cannot be passed in as arguments in the type system + return self._post( + f"/accounts/{account_id}/members", + body=maybe_transform( + { + "email": email, + "roles": roles, + "status": status, + "policies": policies, + }, + member_create_params.MemberCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[MemberCreateResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[MemberCreateResponse]], ResultWrapper[MemberCreateResponse]), ) + @overload def update( self, member_id: str, *, account_id: str, - roles: Iterable[member_update_params.Role] | NotGiven = NOT_GIVEN, + roles: Iterable[member_update_params.MemberRole] | 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, - ) -> MemberUpdateResponse: + ) -> Optional[MemberUpdateResponse]: """ Modify an account member. Args: + account_id: Account identifier tag. + member_id: Membership identifier tag. roles: Roles assigned to this member. @@ -127,22 +187,78 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + ... + + @overload + def update( + self, + member_id: str, + *, + account_id: str, + policies: Iterable[member_update_params.IamUpdateMemberWithPoliciesPolicy], + # 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[MemberUpdateResponse]: + """ + Modify an account member. + + Args: + account_id: Account identifier tag. + + member_id: Membership identifier tag. + + policies: Array of policies associated with this member. + + 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 + """ + ... + + @required_args(["account_id"], ["account_id", "policies"]) + def update( + self, + member_id: str, + *, + account_id: str, + roles: Iterable[member_update_params.MemberRole] | NotGiven = NOT_GIVEN, + policies: Iterable[member_update_params.IamUpdateMemberWithPoliciesPolicy] | 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[MemberUpdateResponse]: if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not member_id: raise ValueError(f"Expected a non-empty value for `member_id` but received {member_id!r}") - return cast( - MemberUpdateResponse, - self._put( - f"/accounts/{account_id}/members/{member_id}", - body=maybe_transform({"roles": roles}, member_update_params.MemberUpdateParams), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=cast( - Any, MemberUpdateResponse - ), # Union types cannot be passed in as arguments in the type system + return self._put( + f"/accounts/{account_id}/members/{member_id}", + body=maybe_transform( + { + "roles": roles, + "policies": policies, + }, + member_update_params.MemberUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[MemberUpdateResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[MemberUpdateResponse]], ResultWrapper[MemberUpdateResponse]), ) def list( @@ -160,11 +276,13 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncV4PagePaginationArray[Member]: + ) -> SyncV4PagePaginationArray[MemberListResponse]: """ List all members of an account. Args: + account_id: Account identifier tag. + direction: Direction to order results. order: Field to order results by. @@ -187,7 +305,7 @@ def list( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._get_api_list( f"/accounts/{account_id}/members", - page=SyncV4PagePaginationArray[Member], + page=SyncV4PagePaginationArray[MemberListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -204,7 +322,7 @@ def list( member_list_params.MemberListParams, ), ), - model=Member, + model=MemberListResponse, ) def delete( @@ -223,6 +341,8 @@ def delete( Remove a member from an account. Args: + account_id: Account identifier tag. + member_id: Membership identifier tag. extra_headers: Send extra headers @@ -260,11 +380,13 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MemberGetResponse: + ) -> Optional[MemberGetResponse]: """ Get information about a specific member of an account. Args: + account_id: Account identifier tag. + member_id: Membership identifier tag. extra_headers: Send extra headers @@ -279,15 +401,16 @@ def get( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not member_id: raise ValueError(f"Expected a non-empty value for `member_id` but received {member_id!r}") - return cast( - MemberGetResponse, - self._get( - f"/accounts/{account_id}/members/{member_id}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=cast(Any, MemberGetResponse), # Union types cannot be passed in as arguments in the type system + return self._get( + f"/accounts/{account_id}/members/{member_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[MemberGetResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[MemberGetResponse]], ResultWrapper[MemberGetResponse]), ) @@ -300,6 +423,7 @@ def with_raw_response(self) -> AsyncMembersResourceWithRawResponse: def with_streaming_response(self) -> AsyncMembersResourceWithStreamingResponse: return AsyncMembersResourceWithStreamingResponse(self) + @overload async def create( self, *, @@ -313,11 +437,13 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MemberCreateResponse: + ) -> Optional[MemberCreateResponse]: """ Add a user to the list of members for this account. Args: + account_id: Account identifier tag. + email: The contact email address of the user. roles: Array of roles associated with this member. @@ -330,46 +456,102 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + ... + + @overload + async def create( + self, + *, + account_id: str, + email: str, + policies: Iterable[member_create_params.IamCreateMemberWithPoliciesPolicy], + status: Literal["accepted", "pending"] | 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[MemberCreateResponse]: + """ + Add a user to the list of members for this account. + + Args: + account_id: Account identifier tag. + + email: The contact email address of the user. + + policies: Array of policies associated with this member. + + 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 + """ + ... + + @required_args(["account_id", "email", "roles"], ["account_id", "email", "policies"]) + async def create( + self, + *, + account_id: str, + email: str, + roles: List[str] | NotGiven = NOT_GIVEN, + status: Literal["accepted", "pending"] | NotGiven = NOT_GIVEN, + policies: Iterable[member_create_params.IamCreateMemberWithPoliciesPolicy] | 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[MemberCreateResponse]: if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return cast( - MemberCreateResponse, - await self._post( - f"/accounts/{account_id}/members", - body=await async_maybe_transform( - { - "email": email, - "roles": roles, - "status": status, - }, - member_create_params.MemberCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=cast( - Any, MemberCreateResponse - ), # Union types cannot be passed in as arguments in the type system + return await self._post( + f"/accounts/{account_id}/members", + body=await async_maybe_transform( + { + "email": email, + "roles": roles, + "status": status, + "policies": policies, + }, + member_create_params.MemberCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[MemberCreateResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[MemberCreateResponse]], ResultWrapper[MemberCreateResponse]), ) + @overload async def update( self, member_id: str, *, account_id: str, - roles: Iterable[member_update_params.Role] | NotGiven = NOT_GIVEN, + roles: Iterable[member_update_params.MemberRole] | 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, - ) -> MemberUpdateResponse: + ) -> Optional[MemberUpdateResponse]: """ Modify an account member. Args: + account_id: Account identifier tag. + member_id: Membership identifier tag. roles: Roles assigned to this member. @@ -382,22 +564,78 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + ... + + @overload + async def update( + self, + member_id: str, + *, + account_id: str, + policies: Iterable[member_update_params.IamUpdateMemberWithPoliciesPolicy], + # 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[MemberUpdateResponse]: + """ + Modify an account member. + + Args: + account_id: Account identifier tag. + + member_id: Membership identifier tag. + + policies: Array of policies associated with this member. + + 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 + """ + ... + + @required_args(["account_id"], ["account_id", "policies"]) + async def update( + self, + member_id: str, + *, + account_id: str, + roles: Iterable[member_update_params.MemberRole] | NotGiven = NOT_GIVEN, + policies: Iterable[member_update_params.IamUpdateMemberWithPoliciesPolicy] | 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[MemberUpdateResponse]: if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not member_id: raise ValueError(f"Expected a non-empty value for `member_id` but received {member_id!r}") - return cast( - MemberUpdateResponse, - await self._put( - f"/accounts/{account_id}/members/{member_id}", - body=await async_maybe_transform({"roles": roles}, member_update_params.MemberUpdateParams), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=cast( - Any, MemberUpdateResponse - ), # Union types cannot be passed in as arguments in the type system + return await self._put( + f"/accounts/{account_id}/members/{member_id}", + body=await async_maybe_transform( + { + "roles": roles, + "policies": policies, + }, + member_update_params.MemberUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[MemberUpdateResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[MemberUpdateResponse]], ResultWrapper[MemberUpdateResponse]), ) def list( @@ -415,11 +653,13 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[Member, AsyncV4PagePaginationArray[Member]]: + ) -> AsyncPaginator[MemberListResponse, AsyncV4PagePaginationArray[MemberListResponse]]: """ List all members of an account. Args: + account_id: Account identifier tag. + direction: Direction to order results. order: Field to order results by. @@ -442,7 +682,7 @@ def list( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._get_api_list( f"/accounts/{account_id}/members", - page=AsyncV4PagePaginationArray[Member], + page=AsyncV4PagePaginationArray[MemberListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -459,7 +699,7 @@ def list( member_list_params.MemberListParams, ), ), - model=Member, + model=MemberListResponse, ) async def delete( @@ -478,6 +718,8 @@ async def delete( Remove a member from an account. Args: + account_id: Account identifier tag. + member_id: Membership identifier tag. extra_headers: Send extra headers @@ -515,11 +757,13 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MemberGetResponse: + ) -> Optional[MemberGetResponse]: """ Get information about a specific member of an account. Args: + account_id: Account identifier tag. + member_id: Membership identifier tag. extra_headers: Send extra headers @@ -534,15 +778,16 @@ async def get( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not member_id: raise ValueError(f"Expected a non-empty value for `member_id` but received {member_id!r}") - return cast( - MemberGetResponse, - await self._get( - f"/accounts/{account_id}/members/{member_id}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=cast(Any, MemberGetResponse), # Union types cannot be passed in as arguments in the type system + return await self._get( + f"/accounts/{account_id}/members/{member_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[MemberGetResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[MemberGetResponse]], ResultWrapper[MemberGetResponse]), ) diff --git a/src/cloudflare/resources/accounts/roles.py b/src/cloudflare/resources/accounts/roles.py index 2cb8405d641..16c89ca10dd 100644 --- a/src/cloudflare/resources/accounts/roles.py +++ b/src/cloudflare/resources/accounts/roles.py @@ -50,6 +50,8 @@ def list( Get all available roles for an account. Args: + account_id: Account identifier tag. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -85,6 +87,8 @@ def get( Get information about a specific role for an account. Args: + account_id: Account identifier tag. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -132,6 +136,8 @@ def list( Get all available roles for an account. Args: + account_id: Account identifier tag. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -167,6 +173,8 @@ async def get( Get information about a specific role for an account. Args: + account_id: Account identifier tag. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request diff --git a/src/cloudflare/resources/kv/namespaces/bulk.py b/src/cloudflare/resources/kv/namespaces/bulk.py index 9c9ee270e5c..7bc398ecfd9 100644 --- a/src/cloudflare/resources/kv/namespaces/bulk.py +++ b/src/cloudflare/resources/kv/namespaces/bulk.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Iterable, cast +from typing import Type, Iterable, Optional, cast import httpx @@ -51,7 +51,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> BulkUpdateResponse: + ) -> Optional[BulkUpdateResponse]: """Write multiple keys and values at once. Body should be an array of up to 10,000 @@ -78,22 +78,17 @@ def update( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") - return cast( - BulkUpdateResponse, - self._put( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk", - body=maybe_transform(body, bulk_update_params.BulkUpdateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[BulkUpdateResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[BulkUpdateResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._put( + f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk", + body=maybe_transform(body, bulk_update_params.BulkUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[BulkUpdateResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[BulkUpdateResponse]], ResultWrapper[BulkUpdateResponse]), ) def delete( @@ -107,7 +102,7 @@ def delete( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> BulkDeleteResponse: + ) -> Optional[BulkDeleteResponse]: """Remove multiple KV pairs from the namespace. Body should be an array of up to @@ -130,21 +125,16 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") - return cast( - BulkDeleteResponse, - self._delete( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[BulkDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[BulkDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[BulkDeleteResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[BulkDeleteResponse]], ResultWrapper[BulkDeleteResponse]), ) @@ -169,7 +159,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> BulkUpdateResponse: + ) -> Optional[BulkUpdateResponse]: """Write multiple keys and values at once. Body should be an array of up to 10,000 @@ -196,22 +186,17 @@ async def update( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") - return cast( - BulkUpdateResponse, - await self._put( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk", - body=await async_maybe_transform(body, bulk_update_params.BulkUpdateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[BulkUpdateResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[BulkUpdateResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._put( + f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk", + body=await async_maybe_transform(body, bulk_update_params.BulkUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[BulkUpdateResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[BulkUpdateResponse]], ResultWrapper[BulkUpdateResponse]), ) async def delete( @@ -225,7 +210,7 @@ async def delete( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> BulkDeleteResponse: + ) -> Optional[BulkDeleteResponse]: """Remove multiple KV pairs from the namespace. Body should be an array of up to @@ -248,21 +233,16 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") - return cast( - BulkDeleteResponse, - await self._delete( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[BulkDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[BulkDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[BulkDeleteResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[BulkDeleteResponse]], ResultWrapper[BulkDeleteResponse]), ) diff --git a/src/cloudflare/resources/kv/namespaces/metadata.py b/src/cloudflare/resources/kv/namespaces/metadata.py index b9a442c88b0..9112053105f 100644 --- a/src/cloudflare/resources/kv/namespaces/metadata.py +++ b/src/cloudflare/resources/kv/namespaces/metadata.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -19,6 +19,7 @@ from ...._base_client import ( make_request_options, ) +from ....types.kv.namespaces.metadata_get_response import MetadataGetResponse __all__ = ["MetadataResource", "AsyncMetadataResource"] @@ -44,7 +45,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> object: + ) -> Optional[MetadataGetResponse]: """Returns the metadata associated with the given key in the given namespace. Use @@ -80,9 +81,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[object]._unwrapper, + post_parser=ResultWrapper[Optional[MetadataGetResponse]]._unwrapper, ), - cast_to=cast(Type[object], ResultWrapper[object]), + cast_to=cast(Type[Optional[MetadataGetResponse]], ResultWrapper[MetadataGetResponse]), ) @@ -107,7 +108,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> object: + ) -> Optional[MetadataGetResponse]: """Returns the metadata associated with the given key in the given namespace. Use @@ -143,9 +144,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[object]._unwrapper, + post_parser=ResultWrapper[Optional[MetadataGetResponse]]._unwrapper, ), - cast_to=cast(Type[object], ResultWrapper[object]), + cast_to=cast(Type[Optional[MetadataGetResponse]], ResultWrapper[MetadataGetResponse]), ) diff --git a/src/cloudflare/resources/kv/namespaces/namespaces.py b/src/cloudflare/resources/kv/namespaces/namespaces.py index 5f25f6cfbf3..be73605e215 100644 --- a/src/cloudflare/resources/kv/namespaces/namespaces.py +++ b/src/cloudflare/resources/kv/namespaces/namespaces.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, cast +from typing import Type, Optional, cast from typing_extensions import Literal import httpx @@ -102,7 +102,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Namespace: + ) -> Optional[Namespace]: """Creates a namespace under the given title. A `400` is returned if the account @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Namespace]._unwrapper, + post_parser=ResultWrapper[Optional[Namespace]]._unwrapper, ), - cast_to=cast(Type[Namespace], ResultWrapper[Namespace]), + cast_to=cast(Type[Optional[Namespace]], ResultWrapper[Namespace]), ) def update( @@ -149,7 +149,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> NamespaceUpdateResponse: + ) -> Optional[NamespaceUpdateResponse]: """ Modifies a namespace's title. @@ -172,22 +172,17 @@ def update( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") - return cast( - NamespaceUpdateResponse, - self._put( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", - body=maybe_transform({"title": title}, namespace_update_params.NamespaceUpdateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[NamespaceUpdateResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[NamespaceUpdateResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._put( + f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", + body=maybe_transform({"title": title}, namespace_update_params.NamespaceUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[NamespaceUpdateResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[NamespaceUpdateResponse]], ResultWrapper[NamespaceUpdateResponse]), ) def list( @@ -261,7 +256,7 @@ def delete( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> NamespaceDeleteResponse: + ) -> Optional[NamespaceDeleteResponse]: """ Deletes the namespace corresponding to the given ID. @@ -282,21 +277,16 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") - return cast( - NamespaceDeleteResponse, - self._delete( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[NamespaceDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[NamespaceDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[NamespaceDeleteResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[NamespaceDeleteResponse]], ResultWrapper[NamespaceDeleteResponse]), ) def get( @@ -310,7 +300,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Namespace: + ) -> Optional[Namespace]: """ Get the namespace corresponding to the given ID. @@ -338,9 +328,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Namespace]._unwrapper, + post_parser=ResultWrapper[Optional[Namespace]]._unwrapper, ), - cast_to=cast(Type[Namespace], ResultWrapper[Namespace]), + cast_to=cast(Type[Optional[Namespace]], ResultWrapper[Namespace]), ) @@ -380,7 +370,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Namespace: + ) -> Optional[Namespace]: """Creates a namespace under the given title. A `400` is returned if the account @@ -410,9 +400,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Namespace]._unwrapper, + post_parser=ResultWrapper[Optional[Namespace]]._unwrapper, ), - cast_to=cast(Type[Namespace], ResultWrapper[Namespace]), + cast_to=cast(Type[Optional[Namespace]], ResultWrapper[Namespace]), ) async def update( @@ -427,7 +417,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> NamespaceUpdateResponse: + ) -> Optional[NamespaceUpdateResponse]: """ Modifies a namespace's title. @@ -450,22 +440,17 @@ async def update( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") - return cast( - NamespaceUpdateResponse, - await self._put( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", - body=await async_maybe_transform({"title": title}, namespace_update_params.NamespaceUpdateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[NamespaceUpdateResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[NamespaceUpdateResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._put( + f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", + body=await async_maybe_transform({"title": title}, namespace_update_params.NamespaceUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[NamespaceUpdateResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[NamespaceUpdateResponse]], ResultWrapper[NamespaceUpdateResponse]), ) def list( @@ -539,7 +524,7 @@ async def delete( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> NamespaceDeleteResponse: + ) -> Optional[NamespaceDeleteResponse]: """ Deletes the namespace corresponding to the given ID. @@ -560,21 +545,16 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") - return cast( - NamespaceDeleteResponse, - await self._delete( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[NamespaceDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[NamespaceDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[NamespaceDeleteResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[NamespaceDeleteResponse]], ResultWrapper[NamespaceDeleteResponse]), ) async def get( @@ -588,7 +568,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Namespace: + ) -> Optional[Namespace]: """ Get the namespace corresponding to the given ID. @@ -616,9 +596,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Namespace]._unwrapper, + post_parser=ResultWrapper[Optional[Namespace]]._unwrapper, ), - cast_to=cast(Type[Namespace], ResultWrapper[Namespace]), + cast_to=cast(Type[Optional[Namespace]], ResultWrapper[Namespace]), ) diff --git a/src/cloudflare/resources/kv/namespaces/values.py b/src/cloudflare/resources/kv/namespaces/values.py index 011fb16adde..b80c2b635bb 100644 --- a/src/cloudflare/resources/kv/namespaces/values.py +++ b/src/cloudflare/resources/kv/namespaces/values.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, cast +from typing import Type, Optional, cast import httpx @@ -14,10 +14,18 @@ from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( + BinaryAPIResponse, + AsyncBinaryAPIResponse, + StreamedBinaryAPIResponse, + AsyncStreamedBinaryAPIResponse, to_raw_response_wrapper, to_streamed_response_wrapper, async_to_raw_response_wrapper, + to_custom_raw_response_wrapper, async_to_streamed_response_wrapper, + to_custom_streamed_response_wrapper, + async_to_custom_raw_response_wrapper, + async_to_custom_streamed_response_wrapper, ) from ...._wrappers import ResultWrapper from ...._base_client import ( @@ -53,7 +61,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> ValueUpdateResponse: + ) -> Optional[ValueUpdateResponse]: """Write a value identified by a key. Use URL-encoding to use special characters @@ -89,28 +97,23 @@ def update( raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") if not key_name: raise ValueError(f"Expected a non-empty value for `key_name` but received {key_name!r}") - return cast( - ValueUpdateResponse, - self._put( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", - body=maybe_transform( - { - "metadata": metadata, - "value": value, - }, - value_update_params.ValueUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[ValueUpdateResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[ValueUpdateResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._put( + f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", + body=maybe_transform( + { + "metadata": metadata, + "value": value, + }, + value_update_params.ValueUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ValueUpdateResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[ValueUpdateResponse]], ResultWrapper[ValueUpdateResponse]), ) def delete( @@ -125,7 +128,7 @@ def delete( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> ValueDeleteResponse: + ) -> Optional[ValueDeleteResponse]: """Remove a KV pair from the namespace. Use URL-encoding to use special characters @@ -153,21 +156,16 @@ def delete( raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") if not key_name: raise ValueError(f"Expected a non-empty value for `key_name` but received {key_name!r}") - return cast( - ValueDeleteResponse, - self._delete( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[ValueDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[ValueDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ValueDeleteResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[ValueDeleteResponse]], ResultWrapper[ValueDeleteResponse]), ) def get( @@ -182,7 +180,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> str: + ) -> BinaryAPIResponse: """Returns the value associated with the given key in the given namespace. Use @@ -213,12 +211,13 @@ def get( raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") if not key_name: raise ValueError(f"Expected a non-empty value for `key_name` but received {key_name!r}") + extra_headers = {"Accept": "application/octet-stream", **(extra_headers or {})} return self._get( f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=str, + cast_to=BinaryAPIResponse, ) @@ -245,7 +244,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> ValueUpdateResponse: + ) -> Optional[ValueUpdateResponse]: """Write a value identified by a key. Use URL-encoding to use special characters @@ -281,28 +280,23 @@ async def update( raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") if not key_name: raise ValueError(f"Expected a non-empty value for `key_name` but received {key_name!r}") - return cast( - ValueUpdateResponse, - await self._put( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", - body=await async_maybe_transform( - { - "metadata": metadata, - "value": value, - }, - value_update_params.ValueUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[ValueUpdateResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[ValueUpdateResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._put( + f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", + body=await async_maybe_transform( + { + "metadata": metadata, + "value": value, + }, + value_update_params.ValueUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ValueUpdateResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[ValueUpdateResponse]], ResultWrapper[ValueUpdateResponse]), ) async def delete( @@ -317,7 +311,7 @@ async def delete( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> ValueDeleteResponse: + ) -> Optional[ValueDeleteResponse]: """Remove a KV pair from the namespace. Use URL-encoding to use special characters @@ -345,21 +339,16 @@ async def delete( raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") if not key_name: raise ValueError(f"Expected a non-empty value for `key_name` but received {key_name!r}") - return cast( - ValueDeleteResponse, - await self._delete( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[ValueDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[ValueDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ValueDeleteResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[ValueDeleteResponse]], ResultWrapper[ValueDeleteResponse]), ) async def get( @@ -374,7 +363,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> str: + ) -> AsyncBinaryAPIResponse: """Returns the value associated with the given key in the given namespace. Use @@ -405,12 +394,13 @@ async def get( raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") if not key_name: raise ValueError(f"Expected a non-empty value for `key_name` but received {key_name!r}") + extra_headers = {"Accept": "application/octet-stream", **(extra_headers or {})} return await self._get( f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=str, + cast_to=AsyncBinaryAPIResponse, ) @@ -424,8 +414,9 @@ def __init__(self, values: ValuesResource) -> None: self.delete = to_raw_response_wrapper( values.delete, ) - self.get = to_raw_response_wrapper( + self.get = to_custom_raw_response_wrapper( values.get, + BinaryAPIResponse, ) @@ -439,8 +430,9 @@ def __init__(self, values: AsyncValuesResource) -> None: self.delete = async_to_raw_response_wrapper( values.delete, ) - self.get = async_to_raw_response_wrapper( + self.get = async_to_custom_raw_response_wrapper( values.get, + AsyncBinaryAPIResponse, ) @@ -454,8 +446,9 @@ def __init__(self, values: ValuesResource) -> None: self.delete = to_streamed_response_wrapper( values.delete, ) - self.get = to_streamed_response_wrapper( + self.get = to_custom_streamed_response_wrapper( values.get, + StreamedBinaryAPIResponse, ) @@ -469,6 +462,7 @@ def __init__(self, values: AsyncValuesResource) -> None: self.delete = async_to_streamed_response_wrapper( values.delete, ) - self.get = async_to_streamed_response_wrapper( + self.get = async_to_custom_streamed_response_wrapper( values.get, + AsyncStreamedBinaryAPIResponse, ) diff --git a/src/cloudflare/resources/memberships.py b/src/cloudflare/resources/memberships.py index 0884e4c7e8b..b4c963fbea7 100644 --- a/src/cloudflare/resources/memberships.py +++ b/src/cloudflare/resources/memberships.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Optional, cast +from typing import Type, Optional, cast from typing_extensions import Literal import httpx @@ -55,7 +55,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MembershipUpdateResponse: + ) -> Optional[MembershipUpdateResponse]: """ Accept or reject this account invitation. @@ -74,18 +74,17 @@ def update( """ if not membership_id: raise ValueError(f"Expected a non-empty value for `membership_id` but received {membership_id!r}") - return cast( - MembershipUpdateResponse, - self._put( - f"/memberships/{membership_id}", - body=maybe_transform({"status": status}, membership_update_params.MembershipUpdateParams), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=cast( - Any, MembershipUpdateResponse - ), # Union types cannot be passed in as arguments in the type system + return self._put( + f"/memberships/{membership_id}", + body=maybe_transform({"status": status}, membership_update_params.MembershipUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[MembershipUpdateResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[MembershipUpdateResponse]], ResultWrapper[MembershipUpdateResponse]), ) def list( @@ -202,7 +201,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MembershipGetResponse: + ) -> Optional[MembershipGetResponse]: """ Get a specific membership. @@ -219,17 +218,16 @@ def get( """ if not membership_id: raise ValueError(f"Expected a non-empty value for `membership_id` but received {membership_id!r}") - return cast( - MembershipGetResponse, - self._get( - f"/memberships/{membership_id}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=cast( - Any, MembershipGetResponse - ), # Union types cannot be passed in as arguments in the type system + return self._get( + f"/memberships/{membership_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[MembershipGetResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[MembershipGetResponse]], ResultWrapper[MembershipGetResponse]), ) @@ -253,7 +251,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MembershipUpdateResponse: + ) -> Optional[MembershipUpdateResponse]: """ Accept or reject this account invitation. @@ -272,18 +270,17 @@ async def update( """ if not membership_id: raise ValueError(f"Expected a non-empty value for `membership_id` but received {membership_id!r}") - return cast( - MembershipUpdateResponse, - await self._put( - f"/memberships/{membership_id}", - body=await async_maybe_transform({"status": status}, membership_update_params.MembershipUpdateParams), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=cast( - Any, MembershipUpdateResponse - ), # Union types cannot be passed in as arguments in the type system + return await self._put( + f"/memberships/{membership_id}", + body=await async_maybe_transform({"status": status}, membership_update_params.MembershipUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[MembershipUpdateResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[MembershipUpdateResponse]], ResultWrapper[MembershipUpdateResponse]), ) def list( @@ -400,7 +397,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MembershipGetResponse: + ) -> Optional[MembershipGetResponse]: """ Get a specific membership. @@ -417,17 +414,16 @@ async def get( """ if not membership_id: raise ValueError(f"Expected a non-empty value for `membership_id` but received {membership_id!r}") - return cast( - MembershipGetResponse, - await self._get( - f"/memberships/{membership_id}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=cast( - Any, MembershipGetResponse - ), # Union types cannot be passed in as arguments in the type system + return await self._get( + f"/memberships/{membership_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[MembershipGetResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[MembershipGetResponse]], ResultWrapper[MembershipGetResponse]), ) diff --git a/src/cloudflare/resources/storage/analytics.py b/src/cloudflare/resources/storage/analytics.py index 9a0621a4f2c..dfef4b35536 100644 --- a/src/cloudflare/resources/storage/analytics.py +++ b/src/cloudflare/resources/storage/analytics.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -50,7 +50,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Schema: + ) -> Optional[Schema]: """ Retrieves Workers KV request metrics for the given account. @@ -77,9 +77,9 @@ def list( extra_body=extra_body, timeout=timeout, query=maybe_transform({"query": query}, analytics_list_params.AnalyticsListParams), - post_parser=ResultWrapper[Schema]._unwrapper, + post_parser=ResultWrapper[Optional[Schema]]._unwrapper, ), - cast_to=cast(Type[Schema], ResultWrapper[Schema]), + cast_to=cast(Type[Optional[Schema]], ResultWrapper[Schema]), ) def stored( @@ -93,7 +93,7 @@ def stored( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Components: + ) -> Optional[Components]: """ Retrieves Workers KV stored data metrics for the given account. @@ -120,9 +120,9 @@ def stored( extra_body=extra_body, timeout=timeout, query=maybe_transform({"query": query}, analytics_stored_params.AnalyticsStoredParams), - post_parser=ResultWrapper[Components]._unwrapper, + post_parser=ResultWrapper[Optional[Components]]._unwrapper, ), - cast_to=cast(Type[Components], ResultWrapper[Components]), + cast_to=cast(Type[Optional[Components]], ResultWrapper[Components]), ) @@ -146,7 +146,7 @@ async def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Schema: + ) -> Optional[Schema]: """ Retrieves Workers KV request metrics for the given account. @@ -173,9 +173,9 @@ async def list( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"query": query}, analytics_list_params.AnalyticsListParams), - post_parser=ResultWrapper[Schema]._unwrapper, + post_parser=ResultWrapper[Optional[Schema]]._unwrapper, ), - cast_to=cast(Type[Schema], ResultWrapper[Schema]), + cast_to=cast(Type[Optional[Schema]], ResultWrapper[Schema]), ) async def stored( @@ -189,7 +189,7 @@ async def stored( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Components: + ) -> Optional[Components]: """ Retrieves Workers KV stored data metrics for the given account. @@ -216,9 +216,9 @@ async def stored( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"query": query}, analytics_stored_params.AnalyticsStoredParams), - post_parser=ResultWrapper[Components]._unwrapper, + post_parser=ResultWrapper[Optional[Components]]._unwrapper, ), - cast_to=cast(Type[Components], ResultWrapper[Components]), + cast_to=cast(Type[Optional[Components]], ResultWrapper[Components]), ) diff --git a/src/cloudflare/resources/user/tokens/permission_groups.py b/src/cloudflare/resources/user/tokens/permission_groups.py index 427b3944862..28efd8ca0e4 100644 --- a/src/cloudflare/resources/user/tokens/permission_groups.py +++ b/src/cloudflare/resources/user/tokens/permission_groups.py @@ -41,7 +41,7 @@ def list( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> SyncSinglePage[object]: - """Find all available permission groups.""" + """Find all available permission groups for API Tokens""" return self._get_api_list( "/user/tokens/permission_groups", page=SyncSinglePage[object], @@ -71,7 +71,7 @@ def list( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> AsyncPaginator[object, AsyncSinglePage[object]]: - """Find all available permission groups.""" + """Find all available permission groups for API Tokens""" return self._get_api_list( "/user/tokens/permission_groups", page=AsyncSinglePage[object], diff --git a/src/cloudflare/resources/workers/scripts/versions.py b/src/cloudflare/resources/workers/scripts/versions.py index 493ece2bd84..a13d69c5e8d 100644 --- a/src/cloudflare/resources/workers/scripts/versions.py +++ b/src/cloudflare/resources/workers/scripts/versions.py @@ -22,10 +22,12 @@ async_to_streamed_response_wrapper, ) from ...._wrappers import ResultWrapper +from ....pagination import SyncV4PagePagination, AsyncV4PagePagination from ...._base_client import ( + AsyncPaginator, make_request_options, ) -from ....types.workers.scripts import version_create_params +from ....types.workers.scripts import version_list_params, version_create_params from ....types.workers.scripts.version_get_response import VersionGetResponse from ....types.workers.scripts.version_list_response import VersionListResponse from ....types.workers.scripts.version_create_response import VersionCreateResponse @@ -113,13 +115,16 @@ def list( script_name: str, *, account_id: str, + deployable: bool | NotGiven = NOT_GIVEN, + 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, - ) -> Optional[VersionListResponse]: + ) -> SyncV4PagePagination[VersionListResponse]: """List of Worker Versions. The first version in the list is the latest version. @@ -129,6 +134,12 @@ def list( script_name: Name of the script. + deployable: Only return versions that can be used in a deployment. Ignores pagination. + + page: Current page. + + per_page: Items per-page. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -141,16 +152,24 @@ def list( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") - return self._get( + return self._get_api_list( f"/accounts/{account_id}/workers/scripts/{script_name}/versions", + page=SyncV4PagePagination[VersionListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[VersionListResponse]]._unwrapper, + query=maybe_transform( + { + "deployable": deployable, + "page": page, + "per_page": per_page, + }, + version_list_params.VersionListParams, + ), ), - cast_to=cast(Type[Optional[VersionListResponse]], ResultWrapper[VersionListResponse]), + model=VersionListResponse, ) def get( @@ -276,18 +295,21 @@ async def create( cast_to=cast(Type[Optional[VersionCreateResponse]], ResultWrapper[VersionCreateResponse]), ) - async def list( + def list( self, script_name: str, *, account_id: str, + deployable: bool | NotGiven = NOT_GIVEN, + 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, - ) -> Optional[VersionListResponse]: + ) -> AsyncPaginator[VersionListResponse, AsyncV4PagePagination[VersionListResponse]]: """List of Worker Versions. The first version in the list is the latest version. @@ -297,6 +319,12 @@ async def list( script_name: Name of the script. + deployable: Only return versions that can be used in a deployment. Ignores pagination. + + page: Current page. + + per_page: Items per-page. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -309,16 +337,24 @@ async def list( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") - return await self._get( + return self._get_api_list( f"/accounts/{account_id}/workers/scripts/{script_name}/versions", + page=AsyncV4PagePagination[VersionListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[VersionListResponse]]._unwrapper, + query=maybe_transform( + { + "deployable": deployable, + "page": page, + "per_page": per_page, + }, + version_list_params.VersionListParams, + ), ), - cast_to=cast(Type[Optional[VersionListResponse]], ResultWrapper[VersionListResponse]), + model=VersionListResponse, ) async def get( diff --git a/src/cloudflare/types/accounts/__init__.py b/src/cloudflare/types/accounts/__init__.py index 5b4a4199ba4..4379841c49a 100644 --- a/src/cloudflare/types/accounts/__init__.py +++ b/src/cloudflare/types/accounts/__init__.py @@ -8,6 +8,7 @@ from .account_list_params import AccountListParams as AccountListParams from .member_get_response import MemberGetResponse as MemberGetResponse from .member_create_params import MemberCreateParams as MemberCreateParams +from .member_list_response import MemberListResponse as MemberListResponse from .member_update_params import MemberUpdateParams as MemberUpdateParams from .account_update_params import AccountUpdateParams as AccountUpdateParams from .member_create_response import MemberCreateResponse as MemberCreateResponse diff --git a/src/cloudflare/types/accounts/member_create_params.py b/src/cloudflare/types/accounts/member_create_params.py index 69acda8f5da..1531d624747 100644 --- a/src/cloudflare/types/accounts/member_create_params.py +++ b/src/cloudflare/types/accounts/member_create_params.py @@ -2,14 +2,22 @@ from __future__ import annotations -from typing import List +from typing import List, Union, Iterable from typing_extensions import Literal, Required, TypedDict -__all__ = ["MemberCreateParams"] +__all__ = [ + "MemberCreateParams", + "IamCreateMemberWithRoles", + "IamCreateMemberWithPolicies", + "IamCreateMemberWithPoliciesPolicy", + "IamCreateMemberWithPoliciesPolicyPermissionGroup", + "IamCreateMemberWithPoliciesPolicyResourceGroup", +] -class MemberCreateParams(TypedDict, total=False): +class IamCreateMemberWithRoles(TypedDict, total=False): account_id: Required[str] + """Account identifier tag.""" email: Required[str] """The contact email address of the user.""" @@ -18,3 +26,40 @@ class MemberCreateParams(TypedDict, total=False): """Array of roles associated with this member.""" status: Literal["accepted", "pending"] + + +class IamCreateMemberWithPolicies(TypedDict, total=False): + account_id: Required[str] + """Account identifier tag.""" + + email: Required[str] + """The contact email address of the user.""" + + policies: Required[Iterable[IamCreateMemberWithPoliciesPolicy]] + """Array of policies associated with this member.""" + + status: Literal["accepted", "pending"] + + +class IamCreateMemberWithPoliciesPolicyPermissionGroup(TypedDict, total=False): + id: Required[str] + """Identifier of the group.""" + + +class IamCreateMemberWithPoliciesPolicyResourceGroup(TypedDict, total=False): + id: Required[str] + """Identifier of the group.""" + + +class IamCreateMemberWithPoliciesPolicy(TypedDict, total=False): + access: Required[Literal["allow", "deny"]] + """Allow or deny operations against the resources.""" + + permission_groups: Required[Iterable[IamCreateMemberWithPoliciesPolicyPermissionGroup]] + """A set of permission groups that are specified to the policy.""" + + resource_groups: Required[Iterable[IamCreateMemberWithPoliciesPolicyResourceGroup]] + """A list of resource groups that the policy applies to.""" + + +MemberCreateParams = Union[IamCreateMemberWithRoles, IamCreateMemberWithPolicies] diff --git a/src/cloudflare/types/accounts/member_create_response.py b/src/cloudflare/types/accounts/member_create_response.py index 02ed65d99c8..dd71bbe04ce 100644 --- a/src/cloudflare/types/accounts/member_create_response.py +++ b/src/cloudflare/types/accounts/member_create_response.py @@ -1,15 +1,112 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union, Optional +from typing import List, Optional +from typing_extensions import Literal from ..._models import BaseModel -from ..shared.member import Member +from ..shared.role import Role -__all__ = ["MemberCreateResponse", "IamAPIResponseCommon"] +__all__ = [ + "MemberCreateResponse", + "Policy", + "PolicyPermissionGroup", + "PolicyResourceGroup", + "PolicyResourceGroupScope", + "PolicyResourceGroupScopeObject", + "User", +] -class IamAPIResponseCommon(BaseModel): - result: Optional[Member] = None +class PolicyPermissionGroup(BaseModel): + id: str + """Identifier of the group.""" + meta: Optional[object] = None + """Attributes associated to the permission group.""" -MemberCreateResponse = Union[IamAPIResponseCommon, IamAPIResponseCommon] + name: Optional[str] = None + """Name of the group.""" + + +class PolicyResourceGroupScopeObject(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Zone ID + etc.) + """ + + +class PolicyResourceGroupScope(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Account + ID etc.) + """ + + objects: List[PolicyResourceGroupScopeObject] + """A list of scope objects for additional context.""" + + +class PolicyResourceGroup(BaseModel): + id: str + """Identifier of the group.""" + + scope: List[PolicyResourceGroupScope] + """The scope associated to the resource group""" + + meta: Optional[object] = None + """Attributes associated to the resource group.""" + + name: Optional[str] = None + """Name of the resource group.""" + + +class Policy(BaseModel): + id: Optional[str] = None + """Policy identifier.""" + + access: Optional[Literal["allow", "deny"]] = None + """Allow or deny operations against the resources.""" + + permission_groups: Optional[List[PolicyPermissionGroup]] = None + """A set of permission groups that are specified to the policy.""" + + resource_groups: Optional[List[PolicyResourceGroup]] = None + """A list of resource groups that the policy applies to.""" + + +class User(BaseModel): + email: str + """The contact email address of the user.""" + + id: Optional[str] = None + """Identifier""" + + first_name: Optional[str] = None + """User's first name""" + + last_name: Optional[str] = None + """User's last name""" + + two_factor_authentication_enabled: Optional[bool] = None + """Indicates whether two-factor authentication is enabled for the user account. + + Does not apply to API authentication. + """ + + +class MemberCreateResponse(BaseModel): + id: Optional[str] = None + """Membership identifier tag.""" + + policies: Optional[List[Policy]] = None + """Access policy for the membership""" + + roles: Optional[List[Role]] = None + """Roles assigned to this Member.""" + + status: Optional[Literal["accepted", "pending"]] = None + """A member's status in the account.""" + + user: Optional[User] = None + """Details of the user associated to the membership.""" diff --git a/src/cloudflare/types/accounts/member_get_response.py b/src/cloudflare/types/accounts/member_get_response.py index b4ff99e9597..61da641cd72 100644 --- a/src/cloudflare/types/accounts/member_get_response.py +++ b/src/cloudflare/types/accounts/member_get_response.py @@ -1,15 +1,112 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union, Optional +from typing import List, Optional +from typing_extensions import Literal from ..._models import BaseModel -from ..shared.member import Member +from ..shared.role import Role -__all__ = ["MemberGetResponse", "IamAPIResponseCommon"] +__all__ = [ + "MemberGetResponse", + "Policy", + "PolicyPermissionGroup", + "PolicyResourceGroup", + "PolicyResourceGroupScope", + "PolicyResourceGroupScopeObject", + "User", +] -class IamAPIResponseCommon(BaseModel): - result: Optional[Member] = None +class PolicyPermissionGroup(BaseModel): + id: str + """Identifier of the group.""" + meta: Optional[object] = None + """Attributes associated to the permission group.""" -MemberGetResponse = Union[IamAPIResponseCommon, IamAPIResponseCommon] + name: Optional[str] = None + """Name of the group.""" + + +class PolicyResourceGroupScopeObject(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Zone ID + etc.) + """ + + +class PolicyResourceGroupScope(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Account + ID etc.) + """ + + objects: List[PolicyResourceGroupScopeObject] + """A list of scope objects for additional context.""" + + +class PolicyResourceGroup(BaseModel): + id: str + """Identifier of the group.""" + + scope: List[PolicyResourceGroupScope] + """The scope associated to the resource group""" + + meta: Optional[object] = None + """Attributes associated to the resource group.""" + + name: Optional[str] = None + """Name of the resource group.""" + + +class Policy(BaseModel): + id: Optional[str] = None + """Policy identifier.""" + + access: Optional[Literal["allow", "deny"]] = None + """Allow or deny operations against the resources.""" + + permission_groups: Optional[List[PolicyPermissionGroup]] = None + """A set of permission groups that are specified to the policy.""" + + resource_groups: Optional[List[PolicyResourceGroup]] = None + """A list of resource groups that the policy applies to.""" + + +class User(BaseModel): + email: str + """The contact email address of the user.""" + + id: Optional[str] = None + """Identifier""" + + first_name: Optional[str] = None + """User's first name""" + + last_name: Optional[str] = None + """User's last name""" + + two_factor_authentication_enabled: Optional[bool] = None + """Indicates whether two-factor authentication is enabled for the user account. + + Does not apply to API authentication. + """ + + +class MemberGetResponse(BaseModel): + id: Optional[str] = None + """Membership identifier tag.""" + + policies: Optional[List[Policy]] = None + """Access policy for the membership""" + + roles: Optional[List[Role]] = None + """Roles assigned to this Member.""" + + status: Optional[Literal["accepted", "pending"]] = None + """A member's status in the account.""" + + user: Optional[User] = None + """Details of the user associated to the membership.""" diff --git a/src/cloudflare/types/accounts/member_list_params.py b/src/cloudflare/types/accounts/member_list_params.py index 1b594104750..cda9328b103 100644 --- a/src/cloudflare/types/accounts/member_list_params.py +++ b/src/cloudflare/types/accounts/member_list_params.py @@ -9,6 +9,7 @@ class MemberListParams(TypedDict, total=False): account_id: Required[str] + """Account identifier tag.""" direction: Literal["asc", "desc"] """Direction to order results.""" diff --git a/src/cloudflare/types/accounts/member_list_response.py b/src/cloudflare/types/accounts/member_list_response.py new file mode 100644 index 00000000000..5a8a4f49c10 --- /dev/null +++ b/src/cloudflare/types/accounts/member_list_response.py @@ -0,0 +1,112 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.role import Role + +__all__ = [ + "MemberListResponse", + "Policy", + "PolicyPermissionGroup", + "PolicyResourceGroup", + "PolicyResourceGroupScope", + "PolicyResourceGroupScopeObject", + "User", +] + + +class PolicyPermissionGroup(BaseModel): + id: str + """Identifier of the group.""" + + meta: Optional[object] = None + """Attributes associated to the permission group.""" + + name: Optional[str] = None + """Name of the group.""" + + +class PolicyResourceGroupScopeObject(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Zone ID + etc.) + """ + + +class PolicyResourceGroupScope(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Account + ID etc.) + """ + + objects: List[PolicyResourceGroupScopeObject] + """A list of scope objects for additional context.""" + + +class PolicyResourceGroup(BaseModel): + id: str + """Identifier of the group.""" + + scope: List[PolicyResourceGroupScope] + """The scope associated to the resource group""" + + meta: Optional[object] = None + """Attributes associated to the resource group.""" + + name: Optional[str] = None + """Name of the resource group.""" + + +class Policy(BaseModel): + id: Optional[str] = None + """Policy identifier.""" + + access: Optional[Literal["allow", "deny"]] = None + """Allow or deny operations against the resources.""" + + permission_groups: Optional[List[PolicyPermissionGroup]] = None + """A set of permission groups that are specified to the policy.""" + + resource_groups: Optional[List[PolicyResourceGroup]] = None + """A list of resource groups that the policy applies to.""" + + +class User(BaseModel): + email: str + """The contact email address of the user.""" + + id: Optional[str] = None + """Identifier""" + + first_name: Optional[str] = None + """User's first name""" + + last_name: Optional[str] = None + """User's last name""" + + two_factor_authentication_enabled: Optional[bool] = None + """Indicates whether two-factor authentication is enabled for the user account. + + Does not apply to API authentication. + """ + + +class MemberListResponse(BaseModel): + id: Optional[str] = None + """Membership identifier tag.""" + + policies: Optional[List[Policy]] = None + """Access policy for the membership""" + + roles: Optional[List[Role]] = None + """Roles assigned to this Member.""" + + status: Optional[Literal["accepted", "pending"]] = None + """A member's status in the account.""" + + user: Optional[User] = None + """Details of the user associated to the membership.""" diff --git a/src/cloudflare/types/accounts/member_update_params.py b/src/cloudflare/types/accounts/member_update_params.py index 66b3ee3cbac..559895f2ca0 100644 --- a/src/cloudflare/types/accounts/member_update_params.py +++ b/src/cloudflare/types/accounts/member_update_params.py @@ -2,19 +2,60 @@ from __future__ import annotations -from typing import Iterable -from typing_extensions import Required, TypedDict +from typing import Union, Iterable +from typing_extensions import Literal, Required, TypedDict -__all__ = ["MemberUpdateParams", "Role"] +__all__ = [ + "MemberUpdateParams", + "Member", + "MemberRole", + "IamUpdateMemberWithPolicies", + "IamUpdateMemberWithPoliciesPolicy", + "IamUpdateMemberWithPoliciesPolicyPermissionGroup", + "IamUpdateMemberWithPoliciesPolicyResourceGroup", +] -class MemberUpdateParams(TypedDict, total=False): +class Member(TypedDict, total=False): account_id: Required[str] + """Account identifier tag.""" - roles: Iterable[Role] + roles: Iterable[MemberRole] """Roles assigned to this member.""" -class Role(TypedDict, total=False): +class MemberRole(TypedDict, total=False): id: Required[str] """Role identifier tag.""" + + +class IamUpdateMemberWithPolicies(TypedDict, total=False): + account_id: Required[str] + """Account identifier tag.""" + + policies: Required[Iterable[IamUpdateMemberWithPoliciesPolicy]] + """Array of policies associated with this member.""" + + +class IamUpdateMemberWithPoliciesPolicyPermissionGroup(TypedDict, total=False): + id: Required[str] + """Identifier of the group.""" + + +class IamUpdateMemberWithPoliciesPolicyResourceGroup(TypedDict, total=False): + id: Required[str] + """Identifier of the group.""" + + +class IamUpdateMemberWithPoliciesPolicy(TypedDict, total=False): + access: Required[Literal["allow", "deny"]] + """Allow or deny operations against the resources.""" + + permission_groups: Required[Iterable[IamUpdateMemberWithPoliciesPolicyPermissionGroup]] + """A set of permission groups that are specified to the policy.""" + + resource_groups: Required[Iterable[IamUpdateMemberWithPoliciesPolicyResourceGroup]] + """A list of resource groups that the policy applies to.""" + + +MemberUpdateParams = Union[Member, IamUpdateMemberWithPolicies] diff --git a/src/cloudflare/types/accounts/member_update_response.py b/src/cloudflare/types/accounts/member_update_response.py index 47de5ca79fe..0c92f9b20fb 100644 --- a/src/cloudflare/types/accounts/member_update_response.py +++ b/src/cloudflare/types/accounts/member_update_response.py @@ -1,15 +1,112 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union, Optional +from typing import List, Optional +from typing_extensions import Literal from ..._models import BaseModel -from ..shared.member import Member +from ..shared.role import Role -__all__ = ["MemberUpdateResponse", "IamAPIResponseCommon"] +__all__ = [ + "MemberUpdateResponse", + "Policy", + "PolicyPermissionGroup", + "PolicyResourceGroup", + "PolicyResourceGroupScope", + "PolicyResourceGroupScopeObject", + "User", +] -class IamAPIResponseCommon(BaseModel): - result: Optional[Member] = None +class PolicyPermissionGroup(BaseModel): + id: str + """Identifier of the group.""" + meta: Optional[object] = None + """Attributes associated to the permission group.""" -MemberUpdateResponse = Union[IamAPIResponseCommon, IamAPIResponseCommon] + name: Optional[str] = None + """Name of the group.""" + + +class PolicyResourceGroupScopeObject(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Zone ID + etc.) + """ + + +class PolicyResourceGroupScope(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Account + ID etc.) + """ + + objects: List[PolicyResourceGroupScopeObject] + """A list of scope objects for additional context.""" + + +class PolicyResourceGroup(BaseModel): + id: str + """Identifier of the group.""" + + scope: List[PolicyResourceGroupScope] + """The scope associated to the resource group""" + + meta: Optional[object] = None + """Attributes associated to the resource group.""" + + name: Optional[str] = None + """Name of the resource group.""" + + +class Policy(BaseModel): + id: Optional[str] = None + """Policy identifier.""" + + access: Optional[Literal["allow", "deny"]] = None + """Allow or deny operations against the resources.""" + + permission_groups: Optional[List[PolicyPermissionGroup]] = None + """A set of permission groups that are specified to the policy.""" + + resource_groups: Optional[List[PolicyResourceGroup]] = None + """A list of resource groups that the policy applies to.""" + + +class User(BaseModel): + email: str + """The contact email address of the user.""" + + id: Optional[str] = None + """Identifier""" + + first_name: Optional[str] = None + """User's first name""" + + last_name: Optional[str] = None + """User's last name""" + + two_factor_authentication_enabled: Optional[bool] = None + """Indicates whether two-factor authentication is enabled for the user account. + + Does not apply to API authentication. + """ + + +class MemberUpdateResponse(BaseModel): + id: Optional[str] = None + """Membership identifier tag.""" + + policies: Optional[List[Policy]] = None + """Access policy for the membership""" + + roles: Optional[List[Role]] = None + """Roles assigned to this Member.""" + + status: Optional[Literal["accepted", "pending"]] = None + """A member's status in the account.""" + + user: Optional[User] = None + """Details of the user associated to the membership.""" diff --git a/src/cloudflare/types/addressing/address_map_create_params.py b/src/cloudflare/types/addressing/address_map_create_params.py index ac313102d61..b0eae43afc8 100644 --- a/src/cloudflare/types/addressing/address_map_create_params.py +++ b/src/cloudflare/types/addressing/address_map_create_params.py @@ -2,10 +2,12 @@ from __future__ import annotations -from typing import List, Iterable, Optional -from typing_extensions import Required, TypedDict +from typing import List, Union, Iterable, Optional +from datetime import datetime +from typing_extensions import Required, Annotated, TypedDict from .kind import Kind +from ..._utils import PropertyInfo __all__ = ["AddressMapCreateParams", "Membership"] @@ -37,6 +39,8 @@ class AddressMapCreateParams(TypedDict, total=False): class Membership(TypedDict, total=False): + created_at: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] + identifier: str """The identifier for the membership (eg. a zone or account tag).""" diff --git a/src/cloudflare/types/kv/namespace_delete_response.py b/src/cloudflare/types/kv/namespace_delete_response.py index 9e59782ae79..eb6f28e4253 100644 --- a/src/cloudflare/types/kv/namespace_delete_response.py +++ b/src/cloudflare/types/kv/namespace_delete_response.py @@ -1,7 +1,11 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union + + +from ..._models import BaseModel __all__ = ["NamespaceDeleteResponse"] -NamespaceDeleteResponse = Union[str, object] + +class NamespaceDeleteResponse(BaseModel): + pass diff --git a/src/cloudflare/types/kv/namespace_update_response.py b/src/cloudflare/types/kv/namespace_update_response.py index fbd61fb15c8..b8f763fc2e9 100644 --- a/src/cloudflare/types/kv/namespace_update_response.py +++ b/src/cloudflare/types/kv/namespace_update_response.py @@ -1,7 +1,11 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union + + +from ..._models import BaseModel __all__ = ["NamespaceUpdateResponse"] -NamespaceUpdateResponse = Union[str, object] + +class NamespaceUpdateResponse(BaseModel): + pass diff --git a/src/cloudflare/types/kv/namespaces/__init__.py b/src/cloudflare/types/kv/namespaces/__init__.py index e7c21904155..69632f0965e 100644 --- a/src/cloudflare/types/kv/namespaces/__init__.py +++ b/src/cloudflare/types/kv/namespaces/__init__.py @@ -5,9 +5,9 @@ from .key import Key as Key from .key_list_params import KeyListParams as KeyListParams from .bulk_update_params import BulkUpdateParams as BulkUpdateParams -from .value_get_response import ValueGetResponse as ValueGetResponse from .value_update_params import ValueUpdateParams as ValueUpdateParams from .bulk_delete_response import BulkDeleteResponse as BulkDeleteResponse from .bulk_update_response import BulkUpdateResponse as BulkUpdateResponse +from .metadata_get_response import MetadataGetResponse as MetadataGetResponse from .value_delete_response import ValueDeleteResponse as ValueDeleteResponse from .value_update_response import ValueUpdateResponse as ValueUpdateResponse diff --git a/src/cloudflare/types/kv/namespaces/bulk_delete_response.py b/src/cloudflare/types/kv/namespaces/bulk_delete_response.py index 56c602c8530..4ae88607764 100644 --- a/src/cloudflare/types/kv/namespaces/bulk_delete_response.py +++ b/src/cloudflare/types/kv/namespaces/bulk_delete_response.py @@ -1,7 +1,11 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union + + +from ...._models import BaseModel __all__ = ["BulkDeleteResponse"] -BulkDeleteResponse = Union[str, object] + +class BulkDeleteResponse(BaseModel): + pass diff --git a/src/cloudflare/types/kv/namespaces/bulk_update_params.py b/src/cloudflare/types/kv/namespaces/bulk_update_params.py index c78d5da68ad..6cb8d8702c8 100644 --- a/src/cloudflare/types/kv/namespaces/bulk_update_params.py +++ b/src/cloudflare/types/kv/namespaces/bulk_update_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Iterable +from typing import Dict, Iterable from typing_extensions import Required, TypedDict __all__ = ["BulkUpdateParams", "Body"] @@ -42,7 +42,7 @@ class Body(TypedDict, total=False): valid. """ - metadata: object + metadata: Dict[str, object] """Arbitrary JSON that is associated with a key.""" value: str diff --git a/src/cloudflare/types/kv/namespaces/bulk_update_response.py b/src/cloudflare/types/kv/namespaces/bulk_update_response.py index 7a1f035d954..55544c65e54 100644 --- a/src/cloudflare/types/kv/namespaces/bulk_update_response.py +++ b/src/cloudflare/types/kv/namespaces/bulk_update_response.py @@ -1,7 +1,11 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union + + +from ...._models import BaseModel __all__ = ["BulkUpdateResponse"] -BulkUpdateResponse = Union[str, object] + +class BulkUpdateResponse(BaseModel): + pass diff --git a/src/cloudflare/types/kv/namespaces/key.py b/src/cloudflare/types/kv/namespaces/key.py index 604b5d06192..5b48057e954 100644 --- a/src/cloudflare/types/kv/namespaces/key.py +++ b/src/cloudflare/types/kv/namespaces/key.py @@ -1,6 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Optional +from typing import Dict, Optional from ...._models import BaseModel @@ -21,5 +21,5 @@ class Key(BaseModel): will expire. This property is omitted for keys that will not expire. """ - metadata: Optional[object] = None + metadata: Optional[Dict[str, object]] = None """Arbitrary JSON that is associated with a key.""" diff --git a/src/cloudflare/types/kv/namespaces/metadata_get_response.py b/src/cloudflare/types/kv/namespaces/metadata_get_response.py new file mode 100644 index 00000000000..6b0475335e2 --- /dev/null +++ b/src/cloudflare/types/kv/namespaces/metadata_get_response.py @@ -0,0 +1,7 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict + +__all__ = ["MetadataGetResponse"] + +MetadataGetResponse = Dict[str, object] diff --git a/src/cloudflare/types/kv/namespaces/value_delete_response.py b/src/cloudflare/types/kv/namespaces/value_delete_response.py index 7c3d2c3fb80..224a80852b0 100644 --- a/src/cloudflare/types/kv/namespaces/value_delete_response.py +++ b/src/cloudflare/types/kv/namespaces/value_delete_response.py @@ -1,7 +1,11 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union + + +from ...._models import BaseModel __all__ = ["ValueDeleteResponse"] -ValueDeleteResponse = Union[str, object] + +class ValueDeleteResponse(BaseModel): + pass diff --git a/src/cloudflare/types/kv/namespaces/value_get_response.py b/src/cloudflare/types/kv/namespaces/value_get_response.py deleted file mode 100644 index 81657f0d82b..00000000000 --- a/src/cloudflare/types/kv/namespaces/value_get_response.py +++ /dev/null @@ -1,6 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - - -__all__ = ["ValueGetResponse"] - -ValueGetResponse = str diff --git a/src/cloudflare/types/kv/namespaces/value_update_response.py b/src/cloudflare/types/kv/namespaces/value_update_response.py index 30f088b4fd9..40ffa943af8 100644 --- a/src/cloudflare/types/kv/namespaces/value_update_response.py +++ b/src/cloudflare/types/kv/namespaces/value_update_response.py @@ -1,7 +1,11 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union + + +from ...._models import BaseModel __all__ = ["ValueUpdateResponse"] -ValueUpdateResponse = Union[str, object] + +class ValueUpdateResponse(BaseModel): + pass diff --git a/src/cloudflare/types/memberships/membership_get_response.py b/src/cloudflare/types/memberships/membership_get_response.py index e586b51180f..d828d038709 100644 --- a/src/cloudflare/types/memberships/membership_get_response.py +++ b/src/cloudflare/types/memberships/membership_get_response.py @@ -1,15 +1,128 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union, Optional +from typing import List, Optional +from typing_extensions import Literal from ..._models import BaseModel -from .membership import Membership +from ..accounts.account import Account +from ..shared.permission_grant import PermissionGrant -__all__ = ["MembershipGetResponse", "IamAPIResponseCommon"] +__all__ = [ + "MembershipGetResponse", + "Permissions", + "Policy", + "PolicyPermissionGroup", + "PolicyResourceGroup", + "PolicyResourceGroupScope", + "PolicyResourceGroupScopeObject", +] -class IamAPIResponseCommon(BaseModel): - result: Optional[Membership] = None +class Permissions(BaseModel): + analytics: Optional[PermissionGrant] = None + billing: Optional[PermissionGrant] = None -MembershipGetResponse = Union[IamAPIResponseCommon, IamAPIResponseCommon] + cache_purge: Optional[PermissionGrant] = None + + dns: Optional[PermissionGrant] = None + + dns_records: Optional[PermissionGrant] = None + + lb: Optional[PermissionGrant] = None + + logs: Optional[PermissionGrant] = None + + organization: Optional[PermissionGrant] = None + + ssl: Optional[PermissionGrant] = None + + waf: Optional[PermissionGrant] = None + + zone_settings: Optional[PermissionGrant] = None + + zones: Optional[PermissionGrant] = None + + +class PolicyPermissionGroup(BaseModel): + id: str + """Identifier of the group.""" + + meta: Optional[object] = None + """Attributes associated to the permission group.""" + + name: Optional[str] = None + """Name of the group.""" + + +class PolicyResourceGroupScopeObject(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Zone ID + etc.) + """ + + +class PolicyResourceGroupScope(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Account + ID etc.) + """ + + objects: List[PolicyResourceGroupScopeObject] + """A list of scope objects for additional context.""" + + +class PolicyResourceGroup(BaseModel): + id: str + """Identifier of the group.""" + + scope: List[PolicyResourceGroupScope] + """The scope associated to the resource group""" + + meta: Optional[object] = None + """Attributes associated to the resource group.""" + + name: Optional[str] = None + """Name of the resource group.""" + + +class Policy(BaseModel): + id: Optional[str] = None + """Policy identifier.""" + + access: Optional[Literal["allow", "deny"]] = None + """Allow or deny operations against the resources.""" + + permission_groups: Optional[List[PolicyPermissionGroup]] = None + """A set of permission groups that are specified to the policy.""" + + resource_groups: Optional[List[PolicyResourceGroup]] = None + """A list of resource groups that the policy applies to.""" + + +class MembershipGetResponse(BaseModel): + id: Optional[str] = None + """Membership identifier tag.""" + + account: Optional[Account] = None + + api_access_enabled: Optional[bool] = None + """Enterprise only. + + Indicates whether or not API access is enabled specifically for this user on a + given account. + """ + + permissions: Optional[Permissions] = None + """All access permissions for the user at the account.""" + + policies: Optional[List[Policy]] = None + """Access policy for the membership""" + + roles: Optional[List[str]] = None + """List of role names for the user at the account.""" + + status: Optional[Literal["accepted", "pending", "rejected"]] = None + """Status of this membership.""" diff --git a/src/cloudflare/types/memberships/membership_update_response.py b/src/cloudflare/types/memberships/membership_update_response.py index 6aa89e9311b..ee118776d7c 100644 --- a/src/cloudflare/types/memberships/membership_update_response.py +++ b/src/cloudflare/types/memberships/membership_update_response.py @@ -1,15 +1,128 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union, Optional +from typing import List, Optional +from typing_extensions import Literal from ..._models import BaseModel -from .membership import Membership +from ..accounts.account import Account +from ..shared.permission_grant import PermissionGrant -__all__ = ["MembershipUpdateResponse", "IamAPIResponseCommon"] +__all__ = [ + "MembershipUpdateResponse", + "Permissions", + "Policy", + "PolicyPermissionGroup", + "PolicyResourceGroup", + "PolicyResourceGroupScope", + "PolicyResourceGroupScopeObject", +] -class IamAPIResponseCommon(BaseModel): - result: Optional[Membership] = None +class Permissions(BaseModel): + analytics: Optional[PermissionGrant] = None + billing: Optional[PermissionGrant] = None -MembershipUpdateResponse = Union[IamAPIResponseCommon, IamAPIResponseCommon] + cache_purge: Optional[PermissionGrant] = None + + dns: Optional[PermissionGrant] = None + + dns_records: Optional[PermissionGrant] = None + + lb: Optional[PermissionGrant] = None + + logs: Optional[PermissionGrant] = None + + organization: Optional[PermissionGrant] = None + + ssl: Optional[PermissionGrant] = None + + waf: Optional[PermissionGrant] = None + + zone_settings: Optional[PermissionGrant] = None + + zones: Optional[PermissionGrant] = None + + +class PolicyPermissionGroup(BaseModel): + id: str + """Identifier of the group.""" + + meta: Optional[object] = None + """Attributes associated to the permission group.""" + + name: Optional[str] = None + """Name of the group.""" + + +class PolicyResourceGroupScopeObject(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Zone ID + etc.) + """ + + +class PolicyResourceGroupScope(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Account + ID etc.) + """ + + objects: List[PolicyResourceGroupScopeObject] + """A list of scope objects for additional context.""" + + +class PolicyResourceGroup(BaseModel): + id: str + """Identifier of the group.""" + + scope: List[PolicyResourceGroupScope] + """The scope associated to the resource group""" + + meta: Optional[object] = None + """Attributes associated to the resource group.""" + + name: Optional[str] = None + """Name of the resource group.""" + + +class Policy(BaseModel): + id: Optional[str] = None + """Policy identifier.""" + + access: Optional[Literal["allow", "deny"]] = None + """Allow or deny operations against the resources.""" + + permission_groups: Optional[List[PolicyPermissionGroup]] = None + """A set of permission groups that are specified to the policy.""" + + resource_groups: Optional[List[PolicyResourceGroup]] = None + """A list of resource groups that the policy applies to.""" + + +class MembershipUpdateResponse(BaseModel): + id: Optional[str] = None + """Membership identifier tag.""" + + account: Optional[Account] = None + + api_access_enabled: Optional[bool] = None + """Enterprise only. + + Indicates whether or not API access is enabled specifically for this user on a + given account. + """ + + permissions: Optional[Permissions] = None + """All access permissions for the user at the account.""" + + policies: Optional[List[Policy]] = None + """Access policy for the membership""" + + roles: Optional[List[str]] = None + """List of role names for the user at the account.""" + + status: Optional[Literal["accepted", "pending", "rejected"]] = None + """Status of this membership.""" diff --git a/src/cloudflare/types/user/token_create_params.py b/src/cloudflare/types/user/token_create_params.py index 842eed61529..b10b10f24ca 100644 --- a/src/cloudflare/types/user/token_create_params.py +++ b/src/cloudflare/types/user/token_create_params.py @@ -32,7 +32,8 @@ class TokenCreateParams(TypedDict, total=False): class PolicyPermissionGroup(TypedDict, total=False): - pass + meta: object + """Attributes associated to the permission group.""" class Policy(TypedDict, total=False): diff --git a/src/cloudflare/types/user/token_update_params.py b/src/cloudflare/types/user/token_update_params.py index 9299975073e..7cd89a8938a 100644 --- a/src/cloudflare/types/user/token_update_params.py +++ b/src/cloudflare/types/user/token_update_params.py @@ -35,7 +35,8 @@ class TokenUpdateParams(TypedDict, total=False): class PolicyPermissionGroup(TypedDict, total=False): - pass + meta: object + """Attributes associated to the permission group.""" class Policy(TypedDict, total=False): diff --git a/src/cloudflare/types/workers/scripts/__init__.py b/src/cloudflare/types/workers/scripts/__init__.py index 233a054aa7a..64f34786b7c 100644 --- a/src/cloudflare/types/workers/scripts/__init__.py +++ b/src/cloudflare/types/workers/scripts/__init__.py @@ -9,6 +9,7 @@ from .tail_get_response import TailGetResponse as TailGetResponse from .tail_create_params import TailCreateParams as TailCreateParams from .setting_edit_params import SettingEditParams as SettingEditParams +from .version_list_params import VersionListParams as VersionListParams from .tail_create_response import TailCreateResponse as TailCreateResponse from .tail_delete_response import TailDeleteResponse as TailDeleteResponse from .version_get_response import VersionGetResponse as VersionGetResponse diff --git a/src/cloudflare/types/workers/scripts/version_list_params.py b/src/cloudflare/types/workers/scripts/version_list_params.py new file mode 100644 index 00000000000..b5c0dd9481e --- /dev/null +++ b/src/cloudflare/types/workers/scripts/version_list_params.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["VersionListParams"] + + +class VersionListParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + deployable: bool + """Only return versions that can be used in a deployment. Ignores pagination.""" + + page: int + """Current page.""" + + per_page: int + """Items per-page.""" diff --git a/src/cloudflare/types/workers/scripts/version_list_response.py b/src/cloudflare/types/workers/scripts/version_list_response.py index fd3de314931..b992e3fab59 100644 --- a/src/cloudflare/types/workers/scripts/version_list_response.py +++ b/src/cloudflare/types/workers/scripts/version_list_response.py @@ -1,19 +1,15 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Optional +from typing import Optional from ...._models import BaseModel -__all__ = ["VersionListResponse", "Item"] +__all__ = ["VersionListResponse"] -class Item(BaseModel): +class VersionListResponse(BaseModel): id: Optional[str] = None metadata: Optional[object] = None number: Optional[float] = None - - -class VersionListResponse(BaseModel): - items: Optional[List[Item]] = None diff --git a/tests/api_resources/accounts/test_members.py b/tests/api_resources/accounts/test_members.py index c1062178a50..b739eead76a 100644 --- a/tests/api_resources/accounts/test_members.py +++ b/tests/api_resources/accounts/test_members.py @@ -10,9 +10,9 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from cloudflare.types.shared import Member from cloudflare.types.accounts import ( MemberGetResponse, + MemberListResponse, MemberCreateResponse, MemberDeleteResponse, MemberUpdateResponse, @@ -25,9 +25,9 @@ class TestMembers: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) @parametrize - def test_method_create(self, client: Cloudflare) -> None: + def test_method_create_overload_1(self, client: Cloudflare) -> None: member = client.accounts.members.create( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", email="user@example.com", roles=[ "3536bcfad5faccb999b47003c79917fb", @@ -35,12 +35,12 @@ def test_method_create(self, client: Cloudflare) -> None: "3536bcfad5faccb999b47003c79917fb", ], ) - assert_matches_type(MemberCreateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) @parametrize - def test_method_create_with_all_params(self, client: Cloudflare) -> None: + def test_method_create_with_all_params_overload_1(self, client: Cloudflare) -> None: member = client.accounts.members.create( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", email="user@example.com", roles=[ "3536bcfad5faccb999b47003c79917fb", @@ -49,12 +49,12 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: ], status="accepted", ) - assert_matches_type(MemberCreateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) @parametrize - def test_raw_response_create(self, client: Cloudflare) -> None: + def test_raw_response_create_overload_1(self, client: Cloudflare) -> None: response = client.accounts.members.with_raw_response.create( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", email="user@example.com", roles=[ "3536bcfad5faccb999b47003c79917fb", @@ -66,12 +66,12 @@ def test_raw_response_create(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = response.parse() - assert_matches_type(MemberCreateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) @parametrize - def test_streaming_response_create(self, client: Cloudflare) -> None: + def test_streaming_response_create_overload_1(self, client: Cloudflare) -> None: with client.accounts.members.with_streaming_response.create( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", email="user@example.com", roles=[ "3536bcfad5faccb999b47003c79917fb", @@ -83,12 +83,12 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = response.parse() - assert_matches_type(MemberCreateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize - def test_path_params_create(self, client: Cloudflare) -> None: + def test_path_params_create_overload_1(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): client.accounts.members.with_raw_response.create( account_id="", @@ -100,60 +100,301 @@ def test_path_params_create(self, client: Cloudflare) -> None: ], ) + @parametrize + def test_method_create_overload_2(self, client: Cloudflare) -> None: + member = client.accounts.members.create( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) + + @parametrize + def test_method_create_with_all_params_overload_2(self, client: Cloudflare) -> None: + member = client.accounts.members.create( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + status="accepted", + ) + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) + + @parametrize + def test_raw_response_create_overload_2(self, client: Cloudflare) -> None: + response = client.accounts.members.with_raw_response.create( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + member = response.parse() + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) + + @parametrize + def test_streaming_response_create_overload_2(self, client: Cloudflare) -> None: + with client.accounts.members.with_streaming_response.create( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + member = response.parse() + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_create_overload_2(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.accounts.members.with_raw_response.create( + account_id="", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_method_update(self, client: Cloudflare) -> None: + def test_method_update_overload_1(self, client: Cloudflare) -> None: member = client.accounts.members.update( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) - assert_matches_type(MemberUpdateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberUpdateResponse], member, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_method_update_with_all_params(self, client: Cloudflare) -> None: + def test_method_update_with_all_params_overload_1(self, client: Cloudflare) -> None: member = client.accounts.members.update( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", roles=[ {"id": "3536bcfad5faccb999b47003c79917fb"}, {"id": "3536bcfad5faccb999b47003c79917fb"}, {"id": "3536bcfad5faccb999b47003c79917fb"}, ], ) - assert_matches_type(MemberUpdateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberUpdateResponse], member, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_raw_response_update(self, client: Cloudflare) -> None: + def test_raw_response_update_overload_1(self, client: Cloudflare) -> None: response = client.accounts.members.with_raw_response.update( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = response.parse() - assert_matches_type(MemberUpdateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberUpdateResponse], member, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_streaming_response_update(self, client: Cloudflare) -> None: + def test_streaming_response_update_overload_1(self, client: Cloudflare) -> None: with client.accounts.members.with_streaming_response.update( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = response.parse() - assert_matches_type(MemberUpdateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberUpdateResponse], member, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_path_params_update(self, client: Cloudflare) -> None: + def test_path_params_update_overload_1(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): client.accounts.members.with_raw_response.update( "4536bcfad5faccb111b47003c79917fa", @@ -163,49 +404,291 @@ def test_path_params_update(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `member_id` but received ''"): client.accounts.members.with_raw_response.update( "", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_overload_2(self, client: Cloudflare) -> None: + member = client.accounts.members.update( + "4536bcfad5faccb111b47003c79917fa", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + assert_matches_type(Optional[MemberUpdateResponse], member, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_update_overload_2(self, client: Cloudflare) -> None: + response = client.accounts.members.with_raw_response.update( + "4536bcfad5faccb111b47003c79917fa", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + member = response.parse() + assert_matches_type(Optional[MemberUpdateResponse], member, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_update_overload_2(self, client: Cloudflare) -> None: + with client.accounts.members.with_streaming_response.update( + "4536bcfad5faccb111b47003c79917fa", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + member = response.parse() + assert_matches_type(Optional[MemberUpdateResponse], member, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_update_overload_2(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.accounts.members.with_raw_response.update( + "4536bcfad5faccb111b47003c79917fa", + account_id="", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `member_id` but received ''"): + client.accounts.members.with_raw_response.update( + "", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], ) @parametrize def test_method_list(self, client: Cloudflare) -> None: member = client.accounts.members.list( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) - assert_matches_type(SyncV4PagePaginationArray[Member], member, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[MemberListResponse], member, path=["response"]) @parametrize def test_method_list_with_all_params(self, client: Cloudflare) -> None: member = client.accounts.members.list( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", direction="desc", order="status", page=1, per_page=5, status="accepted", ) - assert_matches_type(SyncV4PagePaginationArray[Member], member, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[MemberListResponse], member, path=["response"]) @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: response = client.accounts.members.with_raw_response.list( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = response.parse() - assert_matches_type(SyncV4PagePaginationArray[Member], member, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[MemberListResponse], member, path=["response"]) @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: with client.accounts.members.with_streaming_response.list( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = response.parse() - assert_matches_type(SyncV4PagePaginationArray[Member], member, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[MemberListResponse], member, path=["response"]) assert cast(Any, response.is_closed) is True @@ -220,7 +703,7 @@ def test_path_params_list(self, client: Cloudflare) -> None: def test_method_delete(self, client: Cloudflare) -> None: member = client.accounts.members.delete( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert_matches_type(Optional[MemberDeleteResponse], member, path=["response"]) @@ -228,7 +711,7 @@ def test_method_delete(self, client: Cloudflare) -> None: def test_raw_response_delete(self, client: Cloudflare) -> None: response = client.accounts.members.with_raw_response.delete( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert response.is_closed is True @@ -240,7 +723,7 @@ def test_raw_response_delete(self, client: Cloudflare) -> None: def test_streaming_response_delete(self, client: Cloudflare) -> None: with client.accounts.members.with_streaming_response.delete( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -261,40 +744,40 @@ def test_path_params_delete(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `member_id` but received ''"): client.accounts.members.with_raw_response.delete( "", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) @parametrize def test_method_get(self, client: Cloudflare) -> None: member = client.accounts.members.get( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) - assert_matches_type(MemberGetResponse, member, path=["response"]) + assert_matches_type(Optional[MemberGetResponse], member, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: response = client.accounts.members.with_raw_response.get( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = response.parse() - assert_matches_type(MemberGetResponse, member, path=["response"]) + assert_matches_type(Optional[MemberGetResponse], member, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: with client.accounts.members.with_streaming_response.get( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = response.parse() - assert_matches_type(MemberGetResponse, member, path=["response"]) + assert_matches_type(Optional[MemberGetResponse], member, path=["response"]) assert cast(Any, response.is_closed) is True @@ -309,7 +792,7 @@ def test_path_params_get(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `member_id` but received ''"): client.accounts.members.with_raw_response.get( "", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) @@ -317,9 +800,9 @@ class TestAsyncMembers: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @parametrize - async def test_method_create(self, async_client: AsyncCloudflare) -> None: + async def test_method_create_overload_1(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.create( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", email="user@example.com", roles=[ "3536bcfad5faccb999b47003c79917fb", @@ -327,12 +810,12 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "3536bcfad5faccb999b47003c79917fb", ], ) - assert_matches_type(MemberCreateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) @parametrize - async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + async def test_method_create_with_all_params_overload_1(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.create( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", email="user@example.com", roles=[ "3536bcfad5faccb999b47003c79917fb", @@ -341,12 +824,12 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare ], status="accepted", ) - assert_matches_type(MemberCreateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) @parametrize - async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: response = await async_client.accounts.members.with_raw_response.create( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", email="user@example.com", roles=[ "3536bcfad5faccb999b47003c79917fb", @@ -358,12 +841,12 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = await response.parse() - assert_matches_type(MemberCreateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) @parametrize - async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: async with async_client.accounts.members.with_streaming_response.create( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", email="user@example.com", roles=[ "3536bcfad5faccb999b47003c79917fb", @@ -375,12 +858,12 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = await response.parse() - assert_matches_type(MemberCreateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_create_overload_1(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): await async_client.accounts.members.with_raw_response.create( account_id="", @@ -392,60 +875,301 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: ], ) + @parametrize + async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> None: + member = await async_client.accounts.members.create( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) + + @parametrize + async def test_method_create_with_all_params_overload_2(self, async_client: AsyncCloudflare) -> None: + member = await async_client.accounts.members.create( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + status="accepted", + ) + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) + + @parametrize + async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: + response = await async_client.accounts.members.with_raw_response.create( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + member = await response.parse() + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) + + @parametrize + async def test_streaming_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: + async with async_client.accounts.members.with_streaming_response.create( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + member = await response.parse() + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_create_overload_2(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.accounts.members.with_raw_response.create( + account_id="", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update(self, async_client: AsyncCloudflare) -> None: + async def test_method_update_overload_1(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.update( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) - assert_matches_type(MemberUpdateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberUpdateResponse], member, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + async def test_method_update_with_all_params_overload_1(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.update( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", roles=[ {"id": "3536bcfad5faccb999b47003c79917fb"}, {"id": "3536bcfad5faccb999b47003c79917fb"}, {"id": "3536bcfad5faccb999b47003c79917fb"}, ], ) - assert_matches_type(MemberUpdateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberUpdateResponse], member, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: response = await async_client.accounts.members.with_raw_response.update( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = await response.parse() - assert_matches_type(MemberUpdateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberUpdateResponse], member, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: async with async_client.accounts.members.with_streaming_response.update( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = await response.parse() - assert_matches_type(MemberUpdateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberUpdateResponse], member, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_update_overload_1(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): await async_client.accounts.members.with_raw_response.update( "4536bcfad5faccb111b47003c79917fa", @@ -455,49 +1179,291 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `member_id` but received ''"): await async_client.accounts.members.with_raw_response.update( "", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_update_overload_2(self, async_client: AsyncCloudflare) -> None: + member = await async_client.accounts.members.update( + "4536bcfad5faccb111b47003c79917fa", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + assert_matches_type(Optional[MemberUpdateResponse], member, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: + response = await async_client.accounts.members.with_raw_response.update( + "4536bcfad5faccb111b47003c79917fa", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + member = await response.parse() + assert_matches_type(Optional[MemberUpdateResponse], member, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: + async with async_client.accounts.members.with_streaming_response.update( + "4536bcfad5faccb111b47003c79917fa", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + member = await response.parse() + assert_matches_type(Optional[MemberUpdateResponse], member, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_update_overload_2(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.accounts.members.with_raw_response.update( + "4536bcfad5faccb111b47003c79917fa", + account_id="", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `member_id` but received ''"): + await async_client.accounts.members.with_raw_response.update( + "", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], ) @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.list( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) - assert_matches_type(AsyncV4PagePaginationArray[Member], member, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[MemberListResponse], member, path=["response"]) @parametrize async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.list( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", direction="desc", order="status", page=1, per_page=5, status="accepted", ) - assert_matches_type(AsyncV4PagePaginationArray[Member], member, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[MemberListResponse], member, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: response = await async_client.accounts.members.with_raw_response.list( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[Member], member, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[MemberListResponse], member, path=["response"]) @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: async with async_client.accounts.members.with_streaming_response.list( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[Member], member, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[MemberListResponse], member, path=["response"]) assert cast(Any, response.is_closed) is True @@ -512,7 +1478,7 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: async def test_method_delete(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.delete( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert_matches_type(Optional[MemberDeleteResponse], member, path=["response"]) @@ -520,7 +1486,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None: async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: response = await async_client.accounts.members.with_raw_response.delete( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert response.is_closed is True @@ -532,7 +1498,7 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: async with async_client.accounts.members.with_streaming_response.delete( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -553,40 +1519,40 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `member_id` but received ''"): await async_client.accounts.members.with_raw_response.delete( "", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.get( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) - assert_matches_type(MemberGetResponse, member, path=["response"]) + assert_matches_type(Optional[MemberGetResponse], member, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.accounts.members.with_raw_response.get( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = await response.parse() - assert_matches_type(MemberGetResponse, member, path=["response"]) + assert_matches_type(Optional[MemberGetResponse], member, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: async with async_client.accounts.members.with_streaming_response.get( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = await response.parse() - assert_matches_type(MemberGetResponse, member, path=["response"]) + assert_matches_type(Optional[MemberGetResponse], member, path=["response"]) assert cast(Any, response.is_closed) is True @@ -601,5 +1567,5 @@ async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `member_id` but received ''"): await async_client.accounts.members.with_raw_response.get( "", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) diff --git a/tests/api_resources/accounts/test_roles.py b/tests/api_resources/accounts/test_roles.py index 768327bb0a6..4236c1b2b13 100644 --- a/tests/api_resources/accounts/test_roles.py +++ b/tests/api_resources/accounts/test_roles.py @@ -21,14 +21,14 @@ class TestRoles: @parametrize def test_method_list(self, client: Cloudflare) -> None: role = client.accounts.roles.list( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert_matches_type(SyncSinglePage[Role], role, path=["response"]) @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: response = client.accounts.roles.with_raw_response.list( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert response.is_closed is True @@ -39,7 +39,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: with client.accounts.roles.with_streaming_response.list( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -60,7 +60,7 @@ def test_path_params_list(self, client: Cloudflare) -> None: def test_method_get(self, client: Cloudflare) -> None: role = client.accounts.roles.get( {}, - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert_matches_type(object, role, path=["response"]) @@ -68,7 +68,7 @@ def test_method_get(self, client: Cloudflare) -> None: def test_raw_response_get(self, client: Cloudflare) -> None: response = client.accounts.roles.with_raw_response.get( {}, - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert response.is_closed is True @@ -80,7 +80,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: def test_streaming_response_get(self, client: Cloudflare) -> None: with client.accounts.roles.with_streaming_response.get( {}, - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -105,14 +105,14 @@ class TestAsyncRoles: @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: role = await async_client.accounts.roles.list( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert_matches_type(AsyncSinglePage[Role], role, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: response = await async_client.accounts.roles.with_raw_response.list( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert response.is_closed is True @@ -123,7 +123,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: async with async_client.accounts.roles.with_streaming_response.list( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -144,7 +144,7 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: async def test_method_get(self, async_client: AsyncCloudflare) -> None: role = await async_client.accounts.roles.get( {}, - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert_matches_type(object, role, path=["response"]) @@ -152,7 +152,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.accounts.roles.with_raw_response.get( {}, - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert response.is_closed is True @@ -164,7 +164,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: async with async_client.accounts.roles.with_streaming_response.get( {}, - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/api_resources/addressing/test_address_maps.py b/tests/api_resources/addressing/test_address_maps.py index a883e9dfd4b..f8e982e4260 100644 --- a/tests/api_resources/addressing/test_address_maps.py +++ b/tests/api_resources/addressing/test_address_maps.py @@ -9,6 +9,7 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type +from cloudflare._utils import parse_datetime from cloudflare.pagination import SyncSinglePage, AsyncSinglePage from cloudflare.types.addressing import ( AddressMap, @@ -39,14 +40,17 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: ips=["192.0.2.1", "192.0.2.1", "192.0.2.1"], memberships=[ { + "created_at": parse_datetime("2014-01-01T05:20:00.12345Z"), "identifier": "023e105f4ecef8ad9ca31a8372d0c353", "kind": "zone", }, { + "created_at": parse_datetime("2014-01-01T05:20:00.12345Z"), "identifier": "023e105f4ecef8ad9ca31a8372d0c353", "kind": "zone", }, { + "created_at": parse_datetime("2014-01-01T05:20:00.12345Z"), "identifier": "023e105f4ecef8ad9ca31a8372d0c353", "kind": "zone", }, @@ -298,14 +302,17 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare ips=["192.0.2.1", "192.0.2.1", "192.0.2.1"], memberships=[ { + "created_at": parse_datetime("2014-01-01T05:20:00.12345Z"), "identifier": "023e105f4ecef8ad9ca31a8372d0c353", "kind": "zone", }, { + "created_at": parse_datetime("2014-01-01T05:20:00.12345Z"), "identifier": "023e105f4ecef8ad9ca31a8372d0c353", "kind": "zone", }, { + "created_at": parse_datetime("2014-01-01T05:20:00.12345Z"), "identifier": "023e105f4ecef8ad9ca31a8372d0c353", "kind": "zone", }, diff --git a/tests/api_resources/kv/namespaces/test_bulk.py b/tests/api_resources/kv/namespaces/test_bulk.py index c941e118037..6a37a64f90e 100644 --- a/tests/api_resources/kv/namespaces/test_bulk.py +++ b/tests/api_resources/kv/namespaces/test_bulk.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -24,7 +24,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", body=[{}, {}, {}], ) - assert_matches_type(BulkUpdateResponse, bulk, path=["response"]) + assert_matches_type(Optional[BulkUpdateResponse], bulk, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_raw_response_update(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" bulk = response.parse() - assert_matches_type(BulkUpdateResponse, bulk, path=["response"]) + assert_matches_type(Optional[BulkUpdateResponse], bulk, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -50,7 +50,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" bulk = response.parse() - assert_matches_type(BulkUpdateResponse, bulk, path=["response"]) + assert_matches_type(Optional[BulkUpdateResponse], bulk, path=["response"]) assert cast(Any, response.is_closed) is True @@ -76,7 +76,7 @@ def test_method_delete(self, client: Cloudflare) -> None: "0f2ac74b498b48028cb68387c421e279", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(BulkDeleteResponse, bulk, path=["response"]) + assert_matches_type(Optional[BulkDeleteResponse], bulk, path=["response"]) @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: @@ -88,7 +88,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" bulk = response.parse() - assert_matches_type(BulkDeleteResponse, bulk, path=["response"]) + assert_matches_type(Optional[BulkDeleteResponse], bulk, path=["response"]) @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" bulk = response.parse() - assert_matches_type(BulkDeleteResponse, bulk, path=["response"]) + assert_matches_type(Optional[BulkDeleteResponse], bulk, path=["response"]) assert cast(Any, response.is_closed) is True @@ -129,7 +129,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", body=[{}, {}, {}], ) - assert_matches_type(BulkUpdateResponse, bulk, path=["response"]) + assert_matches_type(Optional[BulkUpdateResponse], bulk, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -142,7 +142,7 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" bulk = await response.parse() - assert_matches_type(BulkUpdateResponse, bulk, path=["response"]) + assert_matches_type(Optional[BulkUpdateResponse], bulk, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -155,7 +155,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" bulk = await response.parse() - assert_matches_type(BulkUpdateResponse, bulk, path=["response"]) + assert_matches_type(Optional[BulkUpdateResponse], bulk, path=["response"]) assert cast(Any, response.is_closed) is True @@ -181,7 +181,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None: "0f2ac74b498b48028cb68387c421e279", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(BulkDeleteResponse, bulk, path=["response"]) + assert_matches_type(Optional[BulkDeleteResponse], bulk, path=["response"]) @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: @@ -193,7 +193,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" bulk = await response.parse() - assert_matches_type(BulkDeleteResponse, bulk, path=["response"]) + assert_matches_type(Optional[BulkDeleteResponse], bulk, path=["response"]) @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: @@ -205,7 +205,7 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" bulk = await response.parse() - assert_matches_type(BulkDeleteResponse, bulk, path=["response"]) + assert_matches_type(Optional[BulkDeleteResponse], bulk, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/kv/namespaces/test_metadata.py b/tests/api_resources/kv/namespaces/test_metadata.py index e7f40bbb7bd..7c8a4325a43 100644 --- a/tests/api_resources/kv/namespaces/test_metadata.py +++ b/tests/api_resources/kv/namespaces/test_metadata.py @@ -3,12 +3,13 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type +from cloudflare.types.kv.namespaces import MetadataGetResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -23,7 +24,7 @@ def test_method_get(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", namespace_id="0f2ac74b498b48028cb68387c421e279", ) - assert_matches_type(object, metadata, path=["response"]) + assert_matches_type(Optional[MetadataGetResponse], metadata, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -36,7 +37,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" metadata = response.parse() - assert_matches_type(object, metadata, path=["response"]) + assert_matches_type(Optional[MetadataGetResponse], metadata, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -49,7 +50,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" metadata = response.parse() - assert_matches_type(object, metadata, path=["response"]) + assert_matches_type(Optional[MetadataGetResponse], metadata, path=["response"]) assert cast(Any, response.is_closed) is True @@ -87,7 +88,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", namespace_id="0f2ac74b498b48028cb68387c421e279", ) - assert_matches_type(object, metadata, path=["response"]) + assert_matches_type(Optional[MetadataGetResponse], metadata, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -100,7 +101,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" metadata = await response.parse() - assert_matches_type(object, metadata, path=["response"]) + assert_matches_type(Optional[MetadataGetResponse], metadata, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -113,7 +114,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" metadata = await response.parse() - assert_matches_type(object, metadata, path=["response"]) + assert_matches_type(Optional[MetadataGetResponse], metadata, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/kv/namespaces/test_values.py b/tests/api_resources/kv/namespaces/test_values.py index af7e9da5b3b..d090fd1683d 100644 --- a/tests/api_resources/kv/namespaces/test_values.py +++ b/tests/api_resources/kv/namespaces/test_values.py @@ -3,16 +3,21 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast +import httpx import pytest +from respx import MockRouter from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type -from cloudflare.types.kv.namespaces import ( - ValueDeleteResponse, - ValueUpdateResponse, +from cloudflare._response import ( + BinaryAPIResponse, + AsyncBinaryAPIResponse, + StreamedBinaryAPIResponse, + AsyncStreamedBinaryAPIResponse, ) +from cloudflare.types.kv.namespaces import ValueDeleteResponse, ValueUpdateResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -30,7 +35,7 @@ def test_method_update(self, client: Cloudflare) -> None: metadata='{"someMetadataKey": "someMetadataValue"}', value="Some Value", ) - assert_matches_type(ValueUpdateResponse, value, path=["response"]) + assert_matches_type(Optional[ValueUpdateResponse], value, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -46,7 +51,7 @@ def test_raw_response_update(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" value = response.parse() - assert_matches_type(ValueUpdateResponse, value, path=["response"]) + assert_matches_type(Optional[ValueUpdateResponse], value, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -62,7 +67,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" value = response.parse() - assert_matches_type(ValueUpdateResponse, value, path=["response"]) + assert_matches_type(Optional[ValueUpdateResponse], value, path=["response"]) assert cast(Any, response.is_closed) is True @@ -103,7 +108,7 @@ def test_method_delete(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", namespace_id="0f2ac74b498b48028cb68387c421e279", ) - assert_matches_type(ValueDeleteResponse, value, path=["response"]) + assert_matches_type(Optional[ValueDeleteResponse], value, path=["response"]) @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: @@ -116,7 +121,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" value = response.parse() - assert_matches_type(ValueDeleteResponse, value, path=["response"]) + assert_matches_type(Optional[ValueDeleteResponse], value, path=["response"]) @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: @@ -129,7 +134,7 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" value = response.parse() - assert_matches_type(ValueDeleteResponse, value, path=["response"]) + assert_matches_type(Optional[ValueDeleteResponse], value, path=["response"]) assert cast(Any, response.is_closed) is True @@ -157,43 +162,61 @@ def test_path_params_delete(self, client: Cloudflare) -> None: ) @parametrize - def test_method_get(self, client: Cloudflare) -> None: + @pytest.mark.respx(base_url=base_url) + def test_method_get(self, client: Cloudflare, respx_mock: MockRouter) -> None: + respx_mock.get( + "/accounts/023e105f4ecef8ad9ca31a8372d0c353/storage/kv/namespaces/0f2ac74b498b48028cb68387c421e279/values/My-Key" + ).mock(return_value=httpx.Response(200, json={"foo": "bar"})) value = client.kv.namespaces.values.get( "My-Key", account_id="023e105f4ecef8ad9ca31a8372d0c353", namespace_id="0f2ac74b498b48028cb68387c421e279", ) - assert_matches_type(str, value, path=["response"]) + assert value.is_closed + assert value.json() == {"foo": "bar"} + assert cast(Any, value.is_closed) is True + assert isinstance(value, BinaryAPIResponse) @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.kv.namespaces.values.with_raw_response.get( + @pytest.mark.respx(base_url=base_url) + def test_raw_response_get(self, client: Cloudflare, respx_mock: MockRouter) -> None: + respx_mock.get( + "/accounts/023e105f4ecef8ad9ca31a8372d0c353/storage/kv/namespaces/0f2ac74b498b48028cb68387c421e279/values/My-Key" + ).mock(return_value=httpx.Response(200, json={"foo": "bar"})) + + value = client.kv.namespaces.values.with_raw_response.get( "My-Key", account_id="023e105f4ecef8ad9ca31a8372d0c353", namespace_id="0f2ac74b498b48028cb68387c421e279", ) - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - value = response.parse() - assert_matches_type(str, value, path=["response"]) + assert value.is_closed is True + assert value.http_request.headers.get("X-Stainless-Lang") == "python" + assert value.json() == {"foo": "bar"} + assert isinstance(value, BinaryAPIResponse) @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: + @pytest.mark.respx(base_url=base_url) + def test_streaming_response_get(self, client: Cloudflare, respx_mock: MockRouter) -> None: + respx_mock.get( + "/accounts/023e105f4ecef8ad9ca31a8372d0c353/storage/kv/namespaces/0f2ac74b498b48028cb68387c421e279/values/My-Key" + ).mock(return_value=httpx.Response(200, json={"foo": "bar"})) with client.kv.namespaces.values.with_streaming_response.get( "My-Key", account_id="023e105f4ecef8ad9ca31a8372d0c353", namespace_id="0f2ac74b498b48028cb68387c421e279", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ) as value: + assert not value.is_closed + assert value.http_request.headers.get("X-Stainless-Lang") == "python" - value = response.parse() - assert_matches_type(str, value, path=["response"]) + assert value.json() == {"foo": "bar"} + assert cast(Any, value.is_closed) is True + assert isinstance(value, StreamedBinaryAPIResponse) - assert cast(Any, response.is_closed) is True + assert cast(Any, value.is_closed) is True @parametrize + @pytest.mark.respx(base_url=base_url) 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.kv.namespaces.values.with_raw_response.get( @@ -230,7 +253,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: metadata='{"someMetadataKey": "someMetadataValue"}', value="Some Value", ) - assert_matches_type(ValueUpdateResponse, value, path=["response"]) + assert_matches_type(Optional[ValueUpdateResponse], value, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -246,7 +269,7 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" value = await response.parse() - assert_matches_type(ValueUpdateResponse, value, path=["response"]) + assert_matches_type(Optional[ValueUpdateResponse], value, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -262,7 +285,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" value = await response.parse() - assert_matches_type(ValueUpdateResponse, value, path=["response"]) + assert_matches_type(Optional[ValueUpdateResponse], value, path=["response"]) assert cast(Any, response.is_closed) is True @@ -303,7 +326,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", namespace_id="0f2ac74b498b48028cb68387c421e279", ) - assert_matches_type(ValueDeleteResponse, value, path=["response"]) + assert_matches_type(Optional[ValueDeleteResponse], value, path=["response"]) @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: @@ -316,7 +339,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" value = await response.parse() - assert_matches_type(ValueDeleteResponse, value, path=["response"]) + assert_matches_type(Optional[ValueDeleteResponse], value, path=["response"]) @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: @@ -329,7 +352,7 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" value = await response.parse() - assert_matches_type(ValueDeleteResponse, value, path=["response"]) + assert_matches_type(Optional[ValueDeleteResponse], value, path=["response"]) assert cast(Any, response.is_closed) is True @@ -357,43 +380,61 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: ) @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: + @pytest.mark.respx(base_url=base_url) + async def test_method_get(self, async_client: AsyncCloudflare, respx_mock: MockRouter) -> None: + respx_mock.get( + "/accounts/023e105f4ecef8ad9ca31a8372d0c353/storage/kv/namespaces/0f2ac74b498b48028cb68387c421e279/values/My-Key" + ).mock(return_value=httpx.Response(200, json={"foo": "bar"})) value = await async_client.kv.namespaces.values.get( "My-Key", account_id="023e105f4ecef8ad9ca31a8372d0c353", namespace_id="0f2ac74b498b48028cb68387c421e279", ) - assert_matches_type(str, value, path=["response"]) + assert value.is_closed + assert await value.json() == {"foo": "bar"} + assert cast(Any, value.is_closed) is True + assert isinstance(value, AsyncBinaryAPIResponse) @parametrize - async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.kv.namespaces.values.with_raw_response.get( + @pytest.mark.respx(base_url=base_url) + async def test_raw_response_get(self, async_client: AsyncCloudflare, respx_mock: MockRouter) -> None: + respx_mock.get( + "/accounts/023e105f4ecef8ad9ca31a8372d0c353/storage/kv/namespaces/0f2ac74b498b48028cb68387c421e279/values/My-Key" + ).mock(return_value=httpx.Response(200, json={"foo": "bar"})) + + value = await async_client.kv.namespaces.values.with_raw_response.get( "My-Key", account_id="023e105f4ecef8ad9ca31a8372d0c353", namespace_id="0f2ac74b498b48028cb68387c421e279", ) - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - value = await response.parse() - assert_matches_type(str, value, path=["response"]) + assert value.is_closed is True + assert value.http_request.headers.get("X-Stainless-Lang") == "python" + assert await value.json() == {"foo": "bar"} + assert isinstance(value, AsyncBinaryAPIResponse) @parametrize - async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + @pytest.mark.respx(base_url=base_url) + async def test_streaming_response_get(self, async_client: AsyncCloudflare, respx_mock: MockRouter) -> None: + respx_mock.get( + "/accounts/023e105f4ecef8ad9ca31a8372d0c353/storage/kv/namespaces/0f2ac74b498b48028cb68387c421e279/values/My-Key" + ).mock(return_value=httpx.Response(200, json={"foo": "bar"})) async with async_client.kv.namespaces.values.with_streaming_response.get( "My-Key", account_id="023e105f4ecef8ad9ca31a8372d0c353", namespace_id="0f2ac74b498b48028cb68387c421e279", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ) as value: + assert not value.is_closed + assert value.http_request.headers.get("X-Stainless-Lang") == "python" - value = await response.parse() - assert_matches_type(str, value, path=["response"]) + assert await value.json() == {"foo": "bar"} + assert cast(Any, value.is_closed) is True + assert isinstance(value, AsyncStreamedBinaryAPIResponse) - assert cast(Any, response.is_closed) is True + assert cast(Any, value.is_closed) is True @parametrize + @pytest.mark.respx(base_url=base_url) 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.kv.namespaces.values.with_raw_response.get( diff --git a/tests/api_resources/kv/test_namespaces.py b/tests/api_resources/kv/test_namespaces.py index d263f63eae8..c8be55ff1e2 100644 --- a/tests/api_resources/kv/test_namespaces.py +++ b/tests/api_resources/kv/test_namespaces.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", title="My Own Namespace", ) - assert_matches_type(Namespace, namespace, path=["response"]) + assert_matches_type(Optional[Namespace], namespace, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -40,7 +40,7 @@ def test_raw_response_create(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" namespace = response.parse() - assert_matches_type(Namespace, namespace, path=["response"]) + assert_matches_type(Optional[Namespace], namespace, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" namespace = response.parse() - assert_matches_type(Namespace, namespace, path=["response"]) + assert_matches_type(Optional[Namespace], namespace, path=["response"]) assert cast(Any, response.is_closed) is True @@ -71,7 +71,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", title="My Own Namespace", ) - assert_matches_type(NamespaceUpdateResponse, namespace, path=["response"]) + assert_matches_type(Optional[NamespaceUpdateResponse], namespace, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -84,7 +84,7 @@ def test_raw_response_update(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" namespace = response.parse() - assert_matches_type(NamespaceUpdateResponse, namespace, path=["response"]) + assert_matches_type(Optional[NamespaceUpdateResponse], namespace, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -97,7 +97,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" namespace = response.parse() - assert_matches_type(NamespaceUpdateResponse, namespace, path=["response"]) + assert_matches_type(Optional[NamespaceUpdateResponse], namespace, path=["response"]) assert cast(Any, response.is_closed) is True @@ -172,7 +172,7 @@ def test_method_delete(self, client: Cloudflare) -> None: "0f2ac74b498b48028cb68387c421e279", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(NamespaceDeleteResponse, namespace, path=["response"]) + assert_matches_type(Optional[NamespaceDeleteResponse], namespace, path=["response"]) @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: @@ -184,7 +184,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" namespace = response.parse() - assert_matches_type(NamespaceDeleteResponse, namespace, path=["response"]) + assert_matches_type(Optional[NamespaceDeleteResponse], namespace, path=["response"]) @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: @@ -196,7 +196,7 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" namespace = response.parse() - assert_matches_type(NamespaceDeleteResponse, namespace, path=["response"]) + assert_matches_type(Optional[NamespaceDeleteResponse], namespace, path=["response"]) assert cast(Any, response.is_closed) is True @@ -220,7 +220,7 @@ def test_method_get(self, client: Cloudflare) -> None: "0f2ac74b498b48028cb68387c421e279", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Namespace, namespace, path=["response"]) + assert_matches_type(Optional[Namespace], namespace, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -232,7 +232,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" namespace = response.parse() - assert_matches_type(Namespace, namespace, path=["response"]) + assert_matches_type(Optional[Namespace], namespace, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -244,7 +244,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" namespace = response.parse() - assert_matches_type(Namespace, namespace, path=["response"]) + assert_matches_type(Optional[Namespace], namespace, path=["response"]) assert cast(Any, response.is_closed) is True @@ -272,7 +272,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", title="My Own Namespace", ) - assert_matches_type(Namespace, namespace, path=["response"]) + assert_matches_type(Optional[Namespace], namespace, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -284,7 +284,7 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" namespace = await response.parse() - assert_matches_type(Namespace, namespace, path=["response"]) + assert_matches_type(Optional[Namespace], namespace, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -296,7 +296,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" namespace = await response.parse() - assert_matches_type(Namespace, namespace, path=["response"]) + assert_matches_type(Optional[Namespace], namespace, path=["response"]) assert cast(Any, response.is_closed) is True @@ -315,7 +315,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", title="My Own Namespace", ) - assert_matches_type(NamespaceUpdateResponse, namespace, path=["response"]) + assert_matches_type(Optional[NamespaceUpdateResponse], namespace, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -328,7 +328,7 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" namespace = await response.parse() - assert_matches_type(NamespaceUpdateResponse, namespace, path=["response"]) + assert_matches_type(Optional[NamespaceUpdateResponse], namespace, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -341,7 +341,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" namespace = await response.parse() - assert_matches_type(NamespaceUpdateResponse, namespace, path=["response"]) + assert_matches_type(Optional[NamespaceUpdateResponse], namespace, path=["response"]) assert cast(Any, response.is_closed) is True @@ -416,7 +416,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None: "0f2ac74b498b48028cb68387c421e279", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(NamespaceDeleteResponse, namespace, path=["response"]) + assert_matches_type(Optional[NamespaceDeleteResponse], namespace, path=["response"]) @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: @@ -428,7 +428,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" namespace = await response.parse() - assert_matches_type(NamespaceDeleteResponse, namespace, path=["response"]) + assert_matches_type(Optional[NamespaceDeleteResponse], namespace, path=["response"]) @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: @@ -440,7 +440,7 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" namespace = await response.parse() - assert_matches_type(NamespaceDeleteResponse, namespace, path=["response"]) + assert_matches_type(Optional[NamespaceDeleteResponse], namespace, path=["response"]) assert cast(Any, response.is_closed) is True @@ -464,7 +464,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "0f2ac74b498b48028cb68387c421e279", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Namespace, namespace, path=["response"]) + assert_matches_type(Optional[Namespace], namespace, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -476,7 +476,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" namespace = await response.parse() - assert_matches_type(Namespace, namespace, path=["response"]) + assert_matches_type(Optional[Namespace], namespace, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" namespace = await response.parse() - assert_matches_type(Namespace, namespace, path=["response"]) + assert_matches_type(Optional[Namespace], namespace, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/storage/test_analytics.py b/tests/api_resources/storage/test_analytics.py index bd9e182261e..d75ef09d287 100644 --- a/tests/api_resources/storage/test_analytics.py +++ b/tests/api_resources/storage/test_analytics.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -23,7 +23,7 @@ def test_method_list(self, client: Cloudflare) -> None: analytics = client.storage.analytics.list( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Schema, analytics, path=["response"]) + assert_matches_type(Optional[Schema], analytics, path=["response"]) @parametrize def test_method_list_with_all_params(self, client: Cloudflare) -> None: @@ -39,7 +39,7 @@ def test_method_list_with_all_params(self, client: Cloudflare) -> None: "until": parse_datetime("2019-01-02T03:20:00Z"), }, ) - assert_matches_type(Schema, analytics, path=["response"]) + assert_matches_type(Optional[Schema], analytics, path=["response"]) @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: @@ -50,7 +50,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" analytics = response.parse() - assert_matches_type(Schema, analytics, path=["response"]) + assert_matches_type(Optional[Schema], analytics, path=["response"]) @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" analytics = response.parse() - assert_matches_type(Schema, analytics, path=["response"]) + assert_matches_type(Optional[Schema], analytics, path=["response"]) assert cast(Any, response.is_closed) is True @@ -77,7 +77,7 @@ def test_method_stored(self, client: Cloudflare) -> None: analytics = client.storage.analytics.stored( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Components, analytics, path=["response"]) + assert_matches_type(Optional[Components], analytics, path=["response"]) @parametrize def test_method_stored_with_all_params(self, client: Cloudflare) -> None: @@ -93,7 +93,7 @@ def test_method_stored_with_all_params(self, client: Cloudflare) -> None: "until": parse_datetime("2019-01-02T03:20:00Z"), }, ) - assert_matches_type(Components, analytics, path=["response"]) + assert_matches_type(Optional[Components], analytics, path=["response"]) @parametrize def test_raw_response_stored(self, client: Cloudflare) -> None: @@ -104,7 +104,7 @@ def test_raw_response_stored(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" analytics = response.parse() - assert_matches_type(Components, analytics, path=["response"]) + assert_matches_type(Optional[Components], analytics, path=["response"]) @parametrize def test_streaming_response_stored(self, client: Cloudflare) -> None: @@ -115,7 +115,7 @@ def test_streaming_response_stored(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" analytics = response.parse() - assert_matches_type(Components, analytics, path=["response"]) + assert_matches_type(Optional[Components], analytics, path=["response"]) assert cast(Any, response.is_closed) is True @@ -135,7 +135,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: analytics = await async_client.storage.analytics.list( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Schema, analytics, path=["response"]) + assert_matches_type(Optional[Schema], analytics, path=["response"]) @parametrize async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -151,7 +151,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) "until": parse_datetime("2019-01-02T03:20:00Z"), }, ) - assert_matches_type(Schema, analytics, path=["response"]) + assert_matches_type(Optional[Schema], analytics, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: @@ -162,7 +162,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" analytics = await response.parse() - assert_matches_type(Schema, analytics, path=["response"]) + assert_matches_type(Optional[Schema], analytics, path=["response"]) @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: @@ -173,7 +173,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" analytics = await response.parse() - assert_matches_type(Schema, analytics, path=["response"]) + assert_matches_type(Optional[Schema], analytics, path=["response"]) assert cast(Any, response.is_closed) is True @@ -189,7 +189,7 @@ async def test_method_stored(self, async_client: AsyncCloudflare) -> None: analytics = await async_client.storage.analytics.stored( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Components, analytics, path=["response"]) + assert_matches_type(Optional[Components], analytics, path=["response"]) @parametrize async def test_method_stored_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -205,7 +205,7 @@ async def test_method_stored_with_all_params(self, async_client: AsyncCloudflare "until": parse_datetime("2019-01-02T03:20:00Z"), }, ) - assert_matches_type(Components, analytics, path=["response"]) + assert_matches_type(Optional[Components], analytics, path=["response"]) @parametrize async def test_raw_response_stored(self, async_client: AsyncCloudflare) -> None: @@ -216,7 +216,7 @@ async def test_raw_response_stored(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" analytics = await response.parse() - assert_matches_type(Components, analytics, path=["response"]) + assert_matches_type(Optional[Components], analytics, path=["response"]) @parametrize async def test_streaming_response_stored(self, async_client: AsyncCloudflare) -> None: @@ -227,7 +227,7 @@ async def test_streaming_response_stored(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" analytics = await response.parse() - assert_matches_type(Components, analytics, path=["response"]) + assert_matches_type(Optional[Components], analytics, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_memberships.py b/tests/api_resources/test_memberships.py index f476c5a8e2f..cb5e1358a4c 100644 --- a/tests/api_resources/test_memberships.py +++ b/tests/api_resources/test_memberships.py @@ -29,7 +29,7 @@ def test_method_update(self, client: Cloudflare) -> None: "4536bcfad5faccb111b47003c79917fa", status="accepted", ) - assert_matches_type(MembershipUpdateResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipUpdateResponse], membership, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_update(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" membership = response.parse() - assert_matches_type(MembershipUpdateResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipUpdateResponse], membership, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -53,7 +53,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" membership = response.parse() - assert_matches_type(MembershipUpdateResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipUpdateResponse], membership, path=["response"]) assert cast(Any, response.is_closed) is True @@ -146,7 +146,7 @@ def test_method_get(self, client: Cloudflare) -> None: membership = client.memberships.get( "4536bcfad5faccb111b47003c79917fa", ) - assert_matches_type(MembershipGetResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipGetResponse], membership, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -157,7 +157,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" membership = response.parse() - assert_matches_type(MembershipGetResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipGetResponse], membership, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -168,7 +168,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" membership = response.parse() - assert_matches_type(MembershipGetResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipGetResponse], membership, path=["response"]) assert cast(Any, response.is_closed) is True @@ -189,7 +189,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "4536bcfad5faccb111b47003c79917fa", status="accepted", ) - assert_matches_type(MembershipUpdateResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipUpdateResponse], membership, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -201,7 +201,7 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" membership = await response.parse() - assert_matches_type(MembershipUpdateResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipUpdateResponse], membership, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -213,7 +213,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" membership = await response.parse() - assert_matches_type(MembershipUpdateResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipUpdateResponse], membership, path=["response"]) assert cast(Any, response.is_closed) is True @@ -306,7 +306,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: membership = await async_client.memberships.get( "4536bcfad5faccb111b47003c79917fa", ) - assert_matches_type(MembershipGetResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipGetResponse], membership, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -317,7 +317,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" membership = await response.parse() - assert_matches_type(MembershipGetResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipGetResponse], membership, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -328,7 +328,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" membership = await response.parse() - assert_matches_type(MembershipGetResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipGetResponse], membership, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/user/test_tokens.py b/tests/api_resources/user/test_tokens.py index c91fbe44f60..84f1a588242 100644 --- a/tests/api_resources/user/test_tokens.py +++ b/tests/api_resources/user/test_tokens.py @@ -65,7 +65,20 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: policies=[ { "effect": "allow", - "permission_groups": [{}, {}], + "permission_groups": [ + { + "meta": { + "label": "load_balancer_admin", + "scopes": "com.cloudflare.api.account", + } + }, + { + "meta": { + "label": "fbm_user", + "scopes": "com.cloudflare.api.account", + } + }, + ], "resources": { "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", @@ -73,7 +86,20 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: }, { "effect": "allow", - "permission_groups": [{}, {}], + "permission_groups": [ + { + "meta": { + "label": "load_balancer_admin", + "scopes": "com.cloudflare.api.account", + } + }, + { + "meta": { + "label": "fbm_user", + "scopes": "com.cloudflare.api.account", + } + }, + ], "resources": { "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", @@ -81,7 +107,20 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: }, { "effect": "allow", - "permission_groups": [{}, {}], + "permission_groups": [ + { + "meta": { + "label": "load_balancer_admin", + "scopes": "com.cloudflare.api.account", + } + }, + { + "meta": { + "label": "fbm_user", + "scopes": "com.cloudflare.api.account", + } + }, + ], "resources": { "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", @@ -222,7 +261,20 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: policies=[ { "effect": "allow", - "permission_groups": [{}, {}], + "permission_groups": [ + { + "meta": { + "label": "load_balancer_admin", + "scopes": "com.cloudflare.api.account", + } + }, + { + "meta": { + "label": "fbm_user", + "scopes": "com.cloudflare.api.account", + } + }, + ], "resources": { "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", @@ -230,7 +282,20 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: }, { "effect": "allow", - "permission_groups": [{}, {}], + "permission_groups": [ + { + "meta": { + "label": "load_balancer_admin", + "scopes": "com.cloudflare.api.account", + } + }, + { + "meta": { + "label": "fbm_user", + "scopes": "com.cloudflare.api.account", + } + }, + ], "resources": { "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", @@ -238,7 +303,20 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: }, { "effect": "allow", - "permission_groups": [{}, {}], + "permission_groups": [ + { + "meta": { + "label": "load_balancer_admin", + "scopes": "com.cloudflare.api.account", + } + }, + { + "meta": { + "label": "fbm_user", + "scopes": "com.cloudflare.api.account", + } + }, + ], "resources": { "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", @@ -506,7 +584,20 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare policies=[ { "effect": "allow", - "permission_groups": [{}, {}], + "permission_groups": [ + { + "meta": { + "label": "load_balancer_admin", + "scopes": "com.cloudflare.api.account", + } + }, + { + "meta": { + "label": "fbm_user", + "scopes": "com.cloudflare.api.account", + } + }, + ], "resources": { "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", @@ -514,7 +605,20 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare }, { "effect": "allow", - "permission_groups": [{}, {}], + "permission_groups": [ + { + "meta": { + "label": "load_balancer_admin", + "scopes": "com.cloudflare.api.account", + } + }, + { + "meta": { + "label": "fbm_user", + "scopes": "com.cloudflare.api.account", + } + }, + ], "resources": { "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", @@ -522,7 +626,20 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare }, { "effect": "allow", - "permission_groups": [{}, {}], + "permission_groups": [ + { + "meta": { + "label": "load_balancer_admin", + "scopes": "com.cloudflare.api.account", + } + }, + { + "meta": { + "label": "fbm_user", + "scopes": "com.cloudflare.api.account", + } + }, + ], "resources": { "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", @@ -663,7 +780,20 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare policies=[ { "effect": "allow", - "permission_groups": [{}, {}], + "permission_groups": [ + { + "meta": { + "label": "load_balancer_admin", + "scopes": "com.cloudflare.api.account", + } + }, + { + "meta": { + "label": "fbm_user", + "scopes": "com.cloudflare.api.account", + } + }, + ], "resources": { "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", @@ -671,7 +801,20 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare }, { "effect": "allow", - "permission_groups": [{}, {}], + "permission_groups": [ + { + "meta": { + "label": "load_balancer_admin", + "scopes": "com.cloudflare.api.account", + } + }, + { + "meta": { + "label": "fbm_user", + "scopes": "com.cloudflare.api.account", + } + }, + ], "resources": { "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", @@ -679,7 +822,20 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare }, { "effect": "allow", - "permission_groups": [{}, {}], + "permission_groups": [ + { + "meta": { + "label": "load_balancer_admin", + "scopes": "com.cloudflare.api.account", + } + }, + { + "meta": { + "label": "fbm_user", + "scopes": "com.cloudflare.api.account", + } + }, + ], "resources": { "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", diff --git a/tests/api_resources/workers/scripts/test_versions.py b/tests/api_resources/workers/scripts/test_versions.py index 11e2b69000d..1642da69882 100644 --- a/tests/api_resources/workers/scripts/test_versions.py +++ b/tests/api_resources/workers/scripts/test_versions.py @@ -9,6 +9,7 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type +from cloudflare.pagination import SyncV4PagePagination, AsyncV4PagePagination from cloudflare.types.workers.scripts import ( VersionGetResponse, VersionListResponse, @@ -107,7 +108,18 @@ def test_method_list(self, client: Cloudflare) -> None: "this-is_my_script-01", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[VersionListResponse], version, path=["response"]) + assert_matches_type(SyncV4PagePagination[VersionListResponse], version, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + version = client.workers.scripts.versions.list( + "this-is_my_script-01", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + deployable=True, + page=0, + per_page=0, + ) + assert_matches_type(SyncV4PagePagination[VersionListResponse], version, path=["response"]) @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: @@ -119,7 +131,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" version = response.parse() - assert_matches_type(Optional[VersionListResponse], version, path=["response"]) + assert_matches_type(SyncV4PagePagination[VersionListResponse], version, path=["response"]) @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: @@ -131,7 +143,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" version = response.parse() - assert_matches_type(Optional[VersionListResponse], version, path=["response"]) + assert_matches_type(SyncV4PagePagination[VersionListResponse], version, path=["response"]) assert cast(Any, response.is_closed) is True @@ -299,7 +311,18 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: "this-is_my_script-01", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[VersionListResponse], version, path=["response"]) + assert_matches_type(AsyncV4PagePagination[VersionListResponse], version, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + version = await async_client.workers.scripts.versions.list( + "this-is_my_script-01", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + deployable=True, + page=0, + per_page=0, + ) + assert_matches_type(AsyncV4PagePagination[VersionListResponse], version, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: @@ -311,7 +334,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" version = await response.parse() - assert_matches_type(Optional[VersionListResponse], version, path=["response"]) + assert_matches_type(AsyncV4PagePagination[VersionListResponse], version, path=["response"]) @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: @@ -323,7 +346,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" version = await response.parse() - assert_matches_type(Optional[VersionListResponse], version, path=["response"]) + assert_matches_type(AsyncV4PagePagination[VersionListResponse], version, path=["response"]) assert cast(Any, response.is_closed) is True