From 268e06ce5e360c93bbf3fdac4d4bac3fe6f50201 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 9 Apr 2024 11:08:34 +0000 Subject: [PATCH] feat(api): update via SDK Studio (#244) --- api.md | 6 +++--- src/cloudflare/resources/accounts/roles.py | 14 +++++++------- src/cloudflare/types/accounts/__init__.py | 4 ++-- .../types/accounts/member_list_response.py | 18 ++++++++++++++++-- .../{member_roles.py => member_role.py} | 4 ++-- .../{role.py => role_list_response.py} | 4 ++-- src/cloudflare/types/membership.py | 4 ++-- src/cloudflare/types/user/invite.py | 18 ++++++++++++++++-- tests/api_resources/accounts/test_roles.py | 14 +++++++------- 9 files changed, 57 insertions(+), 29 deletions(-) rename src/cloudflare/types/accounts/{member_roles.py => member_role.py} (69%) rename src/cloudflare/types/accounts/{role.py => role_list_response.py} (86%) diff --git a/api.md b/api.md index 2d7c09ff439..86d355085b2 100644 --- a/api.md +++ b/api.md @@ -38,7 +38,7 @@ Types: ```python from cloudflare.types.accounts import ( Member, - MemberRoles, + MemberRole, MemberWithInviteCode, MemberListResponse, MemberDeleteResponse, @@ -58,12 +58,12 @@ Methods: Types: ```python -from cloudflare.types.accounts import PermissionGrant, Role +from cloudflare.types.accounts import PermissionGrant, RoleListResponse ``` Methods: -- client.accounts.roles.list(\*, account_id) -> SyncSinglePage[Role] +- client.accounts.roles.list(\*, account_id) -> SyncSinglePage[RoleListResponse] - client.accounts.roles.get(role_id, \*, account_id) -> UnnamedSchemaRef9444735ca60712dbcf8afd832eb5716a # OriginCACertificates diff --git a/src/cloudflare/resources/accounts/roles.py b/src/cloudflare/resources/accounts/roles.py index eb3d45ed53a..f6b06f5ff02 100644 --- a/src/cloudflare/resources/accounts/roles.py +++ b/src/cloudflare/resources/accounts/roles.py @@ -22,7 +22,7 @@ make_request_options, ) from ...types.shared import UnnamedSchemaRef9444735ca60712dbcf8afd832eb5716a -from ...types.accounts import Role +from ...types.accounts import RoleListResponse __all__ = ["Roles", "AsyncRoles"] @@ -46,7 +46,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncSinglePage[Role]: + ) -> SyncSinglePage[RoleListResponse]: """ Get all available roles for an account. @@ -61,11 +61,11 @@ def list( """ return self._get_api_list( f"/accounts/{account_id}/roles", - page=SyncSinglePage[Role], + page=SyncSinglePage[RoleListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - model=Role, + model=RoleListResponse, ) def get( @@ -129,7 +129,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[Role, AsyncSinglePage[Role]]: + ) -> AsyncPaginator[RoleListResponse, AsyncSinglePage[RoleListResponse]]: """ Get all available roles for an account. @@ -144,11 +144,11 @@ def list( """ return self._get_api_list( f"/accounts/{account_id}/roles", - page=AsyncSinglePage[Role], + page=AsyncSinglePage[RoleListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - model=Role, + model=RoleListResponse, ) async def get( diff --git a/src/cloudflare/types/accounts/__init__.py b/src/cloudflare/types/accounts/__init__.py index d78d60fb1c3..625005b0112 100644 --- a/src/cloudflare/types/accounts/__init__.py +++ b/src/cloudflare/types/accounts/__init__.py @@ -2,11 +2,11 @@ from __future__ import annotations -from .role import Role as Role from .member import Member as Member -from .member_roles import MemberRoles as MemberRoles +from .member_role import MemberRole as MemberRole from .permission_grant import PermissionGrant as PermissionGrant from .member_list_params import MemberListParams as MemberListParams +from .role_list_response import RoleListResponse as RoleListResponse from .member_create_params import MemberCreateParams as MemberCreateParams from .member_delete_params import MemberDeleteParams as MemberDeleteParams from .member_list_response import MemberListResponse as MemberListResponse diff --git a/src/cloudflare/types/accounts/member_list_response.py b/src/cloudflare/types/accounts/member_list_response.py index 26182b74f97..ae7b932f3c0 100644 --- a/src/cloudflare/types/accounts/member_list_response.py +++ b/src/cloudflare/types/accounts/member_list_response.py @@ -3,10 +3,24 @@ from typing import List, Optional from typing_extensions import Literal -from .role import Role from ..._models import BaseModel +from ..user.tokens import Permission -__all__ = ["MemberListResponse"] +__all__ = ["MemberListResponse", "Role"] + + +class Role(BaseModel): + id: str + """Role identifier tag.""" + + description: str + """Description of role's permissions.""" + + name: str + """Role Name.""" + + permissions: List[Permission] + """Access permissions for this User.""" class MemberListResponse(BaseModel): diff --git a/src/cloudflare/types/accounts/member_roles.py b/src/cloudflare/types/accounts/member_role.py similarity index 69% rename from src/cloudflare/types/accounts/member_roles.py rename to src/cloudflare/types/accounts/member_role.py index 642965ef130..f397dc48575 100644 --- a/src/cloudflare/types/accounts/member_roles.py +++ b/src/cloudflare/types/accounts/member_role.py @@ -2,6 +2,6 @@ from typing import List -__all__ = ["MemberRoles"] +__all__ = ["MemberRole"] -MemberRoles = List[str] +MemberRole = List[str] diff --git a/src/cloudflare/types/accounts/role.py b/src/cloudflare/types/accounts/role_list_response.py similarity index 86% rename from src/cloudflare/types/accounts/role.py rename to src/cloudflare/types/accounts/role_list_response.py index 189c867a5ef..a2ed62ad78b 100644 --- a/src/cloudflare/types/accounts/role.py +++ b/src/cloudflare/types/accounts/role_list_response.py @@ -5,10 +5,10 @@ from ..._models import BaseModel from ..user.tokens import Permission -__all__ = ["Role"] +__all__ = ["RoleListResponse"] -class Role(BaseModel): +class RoleListResponse(BaseModel): id: str """Role identifier tag.""" diff --git a/src/cloudflare/types/membership.py b/src/cloudflare/types/membership.py index c55ba0db3bb..472cc749955 100644 --- a/src/cloudflare/types/membership.py +++ b/src/cloudflare/types/membership.py @@ -5,7 +5,7 @@ from .account import Account from .._models import BaseModel -from .accounts import MemberRoles, PermissionGrant +from .accounts import MemberRole, PermissionGrant __all__ = ["Membership", "Permissions"] @@ -55,7 +55,7 @@ class Membership(BaseModel): permissions: Optional[Permissions] = None """All access permissions for the user at the account.""" - roles: Optional[MemberRoles] = None + roles: Optional[MemberRole] = None """List of role names for the user at the account.""" status: Optional[Literal["accepted", "pending", "rejected"]] = None diff --git a/src/cloudflare/types/user/invite.py b/src/cloudflare/types/user/invite.py index 270306f0aed..fe493799a7a 100644 --- a/src/cloudflare/types/user/invite.py +++ b/src/cloudflare/types/user/invite.py @@ -4,10 +4,24 @@ from datetime import datetime from typing_extensions import Literal +from .tokens import Permission from ..._models import BaseModel -from ..accounts import Role -__all__ = ["Invite"] +__all__ = ["Invite", "Role"] + + +class Role(BaseModel): + id: str + """Role identifier tag.""" + + description: str + """Description of role's permissions.""" + + name: str + """Role Name.""" + + permissions: List[Permission] + """Access permissions for this User.""" class Invite(BaseModel): diff --git a/tests/api_resources/accounts/test_roles.py b/tests/api_resources/accounts/test_roles.py index 9aff85ab569..0fa4f2c8a47 100644 --- a/tests/api_resources/accounts/test_roles.py +++ b/tests/api_resources/accounts/test_roles.py @@ -11,7 +11,7 @@ from tests.utils import assert_matches_type from cloudflare.pagination import SyncSinglePage, AsyncSinglePage from cloudflare.types.shared import UnnamedSchemaRef9444735ca60712dbcf8afd832eb5716a -from cloudflare.types.accounts import Role +from cloudflare.types.accounts import RoleListResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -25,7 +25,7 @@ def test_method_list(self, client: Cloudflare) -> None: role = client.accounts.roles.list( account_id={}, ) - assert_matches_type(SyncSinglePage[Role], role, path=["response"]) + assert_matches_type(SyncSinglePage[RoleListResponse], role, path=["response"]) @pytest.mark.skip() @parametrize @@ -37,7 +37,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" role = response.parse() - assert_matches_type(SyncSinglePage[Role], role, path=["response"]) + assert_matches_type(SyncSinglePage[RoleListResponse], role, path=["response"]) @pytest.mark.skip() @parametrize @@ -49,7 +49,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" role = response.parse() - assert_matches_type(SyncSinglePage[Role], role, path=["response"]) + assert_matches_type(SyncSinglePage[RoleListResponse], role, path=["response"]) assert cast(Any, response.is_closed) is True @@ -100,7 +100,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: role = await async_client.accounts.roles.list( account_id={}, ) - assert_matches_type(AsyncSinglePage[Role], role, path=["response"]) + assert_matches_type(AsyncSinglePage[RoleListResponse], role, path=["response"]) @pytest.mark.skip() @parametrize @@ -112,7 +112,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" role = await response.parse() - assert_matches_type(AsyncSinglePage[Role], role, path=["response"]) + assert_matches_type(AsyncSinglePage[RoleListResponse], role, path=["response"]) @pytest.mark.skip() @parametrize @@ -124,7 +124,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" role = await response.parse() - assert_matches_type(AsyncSinglePage[Role], role, path=["response"]) + assert_matches_type(AsyncSinglePage[RoleListResponse], role, path=["response"]) assert cast(Any, response.is_closed) is True