diff --git a/api.md b/api.md index 09df6c50c00..340d20bfc09 100644 --- a/api.md +++ b/api.md @@ -8,8 +8,12 @@ from cloudflare.types import ( Identifier, LoadBalancerPreview, PaginationInfo, + Permission, + PermissionGrant, ResponseInfo, Result, + Role, + User, ) ``` @@ -38,22 +42,22 @@ 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) -> User +- client.accounts.members.update(member_id, \*, account_id, \*\*params) -> User - 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) -> User +- client.accounts.members.get(member_id, \*, account_id) -> User ## Roles Types: ```python -from cloudflare.types.accounts import PermissionGrant, RoleGetResponse +from cloudflare.types.accounts import RoleGetResponse ``` Methods: -- client.accounts.roles.list(\*, account_id) -> SyncSinglePage[Role] +- client.accounts.roles.list(\*, account_id) -> SyncSinglePage[Role] - client.accounts.roles.get(role_id, \*, account_id) -> RoleGetResponse # OriginCACertificates @@ -108,12 +112,12 @@ Methods: - client.memberships.delete(membership_id, \*\*params) -> MembershipDeleteResponse - client.memberships.get(membership_id) -> MembershipGetResponse -# UserResource +# User Types: ```python -from cloudflare.types import Permission, Role, User, UserEditResponse, UserGetResponse +from cloudflare.types import UserEditResponse, UserGetResponse ``` Methods: diff --git a/src/cloudflare/_client.py b/src/cloudflare/_client.py index 2eec1da5f0c..000dc7fe45a 100644 --- a/src/cloudflare/_client.py +++ b/src/cloudflare/_client.py @@ -51,7 +51,7 @@ class Cloudflare(SyncAPIClient): origin_ca_certificates: resources.OriginCACertificates ips: resources.IPs memberships: resources.Memberships - user: resources.UserResource + user: resources.User zones: resources.Zones load_balancers: resources.LoadBalancers cache: resources.Cache @@ -206,7 +206,7 @@ def __init__( self.origin_ca_certificates = resources.OriginCACertificates(self) self.ips = resources.IPs(self) self.memberships = resources.Memberships(self) - self.user = resources.UserResource(self) + self.user = resources.User(self) self.zones = resources.Zones(self) self.load_balancers = resources.LoadBalancers(self) self.cache = resources.Cache(self) @@ -464,7 +464,7 @@ class AsyncCloudflare(AsyncAPIClient): origin_ca_certificates: resources.AsyncOriginCACertificates ips: resources.AsyncIPs memberships: resources.AsyncMemberships - user: resources.AsyncUserResource + user: resources.AsyncUser zones: resources.AsyncZones load_balancers: resources.AsyncLoadBalancers cache: resources.AsyncCache @@ -619,7 +619,7 @@ def __init__( self.origin_ca_certificates = resources.AsyncOriginCACertificates(self) self.ips = resources.AsyncIPs(self) self.memberships = resources.AsyncMemberships(self) - self.user = resources.AsyncUserResource(self) + self.user = resources.AsyncUser(self) self.zones = resources.AsyncZones(self) self.load_balancers = resources.AsyncLoadBalancers(self) self.cache = resources.AsyncCache(self) @@ -878,7 +878,7 @@ def __init__(self, client: Cloudflare) -> None: self.origin_ca_certificates = resources.OriginCACertificatesWithRawResponse(client.origin_ca_certificates) self.ips = resources.IPsWithRawResponse(client.ips) self.memberships = resources.MembershipsWithRawResponse(client.memberships) - self.user = resources.UserResourceWithRawResponse(client.user) + self.user = resources.UserWithRawResponse(client.user) self.zones = resources.ZonesWithRawResponse(client.zones) self.load_balancers = resources.LoadBalancersWithRawResponse(client.load_balancers) self.cache = resources.CacheWithRawResponse(client.cache) @@ -964,7 +964,7 @@ def __init__(self, client: AsyncCloudflare) -> None: self.origin_ca_certificates = resources.AsyncOriginCACertificatesWithRawResponse(client.origin_ca_certificates) self.ips = resources.AsyncIPsWithRawResponse(client.ips) self.memberships = resources.AsyncMembershipsWithRawResponse(client.memberships) - self.user = resources.AsyncUserResourceWithRawResponse(client.user) + self.user = resources.AsyncUserWithRawResponse(client.user) self.zones = resources.AsyncZonesWithRawResponse(client.zones) self.load_balancers = resources.AsyncLoadBalancersWithRawResponse(client.load_balancers) self.cache = resources.AsyncCacheWithRawResponse(client.cache) @@ -1054,7 +1054,7 @@ def __init__(self, client: Cloudflare) -> None: self.origin_ca_certificates = resources.OriginCACertificatesWithStreamingResponse(client.origin_ca_certificates) self.ips = resources.IPsWithStreamingResponse(client.ips) self.memberships = resources.MembershipsWithStreamingResponse(client.memberships) - self.user = resources.UserResourceWithStreamingResponse(client.user) + self.user = resources.UserWithStreamingResponse(client.user) self.zones = resources.ZonesWithStreamingResponse(client.zones) self.load_balancers = resources.LoadBalancersWithStreamingResponse(client.load_balancers) self.cache = resources.CacheWithStreamingResponse(client.cache) @@ -1146,7 +1146,7 @@ def __init__(self, client: AsyncCloudflare) -> None: ) self.ips = resources.AsyncIPsWithStreamingResponse(client.ips) self.memberships = resources.AsyncMembershipsWithStreamingResponse(client.memberships) - self.user = resources.AsyncUserResourceWithStreamingResponse(client.user) + self.user = resources.AsyncUserWithStreamingResponse(client.user) self.zones = resources.AsyncZonesWithStreamingResponse(client.zones) self.load_balancers = resources.AsyncLoadBalancersWithStreamingResponse(client.load_balancers) self.cache = resources.AsyncCacheWithStreamingResponse(client.cache) diff --git a/src/cloudflare/resources/__init__.py b/src/cloudflare/resources/__init__.py index 7f3257e6d92..22875e389ef 100644 --- a/src/cloudflare/resources/__init__.py +++ b/src/cloudflare/resources/__init__.py @@ -81,12 +81,12 @@ AsyncLogsWithStreamingResponse, ) from .user import ( - UserResource, - AsyncUserResource, - UserResourceWithRawResponse, - AsyncUserResourceWithRawResponse, - UserResourceWithStreamingResponse, - AsyncUserResourceWithStreamingResponse, + User, + AsyncUser, + UserWithRawResponse, + AsyncUserWithRawResponse, + UserWithStreamingResponse, + AsyncUserWithStreamingResponse, ) from .web3 import ( Web3, @@ -666,12 +666,12 @@ "AsyncMembershipsWithRawResponse", "MembershipsWithStreamingResponse", "AsyncMembershipsWithStreamingResponse", - "UserResource", - "AsyncUserResource", - "UserResourceWithRawResponse", - "AsyncUserResourceWithRawResponse", - "UserResourceWithStreamingResponse", - "AsyncUserResourceWithStreamingResponse", + "User", + "AsyncUser", + "UserWithRawResponse", + "AsyncUserWithRawResponse", + "UserWithStreamingResponse", + "AsyncUserWithStreamingResponse", "Zones", "AsyncZones", "ZonesWithRawResponse", diff --git a/src/cloudflare/resources/accounts/members.py b/src/cloudflare/resources/accounts/members.py index 41b7eac0cfc..f91cf7916f9 100644 --- a/src/cloudflare/resources/accounts/members.py +++ b/src/cloudflare/resources/accounts/members.py @@ -7,7 +7,6 @@ import httpx -from ...types import User from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven from ..._utils import ( maybe_transform, @@ -27,6 +26,7 @@ AsyncPaginator, make_request_options, ) +from ...types.shared import User from ...types.accounts import ( MemberListResponse, UserWithInviteCode, diff --git a/src/cloudflare/resources/accounts/roles.py b/src/cloudflare/resources/accounts/roles.py index 694e09bb31c..37497467691 100644 --- a/src/cloudflare/resources/accounts/roles.py +++ b/src/cloudflare/resources/accounts/roles.py @@ -6,7 +6,6 @@ import httpx -from ...types import Role from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource @@ -22,6 +21,7 @@ AsyncPaginator, make_request_options, ) +from ...types.shared import Role from ...types.accounts import RoleGetResponse __all__ = ["Roles", "AsyncRoles"] diff --git a/src/cloudflare/resources/user/__init__.py b/src/cloudflare/resources/user/__init__.py index edfb81c9e9e..ff166570765 100644 --- a/src/cloudflare/resources/user/__init__.py +++ b/src/cloudflare/resources/user/__init__.py @@ -1,12 +1,12 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from .user import ( - UserResource, - AsyncUserResource, - UserResourceWithRawResponse, - AsyncUserResourceWithRawResponse, - UserResourceWithStreamingResponse, - AsyncUserResourceWithStreamingResponse, + User, + AsyncUser, + UserWithRawResponse, + AsyncUserWithRawResponse, + UserWithStreamingResponse, + AsyncUserWithStreamingResponse, ) from .tokens import ( Tokens, @@ -94,10 +94,10 @@ "AsyncTokensWithRawResponse", "TokensWithStreamingResponse", "AsyncTokensWithStreamingResponse", - "UserResource", - "AsyncUserResource", - "UserResourceWithRawResponse", - "AsyncUserResourceWithRawResponse", - "UserResourceWithStreamingResponse", - "AsyncUserResourceWithStreamingResponse", + "User", + "AsyncUser", + "UserWithRawResponse", + "AsyncUserWithRawResponse", + "UserWithStreamingResponse", + "AsyncUserWithStreamingResponse", ] diff --git a/src/cloudflare/resources/user/user.py b/src/cloudflare/resources/user/user.py index 59a87052725..659324ac2fe 100644 --- a/src/cloudflare/resources/user/user.py +++ b/src/cloudflare/resources/user/user.py @@ -75,10 +75,10 @@ ) from .billing.billing import Billing, AsyncBilling -__all__ = ["UserResource", "AsyncUserResource"] +__all__ = ["User", "AsyncUser"] -class UserResource(SyncAPIResource): +class User(SyncAPIResource): @cached_property def audit_logs(self) -> AuditLogs: return AuditLogs(self._client) @@ -104,12 +104,12 @@ def tokens(self) -> Tokens: return Tokens(self._client) @cached_property - def with_raw_response(self) -> UserResourceWithRawResponse: - return UserResourceWithRawResponse(self) + def with_raw_response(self) -> UserWithRawResponse: + return UserWithRawResponse(self) @cached_property - def with_streaming_response(self) -> UserResourceWithStreamingResponse: - return UserResourceWithStreamingResponse(self) + def with_streaming_response(self) -> UserWithStreamingResponse: + return UserWithStreamingResponse(self) def edit( self, @@ -204,7 +204,7 @@ def get( ) -class AsyncUserResource(AsyncAPIResource): +class AsyncUser(AsyncAPIResource): @cached_property def audit_logs(self) -> AsyncAuditLogs: return AsyncAuditLogs(self._client) @@ -230,12 +230,12 @@ def tokens(self) -> AsyncTokens: return AsyncTokens(self._client) @cached_property - def with_raw_response(self) -> AsyncUserResourceWithRawResponse: - return AsyncUserResourceWithRawResponse(self) + def with_raw_response(self) -> AsyncUserWithRawResponse: + return AsyncUserWithRawResponse(self) @cached_property - def with_streaming_response(self) -> AsyncUserResourceWithStreamingResponse: - return AsyncUserResourceWithStreamingResponse(self) + def with_streaming_response(self) -> AsyncUserWithStreamingResponse: + return AsyncUserWithStreamingResponse(self) async def edit( self, @@ -330,8 +330,8 @@ async def get( ) -class UserResourceWithRawResponse: - def __init__(self, user: UserResource) -> None: +class UserWithRawResponse: + def __init__(self, user: User) -> None: self._user = user self.edit = to_raw_response_wrapper( @@ -366,8 +366,8 @@ def tokens(self) -> TokensWithRawResponse: return TokensWithRawResponse(self._user.tokens) -class AsyncUserResourceWithRawResponse: - def __init__(self, user: AsyncUserResource) -> None: +class AsyncUserWithRawResponse: + def __init__(self, user: AsyncUser) -> None: self._user = user self.edit = async_to_raw_response_wrapper( @@ -402,8 +402,8 @@ def tokens(self) -> AsyncTokensWithRawResponse: return AsyncTokensWithRawResponse(self._user.tokens) -class UserResourceWithStreamingResponse: - def __init__(self, user: UserResource) -> None: +class UserWithStreamingResponse: + def __init__(self, user: User) -> None: self._user = user self.edit = to_streamed_response_wrapper( @@ -438,8 +438,8 @@ def tokens(self) -> TokensWithStreamingResponse: return TokensWithStreamingResponse(self._user.tokens) -class AsyncUserResourceWithStreamingResponse: - def __init__(self, user: AsyncUserResource) -> None: +class AsyncUserWithStreamingResponse: + def __init__(self, user: AsyncUser) -> None: self._user = user self.edit = async_to_streamed_response_wrapper( diff --git a/src/cloudflare/types/__init__.py b/src/cloudflare/types/__init__.py index 18ccbc14520..2d68a93c793 100644 --- a/src/cloudflare/types/__init__.py +++ b/src/cloudflare/types/__init__.py @@ -8,8 +8,6 @@ from .host import Host as Host from .info import Info as Info from .pcap import PCAP as PCAP -from .role import Role as Role -from .user import User as User from .zone import Zone as Zone from .queue import Queue as Queue from .route import Route as Route @@ -21,12 +19,16 @@ from .header import Header as Header from .origin import Origin as Origin from .shared import ( + Role as Role, + User as User, Result as Result, AuditLog as AuditLog, ErrorData as ErrorData, Identifier as Identifier, + Permission as Permission, ResponseInfo as ResponseInfo, PaginationInfo as PaginationInfo, + PermissionGrant as PermissionGrant, CloudflareTunnel as CloudflareTunnel, LoadBalancerPreview as LoadBalancerPreview, ) @@ -50,7 +52,6 @@ from .hyperdrive import Hyperdrive as Hyperdrive from .membership import Membership as Membership from .origin_dns import OriginDNS as OriginDNS -from .permission import Permission as Permission from .r2_binding import R2Binding as R2Binding from .rate_limit import RateLimit as RateLimit from .rule_match import RuleMatch as RuleMatch diff --git a/src/cloudflare/types/accounts/__init__.py b/src/cloudflare/types/accounts/__init__.py index f9a21b53a23..07fbe320baa 100644 --- a/src/cloudflare/types/accounts/__init__.py +++ b/src/cloudflare/types/accounts/__init__.py @@ -2,7 +2,6 @@ from __future__ import annotations -from .permission_grant import PermissionGrant as PermissionGrant from .role_get_response import RoleGetResponse as RoleGetResponse from .member_list_params import MemberListParams as MemberListParams from .member_create_params import MemberCreateParams as MemberCreateParams @@ -11,4 +10,3 @@ from .member_update_params import MemberUpdateParams as MemberUpdateParams from .user_with_invite_code import UserWithInviteCode as UserWithInviteCode from .member_delete_response import MemberDeleteResponse as MemberDeleteResponse -from .permission_grant_param import PermissionGrantParam as PermissionGrantParam diff --git a/src/cloudflare/types/accounts/member_list_response.py b/src/cloudflare/types/accounts/member_list_response.py index 5edc940927c..76e07eb38b3 100644 --- a/src/cloudflare/types/accounts/member_list_response.py +++ b/src/cloudflare/types/accounts/member_list_response.py @@ -3,7 +3,7 @@ from typing import List, Optional from typing_extensions import Literal -from ..role import Role +from ..shared import Role from ..._models import BaseModel __all__ = ["MemberListResponse"] diff --git a/src/cloudflare/types/accounts/user_with_invite_code.py b/src/cloudflare/types/accounts/user_with_invite_code.py index 4d121d69f1f..dafaafc28bb 100644 --- a/src/cloudflare/types/accounts/user_with_invite_code.py +++ b/src/cloudflare/types/accounts/user_with_invite_code.py @@ -2,8 +2,8 @@ from typing import List, Optional +from ..shared import PermissionGrant from ..._models import BaseModel -from .permission_grant import PermissionGrant __all__ = ["UserWithInviteCode", "Role", "RolePermissions", "User"] diff --git a/src/cloudflare/types/membership.py b/src/cloudflare/types/membership.py index 190795fd4fe..ea367a09125 100644 --- a/src/cloudflare/types/membership.py +++ b/src/cloudflare/types/membership.py @@ -3,9 +3,9 @@ from typing import List, Optional from typing_extensions import Literal +from .shared import PermissionGrant from .account import Account from .._models import BaseModel -from .accounts import PermissionGrant __all__ = ["Membership", "Permissions"] diff --git a/src/cloudflare/types/shared/__init__.py b/src/cloudflare/types/shared/__init__.py index aed721f25f7..10fae1df7bc 100644 --- a/src/cloudflare/types/shared/__init__.py +++ b/src/cloudflare/types/shared/__init__.py @@ -1,10 +1,14 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +from .role import Role as Role +from .user import User as User from .result import Result as Result from .audit_log import AuditLog as AuditLog from .error_data import ErrorData as ErrorData from .identifier import Identifier as Identifier +from .permission import Permission as Permission from .response_info import ResponseInfo as ResponseInfo from .pagination_info import PaginationInfo as PaginationInfo +from .permission_grant import PermissionGrant as PermissionGrant from .cloudflare_tunnel import CloudflareTunnel as CloudflareTunnel from .load_balancer_preview import LoadBalancerPreview as LoadBalancerPreview diff --git a/src/cloudflare/types/permission.py b/src/cloudflare/types/shared/permission.py similarity index 98% rename from src/cloudflare/types/permission.py rename to src/cloudflare/types/shared/permission.py index ccaf9fcdf5e..09793e2cb6f 100644 --- a/src/cloudflare/types/permission.py +++ b/src/cloudflare/types/shared/permission.py @@ -1,6 +1,8 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + __all__ = ["Permission"] Permission = str diff --git a/src/cloudflare/types/accounts/permission_grant.py b/src/cloudflare/types/shared/permission_grant.py similarity index 100% rename from src/cloudflare/types/accounts/permission_grant.py rename to src/cloudflare/types/shared/permission_grant.py diff --git a/src/cloudflare/types/role.py b/src/cloudflare/types/shared/role.py similarity index 92% rename from src/cloudflare/types/role.py rename to src/cloudflare/types/shared/role.py index 7c1c6bca407..8bfd1f8f6ae 100644 --- a/src/cloudflare/types/role.py +++ b/src/cloudflare/types/shared/role.py @@ -2,7 +2,7 @@ from typing import List -from .._models import BaseModel +from ..._models import BaseModel from .permission import Permission __all__ = ["Role"] diff --git a/src/cloudflare/types/user/user.py b/src/cloudflare/types/shared/user.py similarity index 96% rename from src/cloudflare/types/user/user.py rename to src/cloudflare/types/shared/user.py index 5e40ed59c40..e622f0e0f7d 100644 --- a/src/cloudflare/types/user/user.py +++ b/src/cloudflare/types/shared/user.py @@ -3,7 +3,7 @@ from typing import List, Optional from ..._models import BaseModel -from ..accounts import PermissionGrant +from .permission_grant import PermissionGrant __all__ = ["User", "Role", "RolePermissions"] diff --git a/src/cloudflare/types/shared_params/__init__.py b/src/cloudflare/types/shared_params/__init__.py new file mode 100644 index 00000000000..30c7b6a3a09 --- /dev/null +++ b/src/cloudflare/types/shared_params/__init__.py @@ -0,0 +1,3 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .permission_grant import PermissionGrant as PermissionGrant diff --git a/src/cloudflare/types/accounts/permission_grant_param.py b/src/cloudflare/types/shared_params/permission_grant.py similarity index 69% rename from src/cloudflare/types/accounts/permission_grant_param.py rename to src/cloudflare/types/shared_params/permission_grant.py index c94d30fd6a1..9e670639ee1 100644 --- a/src/cloudflare/types/accounts/permission_grant_param.py +++ b/src/cloudflare/types/shared_params/permission_grant.py @@ -4,10 +4,10 @@ from typing_extensions import TypedDict -__all__ = ["PermissionGrantParam"] +__all__ = ["PermissionGrant"] -class PermissionGrantParam(TypedDict, total=False): +class PermissionGrant(TypedDict, total=False): read: bool write: bool diff --git a/src/cloudflare/types/user/__init__.py b/src/cloudflare/types/user/__init__.py index 1b08cd94127..5cf8009e08a 100644 --- a/src/cloudflare/types/user/__init__.py +++ b/src/cloudflare/types/user/__init__.py @@ -2,7 +2,6 @@ from __future__ import annotations -from .user import User as User from .invite import Invite as Invite from .policy import Policy as Policy from .cidr_list import CIDRList as CIDRList diff --git a/src/cloudflare/types/user/invite.py b/src/cloudflare/types/user/invite.py index 4177387f9c7..94175d058b8 100644 --- a/src/cloudflare/types/user/invite.py +++ b/src/cloudflare/types/user/invite.py @@ -4,7 +4,7 @@ from datetime import datetime from typing_extensions import Literal -from ..role import Role +from ..shared import Role from ..._models import BaseModel __all__ = ["Invite"] diff --git a/src/cloudflare/types/user/organization.py b/src/cloudflare/types/user/organization.py index 83c181d4dcc..0e4881d8e7a 100644 --- a/src/cloudflare/types/user/organization.py +++ b/src/cloudflare/types/user/organization.py @@ -3,8 +3,8 @@ from typing import List, Optional from typing_extensions import Literal +from ..shared import Permission from ..._models import BaseModel -from ..permission import Permission __all__ = ["Organization"] diff --git a/tests/api_resources/accounts/test_members.py b/tests/api_resources/accounts/test_members.py index f340ce21f73..4cff489e6fa 100644 --- a/tests/api_resources/accounts/test_members.py +++ b/tests/api_resources/accounts/test_members.py @@ -9,8 +9,8 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type -from cloudflare.types import User from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from cloudflare.types.shared import User from cloudflare.types.accounts import ( MemberListResponse, UserWithInviteCode, diff --git a/tests/api_resources/accounts/test_roles.py b/tests/api_resources/accounts/test_roles.py index fcb935fa3f4..1410249e0d4 100644 --- a/tests/api_resources/accounts/test_roles.py +++ b/tests/api_resources/accounts/test_roles.py @@ -9,8 +9,8 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type -from cloudflare.types import Role from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.shared import Role from cloudflare.types.accounts import RoleGetResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")