Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#339)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Apr 24, 2024
1 parent 2470684 commit ac3eee6
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 34 deletions.
6 changes: 3 additions & 3 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ from cloudflare.types import (
AuditLog,
CloudflareTunnel,
ErrorData,
IamMember,
Identifier,
LoadBalancerPreview,
Member,
PaginationInfo,
Permission,
PermissionGrant,
Expand Down Expand Up @@ -47,10 +47,10 @@ from cloudflare.types.accounts import UserWithInviteCode, MemberListResponse, Me
Methods:

- <code title="post /accounts/{account_id}/members">client.accounts.members.<a href="./src/cloudflare/resources/accounts/members.py">create</a>(\*, account_id, \*\*<a href="src/cloudflare/types/accounts/member_create_params.py">params</a>) -> <a href="./src/cloudflare/types/accounts/user_with_invite_code.py">UserWithInviteCode</a></code>
- <code title="put /accounts/{account_id}/members/{member_id}">client.accounts.members.<a href="./src/cloudflare/resources/accounts/members.py">update</a>(member_id, \*, account_id, \*\*<a href="src/cloudflare/types/accounts/member_update_params.py">params</a>) -> <a href="./src/cloudflare/types/shared/iam_member.py">IamMember</a></code>
- <code title="put /accounts/{account_id}/members/{member_id}">client.accounts.members.<a href="./src/cloudflare/resources/accounts/members.py">update</a>(member_id, \*, account_id, \*\*<a href="src/cloudflare/types/accounts/member_update_params.py">params</a>) -> <a href="./src/cloudflare/types/shared/member.py">Member</a></code>
- <code title="get /accounts/{account_id}/members">client.accounts.members.<a href="./src/cloudflare/resources/accounts/members.py">list</a>(\*, account_id, \*\*<a href="src/cloudflare/types/accounts/member_list_params.py">params</a>) -> <a href="./src/cloudflare/types/accounts/member_list_response.py">SyncV4PagePaginationArray[MemberListResponse]</a></code>
- <code title="delete /accounts/{account_id}/members/{member_id}">client.accounts.members.<a href="./src/cloudflare/resources/accounts/members.py">delete</a>(member_id, \*, account_id, \*\*<a href="src/cloudflare/types/accounts/member_delete_params.py">params</a>) -> <a href="./src/cloudflare/types/accounts/member_delete_response.py">Optional</a></code>
- <code title="get /accounts/{account_id}/members/{member_id}">client.accounts.members.<a href="./src/cloudflare/resources/accounts/members.py">get</a>(member_id, \*, account_id) -> <a href="./src/cloudflare/types/shared/iam_member.py">IamMember</a></code>
- <code title="get /accounts/{account_id}/members/{member_id}">client.accounts.members.<a href="./src/cloudflare/resources/accounts/members.py">get</a>(member_id, \*, account_id) -> <a href="./src/cloudflare/types/shared/member.py">Member</a></code>

## Roles

Expand Down
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ select = [
"T201",
"T203",
# misuse of typing.TYPE_CHECKING
"TCH004"
"TCH004",
# import rules
"TID251",
]
ignore = [
# mutable defaults
Expand All @@ -178,6 +180,9 @@ ignore-init-module-imports = true
[tool.ruff.format]
docstring-code-format = true

[tool.ruff.lint.flake8-tidy-imports.banned-api]
"functools.lru_cache".msg = "This function does not retain type information for the wrapped function's arguments; The `lru_cache` function from `_utils` should be used instead"

[tool.ruff.lint.isort]
length-sort = true
length-sort-straight = true
Expand Down
3 changes: 1 addition & 2 deletions src/cloudflare/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
cast,
overload,
)
from functools import lru_cache
from typing_extensions import Literal, override, get_origin

import anyio
Expand Down Expand Up @@ -61,7 +60,7 @@
RequestOptions,
ModelBuilderProtocol,
)
from ._utils import is_dict, is_list, is_given, is_mapping
from ._utils import is_dict, is_list, is_given, lru_cache, is_mapping
from ._compat import model_copy, model_dump
from ._models import GenericModel, FinalRequestOptions, validate_type, construct_type
from ._response import (
Expand Down
2 changes: 1 addition & 1 deletion src/cloudflare/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import inspect
from typing import TYPE_CHECKING, Any, Type, Union, Generic, TypeVar, Callable, cast
from datetime import date, datetime
from functools import lru_cache
from typing_extensions import (
Unpack,
Literal,
Expand Down Expand Up @@ -37,6 +36,7 @@
PropertyInfo,
is_list,
is_given,
lru_cache,
is_mapping,
parse_date,
coerce_boolean,
Expand Down
4 changes: 3 additions & 1 deletion src/cloudflare/_utils/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,5 +395,7 @@ def lru_cache(*, maxsize: int | None = 128) -> Callable[[CallableT], CallableT]:
"""A version of functools.lru_cache that retains the type signature
for the wrapped function arguments.
"""
wrapper = functools.lru_cache(maxsize=maxsize)
wrapper = functools.lru_cache( # noqa: TID251
maxsize=maxsize,
)
return cast(Any, wrapper) # type: ignore[no-any-return]
18 changes: 9 additions & 9 deletions src/cloudflare/resources/accounts/members.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
AsyncPaginator,
make_request_options,
)
from ...types.shared import IamMember
from ...types.shared import Member
from ...types.accounts import (
MemberListResponse,
UserWithInviteCode,
Expand Down Expand Up @@ -111,7 +111,7 @@ def update(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> IamMember:
) -> Member:
"""
Modify an account member.
Expand Down Expand Up @@ -140,7 +140,7 @@ def update(
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[IamMember], ResultWrapper[IamMember]),
cast_to=cast(Type[Member], ResultWrapper[Member]),
)

def list(
Expand Down Expand Up @@ -256,7 +256,7 @@ def get(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> IamMember:
) -> Member:
"""
Get information about a specific member of an account.
Expand All @@ -282,7 +282,7 @@ def get(
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[IamMember], ResultWrapper[IamMember]),
cast_to=cast(Type[Member], ResultWrapper[Member]),
)


Expand Down Expand Up @@ -357,7 +357,7 @@ async def update(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> IamMember:
) -> Member:
"""
Modify an account member.
Expand Down Expand Up @@ -386,7 +386,7 @@ async def update(
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[IamMember], ResultWrapper[IamMember]),
cast_to=cast(Type[Member], ResultWrapper[Member]),
)

def list(
Expand Down Expand Up @@ -502,7 +502,7 @@ async def get(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> IamMember:
) -> Member:
"""
Get information about a specific member of an account.
Expand All @@ -528,7 +528,7 @@ async def get(
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[IamMember], ResultWrapper[IamMember]),
cast_to=cast(Type[Member], ResultWrapper[Member]),
)


