mirror of
https://github.com/cloudflare/cloudflare-python.git
synced 2026-01-16 23:01:03 +00:00
feat(queues): add support for purge (#2572)
This commit is contained in:
parent
8b817066d4
commit
23bc225bf9
11 changed files with 906 additions and 3 deletions
|
|
@ -1,2 +1,2 @@
|
|||
configured_endpoints: 1658
|
||||
configured_endpoints: 1661
|
||||
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-7c5dffcd62c967e6fa23a4f90521ede2605166912526af87e8c9a20b3c3c66a2.yml
|
||||
|
|
|
|||
14
api.md
14
api.md
|
|
@ -2619,6 +2619,7 @@ Methods:
|
|||
- <code title="put /accounts/{account_id}/queues/{queue_id}">client.queues.<a href="./src/cloudflare/resources/queues/queues.py">update</a>(queue_id, \*, account_id, \*\*<a href="src/cloudflare/types/queues/queue_update_params.py">params</a>) -> <a href="./src/cloudflare/types/queues/queue.py">Optional[Queue]</a></code>
|
||||
- <code title="get /accounts/{account_id}/queues">client.queues.<a href="./src/cloudflare/resources/queues/queues.py">list</a>(\*, account_id) -> <a href="./src/cloudflare/types/queues/queue.py">SyncSinglePage[Queue]</a></code>
|
||||
- <code title="delete /accounts/{account_id}/queues/{queue_id}">client.queues.<a href="./src/cloudflare/resources/queues/queues.py">delete</a>(queue_id, \*, account_id) -> <a href="./src/cloudflare/types/queues/queue_delete_response.py">QueueDeleteResponse</a></code>
|
||||
- <code title="patch /accounts/{account_id}/queues/{queue_id}">client.queues.<a href="./src/cloudflare/resources/queues/queues.py">edit</a>(queue_id, \*, account_id, \*\*<a href="src/cloudflare/types/queues/queue_edit_params.py">params</a>) -> <a href="./src/cloudflare/types/queues/queue.py">Optional[Queue]</a></code>
|
||||
- <code title="get /accounts/{account_id}/queues/{queue_id}">client.queues.<a href="./src/cloudflare/resources/queues/queues.py">get</a>(queue_id, \*, account_id) -> <a href="./src/cloudflare/types/queues/queue.py">Optional[Queue]</a></code>
|
||||
|
||||
## Consumers
|
||||
|
|
@ -2649,6 +2650,19 @@ Methods:
|
|||
- <code title="post /accounts/{account_id}/queues/{queue_id}/messages/ack">client.queues.messages.<a href="./src/cloudflare/resources/queues/messages.py">ack</a>(queue_id, \*, account_id, \*\*<a href="src/cloudflare/types/queues/message_ack_params.py">params</a>) -> <a href="./src/cloudflare/types/queues/message_ack_response.py">Optional[MessageAckResponse]</a></code>
|
||||
- <code title="post /accounts/{account_id}/queues/{queue_id}/messages/pull">client.queues.messages.<a href="./src/cloudflare/resources/queues/messages.py">pull</a>(queue_id, \*, account_id, \*\*<a href="src/cloudflare/types/queues/message_pull_params.py">params</a>) -> <a href="./src/cloudflare/types/queues/message_pull_response.py">SyncSinglePage[MessagePullResponse]</a></code>
|
||||
|
||||
## Purge
|
||||
|
||||
Types:
|
||||
|
||||
```python
|
||||
from cloudflare.types.queues import PurgeStatusResponse
|
||||
```
|
||||
|
||||
Methods:
|
||||
|
||||
- <code title="post /accounts/{account_id}/queues/{queue_id}/purge">client.queues.purge.<a href="./src/cloudflare/resources/queues/purge.py">start</a>(queue_id, \*, account_id, \*\*<a href="src/cloudflare/types/queues/purge_start_params.py">params</a>) -> <a href="./src/cloudflare/types/queues/queue.py">Optional[Queue]</a></code>
|
||||
- <code title="get /accounts/{account_id}/queues/{queue_id}/purge">client.queues.purge.<a href="./src/cloudflare/resources/queues/purge.py">status</a>(queue_id, \*, account_id) -> <a href="./src/cloudflare/types/queues/purge_status_response.py">Optional[PurgeStatusResponse]</a></code>
|
||||
|
||||
# APIGateway
|
||||
|
||||
## Configurations
|
||||
|
|
|
|||
|
|
@ -1,5 +1,13 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from .purge import (
|
||||
PurgeResource,
|
||||
AsyncPurgeResource,
|
||||
PurgeResourceWithRawResponse,
|
||||
AsyncPurgeResourceWithRawResponse,
|
||||
PurgeResourceWithStreamingResponse,
|
||||
AsyncPurgeResourceWithStreamingResponse,
|
||||
)
|
||||
from .queues import (
|
||||
QueuesResource,
|
||||
AsyncQueuesResource,
|
||||
|
|
@ -38,6 +46,12 @@ __all__ = [
|
|||
"AsyncMessagesResourceWithRawResponse",
|
||||
"MessagesResourceWithStreamingResponse",
|
||||
"AsyncMessagesResourceWithStreamingResponse",
|
||||
"PurgeResource",
|
||||
"AsyncPurgeResource",
|
||||
"PurgeResourceWithRawResponse",
|
||||
"AsyncPurgeResourceWithRawResponse",
|
||||
"PurgeResourceWithStreamingResponse",
|
||||
"AsyncPurgeResourceWithStreamingResponse",
|
||||
"QueuesResource",
|
||||
"AsyncQueuesResource",
|
||||
"QueuesResourceWithRawResponse",
|
||||
|
|
|
|||
306
src/cloudflare/resources/queues/purge.py
Normal file
306
src/cloudflare/resources/queues/purge.py
Normal file
|
|
@ -0,0 +1,306 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Type, Optional, 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.queues import purge_start_params
|
||||
from ...types.queues.queue import Queue
|
||||
from ...types.queues.purge_status_response import PurgeStatusResponse
|
||||
|
||||
__all__ = ["PurgeResource", "AsyncPurgeResource"]
|
||||
|
||||
|
||||
class PurgeResource(SyncAPIResource):
|
||||
@cached_property
|
||||
def with_raw_response(self) -> PurgeResourceWithRawResponse:
|
||||
"""
|
||||
This property can be used as a prefix for any HTTP method call to return
|
||||
the raw response object instead of the parsed content.
|
||||
|
||||
For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers
|
||||
"""
|
||||
return PurgeResourceWithRawResponse(self)
|
||||
|
||||
@cached_property
|
||||
def with_streaming_response(self) -> PurgeResourceWithStreamingResponse:
|
||||
"""
|
||||
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
||||
|
||||
For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response
|
||||
"""
|
||||
return PurgeResourceWithStreamingResponse(self)
|
||||
|
||||
def start(
|
||||
self,
|
||||
queue_id: str,
|
||||
*,
|
||||
account_id: str,
|
||||
delete_messages_permanently: bool | 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,
|
||||
) -> Optional[Queue]:
|
||||
"""
|
||||
Deletes all messages from the Queue.
|
||||
|
||||
Args:
|
||||
account_id: A Resource identifier.
|
||||
|
||||
queue_id: A Resource identifier.
|
||||
|
||||
delete_messages_permanently: Confimation that all messages will be deleted permanently.
|
||||
|
||||
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 queue_id:
|
||||
raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}")
|
||||
return self._post(
|
||||
f"/accounts/{account_id}/queues/{queue_id}/purge",
|
||||
body=maybe_transform(
|
||||
{"delete_messages_permanently": delete_messages_permanently}, purge_start_params.PurgeStartParams
|
||||
),
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[Optional[Queue]]._unwrapper,
|
||||
),
|
||||
cast_to=cast(Type[Optional[Queue]], ResultWrapper[Queue]),
|
||||
)
|
||||
|
||||
def status(
|
||||
self,
|
||||
queue_id: 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,
|
||||
) -> Optional[PurgeStatusResponse]:
|
||||
"""
|
||||
Get details about a Queue's purge status.
|
||||
|
||||
Args:
|
||||
account_id: A Resource identifier.
|
||||
|
||||
queue_id: A Resource 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 queue_id:
|
||||
raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}")
|
||||
return self._get(
|
||||
f"/accounts/{account_id}/queues/{queue_id}/purge",
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[Optional[PurgeStatusResponse]]._unwrapper,
|
||||
),
|
||||
cast_to=cast(Type[Optional[PurgeStatusResponse]], ResultWrapper[PurgeStatusResponse]),
|
||||
)
|
||||
|
||||
|
||||
class AsyncPurgeResource(AsyncAPIResource):
|
||||
@cached_property
|
||||
def with_raw_response(self) -> AsyncPurgeResourceWithRawResponse:
|
||||
"""
|
||||
This property can be used as a prefix for any HTTP method call to return
|
||||
the raw response object instead of the parsed content.
|
||||
|
||||
For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers
|
||||
"""
|
||||
return AsyncPurgeResourceWithRawResponse(self)
|
||||
|
||||
@cached_property
|
||||
def with_streaming_response(self) -> AsyncPurgeResourceWithStreamingResponse:
|
||||
"""
|
||||
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
||||
|
||||
For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response
|
||||
"""
|
||||
return AsyncPurgeResourceWithStreamingResponse(self)
|
||||
|
||||
async def start(
|
||||
self,
|
||||
queue_id: str,
|
||||
*,
|
||||
account_id: str,
|
||||
delete_messages_permanently: bool | 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,
|
||||
) -> Optional[Queue]:
|
||||
"""
|
||||
Deletes all messages from the Queue.
|
||||
|
||||
Args:
|
||||
account_id: A Resource identifier.
|
||||
|
||||
queue_id: A Resource identifier.
|
||||
|
||||
delete_messages_permanently: Confimation that all messages will be deleted permanently.
|
||||
|
||||
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 queue_id:
|
||||
raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}")
|
||||
return await self._post(
|
||||
f"/accounts/{account_id}/queues/{queue_id}/purge",
|
||||
body=await async_maybe_transform(
|
||||
{"delete_messages_permanently": delete_messages_permanently}, purge_start_params.PurgeStartParams
|
||||
),
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[Optional[Queue]]._unwrapper,
|
||||
),
|
||||
cast_to=cast(Type[Optional[Queue]], ResultWrapper[Queue]),
|
||||
)
|
||||
|
||||
async def status(
|
||||
self,
|
||||
queue_id: 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,
|
||||
) -> Optional[PurgeStatusResponse]:
|
||||
"""
|
||||
Get details about a Queue's purge status.
|
||||
|
||||
Args:
|
||||
account_id: A Resource identifier.
|
||||
|
||||
queue_id: A Resource 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 queue_id:
|
||||
raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}")
|
||||
return await self._get(
|
||||
f"/accounts/{account_id}/queues/{queue_id}/purge",
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[Optional[PurgeStatusResponse]]._unwrapper,
|
||||
),
|
||||
cast_to=cast(Type[Optional[PurgeStatusResponse]], ResultWrapper[PurgeStatusResponse]),
|
||||
)
|
||||
|
||||
|
||||
class PurgeResourceWithRawResponse:
|
||||
def __init__(self, purge: PurgeResource) -> None:
|
||||
self._purge = purge
|
||||
|
||||
self.start = to_raw_response_wrapper(
|
||||
purge.start,
|
||||
)
|
||||
self.status = to_raw_response_wrapper(
|
||||
purge.status,
|
||||
)
|
||||
|
||||
|
||||
class AsyncPurgeResourceWithRawResponse:
|
||||
def __init__(self, purge: AsyncPurgeResource) -> None:
|
||||
self._purge = purge
|
||||
|
||||
self.start = async_to_raw_response_wrapper(
|
||||
purge.start,
|
||||
)
|
||||
self.status = async_to_raw_response_wrapper(
|
||||
purge.status,
|
||||
)
|
||||
|
||||
|
||||
class PurgeResourceWithStreamingResponse:
|
||||
def __init__(self, purge: PurgeResource) -> None:
|
||||
self._purge = purge
|
||||
|
||||
self.start = to_streamed_response_wrapper(
|
||||
purge.start,
|
||||
)
|
||||
self.status = to_streamed_response_wrapper(
|
||||
purge.status,
|
||||
)
|
||||
|
||||
|
||||
class AsyncPurgeResourceWithStreamingResponse:
|
||||
def __init__(self, purge: AsyncPurgeResource) -> None:
|
||||
self._purge = purge
|
||||
|
||||
self.start = async_to_streamed_response_wrapper(
|
||||
purge.start,
|
||||
)
|
||||
self.status = async_to_streamed_response_wrapper(
|
||||
purge.status,
|
||||
)
|
||||
|
|
@ -6,6 +6,14 @@ from typing import Type, Optional, cast
|
|||
|
||||
import httpx
|
||||
|
||||
from .purge import (
|
||||
PurgeResource,
|
||||
AsyncPurgeResource,
|
||||
PurgeResourceWithRawResponse,
|
||||
AsyncPurgeResourceWithRawResponse,
|
||||
PurgeResourceWithStreamingResponse,
|
||||
AsyncPurgeResourceWithStreamingResponse,
|
||||
)
|
||||
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
|
||||
from ..._utils import (
|
||||
maybe_transform,
|
||||
|
|
@ -38,7 +46,7 @@ from ..._response import (
|
|||
from ..._wrappers import ResultWrapper
|
||||
from ...pagination import SyncSinglePage, AsyncSinglePage
|
||||
from ..._base_client import AsyncPaginator, make_request_options
|
||||
from ...types.queues import queue_create_params, queue_update_params
|
||||
from ...types.queues import queue_edit_params, queue_create_params, queue_update_params
|
||||
from ...types.queues.queue import Queue
|
||||
from ...types.queues.queue_delete_response import QueueDeleteResponse
|
||||
|
||||
|
|
@ -54,6 +62,10 @@ class QueuesResource(SyncAPIResource):
|
|||
def messages(self) -> MessagesResource:
|
||||
return MessagesResource(self._client)
|
||||
|
||||
@cached_property
|
||||
def purge(self) -> PurgeResource:
|
||||
return PurgeResource(self._client)
|
||||
|
||||
@cached_property
|
||||
def with_raw_response(self) -> QueuesResourceWithRawResponse:
|
||||
"""
|
||||
|
|
@ -246,6 +258,59 @@ class QueuesResource(SyncAPIResource):
|
|||
cast_to=QueueDeleteResponse,
|
||||
)
|
||||
|
||||
def edit(
|
||||
self,
|
||||
queue_id: str,
|
||||
*,
|
||||
account_id: str,
|
||||
queue_name: str | NotGiven = NOT_GIVEN,
|
||||
settings: queue_edit_params.Settings | 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,
|
||||
) -> Optional[Queue]:
|
||||
"""
|
||||
Updates a Queue.
|
||||
|
||||
Args:
|
||||
account_id: A Resource identifier.
|
||||
|
||||
queue_id: A Resource 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 queue_id:
|
||||
raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}")
|
||||
return self._patch(
|
||||
f"/accounts/{account_id}/queues/{queue_id}",
|
||||
body=maybe_transform(
|
||||
{
|
||||
"queue_name": queue_name,
|
||||
"settings": settings,
|
||||
},
|
||||
queue_edit_params.QueueEditParams,
|
||||
),
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[Optional[Queue]]._unwrapper,
|
||||
),
|
||||
cast_to=cast(Type[Optional[Queue]], ResultWrapper[Queue]),
|
||||
)
|
||||
|
||||
def get(
|
||||
self,
|
||||
queue_id: str,
|
||||
|
|
@ -300,6 +365,10 @@ class AsyncQueuesResource(AsyncAPIResource):
|
|||
def messages(self) -> AsyncMessagesResource:
|
||||
return AsyncMessagesResource(self._client)
|
||||
|
||||
@cached_property
|
||||
def purge(self) -> AsyncPurgeResource:
|
||||
return AsyncPurgeResource(self._client)
|
||||
|
||||
@cached_property
|
||||
def with_raw_response(self) -> AsyncQueuesResourceWithRawResponse:
|
||||
"""
|
||||
|
|
@ -492,6 +561,59 @@ class AsyncQueuesResource(AsyncAPIResource):
|
|||
cast_to=QueueDeleteResponse,
|
||||
)
|
||||
|
||||
async def edit(
|
||||
self,
|
||||
queue_id: str,
|
||||
*,
|
||||
account_id: str,
|
||||
queue_name: str | NotGiven = NOT_GIVEN,
|
||||
settings: queue_edit_params.Settings | 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,
|
||||
) -> Optional[Queue]:
|
||||
"""
|
||||
Updates a Queue.
|
||||
|
||||
Args:
|
||||
account_id: A Resource identifier.
|
||||
|
||||
queue_id: A Resource 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 queue_id:
|
||||
raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}")
|
||||
return await self._patch(
|
||||
f"/accounts/{account_id}/queues/{queue_id}",
|
||||
body=await async_maybe_transform(
|
||||
{
|
||||
"queue_name": queue_name,
|
||||
"settings": settings,
|
||||
},
|
||||
queue_edit_params.QueueEditParams,
|
||||
),
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[Optional[Queue]]._unwrapper,
|
||||
),
|
||||
cast_to=cast(Type[Optional[Queue]], ResultWrapper[Queue]),
|
||||
)
|
||||
|
||||
async def get(
|
||||
self,
|
||||
queue_id: str,
|
||||
|
|
@ -553,6 +675,9 @@ class QueuesResourceWithRawResponse:
|
|||
self.delete = to_raw_response_wrapper(
|
||||
queues.delete,
|
||||
)
|
||||
self.edit = to_raw_response_wrapper(
|
||||
queues.edit,
|
||||
)
|
||||
self.get = to_raw_response_wrapper(
|
||||
queues.get,
|
||||
)
|
||||
|
|
@ -565,6 +690,10 @@ class QueuesResourceWithRawResponse:
|
|||
def messages(self) -> MessagesResourceWithRawResponse:
|
||||
return MessagesResourceWithRawResponse(self._queues.messages)
|
||||
|
||||
@cached_property
|
||||
def purge(self) -> PurgeResourceWithRawResponse:
|
||||
return PurgeResourceWithRawResponse(self._queues.purge)
|
||||
|
||||
|
||||
class AsyncQueuesResourceWithRawResponse:
|
||||
def __init__(self, queues: AsyncQueuesResource) -> None:
|
||||
|
|
@ -582,6 +711,9 @@ class AsyncQueuesResourceWithRawResponse:
|
|||
self.delete = async_to_raw_response_wrapper(
|
||||
queues.delete,
|
||||
)
|
||||
self.edit = async_to_raw_response_wrapper(
|
||||
queues.edit,
|
||||
)
|
||||
self.get = async_to_raw_response_wrapper(
|
||||
queues.get,
|
||||
)
|
||||
|
|
@ -594,6 +726,10 @@ class AsyncQueuesResourceWithRawResponse:
|
|||
def messages(self) -> AsyncMessagesResourceWithRawResponse:
|
||||
return AsyncMessagesResourceWithRawResponse(self._queues.messages)
|
||||
|
||||
@cached_property
|
||||
def purge(self) -> AsyncPurgeResourceWithRawResponse:
|
||||
return AsyncPurgeResourceWithRawResponse(self._queues.purge)
|
||||
|
||||
|
||||
class QueuesResourceWithStreamingResponse:
|
||||
def __init__(self, queues: QueuesResource) -> None:
|
||||
|
|
@ -611,6 +747,9 @@ class QueuesResourceWithStreamingResponse:
|
|||
self.delete = to_streamed_response_wrapper(
|
||||
queues.delete,
|
||||
)
|
||||
self.edit = to_streamed_response_wrapper(
|
||||
queues.edit,
|
||||
)
|
||||
self.get = to_streamed_response_wrapper(
|
||||
queues.get,
|
||||
)
|
||||
|
|
@ -623,6 +762,10 @@ class QueuesResourceWithStreamingResponse:
|
|||
def messages(self) -> MessagesResourceWithStreamingResponse:
|
||||
return MessagesResourceWithStreamingResponse(self._queues.messages)
|
||||
|
||||
@cached_property
|
||||
def purge(self) -> PurgeResourceWithStreamingResponse:
|
||||
return PurgeResourceWithStreamingResponse(self._queues.purge)
|
||||
|
||||
|
||||
class AsyncQueuesResourceWithStreamingResponse:
|
||||
def __init__(self, queues: AsyncQueuesResource) -> None:
|
||||
|
|
@ -640,6 +783,9 @@ class AsyncQueuesResourceWithStreamingResponse:
|
|||
self.delete = async_to_streamed_response_wrapper(
|
||||
queues.delete,
|
||||
)
|
||||
self.edit = async_to_streamed_response_wrapper(
|
||||
queues.edit,
|
||||
)
|
||||
self.get = async_to_streamed_response_wrapper(
|
||||
queues.get,
|
||||
)
|
||||
|
|
@ -651,3 +797,7 @@ class AsyncQueuesResourceWithStreamingResponse:
|
|||
@cached_property
|
||||
def messages(self) -> AsyncMessagesResourceWithStreamingResponse:
|
||||
return AsyncMessagesResourceWithStreamingResponse(self._queues.messages)
|
||||
|
||||
@cached_property
|
||||
def purge(self) -> AsyncPurgeResourceWithStreamingResponse:
|
||||
return AsyncPurgeResourceWithStreamingResponse(self._queues.purge)
|
||||
|
|
|
|||
|
|
@ -4,12 +4,15 @@ from __future__ import annotations
|
|||
|
||||
from .queue import Queue as Queue
|
||||
from .consumer import Consumer as Consumer
|
||||
from .queue_edit_params import QueueEditParams as QueueEditParams
|
||||
from .message_ack_params import MessageAckParams as MessageAckParams
|
||||
from .purge_start_params import PurgeStartParams as PurgeStartParams
|
||||
from .message_pull_params import MessagePullParams as MessagePullParams
|
||||
from .queue_create_params import QueueCreateParams as QueueCreateParams
|
||||
from .queue_update_params import QueueUpdateParams as QueueUpdateParams
|
||||
from .message_ack_response import MessageAckResponse as MessageAckResponse
|
||||
from .message_pull_response import MessagePullResponse as MessagePullResponse
|
||||
from .purge_status_response import PurgeStatusResponse as PurgeStatusResponse
|
||||
from .queue_delete_response import QueueDeleteResponse as QueueDeleteResponse
|
||||
from .consumer_create_params import ConsumerCreateParams as ConsumerCreateParams
|
||||
from .consumer_update_params import ConsumerUpdateParams as ConsumerUpdateParams
|
||||
|
|
|
|||
15
src/cloudflare/types/queues/purge_start_params.py
Normal file
15
src/cloudflare/types/queues/purge_start_params.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing_extensions import Required, TypedDict
|
||||
|
||||
__all__ = ["PurgeStartParams"]
|
||||
|
||||
|
||||
class PurgeStartParams(TypedDict, total=False):
|
||||
account_id: Required[str]
|
||||
"""A Resource identifier."""
|
||||
|
||||
delete_messages_permanently: bool
|
||||
"""Confimation that all messages will be deleted permanently."""
|
||||
15
src/cloudflare/types/queues/purge_status_response.py
Normal file
15
src/cloudflare/types/queues/purge_status_response.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from ..._models import BaseModel
|
||||
|
||||
__all__ = ["PurgeStatusResponse"]
|
||||
|
||||
|
||||
class PurgeStatusResponse(BaseModel):
|
||||
completed: Optional[str] = None
|
||||
"""Indicates if the last purge operation completed successfully."""
|
||||
|
||||
started_at: Optional[str] = None
|
||||
"""Timestamp when the last purge operation started."""
|
||||
27
src/cloudflare/types/queues/queue_edit_params.py
Normal file
27
src/cloudflare/types/queues/queue_edit_params.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing_extensions import Required, TypedDict
|
||||
|
||||
__all__ = ["QueueEditParams", "Settings"]
|
||||
|
||||
|
||||
class QueueEditParams(TypedDict, total=False):
|
||||
account_id: Required[str]
|
||||
"""A Resource identifier."""
|
||||
|
||||
queue_name: str
|
||||
|
||||
settings: Settings
|
||||
|
||||
|
||||
class Settings(TypedDict, total=False):
|
||||
delivery_delay: float
|
||||
"""Number of seconds to delay delivery of all messages to consumers."""
|
||||
|
||||
delivery_paused: bool
|
||||
"""Indicates if message delivery to consumers is currently paused."""
|
||||
|
||||
message_retention_period: float
|
||||
"""Number of seconds after which an unconsumed message will be delayed."""
|
||||
232
tests/api_resources/queues/test_purge.py
Normal file
232
tests/api_resources/queues/test_purge.py
Normal file
|
|
@ -0,0 +1,232 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from typing import Any, Optional, cast
|
||||
|
||||
import pytest
|
||||
|
||||
from cloudflare import Cloudflare, AsyncCloudflare
|
||||
from tests.utils import assert_matches_type
|
||||
from cloudflare.types.queues import Queue, PurgeStatusResponse
|
||||
|
||||
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
|
||||
|
||||
|
||||
class TestPurge:
|
||||
parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
|
||||
|
||||
@parametrize
|
||||
def test_method_start(self, client: Cloudflare) -> None:
|
||||
purge = client.queues.purge.start(
|
||||
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert_matches_type(Optional[Queue], purge, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_method_start_with_all_params(self, client: Cloudflare) -> None:
|
||||
purge = client.queues.purge.start(
|
||||
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
delete_messages_permanently=True,
|
||||
)
|
||||
assert_matches_type(Optional[Queue], purge, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_raw_response_start(self, client: Cloudflare) -> None:
|
||||
response = client.queues.purge.with_raw_response.start(
|
||||
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
purge = response.parse()
|
||||
assert_matches_type(Optional[Queue], purge, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_streaming_response_start(self, client: Cloudflare) -> None:
|
||||
with client.queues.purge.with_streaming_response.start(
|
||||
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
purge = response.parse()
|
||||
assert_matches_type(Optional[Queue], purge, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
@parametrize
|
||||
def test_path_params_start(self, client: Cloudflare) -> None:
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
|
||||
client.queues.purge.with_raw_response.start(
|
||||
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="",
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"):
|
||||
client.queues.purge.with_raw_response.start(
|
||||
queue_id="",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
@parametrize
|
||||
def test_method_status(self, client: Cloudflare) -> None:
|
||||
purge = client.queues.purge.status(
|
||||
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert_matches_type(Optional[PurgeStatusResponse], purge, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_raw_response_status(self, client: Cloudflare) -> None:
|
||||
response = client.queues.purge.with_raw_response.status(
|
||||
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
purge = response.parse()
|
||||
assert_matches_type(Optional[PurgeStatusResponse], purge, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_streaming_response_status(self, client: Cloudflare) -> None:
|
||||
with client.queues.purge.with_streaming_response.status(
|
||||
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
purge = response.parse()
|
||||
assert_matches_type(Optional[PurgeStatusResponse], purge, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
@parametrize
|
||||
def test_path_params_status(self, client: Cloudflare) -> None:
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
|
||||
client.queues.purge.with_raw_response.status(
|
||||
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="",
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"):
|
||||
client.queues.purge.with_raw_response.status(
|
||||
queue_id="",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
|
||||
class TestAsyncPurge:
|
||||
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
|
||||
|
||||
@parametrize
|
||||
async def test_method_start(self, async_client: AsyncCloudflare) -> None:
|
||||
purge = await async_client.queues.purge.start(
|
||||
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert_matches_type(Optional[Queue], purge, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_method_start_with_all_params(self, async_client: AsyncCloudflare) -> None:
|
||||
purge = await async_client.queues.purge.start(
|
||||
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
delete_messages_permanently=True,
|
||||
)
|
||||
assert_matches_type(Optional[Queue], purge, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_raw_response_start(self, async_client: AsyncCloudflare) -> None:
|
||||
response = await async_client.queues.purge.with_raw_response.start(
|
||||
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
purge = await response.parse()
|
||||
assert_matches_type(Optional[Queue], purge, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_streaming_response_start(self, async_client: AsyncCloudflare) -> None:
|
||||
async with async_client.queues.purge.with_streaming_response.start(
|
||||
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
purge = await response.parse()
|
||||
assert_matches_type(Optional[Queue], purge, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
@parametrize
|
||||
async def test_path_params_start(self, async_client: AsyncCloudflare) -> None:
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
|
||||
await async_client.queues.purge.with_raw_response.start(
|
||||
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="",
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"):
|
||||
await async_client.queues.purge.with_raw_response.start(
|
||||
queue_id="",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
@parametrize
|
||||
async def test_method_status(self, async_client: AsyncCloudflare) -> None:
|
||||
purge = await async_client.queues.purge.status(
|
||||
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert_matches_type(Optional[PurgeStatusResponse], purge, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_raw_response_status(self, async_client: AsyncCloudflare) -> None:
|
||||
response = await async_client.queues.purge.with_raw_response.status(
|
||||
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
purge = await response.parse()
|
||||
assert_matches_type(Optional[PurgeStatusResponse], purge, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_streaming_response_status(self, async_client: AsyncCloudflare) -> None:
|
||||
async with async_client.queues.purge.with_streaming_response.status(
|
||||
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
purge = await response.parse()
|
||||
assert_matches_type(Optional[PurgeStatusResponse], purge, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
@parametrize
|
||||
async def test_path_params_status(self, async_client: AsyncCloudflare) -> None:
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
|
||||
await async_client.queues.purge.with_raw_response.status(
|
||||
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="",
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"):
|
||||
await async_client.queues.purge.with_raw_response.status(
|
||||
queue_id="",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
|
@ -10,7 +10,10 @@ import pytest
|
|||
from cloudflare import Cloudflare, AsyncCloudflare
|
||||
from tests.utils import assert_matches_type
|
||||
from cloudflare.pagination import SyncSinglePage, AsyncSinglePage
|
||||
from cloudflare.types.queues import Queue, QueueDeleteResponse
|
||||
from cloudflare.types.queues import (
|
||||
Queue,
|
||||
QueueDeleteResponse,
|
||||
)
|
||||
|
||||
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
|
||||
|
||||
|
|
@ -208,6 +211,68 @@ class TestQueues:
|
|||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
@parametrize
|
||||
def test_method_edit(self, client: Cloudflare) -> None:
|
||||
queue = client.queues.edit(
|
||||
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert_matches_type(Optional[Queue], queue, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_method_edit_with_all_params(self, client: Cloudflare) -> None:
|
||||
queue = client.queues.edit(
|
||||
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
queue_name="example-queue",
|
||||
settings={
|
||||
"delivery_delay": 5,
|
||||
"delivery_paused": True,
|
||||
"message_retention_period": 345600,
|
||||
},
|
||||
)
|
||||
assert_matches_type(Optional[Queue], queue, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_raw_response_edit(self, client: Cloudflare) -> None:
|
||||
response = client.queues.with_raw_response.edit(
|
||||
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
queue = response.parse()
|
||||
assert_matches_type(Optional[Queue], queue, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_streaming_response_edit(self, client: Cloudflare) -> None:
|
||||
with client.queues.with_streaming_response.edit(
|
||||
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
queue = response.parse()
|
||||
assert_matches_type(Optional[Queue], queue, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
@parametrize
|
||||
def test_path_params_edit(self, client: Cloudflare) -> None:
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
|
||||
client.queues.with_raw_response.edit(
|
||||
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="",
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"):
|
||||
client.queues.with_raw_response.edit(
|
||||
queue_id="",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
@parametrize
|
||||
def test_method_get(self, client: Cloudflare) -> None:
|
||||
queue = client.queues.get(
|
||||
|
|
@ -450,6 +515,68 @@ class TestAsyncQueues:
|
|||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
@parametrize
|
||||
async def test_method_edit(self, async_client: AsyncCloudflare) -> None:
|
||||
queue = await async_client.queues.edit(
|
||||
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert_matches_type(Optional[Queue], queue, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None:
|
||||
queue = await async_client.queues.edit(
|
||||
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
queue_name="example-queue",
|
||||
settings={
|
||||
"delivery_delay": 5,
|
||||
"delivery_paused": True,
|
||||
"message_retention_period": 345600,
|
||||
},
|
||||
)
|
||||
assert_matches_type(Optional[Queue], queue, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None:
|
||||
response = await async_client.queues.with_raw_response.edit(
|
||||
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
queue = await response.parse()
|
||||
assert_matches_type(Optional[Queue], queue, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None:
|
||||
async with async_client.queues.with_streaming_response.edit(
|
||||
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="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(Optional[Queue], queue, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
@parametrize
|
||||
async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None:
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
|
||||
await async_client.queues.with_raw_response.edit(
|
||||
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="",
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"):
|
||||
await async_client.queues.with_raw_response.edit(
|
||||
queue_id="",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
@parametrize
|
||||
async def test_method_get(self, async_client: AsyncCloudflare) -> None:
|
||||
queue = await async_client.queues.get(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue