From 6be012210168b0881bff84a405d40d0e2251ba3f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 12 Apr 2024 01:55:28 +0000 Subject: [PATCH] feat(api): update via SDK Studio (#302) --- api.md | 6 +-- src/cloudflare/resources/accounts/members.py | 18 ++++----- src/cloudflare/types/__init__.py | 1 + src/cloudflare/types/accounts/__init__.py | 1 - src/cloudflare/types/accounts/member.py | 40 -------------------- src/cloudflare/types/shared/__init__.py | 1 + src/cloudflare/types/shared/user.py | 20 ++++++++++ tests/api_resources/accounts/test_members.py | 26 ++++++------- 8 files changed, 47 insertions(+), 66 deletions(-) delete mode 100644 src/cloudflare/types/accounts/member.py create mode 100644 src/cloudflare/types/shared/user.py diff --git a/api.md b/api.md index af6282d5e79..4fe18906944 100644 --- a/api.md +++ b/api.md @@ -10,6 +10,7 @@ from cloudflare.types import ( PaginationInfo, ResponseInfo, Result, + User, ) ``` @@ -33,7 +34,6 @@ Types: ```python from cloudflare.types.accounts import ( - Member, MemberRole, MemberWithInviteCode, MemberListResponse, @@ -44,10 +44,10 @@ from cloudflare.types.accounts import ( Methods: - client.accounts.members.create(\*, account_id, \*\*params) -> MemberWithInviteCode -- client.accounts.members.update(member_id, \*, account_id, \*\*params) -> Member +- client.accounts.members.update(member_id, \*, account_id, \*\*params) -> User - client.accounts.members.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[MemberListResponse] - client.accounts.members.delete(member_id, \*, account_id, \*\*params) -> Optional -- client.accounts.members.get(member_id, \*, account_id) -> Member +- client.accounts.members.get(member_id, \*, account_id) -> User ## Roles diff --git a/src/cloudflare/resources/accounts/members.py b/src/cloudflare/resources/accounts/members.py index 76b969ef07c..7bcb1a714ab 100644 --- a/src/cloudflare/resources/accounts/members.py +++ b/src/cloudflare/resources/accounts/members.py @@ -26,8 +26,8 @@ AsyncPaginator, make_request_options, ) +from ...types.shared import User from ...types.accounts import ( - Member, MemberRoleParam, MemberListResponse, MemberDeleteResponse, @@ -112,7 +112,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Member: + ) -> User: """ Modify an account member. @@ -141,7 +141,7 @@ def update( timeout=timeout, post_parser=ResultWrapper._unwrapper, ), - cast_to=cast(Type[Member], ResultWrapper[Member]), + cast_to=cast(Type[User], ResultWrapper[User]), ) def list( @@ -257,7 +257,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Member: + ) -> User: """ Get information about a specific member of an account. @@ -283,7 +283,7 @@ def get( timeout=timeout, post_parser=ResultWrapper._unwrapper, ), - cast_to=cast(Type[Member], ResultWrapper[Member]), + cast_to=cast(Type[User], ResultWrapper[User]), ) @@ -358,7 +358,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Member: + ) -> User: """ Modify an account member. @@ -387,7 +387,7 @@ async def update( timeout=timeout, post_parser=ResultWrapper._unwrapper, ), - cast_to=cast(Type[Member], ResultWrapper[Member]), + cast_to=cast(Type[User], ResultWrapper[User]), ) def list( @@ -503,7 +503,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Member: + ) -> User: """ Get information about a specific member of an account. @@ -529,7 +529,7 @@ async def get( timeout=timeout, post_parser=ResultWrapper._unwrapper, ), - cast_to=cast(Type[Member], ResultWrapper[Member]), + cast_to=cast(Type[User], ResultWrapper[User]), ) diff --git a/src/cloudflare/types/__init__.py b/src/cloudflare/types/__init__.py index 618578f0dc5..bad3e5d09ca 100644 --- a/src/cloudflare/types/__init__.py +++ b/src/cloudflare/types/__init__.py @@ -19,6 +19,7 @@ from .header import Header as Header from .origin import Origin as Origin from .shared import ( + User as User, Result as Result, AuditLog as AuditLog, ErrorData as ErrorData, diff --git a/src/cloudflare/types/accounts/__init__.py b/src/cloudflare/types/accounts/__init__.py index a043c35c304..bedf04b227a 100644 --- a/src/cloudflare/types/accounts/__init__.py +++ b/src/cloudflare/types/accounts/__init__.py @@ -2,7 +2,6 @@ from __future__ import annotations -from .member import Member as Member from .member_role import MemberRole as MemberRole from .permission_grant import PermissionGrant as PermissionGrant from .member_role_param import MemberRoleParam as MemberRoleParam diff --git a/src/cloudflare/types/accounts/member.py b/src/cloudflare/types/accounts/member.py deleted file mode 100644 index c357dd2a41f..00000000000 --- a/src/cloudflare/types/accounts/member.py +++ /dev/null @@ -1,40 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Optional - -from ..._models import BaseModel -from .member_role import MemberRole - -__all__ = ["Member", "User"] - - -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 Member(BaseModel): - id: str - """Membership identifier tag.""" - - roles: List[MemberRole] - """Roles assigned to this member.""" - - status: object - - user: User diff --git a/src/cloudflare/types/shared/__init__.py b/src/cloudflare/types/shared/__init__.py index aed721f25f7..5ff5f4f0c0c 100644 --- a/src/cloudflare/types/shared/__init__.py +++ b/src/cloudflare/types/shared/__init__.py @@ -1,5 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +from .user import User as User from .result import Result as Result from .audit_log import AuditLog as AuditLog from .error_data import ErrorData as ErrorData diff --git a/src/cloudflare/types/shared/user.py b/src/cloudflare/types/shared/user.py new file mode 100644 index 00000000000..94dc38fde36 --- /dev/null +++ b/src/cloudflare/types/shared/user.py @@ -0,0 +1,20 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List + +from ..._models import BaseModel +from ..accounts import MemberRole + +__all__ = ["User"] + + +class User(BaseModel): + id: str + """Membership identifier tag.""" + + roles: List[MemberRole] + """Roles assigned to this member.""" + + status: object + + user: User diff --git a/tests/api_resources/accounts/test_members.py b/tests/api_resources/accounts/test_members.py index a6b5f51d162..bfb36a0055b 100644 --- a/tests/api_resources/accounts/test_members.py +++ b/tests/api_resources/accounts/test_members.py @@ -10,8 +10,8 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from cloudflare.types.shared import User from cloudflare.types.accounts import ( - Member, MemberListResponse, MemberDeleteResponse, MemberWithInviteCode, @@ -102,7 +102,7 @@ def test_method_update(self, client: Cloudflare) -> None: {"id": "3536bcfad5faccb999b47003c79917fb"}, ], ) - assert_matches_type(Member, member, path=["response"]) + assert_matches_type(User, member, path=["response"]) @pytest.mark.skip() @parametrize @@ -120,7 +120,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" member = response.parse() - assert_matches_type(Member, member, path=["response"]) + assert_matches_type(User, member, path=["response"]) @pytest.mark.skip() @parametrize @@ -138,7 +138,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = response.parse() - assert_matches_type(Member, member, path=["response"]) + assert_matches_type(User, member, path=["response"]) assert cast(Any, response.is_closed) is True @@ -260,7 +260,7 @@ def test_method_get(self, client: Cloudflare) -> None: "4536bcfad5faccb111b47003c79917fa", account_id={}, ) - assert_matches_type(Member, member, path=["response"]) + assert_matches_type(User, member, path=["response"]) @pytest.mark.skip() @parametrize @@ -273,7 +273,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" member = response.parse() - assert_matches_type(Member, member, path=["response"]) + assert_matches_type(User, member, path=["response"]) @pytest.mark.skip() @parametrize @@ -286,7 +286,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = response.parse() - assert_matches_type(Member, member, path=["response"]) + assert_matches_type(User, member, path=["response"]) assert cast(Any, response.is_closed) is True @@ -382,7 +382,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: {"id": "3536bcfad5faccb999b47003c79917fb"}, ], ) - assert_matches_type(Member, member, path=["response"]) + assert_matches_type(User, member, path=["response"]) @pytest.mark.skip() @parametrize @@ -400,7 +400,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" member = await response.parse() - assert_matches_type(Member, member, path=["response"]) + assert_matches_type(User, member, path=["response"]) @pytest.mark.skip() @parametrize @@ -418,7 +418,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = await response.parse() - assert_matches_type(Member, member, path=["response"]) + assert_matches_type(User, member, path=["response"]) assert cast(Any, response.is_closed) is True @@ -540,7 +540,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "4536bcfad5faccb111b47003c79917fa", account_id={}, ) - assert_matches_type(Member, member, path=["response"]) + assert_matches_type(User, member, path=["response"]) @pytest.mark.skip() @parametrize @@ -553,7 +553,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" member = await response.parse() - assert_matches_type(Member, member, path=["response"]) + assert_matches_type(User, member, path=["response"]) @pytest.mark.skip() @parametrize @@ -566,7 +566,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = await response.parse() - assert_matches_type(Member, member, path=["response"]) + assert_matches_type(User, member, path=["response"]) assert cast(Any, response.is_closed) is True