Expand Down
2 changes: 1 addition & 1 deletion src/cloudflare/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

from .shared import (
Role as Role,
Member as Member,
Result as Result,
AuditLog as AuditLog,
ErrorData as ErrorData,
IamMember as IamMember,
Identifier as Identifier,
Permission as Permission,
ResponseInfo as ResponseInfo,
Expand Down
2 changes: 1 addition & 1 deletion src/cloudflare/types/shared/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from .role import Role as Role
from .member import Member as Member
from .result import Result as Result
from .audit_log import AuditLog as AuditLog
from .error_data import ErrorData as ErrorData
from .iam_member import IamMember as IamMember
from .identifier import Identifier as Identifier
from .permission import Permission as Permission
from .response_info import ResponseInfo as ResponseInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from ..._models import BaseModel
from .permission_grant import PermissionGrant

__all__ = ["IamMember", "Role", "RolePermissions", "User"]
__all__ = ["Member", "Role", "RolePermissions", "User"]


class RolePermissions(BaseModel):
Expand Down Expand Up @@ -67,7 +67,7 @@ class User(BaseModel):
"""


class IamMember(BaseModel):
class Member(BaseModel):
id: str
"""Membership identifier tag."""

Expand Down
26 changes: 13 additions & 13 deletions tests/api_resources/accounts/test_members.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from cloudflare import Cloudflare, AsyncCloudflare
from tests.utils import assert_matches_type
from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
from cloudflare.types.shared import IamMember
from cloudflare.types.shared import Member
from cloudflare.types.accounts import (
MemberListResponse,
UserWithInviteCode,
Expand Down Expand Up @@ -102,7 +102,7 @@ def test_method_update(self, client: Cloudflare) -> None:
{"id": "3536bcfad5faccb999b47003c79917fb"},
],
)
assert_matches_type(IamMember, member, path=["response"])
assert_matches_type(Member, member, path=["response"])

@pytest.mark.skip()
@parametrize
Expand All @@ -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(IamMember, member, path=["response"])
assert_matches_type(Member, member, path=["response"])

@pytest.mark.skip()
@parametrize
Expand All @@ -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(IamMember, member, path=["response"])
assert_matches_type(Member, member, path=["response"])

assert cast(Any, response.is_closed) is True

Expand Down Expand Up @@ -260,7 +260,7 @@ def test_method_get(self, client: Cloudflare) -> None:
"4536bcfad5faccb111b47003c79917fa",
account_id={},
)
assert_matches_type(IamMember, member, path=["response"])
assert_matches_type(Member, member, path=["response"])

@pytest.mark.skip()
@parametrize
Expand All @@ -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(IamMember, member, path=["response"])
assert_matches_type(Member, member, path=["response"])

@pytest.mark.skip()
@parametrize
Expand All @@ -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(IamMember, member, path=["response"])
assert_matches_type(Member, member, path=["response"])

assert cast(Any, response.is_closed) is True

Expand Down Expand Up @@ -382,7 +382,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None:
{"id": "3536bcfad5faccb999b47003c79917fb"},
],
)
assert_matches_type(IamMember, member, path=["response"])
assert_matches_type(Member, member, path=["response"])

@pytest.mark.skip()
@parametrize
Expand All @@ -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(IamMember, member, path=["response"])
assert_matches_type(Member, member, path=["response"])

@pytest.mark.skip()
@parametrize
Expand All @@ -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(IamMember, member, path=["response"])
assert_matches_type(Member, member, path=["response"])

assert cast(Any, response.is_closed) is True

Expand Down Expand Up @@ -540,7 +540,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None:
"4536bcfad5faccb111b47003c79917fa",
account_id={},
)
assert_matches_type(IamMember, member, path=["response"])
assert_matches_type(Member, member, path=["response"])

@pytest.mark.skip()
@parametrize
Expand All @@ -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(IamMember, member, path=["response"])
assert_matches_type(Member, member, path=["response"])

@pytest.mark.skip()
@parametrize
Expand All @@ -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(IamMember, member, path=["response"])
assert_matches_type(Member, member, path=["response"])

assert cast(Any, response.is_closed) is True

Expand Down

0 comments on commit ac3eee6

Please sign in to comment.