From ac3eee684d64b898de829122e786d449bb878126 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 18 Apr 2024 00:55:03 +0000 Subject: [PATCH] feat(api): update via SDK Studio (#339) --- api.md | 6 ++--- pyproject.toml | 7 ++++- src/cloudflare/_base_client.py | 3 +-- src/cloudflare/_models.py | 2 +- src/cloudflare/_utils/_utils.py | 4 ++- src/cloudflare/resources/accounts/members.py | 18 ++++++------- src/cloudflare/types/__init__.py | 2 +- src/cloudflare/types/shared/__init__.py | 2 +- .../types/shared/{iam_member.py => member.py} | 4 +-- tests/api_resources/accounts/test_members.py | 26 +++++++++---------- 10 files changed, 40 insertions(+), 34 deletions(-) rename src/cloudflare/types/shared/{iam_member.py => member.py} (94%) diff --git a/api.md b/api.md index d291e9227d9..5296b26c7ed 100644 --- a/api.md +++ b/api.md @@ -5,9 +5,9 @@ from cloudflare.types import ( AuditLog, CloudflareTunnel, ErrorData, - IamMember, Identifier, LoadBalancerPreview, + Member, PaginationInfo, Permission, PermissionGrant, @@ -47,10 +47,10 @@ from cloudflare.types.accounts import UserWithInviteCode, MemberListResponse, Me Methods: - client.accounts.members.create(\*, account_id, \*\*params) -> UserWithInviteCode -- client.accounts.members.update(member_id, \*, account_id, \*\*params) -> IamMember +- client.accounts.members.update(member_id, \*, account_id, \*\*params) -> Member - client.accounts.members.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[MemberListResponse] - client.accounts.members.delete(member_id, \*, account_id, \*\*params) -> Optional -- client.accounts.members.get(member_id, \*, account_id) -> IamMember +- client.accounts.members.get(member_id, \*, account_id) -> Member ## Roles diff --git a/pyproject.toml b/pyproject.toml index e7932554a83..9fbe296573a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -162,7 +162,9 @@ select = [ "T201", "T203", # misuse of typing.TYPE_CHECKING - "TCH004" + "TCH004", + # import rules + "TID251", ] ignore = [ # mutable defaults @@ -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 diff --git a/src/cloudflare/_base_client.py b/src/cloudflare/_base_client.py index 750773d8246..142430df21a 100644 --- a/src/cloudflare/_base_client.py +++ b/src/cloudflare/_base_client.py @@ -29,7 +29,6 @@ cast, overload, ) -from functools import lru_cache from typing_extensions import Literal, override, get_origin import anyio @@ -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 ( diff --git a/src/cloudflare/_models.py b/src/cloudflare/_models.py index 80ab51256fe..ff93fbd8468 100644 --- a/src/cloudflare/_models.py +++ b/src/cloudflare/_models.py @@ -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, @@ -37,6 +36,7 @@ PropertyInfo, is_list, is_given, + lru_cache, is_mapping, parse_date, coerce_boolean, diff --git a/src/cloudflare/_utils/_utils.py b/src/cloudflare/_utils/_utils.py index 5123a230f1d..fd3a8a4d159 100644 --- a/src/cloudflare/_utils/_utils.py +++ b/src/cloudflare/_utils/_utils.py @@ -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] diff --git a/src/cloudflare/resources/accounts/members.py b/src/cloudflare/resources/accounts/members.py index 099ab5d3cf5..59edf209cc4 100644 --- a/src/cloudflare/resources/accounts/members.py +++ b/src/cloudflare/resources/accounts/members.py @@ -26,7 +26,7 @@ AsyncPaginator, make_request_options, ) -from ...types.shared import IamMember +from ...types.shared import Member from ...types.accounts import ( MemberListResponse, UserWithInviteCode, @@ -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. @@ -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( @@ -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. @@ -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]), ) @@ -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. @@ -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( @@ -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. @@ -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]), ) diff --git a/src/cloudflare/types/__init__.py b/src/cloudflare/types/__init__.py index eaac478697c..7e25cc5541f 100644 --- a/src/cloudflare/types/__init__.py +++ b/src/cloudflare/types/__init__.py @@ -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, diff --git a/src/cloudflare/types/shared/__init__.py b/src/cloudflare/types/shared/__init__.py index 04661dcf3ac..5af47daa5ea 100644 --- a/src/cloudflare/types/shared/__init__.py +++ b/src/cloudflare/types/shared/__init__.py @@ -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 diff --git a/src/cloudflare/types/shared/iam_member.py b/src/cloudflare/types/shared/member.py similarity index 94% rename from src/cloudflare/types/shared/iam_member.py rename to src/cloudflare/types/shared/member.py index 93dd9cac365..101555dd229 100644 --- a/src/cloudflare/types/shared/iam_member.py +++ b/src/cloudflare/types/shared/member.py @@ -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): @@ -67,7 +67,7 @@ class User(BaseModel): """ -class IamMember(BaseModel): +class Member(BaseModel): id: str """Membership identifier tag.""" diff --git a/tests/api_resources/accounts/test_members.py b/tests/api_resources/accounts/test_members.py index 6e647247483..c687d0cb4e1 100644 --- a/tests/api_resources/accounts/test_members.py +++ b/tests/api_resources/accounts/test_members.py @@ -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, @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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