diff --git a/api.md b/api.md index 4de2a531f48..e0c7137075e 100644 --- a/api.md +++ b/api.md @@ -4,7 +4,6 @@ from cloudflare.types import ( AuditLog, ErrorData, - IamRole, Identifier, LoadBalancerPreview, PaginationInfo, @@ -54,12 +53,12 @@ Methods: Types: ```python -from cloudflare.types.accounts import PermissionGrant, RoleGetResponse +from cloudflare.types.accounts import PermissionGrant, RoleListResponse, RoleGetResponse ``` Methods: -- client.accounts.roles.list(\*, account_id) -> SyncSinglePage[IamRole] +- client.accounts.roles.list(\*, account_id) -> SyncSinglePage[RoleListResponse] - client.accounts.roles.get(role_id, \*, account_id) -> RoleGetResponse # OriginCACertificates diff --git a/src/cloudflare/resources/accounts/roles.py b/src/cloudflare/resources/accounts/roles.py index e56831d4144..c3d7190308e 100644 --- a/src/cloudflare/resources/accounts/roles.py +++ b/src/cloudflare/resources/accounts/roles.py @@ -21,8 +21,7 @@ AsyncPaginator, make_request_options, ) -from ...types.shared import IamRole -from ...types.accounts import RoleGetResponse +from ...types.accounts import RoleGetResponse, RoleListResponse __all__ = ["Roles", "AsyncRoles"] @@ -46,7 +45,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncSinglePage[IamRole]: + ) -> SyncSinglePage[RoleListResponse]: """ Get all available roles for an account. @@ -61,11 +60,11 @@ def list( """ return self._get_api_list( f"/accounts/{account_id}/roles", - page=SyncSinglePage[IamRole], + page=SyncSinglePage[RoleListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - model=IamRole, + model=RoleListResponse, ) def get( @@ -129,7 +128,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[IamRole, AsyncSinglePage[IamRole]]: + ) -> AsyncPaginator[RoleListResponse, AsyncSinglePage[RoleListResponse]]: """ Get all available roles for an account. @@ -144,11 +143,11 @@ def list( """ return self._get_api_list( f"/accounts/{account_id}/roles", - page=AsyncSinglePage[IamRole], + page=AsyncSinglePage[RoleListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - model=IamRole, + model=RoleListResponse, ) async def get( diff --git a/src/cloudflare/types/__init__.py b/src/cloudflare/types/__init__.py index add2017238e..ade26412b8e 100644 --- a/src/cloudflare/types/__init__.py +++ b/src/cloudflare/types/__init__.py @@ -20,7 +20,6 @@ from .origin import Origin as Origin from .shared import ( Result as Result, - IamRole as IamRole, AuditLog as AuditLog, ErrorData as ErrorData, Identifier as Identifier, diff --git a/src/cloudflare/types/accounts/__init__.py b/src/cloudflare/types/accounts/__init__.py index 4323e8c1edc..a043c35c304 100644 --- a/src/cloudflare/types/accounts/__init__.py +++ b/src/cloudflare/types/accounts/__init__.py @@ -8,6 +8,7 @@ from .member_role_param import MemberRoleParam as MemberRoleParam from .role_get_response import RoleGetResponse as RoleGetResponse 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 84eb19601f0..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 ..shared import IamRole 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): @@ -19,7 +33,7 @@ class MemberListResponse(BaseModel): name: Optional[str] = None """Member Name.""" - roles: List[IamRole] + roles: List[Role] """Roles assigned to this Member.""" status: Literal["accepted", "invited"] diff --git a/src/cloudflare/types/shared/iam_role.py b/src/cloudflare/types/accounts/role_list_response.py similarity index 86% rename from src/cloudflare/types/shared/iam_role.py rename to src/cloudflare/types/accounts/role_list_response.py index 11cd30c1882..a2ed62ad78b 100644 --- a/src/cloudflare/types/shared/iam_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__ = ["IamRole"] +__all__ = ["RoleListResponse"] -class IamRole(BaseModel): +class RoleListResponse(BaseModel): id: str """Role identifier tag.""" diff --git a/src/cloudflare/types/shared/__init__.py b/src/cloudflare/types/shared/__init__.py index f208be63f6b..ee245acbbe4 100644 --- a/src/cloudflare/types/shared/__init__.py +++ b/src/cloudflare/types/shared/__init__.py @@ -1,7 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from .result import Result as Result -from .iam_role import IamRole as IamRole from .audit_log import AuditLog as AuditLog from .error_data import ErrorData as ErrorData from .identifier import Identifier as Identifier diff --git a/src/cloudflare/types/user/invite.py b/src/cloudflare/types/user/invite.py index 44246165585..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 ..shared import IamRole +from .tokens import Permission from ..._models import BaseModel -__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): @@ -35,7 +49,7 @@ class Invite(BaseModel): organization_name: Optional[str] = None """Organization name.""" - roles: Optional[List[IamRole]] = None + roles: Optional[List[Role]] = None """Roles to be assigned to this user.""" status: Optional[Literal["pending", "accepted", "rejected", "expired"]] = None diff --git a/tests/api_resources/accounts/test_roles.py b/tests/api_resources/accounts/test_roles.py index f2fd87644ca..2cbdcfab4c5 100644 --- a/tests/api_resources/accounts/test_roles.py +++ b/tests/api_resources/accounts/test_roles.py @@ -10,8 +10,7 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.shared import IamRole -from cloudflare.types.accounts import RoleGetResponse +from cloudflare.types.accounts import RoleGetResponse, RoleListResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -25,7 +24,7 @@ def test_method_list(self, client: Cloudflare) -> None: role = client.accounts.roles.list( account_id={}, ) - assert_matches_type(SyncSinglePage[IamRole], role, path=["response"]) + assert_matches_type(SyncSinglePage[RoleListResponse], role, path=["response"]) @pytest.mark.skip() @parametrize @@ -37,7 +36,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[IamRole], role, path=["response"]) + assert_matches_type(SyncSinglePage[RoleListResponse], role, path=["response"]) @pytest.mark.skip() @parametrize @@ -49,7 +48,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[IamRole], role, path=["response"]) + assert_matches_type(SyncSinglePage[RoleListResponse], role, path=["response"]) assert cast(Any, response.is_closed) is True @@ -100,7 +99,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: role = await async_client.accounts.roles.list( account_id={}, ) - assert_matches_type(AsyncSinglePage[IamRole], role, path=["response"]) + assert_matches_type(AsyncSinglePage[RoleListResponse], role, path=["response"]) @pytest.mark.skip() @parametrize @@ -112,7 +111,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[IamRole], role, path=["response"]) + assert_matches_type(AsyncSinglePage[RoleListResponse], role, path=["response"]) @pytest.mark.skip() @parametrize @@ -124,7 +123,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[IamRole], role, path=["response"]) + assert_matches_type(AsyncSinglePage[RoleListResponse], role, path=["response"]) assert cast(Any, response.is_closed) is True