diff --git a/api.md b/api.md index e26b4e9da35..5eeb93126a1 100644 --- a/api.md +++ b/api.md @@ -89,23 +89,16 @@ Methods: Types: ```python -from cloudflare.types.accounts import ( - TokenCreateResponse, - TokenUpdateResponse, - TokenListResponse, - TokenDeleteResponse, - TokenGetResponse, - TokenVerifyResponse, -) +from cloudflare.types.accounts import TokenCreateResponse, TokenDeleteResponse, TokenVerifyResponse ``` Methods: - client.accounts.tokens.create(\*, account_id, \*\*params) -> Optional -- client.accounts.tokens.update(token_id, \*, account_id, \*\*params) -> Optional -- client.accounts.tokens.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[TokenListResponse] +- client.accounts.tokens.update(token_id, \*, account_id, \*\*params) -> Optional +- client.accounts.tokens.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Token] - client.accounts.tokens.delete(token_id, \*, account_id) -> Optional -- client.accounts.tokens.get(token_id, \*, account_id) -> Optional +- client.accounts.tokens.get(token_id, \*, account_id) -> Optional - client.accounts.tokens.verify(\*, account_id) -> Optional ### PermissionGroups @@ -277,10 +270,7 @@ from cloudflare.types.user import ( Policy, Token, TokenCreateResponse, - TokenUpdateResponse, - TokenListResponse, TokenDeleteResponse, - TokenGetResponse, TokenVerifyResponse, ) ``` @@ -288,10 +278,10 @@ from cloudflare.types.user import ( Methods: - client.user.tokens.create(\*\*params) -> Optional -- client.user.tokens.update(token_id, \*\*params) -> Optional -- client.user.tokens.list(\*\*params) -> SyncV4PagePaginationArray[TokenListResponse] +- client.user.tokens.update(token_id, \*\*params) -> Optional +- client.user.tokens.list(\*\*params) -> SyncV4PagePaginationArray[Token] - client.user.tokens.delete(token_id) -> Optional -- client.user.tokens.get(token_id) -> Optional +- client.user.tokens.get(token_id) -> Optional - client.user.tokens.verify() -> Optional ### PermissionGroups diff --git a/src/cloudflare/resources/accounts/tokens/tokens.py b/src/cloudflare/resources/accounts/tokens/tokens.py index 006bca6ae4c..a85f68c4d68 100644 --- a/src/cloudflare/resources/accounts/tokens/tokens.py +++ b/src/cloudflare/resources/accounts/tokens/tokens.py @@ -41,12 +41,10 @@ PermissionGroupsResourceWithStreamingResponse, AsyncPermissionGroupsResourceWithStreamingResponse, ) +from ....types.user.token import Token from ....types.user.policy_param import PolicyParam -from ....types.accounts.token_get_response import TokenGetResponse -from ....types.accounts.token_list_response import TokenListResponse from ....types.accounts.token_create_response import TokenCreateResponse from ....types.accounts.token_delete_response import TokenDeleteResponse -from ....types.accounts.token_update_response import TokenUpdateResponse from ....types.accounts.token_verify_response import TokenVerifyResponse __all__ = ["TokensResource", "AsyncTokensResource"] @@ -160,7 +158,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[TokenUpdateResponse]: + ) -> Optional[Token]: """ Update an existing token. @@ -210,9 +208,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[TokenUpdateResponse]]._unwrapper, + post_parser=ResultWrapper[Optional[Token]]._unwrapper, ), - cast_to=cast(Type[Optional[TokenUpdateResponse]], ResultWrapper[TokenUpdateResponse]), + cast_to=cast(Type[Optional[Token]], ResultWrapper[Token]), ) def list( @@ -228,7 +226,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncV4PagePaginationArray[TokenListResponse]: + ) -> SyncV4PagePaginationArray[Token]: """ List all Account Owned API tokens created for this account. @@ -253,7 +251,7 @@ def list( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._get_api_list( f"/accounts/{account_id}/tokens", - page=SyncV4PagePaginationArray[TokenListResponse], + page=SyncV4PagePaginationArray[Token], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -268,7 +266,7 @@ def list( token_list_params.TokenListParams, ), ), - model=TokenListResponse, + model=Token, ) def delete( @@ -326,7 +324,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[TokenGetResponse]: + ) -> Optional[Token]: """ Get information about a specific Account Owned API token. @@ -354,9 +352,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[TokenGetResponse]]._unwrapper, + post_parser=ResultWrapper[Optional[Token]]._unwrapper, ), - cast_to=cast(Type[Optional[TokenGetResponse]], ResultWrapper[TokenGetResponse]), + cast_to=cast(Type[Optional[Token]], ResultWrapper[Token]), ) def verify( @@ -507,7 +505,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[TokenUpdateResponse]: + ) -> Optional[Token]: """ Update an existing token. @@ -557,9 +555,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[TokenUpdateResponse]]._unwrapper, + post_parser=ResultWrapper[Optional[Token]]._unwrapper, ), - cast_to=cast(Type[Optional[TokenUpdateResponse]], ResultWrapper[TokenUpdateResponse]), + cast_to=cast(Type[Optional[Token]], ResultWrapper[Token]), ) def list( @@ -575,7 +573,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[TokenListResponse, AsyncV4PagePaginationArray[TokenListResponse]]: + ) -> AsyncPaginator[Token, AsyncV4PagePaginationArray[Token]]: """ List all Account Owned API tokens created for this account. @@ -600,7 +598,7 @@ def list( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._get_api_list( f"/accounts/{account_id}/tokens", - page=AsyncV4PagePaginationArray[TokenListResponse], + page=AsyncV4PagePaginationArray[Token], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -615,7 +613,7 @@ def list( token_list_params.TokenListParams, ), ), - model=TokenListResponse, + model=Token, ) async def delete( @@ -673,7 +671,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[TokenGetResponse]: + ) -> Optional[Token]: """ Get information about a specific Account Owned API token. @@ -701,9 +699,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[TokenGetResponse]]._unwrapper, + post_parser=ResultWrapper[Optional[Token]]._unwrapper, ), - cast_to=cast(Type[Optional[TokenGetResponse]], ResultWrapper[TokenGetResponse]), + cast_to=cast(Type[Optional[Token]], ResultWrapper[Token]), ) async def verify( diff --git a/src/cloudflare/resources/user/tokens/tokens.py b/src/cloudflare/resources/user/tokens/tokens.py index 9ec39ce219b..6334bc42d14 100644 --- a/src/cloudflare/resources/user/tokens/tokens.py +++ b/src/cloudflare/resources/user/tokens/tokens.py @@ -41,12 +41,10 @@ PermissionGroupsResourceWithStreamingResponse, AsyncPermissionGroupsResourceWithStreamingResponse, ) +from ....types.user.token import Token from ....types.user.policy_param import PolicyParam -from ....types.user.token_get_response import TokenGetResponse -from ....types.user.token_list_response import TokenListResponse from ....types.user.token_create_response import TokenCreateResponse from ....types.user.token_delete_response import TokenDeleteResponse -from ....types.user.token_update_response import TokenUpdateResponse from ....types.user.token_verify_response import TokenVerifyResponse __all__ = ["TokensResource", "AsyncTokensResource"] @@ -154,7 +152,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[TokenUpdateResponse]: + ) -> Optional[Token]: """ Update an existing token. @@ -200,9 +198,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[TokenUpdateResponse]]._unwrapper, + post_parser=ResultWrapper[Optional[Token]]._unwrapper, ), - cast_to=cast(Type[Optional[TokenUpdateResponse]], ResultWrapper[TokenUpdateResponse]), + cast_to=cast(Type[Optional[Token]], ResultWrapper[Token]), ) def list( @@ -217,7 +215,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncV4PagePaginationArray[TokenListResponse]: + ) -> SyncV4PagePaginationArray[Token]: """ List all access tokens you created. @@ -238,7 +236,7 @@ def list( """ return self._get_api_list( "/user/tokens", - page=SyncV4PagePaginationArray[TokenListResponse], + page=SyncV4PagePaginationArray[Token], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -253,7 +251,7 @@ def list( token_list_params.TokenListParams, ), ), - model=TokenListResponse, + model=Token, ) def delete( @@ -305,7 +303,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[TokenGetResponse]: + ) -> Optional[Token]: """ Get information about a specific token. @@ -329,9 +327,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[TokenGetResponse]]._unwrapper, + post_parser=ResultWrapper[Optional[Token]]._unwrapper, ), - cast_to=cast(Type[Optional[TokenGetResponse]], ResultWrapper[TokenGetResponse]), + cast_to=cast(Type[Optional[Token]], ResultWrapper[Token]), ) def verify( @@ -460,7 +458,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[TokenUpdateResponse]: + ) -> Optional[Token]: """ Update an existing token. @@ -506,9 +504,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[TokenUpdateResponse]]._unwrapper, + post_parser=ResultWrapper[Optional[Token]]._unwrapper, ), - cast_to=cast(Type[Optional[TokenUpdateResponse]], ResultWrapper[TokenUpdateResponse]), + cast_to=cast(Type[Optional[Token]], ResultWrapper[Token]), ) def list( @@ -523,7 +521,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[TokenListResponse, AsyncV4PagePaginationArray[TokenListResponse]]: + ) -> AsyncPaginator[Token, AsyncV4PagePaginationArray[Token]]: """ List all access tokens you created. @@ -544,7 +542,7 @@ def list( """ return self._get_api_list( "/user/tokens", - page=AsyncV4PagePaginationArray[TokenListResponse], + page=AsyncV4PagePaginationArray[Token], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -559,7 +557,7 @@ def list( token_list_params.TokenListParams, ), ), - model=TokenListResponse, + model=Token, ) async def delete( @@ -611,7 +609,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[TokenGetResponse]: + ) -> Optional[Token]: """ Get information about a specific token. @@ -635,9 +633,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[TokenGetResponse]]._unwrapper, + post_parser=ResultWrapper[Optional[Token]]._unwrapper, ), - cast_to=cast(Type[Optional[TokenGetResponse]], ResultWrapper[TokenGetResponse]), + cast_to=cast(Type[Optional[Token]], ResultWrapper[Token]), ) async def verify( diff --git a/src/cloudflare/types/accounts/__init__.py b/src/cloudflare/types/accounts/__init__.py index af56c08969a..261550ea29d 100644 --- a/src/cloudflare/types/accounts/__init__.py +++ b/src/cloudflare/types/accounts/__init__.py @@ -6,10 +6,8 @@ from .account import Account as Account from .token_list_params import TokenListParams as TokenListParams from .member_list_params import MemberListParams as MemberListParams -from .token_get_response import TokenGetResponse as TokenGetResponse from .account_list_params import AccountListParams as AccountListParams from .token_create_params import TokenCreateParams as TokenCreateParams -from .token_list_response import TokenListResponse as TokenListResponse from .token_update_params import TokenUpdateParams as TokenUpdateParams from .member_create_params import MemberCreateParams as MemberCreateParams from .member_update_params import MemberUpdateParams as MemberUpdateParams @@ -17,7 +15,6 @@ from .account_update_params import AccountUpdateParams as AccountUpdateParams from .token_create_response import TokenCreateResponse as TokenCreateResponse from .token_delete_response import TokenDeleteResponse as TokenDeleteResponse -from .token_update_response import TokenUpdateResponse as TokenUpdateResponse from .token_verify_response import TokenVerifyResponse as TokenVerifyResponse from .member_delete_response import MemberDeleteResponse as MemberDeleteResponse from .account_delete_response import AccountDeleteResponse as AccountDeleteResponse diff --git a/src/cloudflare/types/accounts/token_get_response.py b/src/cloudflare/types/accounts/token_get_response.py deleted file mode 100644 index 310d239f501..00000000000 --- a/src/cloudflare/types/accounts/token_get_response.py +++ /dev/null @@ -1,60 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Optional -from datetime import datetime -from typing_extensions import Literal - -from pydantic import Field as FieldInfo - -from ..._models import BaseModel -from ..user.policy import Policy -from ..user.cidr_list import CIDRList - -__all__ = ["TokenGetResponse", "Condition", "ConditionRequestIP"] - - -class ConditionRequestIP(BaseModel): - in_: Optional[List[CIDRList]] = FieldInfo(alias="in", default=None) - """List of IPv4/IPv6 CIDR addresses.""" - - not_in: Optional[List[CIDRList]] = None - """List of IPv4/IPv6 CIDR addresses.""" - - -class Condition(BaseModel): - request_ip: Optional[ConditionRequestIP] = FieldInfo(alias="request.ip", default=None) - """Client IP restrictions.""" - - -class TokenGetResponse(BaseModel): - id: Optional[str] = None - """Token identifier tag.""" - - condition: Optional[Condition] = None - - expires_on: Optional[datetime] = None - """ - The expiration time on or after which the JWT MUST NOT be accepted for - processing. - """ - - issued_on: Optional[datetime] = None - """The time on which the token was created.""" - - last_used_on: Optional[datetime] = None - """Last time the token was used.""" - - modified_on: Optional[datetime] = None - """Last time the token was modified.""" - - name: Optional[str] = None - """Token name.""" - - not_before: Optional[datetime] = None - """The time before which the token MUST NOT be accepted for processing.""" - - policies: Optional[List[Policy]] = None - """List of access policies assigned to the token.""" - - status: Optional[Literal["active", "disabled", "expired"]] = None - """Status of the token.""" diff --git a/src/cloudflare/types/accounts/token_list_response.py b/src/cloudflare/types/accounts/token_list_response.py deleted file mode 100644 index b02b87a1abe..00000000000 --- a/src/cloudflare/types/accounts/token_list_response.py +++ /dev/null @@ -1,60 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Optional -from datetime import datetime -from typing_extensions import Literal - -from pydantic import Field as FieldInfo - -from ..._models import BaseModel -from ..user.policy import Policy -from ..user.cidr_list import CIDRList - -__all__ = ["TokenListResponse", "Condition", "ConditionRequestIP"] - - -class ConditionRequestIP(BaseModel): - in_: Optional[List[CIDRList]] = FieldInfo(alias="in", default=None) - """List of IPv4/IPv6 CIDR addresses.""" - - not_in: Optional[List[CIDRList]] = None - """List of IPv4/IPv6 CIDR addresses.""" - - -class Condition(BaseModel): - request_ip: Optional[ConditionRequestIP] = FieldInfo(alias="request.ip", default=None) - """Client IP restrictions.""" - - -class TokenListResponse(BaseModel): - id: Optional[str] = None - """Token identifier tag.""" - - condition: Optional[Condition] = None - - expires_on: Optional[datetime] = None - """ - The expiration time on or after which the JWT MUST NOT be accepted for - processing. - """ - - issued_on: Optional[datetime] = None - """The time on which the token was created.""" - - last_used_on: Optional[datetime] = None - """Last time the token was used.""" - - modified_on: Optional[datetime] = None - """Last time the token was modified.""" - - name: Optional[str] = None - """Token name.""" - - not_before: Optional[datetime] = None - """The time before which the token MUST NOT be accepted for processing.""" - - policies: Optional[List[Policy]] = None - """List of access policies assigned to the token.""" - - status: Optional[Literal["active", "disabled", "expired"]] = None - """Status of the token.""" diff --git a/src/cloudflare/types/accounts/token_update_response.py b/src/cloudflare/types/accounts/token_update_response.py deleted file mode 100644 index 13567b5e41f..00000000000 --- a/src/cloudflare/types/accounts/token_update_response.py +++ /dev/null @@ -1,60 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Optional -from datetime import datetime -from typing_extensions import Literal - -from pydantic import Field as FieldInfo - -from ..._models import BaseModel -from ..user.policy import Policy -from ..user.cidr_list import CIDRList - -__all__ = ["TokenUpdateResponse", "Condition", "ConditionRequestIP"] - - -class ConditionRequestIP(BaseModel): - in_: Optional[List[CIDRList]] = FieldInfo(alias="in", default=None) - """List of IPv4/IPv6 CIDR addresses.""" - - not_in: Optional[List[CIDRList]] = None - """List of IPv4/IPv6 CIDR addresses.""" - - -class Condition(BaseModel): - request_ip: Optional[ConditionRequestIP] = FieldInfo(alias="request.ip", default=None) - """Client IP restrictions.""" - - -class TokenUpdateResponse(BaseModel): - id: Optional[str] = None - """Token identifier tag.""" - - condition: Optional[Condition] = None - - expires_on: Optional[datetime] = None - """ - The expiration time on or after which the JWT MUST NOT be accepted for - processing. - """ - - issued_on: Optional[datetime] = None - """The time on which the token was created.""" - - last_used_on: Optional[datetime] = None - """Last time the token was used.""" - - modified_on: Optional[datetime] = None - """Last time the token was modified.""" - - name: Optional[str] = None - """Token name.""" - - not_before: Optional[datetime] = None - """The time before which the token MUST NOT be accepted for processing.""" - - policies: Optional[List[Policy]] = None - """List of access policies assigned to the token.""" - - status: Optional[Literal["active", "disabled", "expired"]] = None - """Status of the token.""" diff --git a/src/cloudflare/types/user/__init__.py b/src/cloudflare/types/user/__init__.py index e3c1b776eb6..7f0b1ebf4bf 100644 --- a/src/cloudflare/types/user/__init__.py +++ b/src/cloudflare/types/user/__init__.py @@ -2,6 +2,7 @@ from __future__ import annotations +from .token import Token as Token from .invite import Invite as Invite from .policy import Policy as Policy from .cidr_list import CIDRList as CIDRList @@ -10,14 +11,11 @@ from .user_edit_params import UserEditParams as UserEditParams from .token_list_params import TokenListParams as TokenListParams from .invite_edit_params import InviteEditParams as InviteEditParams -from .token_get_response import TokenGetResponse as TokenGetResponse from .token_create_params import TokenCreateParams as TokenCreateParams -from .token_list_response import TokenListResponse as TokenListResponse from .token_update_params import TokenUpdateParams as TokenUpdateParams from .audit_log_list_params import AuditLogListParams as AuditLogListParams from .token_create_response import TokenCreateResponse as TokenCreateResponse from .token_delete_response import TokenDeleteResponse as TokenDeleteResponse -from .token_update_response import TokenUpdateResponse as TokenUpdateResponse from .token_verify_response import TokenVerifyResponse as TokenVerifyResponse from .organization_list_params import OrganizationListParams as OrganizationListParams from .subscription_get_response import SubscriptionGetResponse as SubscriptionGetResponse diff --git a/src/cloudflare/types/user/token_get_response.py b/src/cloudflare/types/user/token.py similarity index 94% rename from src/cloudflare/types/user/token_get_response.py rename to src/cloudflare/types/user/token.py index d9fee42d192..e865abbfc49 100644 --- a/src/cloudflare/types/user/token_get_response.py +++ b/src/cloudflare/types/user/token.py @@ -10,7 +10,7 @@ from ..._models import BaseModel from .cidr_list import CIDRList -__all__ = ["TokenGetResponse", "Condition", "ConditionRequestIP"] +__all__ = ["Token", "Condition", "ConditionRequestIP"] class ConditionRequestIP(BaseModel): @@ -26,7 +26,7 @@ class Condition(BaseModel): """Client IP restrictions.""" -class TokenGetResponse(BaseModel): +class Token(BaseModel): id: Optional[str] = None """Token identifier tag.""" diff --git a/src/cloudflare/types/user/token_list_response.py b/src/cloudflare/types/user/token_list_response.py deleted file mode 100644 index edda4230d9d..00000000000 --- a/src/cloudflare/types/user/token_list_response.py +++ /dev/null @@ -1,60 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Optional -from datetime import datetime -from typing_extensions import Literal - -from pydantic import Field as FieldInfo - -from .policy import Policy -from ..._models import BaseModel -from .cidr_list import CIDRList - -__all__ = ["TokenListResponse", "Condition", "ConditionRequestIP"] - - -class ConditionRequestIP(BaseModel): - in_: Optional[List[CIDRList]] = FieldInfo(alias="in", default=None) - """List of IPv4/IPv6 CIDR addresses.""" - - not_in: Optional[List[CIDRList]] = None - """List of IPv4/IPv6 CIDR addresses.""" - - -class Condition(BaseModel): - request_ip: Optional[ConditionRequestIP] = FieldInfo(alias="request.ip", default=None) - """Client IP restrictions.""" - - -class TokenListResponse(BaseModel): - id: Optional[str] = None - """Token identifier tag.""" - - condition: Optional[Condition] = None - - expires_on: Optional[datetime] = None - """ - The expiration time on or after which the JWT MUST NOT be accepted for - processing. - """ - - issued_on: Optional[datetime] = None - """The time on which the token was created.""" - - last_used_on: Optional[datetime] = None - """Last time the token was used.""" - - modified_on: Optional[datetime] = None - """Last time the token was modified.""" - - name: Optional[str] = None - """Token name.""" - - not_before: Optional[datetime] = None - """The time before which the token MUST NOT be accepted for processing.""" - - policies: Optional[List[Policy]] = None - """List of access policies assigned to the token.""" - - status: Optional[Literal["active", "disabled", "expired"]] = None - """Status of the token.""" diff --git a/src/cloudflare/types/user/token_update_response.py b/src/cloudflare/types/user/token_update_response.py deleted file mode 100644 index 24b29ad2e44..00000000000 --- a/src/cloudflare/types/user/token_update_response.py +++ /dev/null @@ -1,60 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Optional -from datetime import datetime -from typing_extensions import Literal - -from pydantic import Field as FieldInfo - -from .policy import Policy -from ..._models import BaseModel -from .cidr_list import CIDRList - -__all__ = ["TokenUpdateResponse", "Condition", "ConditionRequestIP"] - - -class ConditionRequestIP(BaseModel): - in_: Optional[List[CIDRList]] = FieldInfo(alias="in", default=None) - """List of IPv4/IPv6 CIDR addresses.""" - - not_in: Optional[List[CIDRList]] = None - """List of IPv4/IPv6 CIDR addresses.""" - - -class Condition(BaseModel): - request_ip: Optional[ConditionRequestIP] = FieldInfo(alias="request.ip", default=None) - """Client IP restrictions.""" - - -class TokenUpdateResponse(BaseModel): - id: Optional[str] = None - """Token identifier tag.""" - - condition: Optional[Condition] = None - - expires_on: Optional[datetime] = None - """ - The expiration time on or after which the JWT MUST NOT be accepted for - processing. - """ - - issued_on: Optional[datetime] = None - """The time on which the token was created.""" - - last_used_on: Optional[datetime] = None - """Last time the token was used.""" - - modified_on: Optional[datetime] = None - """Last time the token was modified.""" - - name: Optional[str] = None - """Token name.""" - - not_before: Optional[datetime] = None - """The time before which the token MUST NOT be accepted for processing.""" - - policies: Optional[List[Policy]] = None - """List of access policies assigned to the token.""" - - status: Optional[Literal["active", "disabled", "expired"]] = None - """Status of the token.""" diff --git a/tests/api_resources/accounts/test_tokens.py b/tests/api_resources/accounts/test_tokens.py index c2c328f76fb..324814cd350 100644 --- a/tests/api_resources/accounts/test_tokens.py +++ b/tests/api_resources/accounts/test_tokens.py @@ -11,12 +11,10 @@ from tests.utils import assert_matches_type from cloudflare._utils import parse_datetime from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from cloudflare.types.user import Token from cloudflare.types.accounts import ( - TokenGetResponse, - TokenListResponse, TokenCreateResponse, TokenDeleteResponse, - TokenUpdateResponse, TokenVerifyResponse, ) @@ -242,7 +240,7 @@ def test_method_update(self, client: Cloudflare) -> None: ], status="active", ) - assert_matches_type(Optional[TokenUpdateResponse], token, path=["response"]) + assert_matches_type(Optional[Token], token, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -325,7 +323,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: expires_on=parse_datetime("2020-01-01T00:00:00Z"), not_before=parse_datetime("2018-07-01T05:20:00Z"), ) - assert_matches_type(Optional[TokenUpdateResponse], token, path=["response"]) + assert_matches_type(Optional[Token], token, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -356,7 +354,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" token = response.parse() - assert_matches_type(Optional[TokenUpdateResponse], token, path=["response"]) + assert_matches_type(Optional[Token], token, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -387,7 +385,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" token = response.parse() - assert_matches_type(Optional[TokenUpdateResponse], token, path=["response"]) + assert_matches_type(Optional[Token], token, path=["response"]) assert cast(Any, response.is_closed) is True @@ -448,7 +446,7 @@ def test_method_list(self, client: Cloudflare) -> None: token = client.accounts.tokens.list( account_id="eb78d65290b24279ba6f44721b3ea3c4", ) - assert_matches_type(SyncV4PagePaginationArray[TokenListResponse], token, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[Token], token, path=["response"]) @parametrize def test_method_list_with_all_params(self, client: Cloudflare) -> None: @@ -458,7 +456,7 @@ def test_method_list_with_all_params(self, client: Cloudflare) -> None: page=1, per_page=5, ) - assert_matches_type(SyncV4PagePaginationArray[TokenListResponse], token, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[Token], token, path=["response"]) @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: @@ -469,7 +467,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" token = response.parse() - assert_matches_type(SyncV4PagePaginationArray[TokenListResponse], token, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[Token], token, path=["response"]) @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: @@ -480,7 +478,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" token = response.parse() - assert_matches_type(SyncV4PagePaginationArray[TokenListResponse], token, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[Token], token, path=["response"]) assert cast(Any, response.is_closed) is True @@ -545,7 +543,7 @@ def test_method_get(self, client: Cloudflare) -> None: token_id="ed17574386854bf78a67040be0a770b0", account_id="eb78d65290b24279ba6f44721b3ea3c4", ) - assert_matches_type(Optional[TokenGetResponse], token, path=["response"]) + assert_matches_type(Optional[Token], token, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -557,7 +555,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" token = response.parse() - assert_matches_type(Optional[TokenGetResponse], token, path=["response"]) + assert_matches_type(Optional[Token], token, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -569,7 +567,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" token = response.parse() - assert_matches_type(Optional[TokenGetResponse], token, path=["response"]) + assert_matches_type(Optional[Token], token, path=["response"]) assert cast(Any, response.is_closed) is True @@ -845,7 +843,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: ], status="active", ) - assert_matches_type(Optional[TokenUpdateResponse], token, path=["response"]) + assert_matches_type(Optional[Token], token, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -928,7 +926,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare expires_on=parse_datetime("2020-01-01T00:00:00Z"), not_before=parse_datetime("2018-07-01T05:20:00Z"), ) - assert_matches_type(Optional[TokenUpdateResponse], token, path=["response"]) + assert_matches_type(Optional[Token], token, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -959,7 +957,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" token = await response.parse() - assert_matches_type(Optional[TokenUpdateResponse], token, path=["response"]) + assert_matches_type(Optional[Token], token, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -990,7 +988,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" token = await response.parse() - assert_matches_type(Optional[TokenUpdateResponse], token, path=["response"]) + assert_matches_type(Optional[Token], token, path=["response"]) assert cast(Any, response.is_closed) is True @@ -1051,7 +1049,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: token = await async_client.accounts.tokens.list( account_id="eb78d65290b24279ba6f44721b3ea3c4", ) - assert_matches_type(AsyncV4PagePaginationArray[TokenListResponse], token, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[Token], token, path=["response"]) @parametrize async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -1061,7 +1059,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) page=1, per_page=5, ) - assert_matches_type(AsyncV4PagePaginationArray[TokenListResponse], token, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[Token], token, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: @@ -1072,7 +1070,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" token = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[TokenListResponse], token, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[Token], token, path=["response"]) @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: @@ -1083,7 +1081,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" token = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[TokenListResponse], token, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[Token], token, path=["response"]) assert cast(Any, response.is_closed) is True @@ -1148,7 +1146,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: token_id="ed17574386854bf78a67040be0a770b0", account_id="eb78d65290b24279ba6f44721b3ea3c4", ) - assert_matches_type(Optional[TokenGetResponse], token, path=["response"]) + assert_matches_type(Optional[Token], token, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -1160,7 +1158,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" token = await response.parse() - assert_matches_type(Optional[TokenGetResponse], token, path=["response"]) + assert_matches_type(Optional[Token], token, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -1172,7 +1170,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" token = await response.parse() - assert_matches_type(Optional[TokenGetResponse], token, path=["response"]) + assert_matches_type(Optional[Token], token, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/user/test_tokens.py b/tests/api_resources/user/test_tokens.py index eab7d15810c..4d84d305962 100644 --- a/tests/api_resources/user/test_tokens.py +++ b/tests/api_resources/user/test_tokens.py @@ -12,11 +12,9 @@ from cloudflare._utils import parse_datetime from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray from cloudflare.types.user import ( - TokenGetResponse, - TokenListResponse, + Token, TokenCreateResponse, TokenDeleteResponse, - TokenUpdateResponse, TokenVerifyResponse, ) @@ -217,7 +215,7 @@ def test_method_update(self, client: Cloudflare) -> None: ], status="active", ) - assert_matches_type(Optional[TokenUpdateResponse], token, path=["response"]) + assert_matches_type(Optional[Token], token, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -300,7 +298,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: expires_on=parse_datetime("2020-01-01T00:00:00Z"), not_before=parse_datetime("2018-07-01T05:20:00Z"), ) - assert_matches_type(Optional[TokenUpdateResponse], token, path=["response"]) + assert_matches_type(Optional[Token], token, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -331,7 +329,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" token = response.parse() - assert_matches_type(Optional[TokenUpdateResponse], token, path=["response"]) + assert_matches_type(Optional[Token], token, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -362,7 +360,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" token = response.parse() - assert_matches_type(Optional[TokenUpdateResponse], token, path=["response"]) + assert_matches_type(Optional[Token], token, path=["response"]) assert cast(Any, response.is_closed) is True @@ -396,7 +394,7 @@ def test_path_params_update(self, client: Cloudflare) -> None: @parametrize def test_method_list(self, client: Cloudflare) -> None: token = client.user.tokens.list() - assert_matches_type(SyncV4PagePaginationArray[TokenListResponse], token, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[Token], token, path=["response"]) @parametrize def test_method_list_with_all_params(self, client: Cloudflare) -> None: @@ -405,7 +403,7 @@ def test_method_list_with_all_params(self, client: Cloudflare) -> None: page=1, per_page=5, ) - assert_matches_type(SyncV4PagePaginationArray[TokenListResponse], token, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[Token], token, path=["response"]) @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: @@ -414,7 +412,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" token = response.parse() - assert_matches_type(SyncV4PagePaginationArray[TokenListResponse], token, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[Token], token, path=["response"]) @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: @@ -423,7 +421,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" token = response.parse() - assert_matches_type(SyncV4PagePaginationArray[TokenListResponse], token, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[Token], token, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +468,7 @@ def test_method_get(self, client: Cloudflare) -> None: token = client.user.tokens.get( "ed17574386854bf78a67040be0a770b0", ) - assert_matches_type(Optional[TokenGetResponse], token, path=["response"]) + assert_matches_type(Optional[Token], token, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -481,7 +479,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" token = response.parse() - assert_matches_type(Optional[TokenGetResponse], token, path=["response"]) + assert_matches_type(Optional[Token], token, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -492,7 +490,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" token = response.parse() - assert_matches_type(Optional[TokenGetResponse], token, path=["response"]) + assert_matches_type(Optional[Token], token, path=["response"]) assert cast(Any, response.is_closed) is True @@ -723,7 +721,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: ], status="active", ) - assert_matches_type(Optional[TokenUpdateResponse], token, path=["response"]) + assert_matches_type(Optional[Token], token, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -806,7 +804,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare expires_on=parse_datetime("2020-01-01T00:00:00Z"), not_before=parse_datetime("2018-07-01T05:20:00Z"), ) - assert_matches_type(Optional[TokenUpdateResponse], token, path=["response"]) + assert_matches_type(Optional[Token], token, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -837,7 +835,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" token = await response.parse() - assert_matches_type(Optional[TokenUpdateResponse], token, path=["response"]) + assert_matches_type(Optional[Token], token, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -868,7 +866,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" token = await response.parse() - assert_matches_type(Optional[TokenUpdateResponse], token, path=["response"]) + assert_matches_type(Optional[Token], token, path=["response"]) assert cast(Any, response.is_closed) is True @@ -902,7 +900,7 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: token = await async_client.user.tokens.list() - assert_matches_type(AsyncV4PagePaginationArray[TokenListResponse], token, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[Token], token, path=["response"]) @parametrize async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -911,7 +909,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) page=1, per_page=5, ) - assert_matches_type(AsyncV4PagePaginationArray[TokenListResponse], token, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[Token], token, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: @@ -920,7 +918,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" token = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[TokenListResponse], token, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[Token], token, path=["response"]) @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: @@ -929,7 +927,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" token = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[TokenListResponse], token, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[Token], token, path=["response"]) assert cast(Any, response.is_closed) is True @@ -976,7 +974,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: token = await async_client.user.tokens.get( "ed17574386854bf78a67040be0a770b0", ) - assert_matches_type(Optional[TokenGetResponse], token, path=["response"]) + assert_matches_type(Optional[Token], token, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -987,7 +985,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" token = await response.parse() - assert_matches_type(Optional[TokenGetResponse], token, path=["response"]) + assert_matches_type(Optional[Token], token, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -998,7 +996,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" token = await response.parse() - assert_matches_type(Optional[TokenGetResponse], token, path=["response"]) + assert_matches_type(Optional[Token], token, path=["response"]) assert cast(Any, response.is_closed) is True