From 1e7ac2471634fea520a36a1e460ba42d54b8c9b7 Mon Sep 17 00:00:00 2001 From: stainless-bot Date: Mon, 29 Apr 2024 16:56:00 +0000 Subject: [PATCH] feat(api): OpenAPI spec update via Stainless API --- .stats.yml | 4 +- api.md | 34 -- src/cloudflare/_client.py | 8 - src/cloudflare/resources/__init__.py | 14 - src/cloudflare/resources/snippets/__init__.py | 47 -- src/cloudflare/resources/snippets/content.py | 166 ------ src/cloudflare/resources/snippets/rules.py | 258 -------- src/cloudflare/resources/snippets/snippets.py | 556 ------------------ src/cloudflare/types/snippets/__init__.py | 7 - .../types/snippets/rule_list_response.py | 18 - .../types/snippets/rule_update_params.py | 24 - .../types/snippets/rule_update_response.py | 21 - src/cloudflare/types/snippets/snippet.py | 18 - .../types/snippets/snippet_delete_response.py | 7 - .../types/snippets/snippet_update_params.py | 22 - tests/api_resources/snippets/__init__.py | 1 - tests/api_resources/snippets/test_content.py | 168 ------ tests/api_resources/snippets/test_rules.py | 247 -------- tests/api_resources/test_snippets.py | 441 -------------- 19 files changed, 2 insertions(+), 2059 deletions(-) delete mode 100644 src/cloudflare/resources/snippets/__init__.py delete mode 100644 src/cloudflare/resources/snippets/content.py delete mode 100644 src/cloudflare/resources/snippets/rules.py delete mode 100644 src/cloudflare/resources/snippets/snippets.py delete mode 100644 src/cloudflare/types/snippets/rule_list_response.py delete mode 100644 src/cloudflare/types/snippets/rule_update_params.py delete mode 100644 src/cloudflare/types/snippets/rule_update_response.py delete mode 100644 src/cloudflare/types/snippets/snippet.py delete mode 100644 src/cloudflare/types/snippets/snippet_delete_response.py delete mode 100644 src/cloudflare/types/snippets/snippet_update_params.py delete mode 100644 tests/api_resources/snippets/__init__.py delete mode 100644 tests/api_resources/snippets/test_content.py delete mode 100644 tests/api_resources/snippets/test_rules.py delete mode 100644 tests/api_resources/test_snippets.py diff --git a/.stats.yml b/.stats.yml index 8200d3d0354..a0d0f16ebb2 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1266 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c4098fcb3861719a0115fe0bd93ede436f466e42ea623f1ed1feeb1f126d9c3d.yml +configured_endpoints: 1259 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-eaeee7cb7327c83a8a9dca926a685e6e2aedc0f64ede2722f8a9004610dc8b3a.yml diff --git a/api.md b/api.md index 5acd8c6e580..2f743e48fcb 100644 --- a/api.md +++ b/api.md @@ -7273,40 +7273,6 @@ Methods: - client.hostnames.settings.tls.delete(hostname, \*, zone_id, setting_id) -> TLSDeleteResponse - client.hostnames.settings.tls.get(setting_id, \*, zone_id) -> Optional -# Snippets - -Types: - -```python -from cloudflare.types.snippets import Snippet, SnippetDeleteResponse -``` - -Methods: - -- client.snippets.update(snippet_name, \*, zone_identifier, \*\*params) -> Snippet -- client.snippets.list(zone_identifier) -> SyncSinglePage[Snippet] -- client.snippets.delete(snippet_name, \*, zone_identifier) -> SnippetDeleteResponse -- client.snippets.get(snippet_name, \*, zone_identifier) -> Snippet - -## Content - -Methods: - -- client.snippets.content.get(snippet_name, \*, zone_identifier) -> BinaryAPIResponse - -## Rules - -Types: - -```python -from cloudflare.types.snippets import RuleUpdateResponse, RuleListResponse -``` - -Methods: - -- client.snippets.rules.update(zone_identifier, \*\*params) -> RuleUpdateResponse -- client.snippets.rules.list(zone_identifier) -> SyncSinglePage[RuleListResponse] - # Calls Types: diff --git a/src/cloudflare/_client.py b/src/cloudflare/_client.py index 41a4fcfac22..402f7e5097b 100644 --- a/src/cloudflare/_client.py +++ b/src/cloudflare/_client.py @@ -124,7 +124,6 @@ class Cloudflare(SyncAPIClient): speed: resources.SpeedResource dcv_delegation: resources.DCVDelegationResource hostnames: resources.HostnamesResource - snippets: resources.SnippetsResource calls: resources.CallsResource cloudforce_one: resources.CloudforceOneResource event_notifications: resources.EventNotificationsResource @@ -280,7 +279,6 @@ def __init__( self.speed = resources.SpeedResource(self) self.dcv_delegation = resources.DCVDelegationResource(self) self.hostnames = resources.HostnamesResource(self) - self.snippets = resources.SnippetsResource(self) self.calls = resources.CallsResource(self) self.cloudforce_one = resources.CloudforceOneResource(self) self.event_notifications = resources.EventNotificationsResource(self) @@ -539,7 +537,6 @@ class AsyncCloudflare(AsyncAPIClient): speed: resources.AsyncSpeedResource dcv_delegation: resources.AsyncDCVDelegationResource hostnames: resources.AsyncHostnamesResource - snippets: resources.AsyncSnippetsResource calls: resources.AsyncCallsResource cloudforce_one: resources.AsyncCloudforceOneResource event_notifications: resources.AsyncEventNotificationsResource @@ -695,7 +692,6 @@ def __init__( self.speed = resources.AsyncSpeedResource(self) self.dcv_delegation = resources.AsyncDCVDelegationResource(self) self.hostnames = resources.AsyncHostnamesResource(self) - self.snippets = resources.AsyncSnippetsResource(self) self.calls = resources.AsyncCallsResource(self) self.cloudforce_one = resources.AsyncCloudforceOneResource(self) self.event_notifications = resources.AsyncEventNotificationsResource(self) @@ -965,7 +961,6 @@ def __init__(self, client: Cloudflare) -> None: self.speed = resources.SpeedResourceWithRawResponse(client.speed) self.dcv_delegation = resources.DCVDelegationResourceWithRawResponse(client.dcv_delegation) self.hostnames = resources.HostnamesResourceWithRawResponse(client.hostnames) - self.snippets = resources.SnippetsResourceWithRawResponse(client.snippets) self.calls = resources.CallsResourceWithRawResponse(client.calls) self.cloudforce_one = resources.CloudforceOneResourceWithRawResponse(client.cloudforce_one) self.event_notifications = resources.EventNotificationsResourceWithRawResponse(client.event_notifications) @@ -1064,7 +1059,6 @@ def __init__(self, client: AsyncCloudflare) -> None: self.speed = resources.AsyncSpeedResourceWithRawResponse(client.speed) self.dcv_delegation = resources.AsyncDCVDelegationResourceWithRawResponse(client.dcv_delegation) self.hostnames = resources.AsyncHostnamesResourceWithRawResponse(client.hostnames) - self.snippets = resources.AsyncSnippetsResourceWithRawResponse(client.snippets) self.calls = resources.AsyncCallsResourceWithRawResponse(client.calls) self.cloudforce_one = resources.AsyncCloudforceOneResourceWithRawResponse(client.cloudforce_one) self.event_notifications = resources.AsyncEventNotificationsResourceWithRawResponse(client.event_notifications) @@ -1163,7 +1157,6 @@ def __init__(self, client: Cloudflare) -> None: self.speed = resources.SpeedResourceWithStreamingResponse(client.speed) self.dcv_delegation = resources.DCVDelegationResourceWithStreamingResponse(client.dcv_delegation) self.hostnames = resources.HostnamesResourceWithStreamingResponse(client.hostnames) - self.snippets = resources.SnippetsResourceWithStreamingResponse(client.snippets) self.calls = resources.CallsResourceWithStreamingResponse(client.calls) self.cloudforce_one = resources.CloudforceOneResourceWithStreamingResponse(client.cloudforce_one) self.event_notifications = resources.EventNotificationsResourceWithStreamingResponse(client.event_notifications) @@ -1268,7 +1261,6 @@ def __init__(self, client: AsyncCloudflare) -> None: self.speed = resources.AsyncSpeedResourceWithStreamingResponse(client.speed) self.dcv_delegation = resources.AsyncDCVDelegationResourceWithStreamingResponse(client.dcv_delegation) self.hostnames = resources.AsyncHostnamesResourceWithStreamingResponse(client.hostnames) - self.snippets = resources.AsyncSnippetsResourceWithStreamingResponse(client.snippets) self.calls = resources.AsyncCallsResourceWithStreamingResponse(client.calls) self.cloudforce_one = resources.AsyncCloudforceOneResourceWithStreamingResponse(client.cloudforce_one) self.event_notifications = resources.AsyncEventNotificationsResourceWithStreamingResponse( diff --git a/src/cloudflare/resources/__init__.py b/src/cloudflare/resources/__init__.py index e4d0f926f5d..7f73728a7bb 100644 --- a/src/cloudflare/resources/__init__.py +++ b/src/cloudflare/resources/__init__.py @@ -280,14 +280,6 @@ RulesetsResourceWithStreamingResponse, AsyncRulesetsResourceWithStreamingResponse, ) -from .snippets import ( - SnippetsResource, - AsyncSnippetsResource, - SnippetsResourceWithRawResponse, - AsyncSnippetsResourceWithRawResponse, - SnippetsResourceWithStreamingResponse, - AsyncSnippetsResourceWithStreamingResponse, -) from .spectrum import ( SpectrumResource, AsyncSpectrumResource, @@ -1112,12 +1104,6 @@ "AsyncHostnamesResourceWithRawResponse", "HostnamesResourceWithStreamingResponse", "AsyncHostnamesResourceWithStreamingResponse", - "SnippetsResource", - "AsyncSnippetsResource", - "SnippetsResourceWithRawResponse", - "AsyncSnippetsResourceWithRawResponse", - "SnippetsResourceWithStreamingResponse", - "AsyncSnippetsResourceWithStreamingResponse", "CallsResource", "AsyncCallsResource", "CallsResourceWithRawResponse", diff --git a/src/cloudflare/resources/snippets/__init__.py b/src/cloudflare/resources/snippets/__init__.py deleted file mode 100644 index e3270af6c0a..00000000000 --- a/src/cloudflare/resources/snippets/__init__.py +++ /dev/null @@ -1,47 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from .rules import ( - RulesResource, - AsyncRulesResource, - RulesResourceWithRawResponse, - AsyncRulesResourceWithRawResponse, - RulesResourceWithStreamingResponse, - AsyncRulesResourceWithStreamingResponse, -) -from .content import ( - ContentResource, - AsyncContentResource, - ContentResourceWithRawResponse, - AsyncContentResourceWithRawResponse, - ContentResourceWithStreamingResponse, - AsyncContentResourceWithStreamingResponse, -) -from .snippets import ( - SnippetsResource, - AsyncSnippetsResource, - SnippetsResourceWithRawResponse, - AsyncSnippetsResourceWithRawResponse, - SnippetsResourceWithStreamingResponse, - AsyncSnippetsResourceWithStreamingResponse, -) - -__all__ = [ - "ContentResource", - "AsyncContentResource", - "ContentResourceWithRawResponse", - "AsyncContentResourceWithRawResponse", - "ContentResourceWithStreamingResponse", - "AsyncContentResourceWithStreamingResponse", - "RulesResource", - "AsyncRulesResource", - "RulesResourceWithRawResponse", - "AsyncRulesResourceWithRawResponse", - "RulesResourceWithStreamingResponse", - "AsyncRulesResourceWithStreamingResponse", - "SnippetsResource", - "AsyncSnippetsResource", - "SnippetsResourceWithRawResponse", - "AsyncSnippetsResourceWithRawResponse", - "SnippetsResourceWithStreamingResponse", - "AsyncSnippetsResourceWithStreamingResponse", -] diff --git a/src/cloudflare/resources/snippets/content.py b/src/cloudflare/resources/snippets/content.py deleted file mode 100644 index 3c010cbae16..00000000000 --- a/src/cloudflare/resources/snippets/content.py +++ /dev/null @@ -1,166 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import httpx - -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._compat import cached_property -from ..._resource import SyncAPIResource, AsyncAPIResource -from ..._response import ( - BinaryAPIResponse, - AsyncBinaryAPIResponse, - StreamedBinaryAPIResponse, - AsyncStreamedBinaryAPIResponse, - to_custom_raw_response_wrapper, - to_custom_streamed_response_wrapper, - async_to_custom_raw_response_wrapper, - async_to_custom_streamed_response_wrapper, -) -from ..._base_client import ( - make_request_options, -) - -__all__ = ["ContentResource", "AsyncContentResource"] - - -class ContentResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> ContentResourceWithRawResponse: - return ContentResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> ContentResourceWithStreamingResponse: - return ContentResourceWithStreamingResponse(self) - - def get( - self, - snippet_name: str, - *, - zone_identifier: 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, - ) -> BinaryAPIResponse: - """ - Snippet Content - - Args: - zone_identifier: Identifier - - snippet_name: Snippet identifying name - - 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 zone_identifier: - raise ValueError(f"Expected a non-empty value for `zone_identifier` but received {zone_identifier!r}") - if not snippet_name: - raise ValueError(f"Expected a non-empty value for `snippet_name` but received {snippet_name!r}") - extra_headers = {"Accept": "multipart/form-data", **(extra_headers or {})} - return self._get( - f"/zones/{zone_identifier}/snippets/{snippet_name}/content", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=BinaryAPIResponse, - ) - - -class AsyncContentResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncContentResourceWithRawResponse: - return AsyncContentResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncContentResourceWithStreamingResponse: - return AsyncContentResourceWithStreamingResponse(self) - - async def get( - self, - snippet_name: str, - *, - zone_identifier: 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, - ) -> AsyncBinaryAPIResponse: - """ - Snippet Content - - Args: - zone_identifier: Identifier - - snippet_name: Snippet identifying name - - 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 zone_identifier: - raise ValueError(f"Expected a non-empty value for `zone_identifier` but received {zone_identifier!r}") - if not snippet_name: - raise ValueError(f"Expected a non-empty value for `snippet_name` but received {snippet_name!r}") - extra_headers = {"Accept": "multipart/form-data", **(extra_headers or {})} - return await self._get( - f"/zones/{zone_identifier}/snippets/{snippet_name}/content", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=AsyncBinaryAPIResponse, - ) - - -class ContentResourceWithRawResponse: - def __init__(self, content: ContentResource) -> None: - self._content = content - - self.get = to_custom_raw_response_wrapper( - content.get, - BinaryAPIResponse, - ) - - -class AsyncContentResourceWithRawResponse: - def __init__(self, content: AsyncContentResource) -> None: - self._content = content - - self.get = async_to_custom_raw_response_wrapper( - content.get, - AsyncBinaryAPIResponse, - ) - - -class ContentResourceWithStreamingResponse: - def __init__(self, content: ContentResource) -> None: - self._content = content - - self.get = to_custom_streamed_response_wrapper( - content.get, - StreamedBinaryAPIResponse, - ) - - -class AsyncContentResourceWithStreamingResponse: - def __init__(self, content: AsyncContentResource) -> None: - self._content = content - - self.get = async_to_custom_streamed_response_wrapper( - content.get, - AsyncStreamedBinaryAPIResponse, - ) diff --git a/src/cloudflare/resources/snippets/rules.py b/src/cloudflare/resources/snippets/rules.py deleted file mode 100644 index 29923f06348..00000000000 --- a/src/cloudflare/resources/snippets/rules.py +++ /dev/null @@ -1,258 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import 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 ...pagination import SyncSinglePage, AsyncSinglePage -from ..._base_client import ( - AsyncPaginator, - make_request_options, -) -from ...types.snippets import rule_update_params -from ...types.snippets.rule_list_response import RuleListResponse -from ...types.snippets.rule_update_response import RuleUpdateResponse - -__all__ = ["RulesResource", "AsyncRulesResource"] - - -class RulesResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> RulesResourceWithRawResponse: - return RulesResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> RulesResourceWithStreamingResponse: - return RulesResourceWithStreamingResponse(self) - - def update( - self, - zone_identifier: str, - *, - rules: Iterable[rule_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, - ) -> RuleUpdateResponse: - """ - Put Rules - - Args: - zone_identifier: Identifier - - rules: List of snippet rules - - 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 zone_identifier: - raise ValueError(f"Expected a non-empty value for `zone_identifier` but received {zone_identifier!r}") - return self._put( - f"/zones/{zone_identifier}/snippets/snippet_rules", - body=maybe_transform({"rules": rules}, rule_update_params.RuleUpdateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RuleUpdateResponse]._unwrapper, - ), - cast_to=cast(Type[RuleUpdateResponse], ResultWrapper[RuleUpdateResponse]), - ) - - def list( - self, - zone_identifier: 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, - ) -> SyncSinglePage[RuleListResponse]: - """ - Rules - - Args: - zone_identifier: 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 zone_identifier: - raise ValueError(f"Expected a non-empty value for `zone_identifier` but received {zone_identifier!r}") - return self._get_api_list( - f"/zones/{zone_identifier}/snippets/snippet_rules", - page=SyncSinglePage[RuleListResponse], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=RuleListResponse, - ) - - -class AsyncRulesResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncRulesResourceWithRawResponse: - return AsyncRulesResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncRulesResourceWithStreamingResponse: - return AsyncRulesResourceWithStreamingResponse(self) - - async def update( - self, - zone_identifier: str, - *, - rules: Iterable[rule_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, - ) -> RuleUpdateResponse: - """ - Put Rules - - Args: - zone_identifier: Identifier - - rules: List of snippet rules - - 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 zone_identifier: - raise ValueError(f"Expected a non-empty value for `zone_identifier` but received {zone_identifier!r}") - return await self._put( - f"/zones/{zone_identifier}/snippets/snippet_rules", - body=await async_maybe_transform({"rules": rules}, rule_update_params.RuleUpdateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RuleUpdateResponse]._unwrapper, - ), - cast_to=cast(Type[RuleUpdateResponse], ResultWrapper[RuleUpdateResponse]), - ) - - def list( - self, - zone_identifier: 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, - ) -> AsyncPaginator[RuleListResponse, AsyncSinglePage[RuleListResponse]]: - """ - Rules - - Args: - zone_identifier: 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 zone_identifier: - raise ValueError(f"Expected a non-empty value for `zone_identifier` but received {zone_identifier!r}") - return self._get_api_list( - f"/zones/{zone_identifier}/snippets/snippet_rules", - page=AsyncSinglePage[RuleListResponse], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=RuleListResponse, - ) - - -class RulesResourceWithRawResponse: - def __init__(self, rules: RulesResource) -> None: - self._rules = rules - - self.update = to_raw_response_wrapper( - rules.update, - ) - self.list = to_raw_response_wrapper( - rules.list, - ) - - -class AsyncRulesResourceWithRawResponse: - def __init__(self, rules: AsyncRulesResource) -> None: - self._rules = rules - - self.update = async_to_raw_response_wrapper( - rules.update, - ) - self.list = async_to_raw_response_wrapper( - rules.list, - ) - - -class RulesResourceWithStreamingResponse: - def __init__(self, rules: RulesResource) -> None: - self._rules = rules - - self.update = to_streamed_response_wrapper( - rules.update, - ) - self.list = to_streamed_response_wrapper( - rules.list, - ) - - -class AsyncRulesResourceWithStreamingResponse: - def __init__(self, rules: AsyncRulesResource) -> None: - self._rules = rules - - self.update = async_to_streamed_response_wrapper( - rules.update, - ) - self.list = async_to_streamed_response_wrapper( - rules.list, - ) diff --git a/src/cloudflare/resources/snippets/snippets.py b/src/cloudflare/resources/snippets/snippets.py deleted file mode 100644 index 15d503d6bd1..00000000000 --- a/src/cloudflare/resources/snippets/snippets.py +++ /dev/null @@ -1,556 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Any, Type, cast - -import httpx - -from .rules import ( - RulesResource, - AsyncRulesResource, - RulesResourceWithRawResponse, - AsyncRulesResourceWithRawResponse, - RulesResourceWithStreamingResponse, - AsyncRulesResourceWithStreamingResponse, -) -from .content import ( - ContentResource, - AsyncContentResource, - ContentResourceWithRawResponse, - AsyncContentResourceWithRawResponse, - ContentResourceWithStreamingResponse, - AsyncContentResourceWithStreamingResponse, -) -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 ...pagination import SyncSinglePage, AsyncSinglePage -from ..._base_client import ( - AsyncPaginator, - make_request_options, -) -from ...types.snippets import snippet_update_params -from ...types.snippets.snippet import Snippet -from ...types.snippets.snippet_delete_response import SnippetDeleteResponse - -__all__ = ["SnippetsResource", "AsyncSnippetsResource"] - - -class SnippetsResource(SyncAPIResource): - @cached_property - def content(self) -> ContentResource: - return ContentResource(self._client) - - @cached_property - def rules(self) -> RulesResource: - return RulesResource(self._client) - - @cached_property - def with_raw_response(self) -> SnippetsResourceWithRawResponse: - return SnippetsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> SnippetsResourceWithStreamingResponse: - return SnippetsResourceWithStreamingResponse(self) - - def update( - self, - snippet_name: str, - *, - zone_identifier: str, - files: str | NotGiven = NOT_GIVEN, - metadata: snippet_update_params.Metadata | 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, - ) -> Snippet: - """ - Put Snippet - - Args: - zone_identifier: Identifier - - snippet_name: Snippet identifying name - - files: Content files of uploaded snippet - - 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 zone_identifier: - raise ValueError(f"Expected a non-empty value for `zone_identifier` but received {zone_identifier!r}") - if not snippet_name: - raise ValueError(f"Expected a non-empty value for `snippet_name` but received {snippet_name!r}") - return self._put( - f"/zones/{zone_identifier}/snippets/{snippet_name}", - body=maybe_transform( - { - "files": files, - "metadata": metadata, - }, - snippet_update_params.SnippetUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Snippet]._unwrapper, - ), - cast_to=cast(Type[Snippet], ResultWrapper[Snippet]), - ) - - def list( - self, - zone_identifier: 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, - ) -> SyncSinglePage[Snippet]: - """ - All Snippets - - Args: - zone_identifier: 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 zone_identifier: - raise ValueError(f"Expected a non-empty value for `zone_identifier` but received {zone_identifier!r}") - return self._get_api_list( - f"/zones/{zone_identifier}/snippets", - page=SyncSinglePage[Snippet], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=Snippet, - ) - - def delete( - self, - snippet_name: str, - *, - zone_identifier: 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, - ) -> SnippetDeleteResponse: - """ - Delete Snippet - - Args: - zone_identifier: Identifier - - snippet_name: Snippet identifying name - - 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 zone_identifier: - raise ValueError(f"Expected a non-empty value for `zone_identifier` but received {zone_identifier!r}") - if not snippet_name: - raise ValueError(f"Expected a non-empty value for `snippet_name` but received {snippet_name!r}") - return cast( - SnippetDeleteResponse, - self._delete( - f"/zones/{zone_identifier}/snippets/{snippet_name}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[SnippetDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[SnippetDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system - ), - ) - - def get( - self, - snippet_name: str, - *, - zone_identifier: 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, - ) -> Snippet: - """ - Snippet - - Args: - zone_identifier: Identifier - - snippet_name: Snippet identifying name - - 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 zone_identifier: - raise ValueError(f"Expected a non-empty value for `zone_identifier` but received {zone_identifier!r}") - if not snippet_name: - raise ValueError(f"Expected a non-empty value for `snippet_name` but received {snippet_name!r}") - return self._get( - f"/zones/{zone_identifier}/snippets/{snippet_name}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Snippet]._unwrapper, - ), - cast_to=cast(Type[Snippet], ResultWrapper[Snippet]), - ) - - -class AsyncSnippetsResource(AsyncAPIResource): - @cached_property - def content(self) -> AsyncContentResource: - return AsyncContentResource(self._client) - - @cached_property - def rules(self) -> AsyncRulesResource: - return AsyncRulesResource(self._client) - - @cached_property - def with_raw_response(self) -> AsyncSnippetsResourceWithRawResponse: - return AsyncSnippetsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncSnippetsResourceWithStreamingResponse: - return AsyncSnippetsResourceWithStreamingResponse(self) - - async def update( - self, - snippet_name: str, - *, - zone_identifier: str, - files: str | NotGiven = NOT_GIVEN, - metadata: snippet_update_params.Metadata | 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, - ) -> Snippet: - """ - Put Snippet - - Args: - zone_identifier: Identifier - - snippet_name: Snippet identifying name - - files: Content files of uploaded snippet - - 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 zone_identifier: - raise ValueError(f"Expected a non-empty value for `zone_identifier` but received {zone_identifier!r}") - if not snippet_name: - raise ValueError(f"Expected a non-empty value for `snippet_name` but received {snippet_name!r}") - return await self._put( - f"/zones/{zone_identifier}/snippets/{snippet_name}", - body=await async_maybe_transform( - { - "files": files, - "metadata": metadata, - }, - snippet_update_params.SnippetUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Snippet]._unwrapper, - ), - cast_to=cast(Type[Snippet], ResultWrapper[Snippet]), - ) - - def list( - self, - zone_identifier: 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, - ) -> AsyncPaginator[Snippet, AsyncSinglePage[Snippet]]: - """ - All Snippets - - Args: - zone_identifier: 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 zone_identifier: - raise ValueError(f"Expected a non-empty value for `zone_identifier` but received {zone_identifier!r}") - return self._get_api_list( - f"/zones/{zone_identifier}/snippets", - page=AsyncSinglePage[Snippet], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=Snippet, - ) - - async def delete( - self, - snippet_name: str, - *, - zone_identifier: 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, - ) -> SnippetDeleteResponse: - """ - Delete Snippet - - Args: - zone_identifier: Identifier - - snippet_name: Snippet identifying name - - 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 zone_identifier: - raise ValueError(f"Expected a non-empty value for `zone_identifier` but received {zone_identifier!r}") - if not snippet_name: - raise ValueError(f"Expected a non-empty value for `snippet_name` but received {snippet_name!r}") - return cast( - SnippetDeleteResponse, - await self._delete( - f"/zones/{zone_identifier}/snippets/{snippet_name}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[SnippetDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[SnippetDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system - ), - ) - - async def get( - self, - snippet_name: str, - *, - zone_identifier: 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, - ) -> Snippet: - """ - Snippet - - Args: - zone_identifier: Identifier - - snippet_name: Snippet identifying name - - 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 zone_identifier: - raise ValueError(f"Expected a non-empty value for `zone_identifier` but received {zone_identifier!r}") - if not snippet_name: - raise ValueError(f"Expected a non-empty value for `snippet_name` but received {snippet_name!r}") - return await self._get( - f"/zones/{zone_identifier}/snippets/{snippet_name}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Snippet]._unwrapper, - ), - cast_to=cast(Type[Snippet], ResultWrapper[Snippet]), - ) - - -class SnippetsResourceWithRawResponse: - def __init__(self, snippets: SnippetsResource) -> None: - self._snippets = snippets - - self.update = to_raw_response_wrapper( - snippets.update, - ) - self.list = to_raw_response_wrapper( - snippets.list, - ) - self.delete = to_raw_response_wrapper( - snippets.delete, - ) - self.get = to_raw_response_wrapper( - snippets.get, - ) - - @cached_property - def content(self) -> ContentResourceWithRawResponse: - return ContentResourceWithRawResponse(self._snippets.content) - - @cached_property - def rules(self) -> RulesResourceWithRawResponse: - return RulesResourceWithRawResponse(self._snippets.rules) - - -class AsyncSnippetsResourceWithRawResponse: - def __init__(self, snippets: AsyncSnippetsResource) -> None: - self._snippets = snippets - - self.update = async_to_raw_response_wrapper( - snippets.update, - ) - self.list = async_to_raw_response_wrapper( - snippets.list, - ) - self.delete = async_to_raw_response_wrapper( - snippets.delete, - ) - self.get = async_to_raw_response_wrapper( - snippets.get, - ) - - @cached_property - def content(self) -> AsyncContentResourceWithRawResponse: - return AsyncContentResourceWithRawResponse(self._snippets.content) - - @cached_property - def rules(self) -> AsyncRulesResourceWithRawResponse: - return AsyncRulesResourceWithRawResponse(self._snippets.rules) - - -class SnippetsResourceWithStreamingResponse: - def __init__(self, snippets: SnippetsResource) -> None: - self._snippets = snippets - - self.update = to_streamed_response_wrapper( - snippets.update, - ) - self.list = to_streamed_response_wrapper( - snippets.list, - ) - self.delete = to_streamed_response_wrapper( - snippets.delete, - ) - self.get = to_streamed_response_wrapper( - snippets.get, - ) - - @cached_property - def content(self) -> ContentResourceWithStreamingResponse: - return ContentResourceWithStreamingResponse(self._snippets.content) - - @cached_property - def rules(self) -> RulesResourceWithStreamingResponse: - return RulesResourceWithStreamingResponse(self._snippets.rules) - - -class AsyncSnippetsResourceWithStreamingResponse: - def __init__(self, snippets: AsyncSnippetsResource) -> None: - self._snippets = snippets - - self.update = async_to_streamed_response_wrapper( - snippets.update, - ) - self.list = async_to_streamed_response_wrapper( - snippets.list, - ) - self.delete = async_to_streamed_response_wrapper( - snippets.delete, - ) - self.get = async_to_streamed_response_wrapper( - snippets.get, - ) - - @cached_property - def content(self) -> AsyncContentResourceWithStreamingResponse: - return AsyncContentResourceWithStreamingResponse(self._snippets.content) - - @cached_property - def rules(self) -> AsyncRulesResourceWithStreamingResponse: - return AsyncRulesResourceWithStreamingResponse(self._snippets.rules) diff --git a/src/cloudflare/types/snippets/__init__.py b/src/cloudflare/types/snippets/__init__.py index 2084aa6e7bb..f8ee8b14b1c 100644 --- a/src/cloudflare/types/snippets/__init__.py +++ b/src/cloudflare/types/snippets/__init__.py @@ -1,10 +1,3 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations - -from .snippet import Snippet as Snippet -from .rule_list_response import RuleListResponse as RuleListResponse -from .rule_update_params import RuleUpdateParams as RuleUpdateParams -from .rule_update_response import RuleUpdateResponse as RuleUpdateResponse -from .snippet_update_params import SnippetUpdateParams as SnippetUpdateParams -from .snippet_delete_response import SnippetDeleteResponse as SnippetDeleteResponse diff --git a/src/cloudflare/types/snippets/rule_list_response.py b/src/cloudflare/types/snippets/rule_list_response.py deleted file mode 100644 index 63c540e55c7..00000000000 --- a/src/cloudflare/types/snippets/rule_list_response.py +++ /dev/null @@ -1,18 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional - -from ..._models import BaseModel - -__all__ = ["RuleListResponse"] - - -class RuleListResponse(BaseModel): - description: Optional[str] = None - - enabled: Optional[bool] = None - - expression: Optional[str] = None - - snippet_name: Optional[str] = None - """Snippet identifying name""" diff --git a/src/cloudflare/types/snippets/rule_update_params.py b/src/cloudflare/types/snippets/rule_update_params.py deleted file mode 100644 index d33769231d6..00000000000 --- a/src/cloudflare/types/snippets/rule_update_params.py +++ /dev/null @@ -1,24 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Iterable -from typing_extensions import TypedDict - -__all__ = ["RuleUpdateParams", "Rule"] - - -class RuleUpdateParams(TypedDict, total=False): - rules: Iterable[Rule] - """List of snippet rules""" - - -class Rule(TypedDict, total=False): - description: str - - enabled: bool - - expression: str - - snippet_name: str - """Snippet identifying name""" diff --git a/src/cloudflare/types/snippets/rule_update_response.py b/src/cloudflare/types/snippets/rule_update_response.py deleted file mode 100644 index 2abc8f16900..00000000000 --- a/src/cloudflare/types/snippets/rule_update_response.py +++ /dev/null @@ -1,21 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Optional - -from ..._models import BaseModel - -__all__ = ["RuleUpdateResponse", "RuleUpdateResponseItem"] - - -class RuleUpdateResponseItem(BaseModel): - description: Optional[str] = None - - enabled: Optional[bool] = None - - expression: Optional[str] = None - - snippet_name: Optional[str] = None - """Snippet identifying name""" - - -RuleUpdateResponse = List[RuleUpdateResponseItem] diff --git a/src/cloudflare/types/snippets/snippet.py b/src/cloudflare/types/snippets/snippet.py deleted file mode 100644 index 69dc660896e..00000000000 --- a/src/cloudflare/types/snippets/snippet.py +++ /dev/null @@ -1,18 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional - -from ..._models import BaseModel - -__all__ = ["Snippet"] - - -class Snippet(BaseModel): - created_on: Optional[str] = None - """Creation time of the snippet""" - - modified_on: Optional[str] = None - """Modification time of the snippet""" - - snippet_name: Optional[str] = None - """Snippet identifying name""" diff --git a/src/cloudflare/types/snippets/snippet_delete_response.py b/src/cloudflare/types/snippets/snippet_delete_response.py deleted file mode 100644 index 4d10682f00e..00000000000 --- a/src/cloudflare/types/snippets/snippet_delete_response.py +++ /dev/null @@ -1,7 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Union - -__all__ = ["SnippetDeleteResponse"] - -SnippetDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/snippets/snippet_update_params.py b/src/cloudflare/types/snippets/snippet_update_params.py deleted file mode 100644 index 4633aeb6967..00000000000 --- a/src/cloudflare/types/snippets/snippet_update_params.py +++ /dev/null @@ -1,22 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Required, TypedDict - -__all__ = ["SnippetUpdateParams", "Metadata"] - - -class SnippetUpdateParams(TypedDict, total=False): - zone_identifier: Required[str] - """Identifier""" - - files: str - """Content files of uploaded snippet""" - - metadata: Metadata - - -class Metadata(TypedDict, total=False): - main_module: str - """Main module name of uploaded snippet""" diff --git a/tests/api_resources/snippets/__init__.py b/tests/api_resources/snippets/__init__.py deleted file mode 100644 index fd8019a9a1a..00000000000 --- a/tests/api_resources/snippets/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/snippets/test_content.py b/tests/api_resources/snippets/test_content.py deleted file mode 100644 index cbb90cef7ff..00000000000 --- a/tests/api_resources/snippets/test_content.py +++ /dev/null @@ -1,168 +0,0 @@ -# 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 httpx -import pytest -from respx import MockRouter - -from cloudflare import Cloudflare, AsyncCloudflare -from cloudflare._response import ( - BinaryAPIResponse, - AsyncBinaryAPIResponse, - StreamedBinaryAPIResponse, - AsyncStreamedBinaryAPIResponse, -) - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestContent: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip() - @parametrize - @pytest.mark.respx(base_url=base_url) - def test_method_get(self, client: Cloudflare, respx_mock: MockRouter) -> None: - respx_mock.get("/zones/023e105f4ecef8ad9ca31a8372d0c353/snippets/snippet_name_01/content").mock( - return_value=httpx.Response(200, json={"foo": "bar"}) - ) - content = client.snippets.content.get( - "snippet_name_01", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert content.is_closed - assert content.json() == {"foo": "bar"} - assert cast(Any, content.is_closed) is True - assert isinstance(content, BinaryAPIResponse) - - @pytest.mark.skip() - @parametrize - @pytest.mark.respx(base_url=base_url) - def test_raw_response_get(self, client: Cloudflare, respx_mock: MockRouter) -> None: - respx_mock.get("/zones/023e105f4ecef8ad9ca31a8372d0c353/snippets/snippet_name_01/content").mock( - return_value=httpx.Response(200, json={"foo": "bar"}) - ) - - content = client.snippets.content.with_raw_response.get( - "snippet_name_01", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert content.is_closed is True - assert content.http_request.headers.get("X-Stainless-Lang") == "python" - assert content.json() == {"foo": "bar"} - assert isinstance(content, BinaryAPIResponse) - - @pytest.mark.skip() - @parametrize - @pytest.mark.respx(base_url=base_url) - def test_streaming_response_get(self, client: Cloudflare, respx_mock: MockRouter) -> None: - respx_mock.get("/zones/023e105f4ecef8ad9ca31a8372d0c353/snippets/snippet_name_01/content").mock( - return_value=httpx.Response(200, json={"foo": "bar"}) - ) - with client.snippets.content.with_streaming_response.get( - "snippet_name_01", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as content: - assert not content.is_closed - assert content.http_request.headers.get("X-Stainless-Lang") == "python" - - assert content.json() == {"foo": "bar"} - assert cast(Any, content.is_closed) is True - assert isinstance(content, StreamedBinaryAPIResponse) - - assert cast(Any, content.is_closed) is True - - @pytest.mark.skip() - @parametrize - @pytest.mark.respx(base_url=base_url) - def test_path_params_get(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - client.snippets.content.with_raw_response.get( - "snippet_name_01", - zone_identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `snippet_name` but received ''"): - client.snippets.content.with_raw_response.get( - "", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - -class TestAsyncContent: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip() - @parametrize - @pytest.mark.respx(base_url=base_url) - async def test_method_get(self, async_client: AsyncCloudflare, respx_mock: MockRouter) -> None: - respx_mock.get("/zones/023e105f4ecef8ad9ca31a8372d0c353/snippets/snippet_name_01/content").mock( - return_value=httpx.Response(200, json={"foo": "bar"}) - ) - content = await async_client.snippets.content.get( - "snippet_name_01", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert content.is_closed - assert await content.json() == {"foo": "bar"} - assert cast(Any, content.is_closed) is True - assert isinstance(content, AsyncBinaryAPIResponse) - - @pytest.mark.skip() - @parametrize - @pytest.mark.respx(base_url=base_url) - async def test_raw_response_get(self, async_client: AsyncCloudflare, respx_mock: MockRouter) -> None: - respx_mock.get("/zones/023e105f4ecef8ad9ca31a8372d0c353/snippets/snippet_name_01/content").mock( - return_value=httpx.Response(200, json={"foo": "bar"}) - ) - - content = await async_client.snippets.content.with_raw_response.get( - "snippet_name_01", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert content.is_closed is True - assert content.http_request.headers.get("X-Stainless-Lang") == "python" - assert await content.json() == {"foo": "bar"} - assert isinstance(content, AsyncBinaryAPIResponse) - - @pytest.mark.skip() - @parametrize - @pytest.mark.respx(base_url=base_url) - async def test_streaming_response_get(self, async_client: AsyncCloudflare, respx_mock: MockRouter) -> None: - respx_mock.get("/zones/023e105f4ecef8ad9ca31a8372d0c353/snippets/snippet_name_01/content").mock( - return_value=httpx.Response(200, json={"foo": "bar"}) - ) - async with async_client.snippets.content.with_streaming_response.get( - "snippet_name_01", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as content: - assert not content.is_closed - assert content.http_request.headers.get("X-Stainless-Lang") == "python" - - assert await content.json() == {"foo": "bar"} - assert cast(Any, content.is_closed) is True - assert isinstance(content, AsyncStreamedBinaryAPIResponse) - - assert cast(Any, content.is_closed) is True - - @pytest.mark.skip() - @parametrize - @pytest.mark.respx(base_url=base_url) - async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - await async_client.snippets.content.with_raw_response.get( - "snippet_name_01", - zone_identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `snippet_name` but received ''"): - await async_client.snippets.content.with_raw_response.get( - "", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) diff --git a/tests/api_resources/snippets/test_rules.py b/tests/api_resources/snippets/test_rules.py deleted file mode 100644 index 83e10168142..00000000000 --- a/tests/api_resources/snippets/test_rules.py +++ /dev/null @@ -1,247 +0,0 @@ -# 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.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.snippets import RuleListResponse, RuleUpdateResponse - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestRules: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip() - @parametrize - def test_method_update(self, client: Cloudflare) -> None: - rule = client.snippets.rules.update( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(RuleUpdateResponse, rule, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_method_update_with_all_params(self, client: Cloudflare) -> None: - rule = client.snippets.rules.update( - "023e105f4ecef8ad9ca31a8372d0c353", - rules=[ - { - "description": "Rule description", - "enabled": True, - "expression": 'http.cookie eq "a=b"', - "snippet_name": "snippet_name_01", - }, - { - "description": "Rule description", - "enabled": True, - "expression": 'http.cookie eq "a=b"', - "snippet_name": "snippet_name_01", - }, - { - "description": "Rule description", - "enabled": True, - "expression": 'http.cookie eq "a=b"', - "snippet_name": "snippet_name_01", - }, - ], - ) - assert_matches_type(RuleUpdateResponse, rule, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_raw_response_update(self, client: Cloudflare) -> None: - response = client.snippets.rules.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() - assert_matches_type(RuleUpdateResponse, rule, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_streaming_response_update(self, client: Cloudflare) -> None: - with client.snippets.rules.with_streaming_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = response.parse() - assert_matches_type(RuleUpdateResponse, rule, 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 `zone_identifier` but received ''"): - client.snippets.rules.with_raw_response.update( - "", - ) - - @pytest.mark.skip() - @parametrize - def test_method_list(self, client: Cloudflare) -> None: - rule = client.snippets.rules.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(SyncSinglePage[RuleListResponse], rule, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.snippets.rules.with_raw_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() - assert_matches_type(SyncSinglePage[RuleListResponse], rule, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.snippets.rules.with_streaming_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = response.parse() - assert_matches_type(SyncSinglePage[RuleListResponse], rule, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip() - @parametrize - def test_path_params_list(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - client.snippets.rules.with_raw_response.list( - "", - ) - - -class TestAsyncRules: - 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: - rule = await async_client.snippets.rules.update( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(RuleUpdateResponse, rule, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.snippets.rules.update( - "023e105f4ecef8ad9ca31a8372d0c353", - rules=[ - { - "description": "Rule description", - "enabled": True, - "expression": 'http.cookie eq "a=b"', - "snippet_name": "snippet_name_01", - }, - { - "description": "Rule description", - "enabled": True, - "expression": 'http.cookie eq "a=b"', - "snippet_name": "snippet_name_01", - }, - { - "description": "Rule description", - "enabled": True, - "expression": 'http.cookie eq "a=b"', - "snippet_name": "snippet_name_01", - }, - ], - ) - assert_matches_type(RuleUpdateResponse, rule, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: - response = await async_client.snippets.rules.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = await response.parse() - assert_matches_type(RuleUpdateResponse, rule, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: - async with async_client.snippets.rules.with_streaming_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = await response.parse() - assert_matches_type(RuleUpdateResponse, rule, 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 `zone_identifier` but received ''"): - await async_client.snippets.rules.with_raw_response.update( - "", - ) - - @pytest.mark.skip() - @parametrize - async def test_method_list(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.snippets.rules.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(AsyncSinglePage[RuleListResponse], rule, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.snippets.rules.with_raw_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = await response.parse() - assert_matches_type(AsyncSinglePage[RuleListResponse], rule, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.snippets.rules.with_streaming_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = await response.parse() - assert_matches_type(AsyncSinglePage[RuleListResponse], rule, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip() - @parametrize - async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - await async_client.snippets.rules.with_raw_response.list( - "", - ) diff --git a/tests/api_resources/test_snippets.py b/tests/api_resources/test_snippets.py deleted file mode 100644 index c50daf3c503..00000000000 --- a/tests/api_resources/test_snippets.py +++ /dev/null @@ -1,441 +0,0 @@ -# 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.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.snippets import Snippet, SnippetDeleteResponse - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestSnippets: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip() - @parametrize - def test_method_update(self, client: Cloudflare) -> None: - snippet = client.snippets.update( - "snippet_name_01", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Snippet, snippet, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_method_update_with_all_params(self, client: Cloudflare) -> None: - snippet = client.snippets.update( - "snippet_name_01", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - files="export { async function fetch(request, env) {return new Response('some_response') } }", - metadata={"main_module": "main.js"}, - ) - assert_matches_type(Snippet, snippet, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_raw_response_update(self, client: Cloudflare) -> None: - response = client.snippets.with_raw_response.update( - "snippet_name_01", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - snippet = response.parse() - assert_matches_type(Snippet, snippet, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_streaming_response_update(self, client: Cloudflare) -> None: - with client.snippets.with_streaming_response.update( - "snippet_name_01", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - snippet = response.parse() - assert_matches_type(Snippet, snippet, 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 `zone_identifier` but received ''"): - client.snippets.with_raw_response.update( - "snippet_name_01", - zone_identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `snippet_name` but received ''"): - client.snippets.with_raw_response.update( - "", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @pytest.mark.skip() - @parametrize - def test_method_list(self, client: Cloudflare) -> None: - snippet = client.snippets.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(SyncSinglePage[Snippet], snippet, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.snippets.with_raw_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - snippet = response.parse() - assert_matches_type(SyncSinglePage[Snippet], snippet, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.snippets.with_streaming_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - snippet = response.parse() - assert_matches_type(SyncSinglePage[Snippet], snippet, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip() - @parametrize - def test_path_params_list(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - client.snippets.with_raw_response.list( - "", - ) - - @pytest.mark.skip() - @parametrize - def test_method_delete(self, client: Cloudflare) -> None: - snippet = client.snippets.delete( - "snippet_name_01", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(SnippetDeleteResponse, snippet, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_raw_response_delete(self, client: Cloudflare) -> None: - response = client.snippets.with_raw_response.delete( - "snippet_name_01", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - snippet = response.parse() - assert_matches_type(SnippetDeleteResponse, snippet, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_streaming_response_delete(self, client: Cloudflare) -> None: - with client.snippets.with_streaming_response.delete( - "snippet_name_01", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - snippet = response.parse() - assert_matches_type(SnippetDeleteResponse, snippet, 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 `zone_identifier` but received ''"): - client.snippets.with_raw_response.delete( - "snippet_name_01", - zone_identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `snippet_name` but received ''"): - client.snippets.with_raw_response.delete( - "", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @pytest.mark.skip() - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - snippet = client.snippets.get( - "snippet_name_01", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Snippet, snippet, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.snippets.with_raw_response.get( - "snippet_name_01", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - snippet = response.parse() - assert_matches_type(Snippet, snippet, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.snippets.with_streaming_response.get( - "snippet_name_01", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - snippet = response.parse() - assert_matches_type(Snippet, snippet, 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 `zone_identifier` but received ''"): - client.snippets.with_raw_response.get( - "snippet_name_01", - zone_identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `snippet_name` but received ''"): - client.snippets.with_raw_response.get( - "", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - -class TestAsyncSnippets: - 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: - snippet = await async_client.snippets.update( - "snippet_name_01", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Snippet, snippet, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: - snippet = await async_client.snippets.update( - "snippet_name_01", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - files="export { async function fetch(request, env) {return new Response('some_response') } }", - metadata={"main_module": "main.js"}, - ) - assert_matches_type(Snippet, snippet, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: - response = await async_client.snippets.with_raw_response.update( - "snippet_name_01", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - snippet = await response.parse() - assert_matches_type(Snippet, snippet, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: - async with async_client.snippets.with_streaming_response.update( - "snippet_name_01", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - snippet = await response.parse() - assert_matches_type(Snippet, snippet, 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 `zone_identifier` but received ''"): - await async_client.snippets.with_raw_response.update( - "snippet_name_01", - zone_identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `snippet_name` but received ''"): - await async_client.snippets.with_raw_response.update( - "", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @pytest.mark.skip() - @parametrize - async def test_method_list(self, async_client: AsyncCloudflare) -> None: - snippet = await async_client.snippets.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(AsyncSinglePage[Snippet], snippet, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.snippets.with_raw_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - snippet = await response.parse() - assert_matches_type(AsyncSinglePage[Snippet], snippet, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.snippets.with_streaming_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - snippet = await response.parse() - assert_matches_type(AsyncSinglePage[Snippet], snippet, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip() - @parametrize - async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - await async_client.snippets.with_raw_response.list( - "", - ) - - @pytest.mark.skip() - @parametrize - async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - snippet = await async_client.snippets.delete( - "snippet_name_01", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(SnippetDeleteResponse, snippet, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - response = await async_client.snippets.with_raw_response.delete( - "snippet_name_01", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - snippet = await response.parse() - assert_matches_type(SnippetDeleteResponse, snippet, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - async with async_client.snippets.with_streaming_response.delete( - "snippet_name_01", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - snippet = await response.parse() - assert_matches_type(SnippetDeleteResponse, snippet, 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 `zone_identifier` but received ''"): - await async_client.snippets.with_raw_response.delete( - "snippet_name_01", - zone_identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `snippet_name` but received ''"): - await async_client.snippets.with_raw_response.delete( - "", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @pytest.mark.skip() - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - snippet = await async_client.snippets.get( - "snippet_name_01", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Snippet, snippet, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.snippets.with_raw_response.get( - "snippet_name_01", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - snippet = await response.parse() - assert_matches_type(Snippet, snippet, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - async with async_client.snippets.with_streaming_response.get( - "snippet_name_01", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - snippet = await response.parse() - assert_matches_type(Snippet, snippet, 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 `zone_identifier` but received ''"): - await async_client.snippets.with_raw_response.get( - "snippet_name_01", - zone_identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `snippet_name` but received ''"): - await async_client.snippets.with_raw_response.get( - "", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - )