Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Apr 22, 2024
1 parent cc646b9 commit 268e06c
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 29 deletions.
6 changes: 3 additions & 3 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Types:
```python
from cloudflare.types.accounts import (
Member,
MemberRoles,
MemberRole,
MemberWithInviteCode,
MemberListResponse,
MemberDeleteResponse,
Expand All @@ -58,12 +58,12 @@ Methods:
Types:

```python
from cloudflare.types.accounts import PermissionGrant, Role
from cloudflare.types.accounts import PermissionGrant, RoleListResponse
```

Methods:

- <code title="get /accounts/{account_id}/roles">client.accounts.roles.<a href="./src/cloudflare/resources/accounts/roles.py">list</a>(\*, account_id) -> <a href="./src/cloudflare/types/accounts/role.py">SyncSinglePage[Role]</a></code>
- <code title="get /accounts/{account_id}/roles">client.accounts.roles.<a href="./src/cloudflare/resources/accounts/roles.py">list</a>(\*, account_id) -> <a href="./src/cloudflare/types/accounts/role_list_response.py">SyncSinglePage[RoleListResponse]</a></code>
- <code title="get /accounts/{account_id}/roles/{role_id}">client.accounts.roles.<a href="./src/cloudflare/resources/accounts/roles.py">get</a>(role_id, \*, account_id) -> <a href="./src/cloudflare/types/shared/unnamed_schema_ref_9444735ca60712dbcf8afd832eb5716a.py">UnnamedSchemaRef9444735ca60712dbcf8afd832eb5716a</a></code>

# OriginCACertificates
Expand Down
14 changes: 7 additions & 7 deletions src/cloudflare/resources/accounts/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand All @@ -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.
Expand All @@ -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(
Expand Down Expand Up @@ -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.
Expand All @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/cloudflare/types/accounts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 16 additions & 2 deletions src/cloudflare/types/accounts/member_list_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

from typing import List

__all__ = ["MemberRoles"]
__all__ = ["MemberRole"]

MemberRoles = List[str]
MemberRole = List[str]
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down
4 changes: 2 additions & 2 deletions src/cloudflare/types/membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down Expand Up @@ -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
Expand Down
18 changes: 16 additions & 2 deletions src/cloudflare/types/user/invite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
14 changes: 7 additions & 7 deletions tests/api_resources/accounts/test_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 268e06c

Please sign in to comment.