Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#287)
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 e4f36e1 commit 14b8cac
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 29 deletions.
5 changes: 2 additions & 3 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from cloudflare.types import (
AuditLog,
ErrorData,
IamRole,
Identifier,
LoadBalancerPreview,
PaginationInfo,
Expand Down Expand Up @@ -54,12 +53,12 @@ Methods:
Types:

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

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/shared/iam_role.py">SyncSinglePage[IamRole]</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/accounts/role_get_response.py">RoleGetResponse</a></code>

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

Expand All @@ -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.
Expand All @@ -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(
Expand Down Expand Up @@ -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.
Expand All @@ -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(
Expand Down
1 change: 0 additions & 1 deletion src/cloudflare/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/cloudflare/types/accounts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 17 additions & 3 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 ..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):
Expand All @@ -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"]
Expand Down
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__ = ["IamRole"]
__all__ = ["RoleListResponse"]


class IamRole(BaseModel):
class RoleListResponse(BaseModel):
id: str
"""Role identifier tag."""

Expand Down
1 change: 0 additions & 1 deletion src/cloudflare/types/shared/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 17 additions & 3 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 ..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):
Expand Down Expand Up @@ -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
Expand Down
15 changes: 7 additions & 8 deletions tests/api_resources/accounts/test_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

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

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

Expand Down

0 comments on commit 14b8cac

Please sign in to comment.