From ff64338a2d71ef302f150c7dd3cdc3ff9a626f75 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 9 Mar 2025 22:38:05 +0000 Subject: [PATCH] fix(r2_custom_domain): update path placeholders to de-duplicate internal values --- .stats.yml | 2 +- api.md | 11 +- .../resources/r2/buckets/domains/custom.py | 405 ++++++++++++++- .../types/r2/buckets/domains/__init__.py | 4 + .../buckets/domains/custom_delete_response.py | 11 + .../r2/buckets/domains/custom_get_response.py | 40 ++ .../buckets/domains/custom_update_params.py | 29 ++ .../buckets/domains/custom_update_response.py | 24 + .../r2/buckets/domains/test_custom.py | 462 +++++++++++++++++- 9 files changed, 984 insertions(+), 4 deletions(-) create mode 100644 src/cloudflare/types/r2/buckets/domains/custom_delete_response.py create mode 100644 src/cloudflare/types/r2/buckets/domains/custom_get_response.py create mode 100644 src/cloudflare/types/r2/buckets/domains/custom_update_params.py create mode 100644 src/cloudflare/types/r2/buckets/domains/custom_update_response.py diff --git a/.stats.yml b/.stats.yml index da267080c99..e2232ffc182 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1571 +configured_endpoints: 1574 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-49794d21f9c5b1d528a53fc9c10d5d9de6eed9bd412a262d1cad78fa453be1b4.yml diff --git a/api.md b/api.md index c92acbc286a..f130945376c 100644 --- a/api.md +++ b/api.md @@ -4693,13 +4693,22 @@ Methods: Types: ```python -from cloudflare.types.r2.buckets.domains import CustomCreateResponse, CustomListResponse +from cloudflare.types.r2.buckets.domains import ( + CustomCreateResponse, + CustomUpdateResponse, + CustomListResponse, + CustomDeleteResponse, + CustomGetResponse, +) ``` Methods: - client.r2.buckets.domains.custom.create(bucket_name, \*, account_id, \*\*params) -> CustomCreateResponse +- client.r2.buckets.domains.custom.update(domain, \*, account_id, bucket_name, \*\*params) -> CustomUpdateResponse - client.r2.buckets.domains.custom.list(bucket_name, \*, account_id) -> CustomListResponse +- client.r2.buckets.domains.custom.delete(domain, \*, account_id, bucket_name) -> CustomDeleteResponse +- client.r2.buckets.domains.custom.get(domain, \*, account_id, bucket_name) -> CustomGetResponse #### Managed diff --git a/src/cloudflare/resources/r2/buckets/domains/custom.py b/src/cloudflare/resources/r2/buckets/domains/custom.py index 6b3a32baa6c..cd2cdd41efb 100644 --- a/src/cloudflare/resources/r2/buckets/domains/custom.py +++ b/src/cloudflare/resources/r2/buckets/domains/custom.py @@ -24,9 +24,12 @@ ) from ....._wrappers import ResultWrapper from ....._base_client import make_request_options -from .....types.r2.buckets.domains import custom_create_params +from .....types.r2.buckets.domains import custom_create_params, custom_update_params +from .....types.r2.buckets.domains.custom_get_response import CustomGetResponse from .....types.r2.buckets.domains.custom_list_response import CustomListResponse from .....types.r2.buckets.domains.custom_create_response import CustomCreateResponse +from .....types.r2.buckets.domains.custom_delete_response import CustomDeleteResponse +from .....types.r2.buckets.domains.custom_update_response import CustomUpdateResponse __all__ = ["CustomResource", "AsyncCustomResource"] @@ -125,6 +128,76 @@ def create( cast_to=cast(Type[CustomCreateResponse], ResultWrapper[CustomCreateResponse]), ) + def update( + self, + domain: str, + *, + account_id: str, + bucket_name: str, + enabled: bool | NotGiven = NOT_GIVEN, + min_tls: Literal["1.0", "1.1", "1.2", "1.3"] | NotGiven = NOT_GIVEN, + jurisdiction: Literal["default", "eu", "fedramp"] | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> CustomUpdateResponse: + """ + Edit the configuration for a custom domain on an existing R2 bucket. + + Args: + account_id: Account ID + + bucket_name: Name of the bucket + + domain: Name of the custom domain + + enabled: Whether to enable public bucket access at the specified custom domain + + min_tls: Minimum TLS Version the custom domain will accept for incoming connections. If + not set, defaults to previous value. + + jurisdiction: The bucket jurisdiction + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not bucket_name: + raise ValueError(f"Expected a non-empty value for `bucket_name` but received {bucket_name!r}") + if not domain: + raise ValueError(f"Expected a non-empty value for `domain` but received {domain!r}") + extra_headers = { + **strip_not_given({"cf-r2-jurisdiction": str(jurisdiction) if is_given(jurisdiction) else NOT_GIVEN}), + **(extra_headers or {}), + } + return self._put( + f"/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom/{domain}", + body=maybe_transform( + { + "enabled": enabled, + "min_tls": min_tls, + }, + custom_update_params.CustomUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[CustomUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[CustomUpdateResponse], ResultWrapper[CustomUpdateResponse]), + ) + def list( self, bucket_name: str, @@ -176,6 +249,118 @@ def list( cast_to=cast(Type[CustomListResponse], ResultWrapper[CustomListResponse]), ) + def delete( + self, + domain: str, + *, + account_id: str, + bucket_name: str, + jurisdiction: Literal["default", "eu", "fedramp"] | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> CustomDeleteResponse: + """ + Remove custom domain registration from an existing R2 bucket + + Args: + account_id: Account ID + + bucket_name: Name of the bucket + + domain: Name of the custom domain + + jurisdiction: The bucket jurisdiction + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not bucket_name: + raise ValueError(f"Expected a non-empty value for `bucket_name` but received {bucket_name!r}") + if not domain: + raise ValueError(f"Expected a non-empty value for `domain` but received {domain!r}") + extra_headers = { + **strip_not_given({"cf-r2-jurisdiction": str(jurisdiction) if is_given(jurisdiction) else NOT_GIVEN}), + **(extra_headers or {}), + } + return self._delete( + f"/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom/{domain}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[CustomDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[CustomDeleteResponse], ResultWrapper[CustomDeleteResponse]), + ) + + def get( + self, + domain: str, + *, + account_id: str, + bucket_name: str, + jurisdiction: Literal["default", "eu", "fedramp"] | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> CustomGetResponse: + """ + Get the configuration for a custom domain on an existing R2 bucket. + + Args: + account_id: Account ID + + bucket_name: Name of the bucket + + domain: Name of the custom domain + + jurisdiction: The bucket jurisdiction + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not bucket_name: + raise ValueError(f"Expected a non-empty value for `bucket_name` but received {bucket_name!r}") + if not domain: + raise ValueError(f"Expected a non-empty value for `domain` but received {domain!r}") + extra_headers = { + **strip_not_given({"cf-r2-jurisdiction": str(jurisdiction) if is_given(jurisdiction) else NOT_GIVEN}), + **(extra_headers or {}), + } + return self._get( + f"/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom/{domain}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[CustomGetResponse]._unwrapper, + ), + cast_to=cast(Type[CustomGetResponse], ResultWrapper[CustomGetResponse]), + ) + class AsyncCustomResource(AsyncAPIResource): @cached_property @@ -271,6 +456,76 @@ async def create( cast_to=cast(Type[CustomCreateResponse], ResultWrapper[CustomCreateResponse]), ) + async def update( + self, + domain: str, + *, + account_id: str, + bucket_name: str, + enabled: bool | NotGiven = NOT_GIVEN, + min_tls: Literal["1.0", "1.1", "1.2", "1.3"] | NotGiven = NOT_GIVEN, + jurisdiction: Literal["default", "eu", "fedramp"] | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> CustomUpdateResponse: + """ + Edit the configuration for a custom domain on an existing R2 bucket. + + Args: + account_id: Account ID + + bucket_name: Name of the bucket + + domain: Name of the custom domain + + enabled: Whether to enable public bucket access at the specified custom domain + + min_tls: Minimum TLS Version the custom domain will accept for incoming connections. If + not set, defaults to previous value. + + jurisdiction: The bucket jurisdiction + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not bucket_name: + raise ValueError(f"Expected a non-empty value for `bucket_name` but received {bucket_name!r}") + if not domain: + raise ValueError(f"Expected a non-empty value for `domain` but received {domain!r}") + extra_headers = { + **strip_not_given({"cf-r2-jurisdiction": str(jurisdiction) if is_given(jurisdiction) else NOT_GIVEN}), + **(extra_headers or {}), + } + return await self._put( + f"/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom/{domain}", + body=await async_maybe_transform( + { + "enabled": enabled, + "min_tls": min_tls, + }, + custom_update_params.CustomUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[CustomUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[CustomUpdateResponse], ResultWrapper[CustomUpdateResponse]), + ) + async def list( self, bucket_name: str, @@ -322,6 +577,118 @@ async def list( cast_to=cast(Type[CustomListResponse], ResultWrapper[CustomListResponse]), ) + async def delete( + self, + domain: str, + *, + account_id: str, + bucket_name: str, + jurisdiction: Literal["default", "eu", "fedramp"] | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> CustomDeleteResponse: + """ + Remove custom domain registration from an existing R2 bucket + + Args: + account_id: Account ID + + bucket_name: Name of the bucket + + domain: Name of the custom domain + + jurisdiction: The bucket jurisdiction + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not bucket_name: + raise ValueError(f"Expected a non-empty value for `bucket_name` but received {bucket_name!r}") + if not domain: + raise ValueError(f"Expected a non-empty value for `domain` but received {domain!r}") + extra_headers = { + **strip_not_given({"cf-r2-jurisdiction": str(jurisdiction) if is_given(jurisdiction) else NOT_GIVEN}), + **(extra_headers or {}), + } + return await self._delete( + f"/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom/{domain}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[CustomDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[CustomDeleteResponse], ResultWrapper[CustomDeleteResponse]), + ) + + async def get( + self, + domain: str, + *, + account_id: str, + bucket_name: str, + jurisdiction: Literal["default", "eu", "fedramp"] | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> CustomGetResponse: + """ + Get the configuration for a custom domain on an existing R2 bucket. + + Args: + account_id: Account ID + + bucket_name: Name of the bucket + + domain: Name of the custom domain + + jurisdiction: The bucket jurisdiction + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not bucket_name: + raise ValueError(f"Expected a non-empty value for `bucket_name` but received {bucket_name!r}") + if not domain: + raise ValueError(f"Expected a non-empty value for `domain` but received {domain!r}") + extra_headers = { + **strip_not_given({"cf-r2-jurisdiction": str(jurisdiction) if is_given(jurisdiction) else NOT_GIVEN}), + **(extra_headers or {}), + } + return await self._get( + f"/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom/{domain}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[CustomGetResponse]._unwrapper, + ), + cast_to=cast(Type[CustomGetResponse], ResultWrapper[CustomGetResponse]), + ) + class CustomResourceWithRawResponse: def __init__(self, custom: CustomResource) -> None: @@ -330,9 +697,18 @@ def __init__(self, custom: CustomResource) -> None: self.create = to_raw_response_wrapper( custom.create, ) + self.update = to_raw_response_wrapper( + custom.update, + ) self.list = to_raw_response_wrapper( custom.list, ) + self.delete = to_raw_response_wrapper( + custom.delete, + ) + self.get = to_raw_response_wrapper( + custom.get, + ) class AsyncCustomResourceWithRawResponse: @@ -342,9 +718,18 @@ def __init__(self, custom: AsyncCustomResource) -> None: self.create = async_to_raw_response_wrapper( custom.create, ) + self.update = async_to_raw_response_wrapper( + custom.update, + ) self.list = async_to_raw_response_wrapper( custom.list, ) + self.delete = async_to_raw_response_wrapper( + custom.delete, + ) + self.get = async_to_raw_response_wrapper( + custom.get, + ) class CustomResourceWithStreamingResponse: @@ -354,9 +739,18 @@ def __init__(self, custom: CustomResource) -> None: self.create = to_streamed_response_wrapper( custom.create, ) + self.update = to_streamed_response_wrapper( + custom.update, + ) self.list = to_streamed_response_wrapper( custom.list, ) + self.delete = to_streamed_response_wrapper( + custom.delete, + ) + self.get = to_streamed_response_wrapper( + custom.get, + ) class AsyncCustomResourceWithStreamingResponse: @@ -366,6 +760,15 @@ def __init__(self, custom: AsyncCustomResource) -> None: self.create = async_to_streamed_response_wrapper( custom.create, ) + self.update = async_to_streamed_response_wrapper( + custom.update, + ) self.list = async_to_streamed_response_wrapper( custom.list, ) + self.delete = async_to_streamed_response_wrapper( + custom.delete, + ) + self.get = async_to_streamed_response_wrapper( + custom.get, + ) diff --git a/src/cloudflare/types/r2/buckets/domains/__init__.py b/src/cloudflare/types/r2/buckets/domains/__init__.py index 625236bd8d0..3848ddc7940 100644 --- a/src/cloudflare/types/r2/buckets/domains/__init__.py +++ b/src/cloudflare/types/r2/buckets/domains/__init__.py @@ -2,9 +2,13 @@ from __future__ import annotations +from .custom_get_response import CustomGetResponse as CustomGetResponse from .custom_create_params import CustomCreateParams as CustomCreateParams from .custom_list_response import CustomListResponse as CustomListResponse +from .custom_update_params import CustomUpdateParams as CustomUpdateParams from .managed_list_response import ManagedListResponse as ManagedListResponse from .managed_update_params import ManagedUpdateParams as ManagedUpdateParams from .custom_create_response import CustomCreateResponse as CustomCreateResponse +from .custom_delete_response import CustomDeleteResponse as CustomDeleteResponse +from .custom_update_response import CustomUpdateResponse as CustomUpdateResponse from .managed_update_response import ManagedUpdateResponse as ManagedUpdateResponse diff --git a/src/cloudflare/types/r2/buckets/domains/custom_delete_response.py b/src/cloudflare/types/r2/buckets/domains/custom_delete_response.py new file mode 100644 index 00000000000..67344ff691c --- /dev/null +++ b/src/cloudflare/types/r2/buckets/domains/custom_delete_response.py @@ -0,0 +1,11 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +from ....._models import BaseModel + +__all__ = ["CustomDeleteResponse"] + + +class CustomDeleteResponse(BaseModel): + domain: str + """Name of the removed custom domain""" diff --git a/src/cloudflare/types/r2/buckets/domains/custom_get_response.py b/src/cloudflare/types/r2/buckets/domains/custom_get_response.py new file mode 100644 index 00000000000..bf54feb14dd --- /dev/null +++ b/src/cloudflare/types/r2/buckets/domains/custom_get_response.py @@ -0,0 +1,40 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ....._models import BaseModel + +__all__ = ["CustomGetResponse", "Status"] + + +class Status(BaseModel): + ownership: Literal["pending", "active", "deactivated", "blocked", "error", "unknown"] + """Ownership status of the domain""" + + ssl: Literal["initializing", "pending", "active", "deactivated", "error", "unknown"] + """SSL certificate status""" + + +class CustomGetResponse(BaseModel): + domain: str + """Domain name of the custom domain to be added""" + + enabled: bool + """Whether this bucket is publicly accessible at the specified custom domain""" + + status: Status + + min_tls: Optional[Literal["1.0", "1.1", "1.2", "1.3"]] = FieldInfo(alias="minTLS", default=None) + """Minimum TLS Version the custom domain will accept for incoming connections. + + If not set, defaults to 1.0. + """ + + zone_id: Optional[str] = FieldInfo(alias="zoneId", default=None) + """Zone ID of the custom domain resides in""" + + zone_name: Optional[str] = FieldInfo(alias="zoneName", default=None) + """Zone that the custom domain resides in""" diff --git a/src/cloudflare/types/r2/buckets/domains/custom_update_params.py b/src/cloudflare/types/r2/buckets/domains/custom_update_params.py new file mode 100644 index 00000000000..5719767b9bb --- /dev/null +++ b/src/cloudflare/types/r2/buckets/domains/custom_update_params.py @@ -0,0 +1,29 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, Annotated, TypedDict + +from ....._utils import PropertyInfo + +__all__ = ["CustomUpdateParams"] + + +class CustomUpdateParams(TypedDict, total=False): + account_id: Required[str] + """Account ID""" + + bucket_name: Required[str] + """Name of the bucket""" + + enabled: bool + """Whether to enable public bucket access at the specified custom domain""" + + min_tls: Annotated[Literal["1.0", "1.1", "1.2", "1.3"], PropertyInfo(alias="minTLS")] + """Minimum TLS Version the custom domain will accept for incoming connections. + + If not set, defaults to previous value. + """ + + jurisdiction: Annotated[Literal["default", "eu", "fedramp"], PropertyInfo(alias="cf-r2-jurisdiction")] + """The bucket jurisdiction""" diff --git a/src/cloudflare/types/r2/buckets/domains/custom_update_response.py b/src/cloudflare/types/r2/buckets/domains/custom_update_response.py new file mode 100644 index 00000000000..2b142ec8868 --- /dev/null +++ b/src/cloudflare/types/r2/buckets/domains/custom_update_response.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ....._models import BaseModel + +__all__ = ["CustomUpdateResponse"] + + +class CustomUpdateResponse(BaseModel): + domain: str + """Domain name of the affected custom domain""" + + enabled: Optional[bool] = None + """Whether this bucket is publicly accessible at the specified custom domain""" + + min_tls: Optional[Literal["1.0", "1.1", "1.2", "1.3"]] = FieldInfo(alias="minTLS", default=None) + """Minimum TLS Version the custom domain will accept for incoming connections. + + If not set, defaults to 1.0. + """ diff --git a/tests/api_resources/r2/buckets/domains/test_custom.py b/tests/api_resources/r2/buckets/domains/test_custom.py index 3ba9dc885f2..233c1816595 100644 --- a/tests/api_resources/r2/buckets/domains/test_custom.py +++ b/tests/api_resources/r2/buckets/domains/test_custom.py @@ -9,7 +9,13 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type -from cloudflare.types.r2.buckets.domains import CustomListResponse, CustomCreateResponse +from cloudflare.types.r2.buckets.domains import ( + CustomGetResponse, + CustomListResponse, + CustomCreateResponse, + CustomDeleteResponse, + CustomUpdateResponse, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -98,6 +104,83 @@ def test_path_params_create(self, client: Cloudflare) -> None: zone_id="36ca64a6d92827b8a6b90be344bb1bfd", ) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + custom = client.r2.buckets.domains.custom.update( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + ) + assert_matches_type(CustomUpdateResponse, custom, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + custom = client.r2.buckets.domains.custom.update( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + enabled=True, + min_tls="1.0", + jurisdiction="default", + ) + assert_matches_type(CustomUpdateResponse, custom, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.r2.buckets.domains.custom.with_raw_response.update( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + custom = response.parse() + assert_matches_type(CustomUpdateResponse, custom, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.r2.buckets.domains.custom.with_streaming_response.update( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + custom = response.parse() + assert_matches_type(CustomUpdateResponse, custom, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.r2.buckets.domains.custom.with_raw_response.update( + domain="example-domain/custom-domain.com", + account_id="", + bucket_name="example-bucket", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + client.r2.buckets.domains.custom.with_raw_response.update( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `domain` but received ''"): + client.r2.buckets.domains.custom.with_raw_response.update( + domain="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + ) + @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_list(self, client: Cloudflare) -> None: @@ -160,6 +243,156 @@ def test_path_params_list(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", ) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + custom = client.r2.buckets.domains.custom.delete( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + ) + assert_matches_type(CustomDeleteResponse, custom, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_delete_with_all_params(self, client: Cloudflare) -> None: + custom = client.r2.buckets.domains.custom.delete( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + jurisdiction="default", + ) + assert_matches_type(CustomDeleteResponse, custom, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.r2.buckets.domains.custom.with_raw_response.delete( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + custom = response.parse() + assert_matches_type(CustomDeleteResponse, custom, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.r2.buckets.domains.custom.with_streaming_response.delete( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + custom = response.parse() + assert_matches_type(CustomDeleteResponse, custom, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.r2.buckets.domains.custom.with_raw_response.delete( + domain="example-domain/custom-domain.com", + account_id="", + bucket_name="example-bucket", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + client.r2.buckets.domains.custom.with_raw_response.delete( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `domain` but received ''"): + client.r2.buckets.domains.custom.with_raw_response.delete( + domain="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + custom = client.r2.buckets.domains.custom.get( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + ) + assert_matches_type(CustomGetResponse, custom, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + custom = client.r2.buckets.domains.custom.get( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + jurisdiction="default", + ) + assert_matches_type(CustomGetResponse, custom, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.r2.buckets.domains.custom.with_raw_response.get( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + custom = response.parse() + assert_matches_type(CustomGetResponse, custom, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.r2.buckets.domains.custom.with_streaming_response.get( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + custom = response.parse() + assert_matches_type(CustomGetResponse, custom, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.r2.buckets.domains.custom.with_raw_response.get( + domain="example-domain/custom-domain.com", + account_id="", + bucket_name="example-bucket", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + client.r2.buckets.domains.custom.with_raw_response.get( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `domain` but received ''"): + client.r2.buckets.domains.custom.with_raw_response.get( + domain="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + ) + class TestAsyncCustom: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -245,6 +478,83 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: zone_id="36ca64a6d92827b8a6b90be344bb1bfd", ) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + custom = await async_client.r2.buckets.domains.custom.update( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + ) + assert_matches_type(CustomUpdateResponse, custom, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + custom = await async_client.r2.buckets.domains.custom.update( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + enabled=True, + min_tls="1.0", + jurisdiction="default", + ) + assert_matches_type(CustomUpdateResponse, custom, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.r2.buckets.domains.custom.with_raw_response.update( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + custom = await response.parse() + assert_matches_type(CustomUpdateResponse, custom, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.r2.buckets.domains.custom.with_streaming_response.update( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + custom = await response.parse() + assert_matches_type(CustomUpdateResponse, custom, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.r2.buckets.domains.custom.with_raw_response.update( + domain="example-domain/custom-domain.com", + account_id="", + bucket_name="example-bucket", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + await async_client.r2.buckets.domains.custom.with_raw_response.update( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `domain` but received ''"): + await async_client.r2.buckets.domains.custom.with_raw_response.update( + domain="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + ) + @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: @@ -306,3 +616,153 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: bucket_name="", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + custom = await async_client.r2.buckets.domains.custom.delete( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + ) + assert_matches_type(CustomDeleteResponse, custom, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare) -> None: + custom = await async_client.r2.buckets.domains.custom.delete( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + jurisdiction="default", + ) + assert_matches_type(CustomDeleteResponse, custom, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.r2.buckets.domains.custom.with_raw_response.delete( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + custom = await response.parse() + assert_matches_type(CustomDeleteResponse, custom, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.r2.buckets.domains.custom.with_streaming_response.delete( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + custom = await response.parse() + assert_matches_type(CustomDeleteResponse, custom, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.r2.buckets.domains.custom.with_raw_response.delete( + domain="example-domain/custom-domain.com", + account_id="", + bucket_name="example-bucket", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + await async_client.r2.buckets.domains.custom.with_raw_response.delete( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `domain` but received ''"): + await async_client.r2.buckets.domains.custom.with_raw_response.delete( + domain="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + custom = await async_client.r2.buckets.domains.custom.get( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + ) + assert_matches_type(CustomGetResponse, custom, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + custom = await async_client.r2.buckets.domains.custom.get( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + jurisdiction="default", + ) + assert_matches_type(CustomGetResponse, custom, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.r2.buckets.domains.custom.with_raw_response.get( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + custom = await response.parse() + assert_matches_type(CustomGetResponse, custom, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.r2.buckets.domains.custom.with_streaming_response.get( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + custom = await response.parse() + assert_matches_type(CustomGetResponse, custom, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.r2.buckets.domains.custom.with_raw_response.get( + domain="example-domain/custom-domain.com", + account_id="", + bucket_name="example-bucket", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + await async_client.r2.buckets.domains.custom.with_raw_response.get( + domain="example-domain/custom-domain.com", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `domain` but received ''"): + await async_client.r2.buckets.domains.custom.with_raw_response.get( + domain="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="example-bucket", + )