From 5a497132195d7c1b63775c9aa3b649490000019d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 01:09:28 +0000 Subject: [PATCH] feat(api): update via SDK Studio (#308) --- .stats.yml | 2 +- api.md | 32 ++ src/cloudflare/_client.py | 8 + src/cloudflare/resources/__init__.py | 14 + .../resources/event_notifications/__init__.py | 33 ++ .../event_notifications.py | 81 +++++ .../event_notifications/r2/__init__.py | 33 ++ .../r2/configuration/__init__.py | 33 ++ .../r2/configuration/configuration.py | 202 +++++++++++ .../r2/configuration/queues.py | 320 +++++++++++++++++ .../resources/event_notifications/r2/r2.py | 81 +++++ .../types/event_notifications/__init__.py | 3 + .../types/event_notifications/r2/__init__.py | 5 + .../r2/configuration/__init__.py | 7 + .../r2/configuration/queue_delete_response.py | 7 + .../r2/configuration/queue_update_params.py | 32 ++ .../r2/configuration/queue_update_response.py | 11 + .../r2/configuration_get_response.py | 34 ++ .../event_notifications/__init__.py | 1 + .../event_notifications/r2/__init__.py | 1 + .../r2/configuration/__init__.py | 1 + .../r2/configuration/test_queues.py | 335 ++++++++++++++++++ .../r2/test_configuration.py | 126 +++++++ 23 files changed, 1401 insertions(+), 1 deletion(-) create mode 100644 src/cloudflare/resources/event_notifications/__init__.py create mode 100644 src/cloudflare/resources/event_notifications/event_notifications.py create mode 100644 src/cloudflare/resources/event_notifications/r2/__init__.py create mode 100644 src/cloudflare/resources/event_notifications/r2/configuration/__init__.py create mode 100644 src/cloudflare/resources/event_notifications/r2/configuration/configuration.py create mode 100644 src/cloudflare/resources/event_notifications/r2/configuration/queues.py create mode 100644 src/cloudflare/resources/event_notifications/r2/r2.py create mode 100644 src/cloudflare/types/event_notifications/__init__.py create mode 100644 src/cloudflare/types/event_notifications/r2/__init__.py create mode 100644 src/cloudflare/types/event_notifications/r2/configuration/__init__.py create mode 100644 src/cloudflare/types/event_notifications/r2/configuration/queue_delete_response.py create mode 100644 src/cloudflare/types/event_notifications/r2/configuration/queue_update_params.py create mode 100644 src/cloudflare/types/event_notifications/r2/configuration/queue_update_response.py create mode 100644 src/cloudflare/types/event_notifications/r2/configuration_get_response.py create mode 100644 tests/api_resources/event_notifications/__init__.py create mode 100644 tests/api_resources/event_notifications/r2/__init__.py create mode 100644 tests/api_resources/event_notifications/r2/configuration/__init__.py create mode 100644 tests/api_resources/event_notifications/r2/configuration/test_queues.py create mode 100644 tests/api_resources/event_notifications/r2/test_configuration.py diff --git a/.stats.yml b/.stats.yml index d0e375fdcb3..ae473c1891a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 1256 +configured_endpoints: 1259 diff --git a/api.md b/api.md index 91c61fd0011..a69d8217e3c 100644 --- a/api.md +++ b/api.md @@ -7345,3 +7345,35 @@ Methods: - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse - client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item - client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota + +# EventNotifications + +## R2 + +### Configuration + +Types: + +```python +from cloudflare.types.event_notifications.r2 import ConfigurationGetResponse +``` + +Methods: + +- client.event_notifications.r2.configuration.get(bucket_name, \*, account_id) -> ConfigurationGetResponse + +#### Queues + +Types: + +```python +from cloudflare.types.event_notifications.r2.configuration import ( + QueueUpdateResponse, + QueueDeleteResponse, +) +``` + +Methods: + +- client.event_notifications.r2.configuration.queues.update(queue_id, \*, account_id, bucket_name, \*\*params) -> QueueUpdateResponse +- client.event_notifications.r2.configuration.queues.delete(queue_id, \*, account_id, bucket_name) -> QueueDeleteResponse diff --git a/src/cloudflare/_client.py b/src/cloudflare/_client.py index 000dc7fe45a..1e34cb57856 100644 --- a/src/cloudflare/_client.py +++ b/src/cloudflare/_client.py @@ -127,6 +127,7 @@ class Cloudflare(SyncAPIClient): snippets: resources.Snippets calls: resources.Calls cloudforce_one: resources.CloudforceOne + event_notifications: resources.EventNotifications with_raw_response: CloudflareWithRawResponse with_streaming_response: CloudflareWithStreamedResponse @@ -282,6 +283,7 @@ def __init__( self.snippets = resources.Snippets(self) self.calls = resources.Calls(self) self.cloudforce_one = resources.CloudforceOne(self) + self.event_notifications = resources.EventNotifications(self) self.with_raw_response = CloudflareWithRawResponse(self) self.with_streaming_response = CloudflareWithStreamedResponse(self) @@ -540,6 +542,7 @@ class AsyncCloudflare(AsyncAPIClient): snippets: resources.AsyncSnippets calls: resources.AsyncCalls cloudforce_one: resources.AsyncCloudforceOne + event_notifications: resources.AsyncEventNotifications with_raw_response: AsyncCloudflareWithRawResponse with_streaming_response: AsyncCloudflareWithStreamedResponse @@ -695,6 +698,7 @@ def __init__( self.snippets = resources.AsyncSnippets(self) self.calls = resources.AsyncCalls(self) self.cloudforce_one = resources.AsyncCloudforceOne(self) + self.event_notifications = resources.AsyncEventNotifications(self) self.with_raw_response = AsyncCloudflareWithRawResponse(self) self.with_streaming_response = AsyncCloudflareWithStreamedResponse(self) @@ -956,6 +960,7 @@ def __init__(self, client: Cloudflare) -> None: self.snippets = resources.SnippetsWithRawResponse(client.snippets) self.calls = resources.CallsWithRawResponse(client.calls) self.cloudforce_one = resources.CloudforceOneWithRawResponse(client.cloudforce_one) + self.event_notifications = resources.EventNotificationsWithRawResponse(client.event_notifications) class AsyncCloudflareWithRawResponse: @@ -1046,6 +1051,7 @@ def __init__(self, client: AsyncCloudflare) -> None: self.snippets = resources.AsyncSnippetsWithRawResponse(client.snippets) self.calls = resources.AsyncCallsWithRawResponse(client.calls) self.cloudforce_one = resources.AsyncCloudforceOneWithRawResponse(client.cloudforce_one) + self.event_notifications = resources.AsyncEventNotificationsWithRawResponse(client.event_notifications) class CloudflareWithStreamedResponse: @@ -1136,6 +1142,7 @@ def __init__(self, client: Cloudflare) -> None: self.snippets = resources.SnippetsWithStreamingResponse(client.snippets) self.calls = resources.CallsWithStreamingResponse(client.calls) self.cloudforce_one = resources.CloudforceOneWithStreamingResponse(client.cloudforce_one) + self.event_notifications = resources.EventNotificationsWithStreamingResponse(client.event_notifications) class AsyncCloudflareWithStreamedResponse: @@ -1232,6 +1239,7 @@ def __init__(self, client: AsyncCloudflare) -> None: self.snippets = resources.AsyncSnippetsWithStreamingResponse(client.snippets) self.calls = resources.AsyncCallsWithStreamingResponse(client.calls) self.cloudforce_one = resources.AsyncCloudforceOneWithStreamingResponse(client.cloudforce_one) + self.event_notifications = resources.AsyncEventNotificationsWithStreamingResponse(client.event_notifications) Client = Cloudflare diff --git a/src/cloudflare/resources/__init__.py b/src/cloudflare/resources/__init__.py index 22875e389ef..bc46849e478 100644 --- a/src/cloudflare/resources/__init__.py +++ b/src/cloudflare/resources/__init__.py @@ -584,6 +584,14 @@ CustomCertificatesWithStreamingResponse, AsyncCustomCertificatesWithStreamingResponse, ) +from .event_notifications import ( + EventNotifications, + AsyncEventNotifications, + EventNotificationsWithRawResponse, + AsyncEventNotificationsWithRawResponse, + EventNotificationsWithStreamingResponse, + AsyncEventNotificationsWithStreamingResponse, +) from .keyless_certificates import ( KeylessCertificates, AsyncKeylessCertificates, @@ -1122,4 +1130,10 @@ "AsyncCloudforceOneWithRawResponse", "CloudforceOneWithStreamingResponse", "AsyncCloudforceOneWithStreamingResponse", + "EventNotifications", + "AsyncEventNotifications", + "EventNotificationsWithRawResponse", + "AsyncEventNotificationsWithRawResponse", + "EventNotificationsWithStreamingResponse", + "AsyncEventNotificationsWithStreamingResponse", ] diff --git a/src/cloudflare/resources/event_notifications/__init__.py b/src/cloudflare/resources/event_notifications/__init__.py new file mode 100644 index 00000000000..68394e89f36 --- /dev/null +++ b/src/cloudflare/resources/event_notifications/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .r2 import ( + R2, + AsyncR2, + R2WithRawResponse, + AsyncR2WithRawResponse, + R2WithStreamingResponse, + AsyncR2WithStreamingResponse, +) +from .event_notifications import ( + EventNotifications, + AsyncEventNotifications, + EventNotificationsWithRawResponse, + AsyncEventNotificationsWithRawResponse, + EventNotificationsWithStreamingResponse, + AsyncEventNotificationsWithStreamingResponse, +) + +__all__ = [ + "R2", + "AsyncR2", + "R2WithRawResponse", + "AsyncR2WithRawResponse", + "R2WithStreamingResponse", + "AsyncR2WithStreamingResponse", + "EventNotifications", + "AsyncEventNotifications", + "EventNotificationsWithRawResponse", + "AsyncEventNotificationsWithRawResponse", + "EventNotificationsWithStreamingResponse", + "AsyncEventNotificationsWithStreamingResponse", +] diff --git a/src/cloudflare/resources/event_notifications/event_notifications.py b/src/cloudflare/resources/event_notifications/event_notifications.py new file mode 100644 index 00000000000..830b4dd520f --- /dev/null +++ b/src/cloudflare/resources/event_notifications/event_notifications.py @@ -0,0 +1,81 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .r2 import ( + R2, + AsyncR2, + R2WithRawResponse, + AsyncR2WithRawResponse, + R2WithStreamingResponse, + AsyncR2WithStreamingResponse, +) +from .r2.r2 import R2, AsyncR2 +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource + +__all__ = ["EventNotifications", "AsyncEventNotifications"] + + +class EventNotifications(SyncAPIResource): + @cached_property + def r2(self) -> R2: + return R2(self._client) + + @cached_property + def with_raw_response(self) -> EventNotificationsWithRawResponse: + return EventNotificationsWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> EventNotificationsWithStreamingResponse: + return EventNotificationsWithStreamingResponse(self) + + +class AsyncEventNotifications(AsyncAPIResource): + @cached_property + def r2(self) -> AsyncR2: + return AsyncR2(self._client) + + @cached_property + def with_raw_response(self) -> AsyncEventNotificationsWithRawResponse: + return AsyncEventNotificationsWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncEventNotificationsWithStreamingResponse: + return AsyncEventNotificationsWithStreamingResponse(self) + + +class EventNotificationsWithRawResponse: + def __init__(self, event_notifications: EventNotifications) -> None: + self._event_notifications = event_notifications + + @cached_property + def r2(self) -> R2WithRawResponse: + return R2WithRawResponse(self._event_notifications.r2) + + +class AsyncEventNotificationsWithRawResponse: + def __init__(self, event_notifications: AsyncEventNotifications) -> None: + self._event_notifications = event_notifications + + @cached_property + def r2(self) -> AsyncR2WithRawResponse: + return AsyncR2WithRawResponse(self._event_notifications.r2) + + +class EventNotificationsWithStreamingResponse: + def __init__(self, event_notifications: EventNotifications) -> None: + self._event_notifications = event_notifications + + @cached_property + def r2(self) -> R2WithStreamingResponse: + return R2WithStreamingResponse(self._event_notifications.r2) + + +class AsyncEventNotificationsWithStreamingResponse: + def __init__(self, event_notifications: AsyncEventNotifications) -> None: + self._event_notifications = event_notifications + + @cached_property + def r2(self) -> AsyncR2WithStreamingResponse: + return AsyncR2WithStreamingResponse(self._event_notifications.r2) diff --git a/src/cloudflare/resources/event_notifications/r2/__init__.py b/src/cloudflare/resources/event_notifications/r2/__init__.py new file mode 100644 index 00000000000..633b853d167 --- /dev/null +++ b/src/cloudflare/resources/event_notifications/r2/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .r2 import ( + R2, + AsyncR2, + R2WithRawResponse, + AsyncR2WithRawResponse, + R2WithStreamingResponse, + AsyncR2WithStreamingResponse, +) +from .configuration import ( + Configuration, + AsyncConfiguration, + ConfigurationWithRawResponse, + AsyncConfigurationWithRawResponse, + ConfigurationWithStreamingResponse, + AsyncConfigurationWithStreamingResponse, +) + +__all__ = [ + "Configuration", + "AsyncConfiguration", + "ConfigurationWithRawResponse", + "AsyncConfigurationWithRawResponse", + "ConfigurationWithStreamingResponse", + "AsyncConfigurationWithStreamingResponse", + "R2", + "AsyncR2", + "R2WithRawResponse", + "AsyncR2WithRawResponse", + "R2WithStreamingResponse", + "AsyncR2WithStreamingResponse", +] diff --git a/src/cloudflare/resources/event_notifications/r2/configuration/__init__.py b/src/cloudflare/resources/event_notifications/r2/configuration/__init__.py new file mode 100644 index 00000000000..f78f824aaf5 --- /dev/null +++ b/src/cloudflare/resources/event_notifications/r2/configuration/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .queues import ( + Queues, + AsyncQueues, + QueuesWithRawResponse, + AsyncQueuesWithRawResponse, + QueuesWithStreamingResponse, + AsyncQueuesWithStreamingResponse, +) +from .configuration import ( + Configuration, + AsyncConfiguration, + ConfigurationWithRawResponse, + AsyncConfigurationWithRawResponse, + ConfigurationWithStreamingResponse, + AsyncConfigurationWithStreamingResponse, +) + +__all__ = [ + "Queues", + "AsyncQueues", + "QueuesWithRawResponse", + "AsyncQueuesWithRawResponse", + "QueuesWithStreamingResponse", + "AsyncQueuesWithStreamingResponse", + "Configuration", + "AsyncConfiguration", + "ConfigurationWithRawResponse", + "AsyncConfigurationWithRawResponse", + "ConfigurationWithStreamingResponse", + "AsyncConfigurationWithStreamingResponse", +] diff --git a/src/cloudflare/resources/event_notifications/r2/configuration/configuration.py b/src/cloudflare/resources/event_notifications/r2/configuration/configuration.py new file mode 100644 index 00000000000..4861c581e37 --- /dev/null +++ b/src/cloudflare/resources/event_notifications/r2/configuration/configuration.py @@ -0,0 +1,202 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast + +import httpx + +from .queues import ( + Queues, + AsyncQueues, + QueuesWithRawResponse, + AsyncQueuesWithRawResponse, + QueuesWithStreamingResponse, + AsyncQueuesWithStreamingResponse, +) +from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from ....._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ....._wrappers import ResultWrapper +from ....._base_client import ( + make_request_options, +) +from .....types.event_notifications.r2 import ConfigurationGetResponse + +__all__ = ["Configuration", "AsyncConfiguration"] + + +class Configuration(SyncAPIResource): + @cached_property + def queues(self) -> Queues: + return Queues(self._client) + + @cached_property + def with_raw_response(self) -> ConfigurationWithRawResponse: + return ConfigurationWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ConfigurationWithStreamingResponse: + return ConfigurationWithStreamingResponse(self) + + def get( + self, + bucket_name: str, + *, + account_id: str, + # 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, + ) -> ConfigurationGetResponse: + """ + Returns all notification rules for each queue for which bucket notifications are + produced. + + Args: + account_id: Identifier + + bucket_name: Identifier + + 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}") + return self._get( + f"/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[ConfigurationGetResponse], ResultWrapper[ConfigurationGetResponse]), + ) + + +class AsyncConfiguration(AsyncAPIResource): + @cached_property + def queues(self) -> AsyncQueues: + return AsyncQueues(self._client) + + @cached_property + def with_raw_response(self) -> AsyncConfigurationWithRawResponse: + return AsyncConfigurationWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncConfigurationWithStreamingResponse: + return AsyncConfigurationWithStreamingResponse(self) + + async def get( + self, + bucket_name: str, + *, + account_id: str, + # 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, + ) -> ConfigurationGetResponse: + """ + Returns all notification rules for each queue for which bucket notifications are + produced. + + Args: + account_id: Identifier + + bucket_name: Identifier + + 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}") + return await self._get( + f"/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[ConfigurationGetResponse], ResultWrapper[ConfigurationGetResponse]), + ) + + +class ConfigurationWithRawResponse: + def __init__(self, configuration: Configuration) -> None: + self._configuration = configuration + + self.get = to_raw_response_wrapper( + configuration.get, + ) + + @cached_property + def queues(self) -> QueuesWithRawResponse: + return QueuesWithRawResponse(self._configuration.queues) + + +class AsyncConfigurationWithRawResponse: + def __init__(self, configuration: AsyncConfiguration) -> None: + self._configuration = configuration + + self.get = async_to_raw_response_wrapper( + configuration.get, + ) + + @cached_property + def queues(self) -> AsyncQueuesWithRawResponse: + return AsyncQueuesWithRawResponse(self._configuration.queues) + + +class ConfigurationWithStreamingResponse: + def __init__(self, configuration: Configuration) -> None: + self._configuration = configuration + + self.get = to_streamed_response_wrapper( + configuration.get, + ) + + @cached_property + def queues(self) -> QueuesWithStreamingResponse: + return QueuesWithStreamingResponse(self._configuration.queues) + + +class AsyncConfigurationWithStreamingResponse: + def __init__(self, configuration: AsyncConfiguration) -> None: + self._configuration = configuration + + self.get = async_to_streamed_response_wrapper( + configuration.get, + ) + + @cached_property + def queues(self) -> AsyncQueuesWithStreamingResponse: + return AsyncQueuesWithStreamingResponse(self._configuration.queues) diff --git a/src/cloudflare/resources/event_notifications/r2/configuration/queues.py b/src/cloudflare/resources/event_notifications/r2/configuration/queues.py new file mode 100644 index 00000000000..727a0118fa0 --- /dev/null +++ b/src/cloudflare/resources/event_notifications/r2/configuration/queues.py @@ -0,0 +1,320 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Any, Type, Iterable, cast + +import httpx + +from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ....._utils import ( + maybe_transform, + async_maybe_transform, +) +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from ....._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ....._wrappers import ResultWrapper +from ....._base_client import ( + make_request_options, +) +from .....types.event_notifications.r2.configuration import ( + QueueDeleteResponse, + QueueUpdateResponse, + queue_update_params, +) + +__all__ = ["Queues", "AsyncQueues"] + + +class Queues(SyncAPIResource): + @cached_property + def with_raw_response(self) -> QueuesWithRawResponse: + return QueuesWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> QueuesWithStreamingResponse: + return QueuesWithStreamingResponse(self) + + def update( + self, + queue_id: str, + *, + account_id: str, + bucket_name: str, + rules: Iterable[queue_update_params.Rule] | 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, + ) -> QueueUpdateResponse: + """ + Define the rules for a given queue which will determine event notification + production. + + Args: + account_id: Identifier + + bucket_name: Identifier + + queue_id: Identifier + + rules: Array of rules to drive notifications + + 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 queue_id: + raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") + return self._put( + f"/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}", + body=maybe_transform({"rules": rules}, queue_update_params.QueueUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[QueueUpdateResponse], ResultWrapper[QueueUpdateResponse]), + ) + + def delete( + self, + queue_id: str, + *, + account_id: str, + bucket_name: str, + # 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, + ) -> QueueDeleteResponse: + """Turn off all event notifications configured for delivery to a given queue. + + No + further notifications will be produced for the queue once complete. + + Args: + account_id: Identifier + + bucket_name: Identifier + + queue_id: Identifier + + 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 queue_id: + raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") + return cast( + QueueDeleteResponse, + self._delete( + f"/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[QueueDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + +class AsyncQueues(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncQueuesWithRawResponse: + return AsyncQueuesWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncQueuesWithStreamingResponse: + return AsyncQueuesWithStreamingResponse(self) + + async def update( + self, + queue_id: str, + *, + account_id: str, + bucket_name: str, + rules: Iterable[queue_update_params.Rule] | 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, + ) -> QueueUpdateResponse: + """ + Define the rules for a given queue which will determine event notification + production. + + Args: + account_id: Identifier + + bucket_name: Identifier + + queue_id: Identifier + + rules: Array of rules to drive notifications + + 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 queue_id: + raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") + return await self._put( + f"/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}", + body=await async_maybe_transform({"rules": rules}, queue_update_params.QueueUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[QueueUpdateResponse], ResultWrapper[QueueUpdateResponse]), + ) + + async def delete( + self, + queue_id: str, + *, + account_id: str, + bucket_name: str, + # 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, + ) -> QueueDeleteResponse: + """Turn off all event notifications configured for delivery to a given queue. + + No + further notifications will be produced for the queue once complete. + + Args: + account_id: Identifier + + bucket_name: Identifier + + queue_id: Identifier + + 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 queue_id: + raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") + return cast( + QueueDeleteResponse, + await self._delete( + f"/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[QueueDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + +class QueuesWithRawResponse: + def __init__(self, queues: Queues) -> None: + self._queues = queues + + self.update = to_raw_response_wrapper( + queues.update, + ) + self.delete = to_raw_response_wrapper( + queues.delete, + ) + + +class AsyncQueuesWithRawResponse: + def __init__(self, queues: AsyncQueues) -> None: + self._queues = queues + + self.update = async_to_raw_response_wrapper( + queues.update, + ) + self.delete = async_to_raw_response_wrapper( + queues.delete, + ) + + +class QueuesWithStreamingResponse: + def __init__(self, queues: Queues) -> None: + self._queues = queues + + self.update = to_streamed_response_wrapper( + queues.update, + ) + self.delete = to_streamed_response_wrapper( + queues.delete, + ) + + +class AsyncQueuesWithStreamingResponse: + def __init__(self, queues: AsyncQueues) -> None: + self._queues = queues + + self.update = async_to_streamed_response_wrapper( + queues.update, + ) + self.delete = async_to_streamed_response_wrapper( + queues.delete, + ) diff --git a/src/cloudflare/resources/event_notifications/r2/r2.py b/src/cloudflare/resources/event_notifications/r2/r2.py new file mode 100644 index 00000000000..cd09295390e --- /dev/null +++ b/src/cloudflare/resources/event_notifications/r2/r2.py @@ -0,0 +1,81 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from .configuration import ( + Configuration, + AsyncConfiguration, + ConfigurationWithRawResponse, + AsyncConfigurationWithRawResponse, + ConfigurationWithStreamingResponse, + AsyncConfigurationWithStreamingResponse, +) +from .configuration.configuration import Configuration, AsyncConfiguration + +__all__ = ["R2", "AsyncR2"] + + +class R2(SyncAPIResource): + @cached_property + def configuration(self) -> Configuration: + return Configuration(self._client) + + @cached_property + def with_raw_response(self) -> R2WithRawResponse: + return R2WithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> R2WithStreamingResponse: + return R2WithStreamingResponse(self) + + +class AsyncR2(AsyncAPIResource): + @cached_property + def configuration(self) -> AsyncConfiguration: + return AsyncConfiguration(self._client) + + @cached_property + def with_raw_response(self) -> AsyncR2WithRawResponse: + return AsyncR2WithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncR2WithStreamingResponse: + return AsyncR2WithStreamingResponse(self) + + +class R2WithRawResponse: + def __init__(self, r2: R2) -> None: + self._r2 = r2 + + @cached_property + def configuration(self) -> ConfigurationWithRawResponse: + return ConfigurationWithRawResponse(self._r2.configuration) + + +class AsyncR2WithRawResponse: + def __init__(self, r2: AsyncR2) -> None: + self._r2 = r2 + + @cached_property + def configuration(self) -> AsyncConfigurationWithRawResponse: + return AsyncConfigurationWithRawResponse(self._r2.configuration) + + +class R2WithStreamingResponse: + def __init__(self, r2: R2) -> None: + self._r2 = r2 + + @cached_property + def configuration(self) -> ConfigurationWithStreamingResponse: + return ConfigurationWithStreamingResponse(self._r2.configuration) + + +class AsyncR2WithStreamingResponse: + def __init__(self, r2: AsyncR2) -> None: + self._r2 = r2 + + @cached_property + def configuration(self) -> AsyncConfigurationWithStreamingResponse: + return AsyncConfigurationWithStreamingResponse(self._r2.configuration) diff --git a/src/cloudflare/types/event_notifications/__init__.py b/src/cloudflare/types/event_notifications/__init__.py new file mode 100644 index 00000000000..f8ee8b14b1c --- /dev/null +++ b/src/cloudflare/types/event_notifications/__init__.py @@ -0,0 +1,3 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations diff --git a/src/cloudflare/types/event_notifications/r2/__init__.py b/src/cloudflare/types/event_notifications/r2/__init__.py new file mode 100644 index 00000000000..b1fcfe993b2 --- /dev/null +++ b/src/cloudflare/types/event_notifications/r2/__init__.py @@ -0,0 +1,5 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .configuration_get_response import ConfigurationGetResponse as ConfigurationGetResponse diff --git a/src/cloudflare/types/event_notifications/r2/configuration/__init__.py b/src/cloudflare/types/event_notifications/r2/configuration/__init__.py new file mode 100644 index 00000000000..9b08b16f6f8 --- /dev/null +++ b/src/cloudflare/types/event_notifications/r2/configuration/__init__.py @@ -0,0 +1,7 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .queue_update_params import QueueUpdateParams as QueueUpdateParams +from .queue_delete_response import QueueDeleteResponse as QueueDeleteResponse +from .queue_update_response import QueueUpdateResponse as QueueUpdateResponse diff --git a/src/cloudflare/types/event_notifications/r2/configuration/queue_delete_response.py b/src/cloudflare/types/event_notifications/r2/configuration/queue_delete_response.py new file mode 100644 index 00000000000..578c4867074 --- /dev/null +++ b/src/cloudflare/types/event_notifications/r2/configuration/queue_delete_response.py @@ -0,0 +1,7 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union + +__all__ = ["QueueDeleteResponse"] + +QueueDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/event_notifications/r2/configuration/queue_update_params.py b/src/cloudflare/types/event_notifications/r2/configuration/queue_update_params.py new file mode 100644 index 00000000000..08718f376d4 --- /dev/null +++ b/src/cloudflare/types/event_notifications/r2/configuration/queue_update_params.py @@ -0,0 +1,32 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Iterable +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["QueueUpdateParams", "Rule"] + + +class QueueUpdateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + bucket_name: Required[str] + """Identifier""" + + rules: Iterable[Rule] + """Array of rules to drive notifications""" + + +class Rule(TypedDict, total=False): + actions: Required[ + List[Literal["PutObject", "CopyObject", "DeleteObject", "CompleteMultipartUpload", "AbortMultipartUpload"]] + ] + """Array of R2 object actions that will trigger notifications""" + + prefix: str + """Notifications will be sent only for objects with this prefix""" + + suffix: str + """Notifications will be sent only for objects with this suffix""" diff --git a/src/cloudflare/types/event_notifications/r2/configuration/queue_update_response.py b/src/cloudflare/types/event_notifications/r2/configuration/queue_update_response.py new file mode 100644 index 00000000000..2d2f608f91f --- /dev/null +++ b/src/cloudflare/types/event_notifications/r2/configuration/queue_update_response.py @@ -0,0 +1,11 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ....._models import BaseModel + +__all__ = ["QueueUpdateResponse"] + + +class QueueUpdateResponse(BaseModel): + event_notification_detail_id: Optional[str] = None diff --git a/src/cloudflare/types/event_notifications/r2/configuration_get_response.py b/src/cloudflare/types/event_notifications/r2/configuration_get_response.py new file mode 100644 index 00000000000..ae1ed76ea41 --- /dev/null +++ b/src/cloudflare/types/event_notifications/r2/configuration_get_response.py @@ -0,0 +1,34 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = [ + "ConfigurationGetResponse", + "ConfigurationGetResponseItemConfigurationGetResponseItemItem", + "ConfigurationGetResponseItemConfigurationGetResponseItemItemRule", +] + + +class ConfigurationGetResponseItemConfigurationGetResponseItemItemRule(BaseModel): + actions: List[Literal["PutObject", "CopyObject", "DeleteObject", "CompleteMultipartUpload", "AbortMultipartUpload"]] + """Array of R2 object actions that will trigger notifications""" + + prefix: Optional[str] = None + """Notifications will be sent only for objects with this prefix""" + + suffix: Optional[str] = None + """Notifications will be sent only for objects with this suffix""" + + +class ConfigurationGetResponseItemConfigurationGetResponseItemItem(BaseModel): + queue: str + """Queue ID that will receive notifications based on the configured rules""" + + rules: List[ConfigurationGetResponseItemConfigurationGetResponseItemItemRule] + """Array of rules to drive notifications""" + + +ConfigurationGetResponse = Dict[str, Dict[str, ConfigurationGetResponseItemConfigurationGetResponseItemItem]] diff --git a/tests/api_resources/event_notifications/__init__.py b/tests/api_resources/event_notifications/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/event_notifications/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/event_notifications/r2/__init__.py b/tests/api_resources/event_notifications/r2/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/event_notifications/r2/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/event_notifications/r2/configuration/__init__.py b/tests/api_resources/event_notifications/r2/configuration/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/event_notifications/r2/configuration/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/event_notifications/r2/configuration/test_queues.py b/tests/api_resources/event_notifications/r2/configuration/test_queues.py new file mode 100644 index 00000000000..86d44184798 --- /dev/null +++ b/tests/api_resources/event_notifications/r2/configuration/test_queues.py @@ -0,0 +1,335 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.event_notifications.r2.configuration import ( + QueueDeleteResponse, + QueueUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestQueues: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + queue = client.event_notifications.r2.configuration.queues.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(QueueUpdateResponse, queue, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + queue = client.event_notifications.r2.configuration.queues.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="023e105f4ecef8ad9ca31a8372d0c353", + rules=[ + { + "actions": ["PutObject", "CopyObject"], + "prefix": "img/", + "suffix": ".jpeg", + }, + { + "actions": ["PutObject", "CopyObject"], + "prefix": "img/", + "suffix": ".jpeg", + }, + { + "actions": ["PutObject", "CopyObject"], + "prefix": "img/", + "suffix": ".jpeg", + }, + ], + ) + assert_matches_type(QueueUpdateResponse, queue, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.event_notifications.r2.configuration.queues.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + queue = response.parse() + assert_matches_type(QueueUpdateResponse, queue, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.event_notifications.r2.configuration.queues.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + queue = response.parse() + assert_matches_type(QueueUpdateResponse, queue, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @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.event_notifications.r2.configuration.queues.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + bucket_name="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + client.event_notifications.r2.configuration.queues.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"): + client.event_notifications.r2.configuration.queues.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + queue = client.event_notifications.r2.configuration.queues.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(QueueDeleteResponse, queue, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.event_notifications.r2.configuration.queues.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + queue = response.parse() + assert_matches_type(QueueDeleteResponse, queue, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.event_notifications.r2.configuration.queues.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + queue = response.parse() + assert_matches_type(QueueDeleteResponse, queue, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @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.event_notifications.r2.configuration.queues.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + bucket_name="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + client.event_notifications.r2.configuration.queues.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"): + client.event_notifications.r2.configuration.queues.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncQueues: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + queue = await async_client.event_notifications.r2.configuration.queues.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(QueueUpdateResponse, queue, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + queue = await async_client.event_notifications.r2.configuration.queues.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="023e105f4ecef8ad9ca31a8372d0c353", + rules=[ + { + "actions": ["PutObject", "CopyObject"], + "prefix": "img/", + "suffix": ".jpeg", + }, + { + "actions": ["PutObject", "CopyObject"], + "prefix": "img/", + "suffix": ".jpeg", + }, + { + "actions": ["PutObject", "CopyObject"], + "prefix": "img/", + "suffix": ".jpeg", + }, + ], + ) + assert_matches_type(QueueUpdateResponse, queue, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.event_notifications.r2.configuration.queues.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + queue = await response.parse() + assert_matches_type(QueueUpdateResponse, queue, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.event_notifications.r2.configuration.queues.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + queue = await response.parse() + assert_matches_type(QueueUpdateResponse, queue, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @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.event_notifications.r2.configuration.queues.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + bucket_name="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + await async_client.event_notifications.r2.configuration.queues.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"): + await async_client.event_notifications.r2.configuration.queues.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + queue = await async_client.event_notifications.r2.configuration.queues.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(QueueDeleteResponse, queue, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.event_notifications.r2.configuration.queues.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + queue = await response.parse() + assert_matches_type(QueueDeleteResponse, queue, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.event_notifications.r2.configuration.queues.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + queue = await response.parse() + assert_matches_type(QueueDeleteResponse, queue, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @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.event_notifications.r2.configuration.queues.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + bucket_name="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + await async_client.event_notifications.r2.configuration.queues.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"): + await async_client.event_notifications.r2.configuration.queues.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket_name="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/event_notifications/r2/test_configuration.py b/tests/api_resources/event_notifications/r2/test_configuration.py new file mode 100644 index 00000000000..7fb8bfb1965 --- /dev/null +++ b/tests/api_resources/event_notifications/r2/test_configuration.py @@ -0,0 +1,126 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.event_notifications.r2 import ConfigurationGetResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestConfiguration: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + configuration = client.event_notifications.r2.configuration.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(ConfigurationGetResponse, configuration, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.event_notifications.r2.configuration.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + configuration = response.parse() + assert_matches_type(ConfigurationGetResponse, configuration, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.event_notifications.r2.configuration.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + configuration = response.parse() + assert_matches_type(ConfigurationGetResponse, configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @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.event_notifications.r2.configuration.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + client.event_notifications.r2.configuration.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncConfiguration: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + configuration = await async_client.event_notifications.r2.configuration.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(ConfigurationGetResponse, configuration, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.event_notifications.r2.configuration.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + configuration = await response.parse() + assert_matches_type(ConfigurationGetResponse, configuration, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.event_notifications.r2.configuration.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + configuration = await response.parse() + assert_matches_type(ConfigurationGetResponse, configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @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.event_notifications.r2.configuration.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + await async_client.event_notifications.r2.configuration.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + )