From 9312532ca4dd380c1376e54ac184e3c25f968288 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Thu, 2 May 2024 05:18:34 +0000
Subject: [PATCH] feat(api): update via SDK Studio (#417)
---
api.md | 41 +-
src/cloudflare/resources/speed/__init__.py | 14 -
src/cloudflare/resources/speed/pages.py | 151 -----
.../resources/speed/pages/__init__.py | 33 +
src/cloudflare/resources/speed/pages/pages.py | 388 ++++++++++++
.../resources/speed/{ => pages}/tests.py | 22 +-
src/cloudflare/resources/speed/schedule.py | 312 +++++++++-
src/cloudflare/resources/speed/speed.py | 564 +-----------------
src/cloudflare/types/speed/__init__.py | 14 +-
.../types/speed/page_list_response.py | 2 +-
...ds_list_params.py => page_trend_params.py} | 4 +-
src/cloudflare/types/speed/pages/__init__.py | 10 +
.../types/speed/{ => pages}/test.py | 6 +-
.../speed/{ => pages}/test_create_params.py | 0
.../speed/{ => pages}/test_delete_params.py | 0
.../speed/{ => pages}/test_delete_response.py | 2 +-
.../speed/{ => pages}/test_list_params.py | 0
.../speed/{ => pages}/test_list_response.py | 4 +-
.../types/speed/schedule_create_response.py | 2 +-
...et_params.py => schedule_delete_params.py} | 4 +-
...esponse.py => schedule_delete_response.py} | 4 +-
...elete_params.py => schedule_get_params.py} | 4 +-
tests/api_resources/speed/pages/__init__.py | 1 +
.../speed/{ => pages}/test_tests.py | 98 +--
tests/api_resources/speed/test_pages.py | 189 +++++-
tests/api_resources/speed/test_schedule.py | 234 +++++++-
tests/api_resources/test_speed.py | 439 --------------
27 files changed, 1263 insertions(+), 1279 deletions(-)
delete mode 100644 src/cloudflare/resources/speed/pages.py
create mode 100644 src/cloudflare/resources/speed/pages/__init__.py
create mode 100644 src/cloudflare/resources/speed/pages/pages.py
rename src/cloudflare/resources/speed/{ => pages}/tests.py (97%)
rename src/cloudflare/types/speed/{speed_trends_list_params.py => page_trend_params.py} (94%)
create mode 100644 src/cloudflare/types/speed/pages/__init__.py
rename src/cloudflare/types/speed/{ => pages}/test.py (87%)
rename src/cloudflare/types/speed/{ => pages}/test_create_params.py (100%)
rename src/cloudflare/types/speed/{ => pages}/test_delete_params.py (100%)
rename src/cloudflare/types/speed/{ => pages}/test_delete_response.py (89%)
rename src/cloudflare/types/speed/{ => pages}/test_list_params.py (100%)
rename src/cloudflare/types/speed/{ => pages}/test_list_response.py (87%)
rename src/cloudflare/types/speed/{speed_schedule_get_params.py => schedule_delete_params.py} (89%)
rename src/cloudflare/types/speed/{speed_delete_response.py => schedule_delete_response.py} (74%)
rename src/cloudflare/types/speed/{speed_delete_params.py => schedule_get_params.py} (90%)
create mode 100644 tests/api_resources/speed/pages/__init__.py
rename tests/api_resources/speed/{ => pages}/test_tests.py (83%)
delete mode 100644 tests/api_resources/test_speed.py
diff --git a/api.md b/api.md
index cab0bc68d50..f2698a5ade0 100644
--- a/api.md
+++ b/api.md
@@ -7176,65 +7176,62 @@ Methods:
Types:
```python
-from cloudflare.types.speed import LabeledRegion, LighthouseReport, Trend, SpeedDeleteResponse
+from cloudflare.types.speed import LabeledRegion, LighthouseReport, Trend
```
-Methods:
-
-- client.speed.delete(url, \*, zone_id, \*\*params) -> Optional
-- client.speed.schedule_get(url, \*, zone_id, \*\*params) -> Optional
-- client.speed.trends_list(url, \*, zone_id, \*\*params) -> Optional
-
-## Tests
+## Schedule
Types:
```python
-from cloudflare.types.speed import Test, TestListResponse, TestDeleteResponse
+from cloudflare.types.speed import Schedule, ScheduleCreateResponse, ScheduleDeleteResponse
```
Methods:
-- client.speed.tests.create(url, \*, zone_id, \*\*params) -> Optional
-- client.speed.tests.list(url, \*, zone_id, \*\*params) -> TestListResponse
-- client.speed.tests.delete(url, \*, zone_id, \*\*params) -> Optional
-- client.speed.tests.get(test_id, \*, zone_id, url) -> Optional
+- client.speed.schedule.create(url, \*, zone_id, \*\*params) -> Optional
+- client.speed.schedule.delete(url, \*, zone_id, \*\*params) -> Optional
+- client.speed.schedule.get(url, \*, zone_id, \*\*params) -> Optional
-## Schedule
+## Availabilities
Types:
```python
-from cloudflare.types.speed import Schedule, ScheduleCreateResponse
+from cloudflare.types.speed import Availability
```
Methods:
-- client.speed.schedule.create(url, \*, zone_id, \*\*params) -> Optional
+- client.speed.availabilities.list(\*, zone_id) -> Optional
-## Availabilities
+## Pages
Types:
```python
-from cloudflare.types.speed import Availability
+from cloudflare.types.speed import PageListResponse
```
Methods:
-- client.speed.availabilities.list(\*, zone_id) -> Optional
+- client.speed.pages.list(\*, zone_id) -> SyncSinglePage[PageListResponse]
+- client.speed.pages.trend(url, \*, zone_id, \*\*params) -> Optional
-## Pages
+### Tests
Types:
```python
-from cloudflare.types.speed import PageListResponse
+from cloudflare.types.speed.pages import Test, TestListResponse, TestDeleteResponse
```
Methods:
-- client.speed.pages.list(\*, zone_id) -> SyncSinglePage[PageListResponse]
+- client.speed.pages.tests.create(url, \*, zone_id, \*\*params) -> Optional
+- client.speed.pages.tests.list(url, \*, zone_id, \*\*params) -> TestListResponse
+- client.speed.pages.tests.delete(url, \*, zone_id, \*\*params) -> Optional
+- client.speed.pages.tests.get(test_id, \*, zone_id, url) -> Optional
# DCVDelegation
diff --git a/src/cloudflare/resources/speed/__init__.py b/src/cloudflare/resources/speed/__init__.py
index c94c9837fa9..2c45eaaa70e 100644
--- a/src/cloudflare/resources/speed/__init__.py
+++ b/src/cloudflare/resources/speed/__init__.py
@@ -16,14 +16,6 @@
SpeedResourceWithStreamingResponse,
AsyncSpeedResourceWithStreamingResponse,
)
-from .tests import (
- TestsResource,
- AsyncTestsResource,
- TestsResourceWithRawResponse,
- AsyncTestsResourceWithRawResponse,
- TestsResourceWithStreamingResponse,
- AsyncTestsResourceWithStreamingResponse,
-)
from .schedule import (
ScheduleResource,
AsyncScheduleResource,
@@ -42,12 +34,6 @@
)
__all__ = [
- "TestsResource",
- "AsyncTestsResource",
- "TestsResourceWithRawResponse",
- "AsyncTestsResourceWithRawResponse",
- "TestsResourceWithStreamingResponse",
- "AsyncTestsResourceWithStreamingResponse",
"ScheduleResource",
"AsyncScheduleResource",
"ScheduleResourceWithRawResponse",
diff --git a/src/cloudflare/resources/speed/pages.py b/src/cloudflare/resources/speed/pages.py
deleted file mode 100644
index b75c1c6d06b..00000000000
--- a/src/cloudflare/resources/speed/pages.py
+++ /dev/null
@@ -1,151 +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 (
- to_raw_response_wrapper,
- to_streamed_response_wrapper,
- async_to_raw_response_wrapper,
- async_to_streamed_response_wrapper,
-)
-from ...pagination import SyncSinglePage, AsyncSinglePage
-from ..._base_client import (
- AsyncPaginator,
- make_request_options,
-)
-from ...types.speed.page_list_response import PageListResponse
-
-__all__ = ["PagesResource", "AsyncPagesResource"]
-
-
-class PagesResource(SyncAPIResource):
- @cached_property
- def with_raw_response(self) -> PagesResourceWithRawResponse:
- return PagesResourceWithRawResponse(self)
-
- @cached_property
- def with_streaming_response(self) -> PagesResourceWithStreamingResponse:
- return PagesResourceWithStreamingResponse(self)
-
- def list(
- self,
- *,
- zone_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,
- ) -> SyncSinglePage[PageListResponse]:
- """
- Lists all webpages which have been tested.
-
- Args:
- zone_id: Identifier
-
- extra_headers: Send extra headers
-
- extra_query: Add additional query parameters to the request
-
- extra_body: Add additional JSON properties to the request
-
- timeout: Override the client-level default timeout for this request, in seconds
- """
- if not zone_id:
- raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
- return self._get_api_list(
- f"/zones/{zone_id}/speed_api/pages",
- page=SyncSinglePage[PageListResponse],
- options=make_request_options(
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
- ),
- model=PageListResponse,
- )
-
-
-class AsyncPagesResource(AsyncAPIResource):
- @cached_property
- def with_raw_response(self) -> AsyncPagesResourceWithRawResponse:
- return AsyncPagesResourceWithRawResponse(self)
-
- @cached_property
- def with_streaming_response(self) -> AsyncPagesResourceWithStreamingResponse:
- return AsyncPagesResourceWithStreamingResponse(self)
-
- def list(
- self,
- *,
- zone_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,
- ) -> AsyncPaginator[PageListResponse, AsyncSinglePage[PageListResponse]]:
- """
- Lists all webpages which have been tested.
-
- Args:
- zone_id: Identifier
-
- extra_headers: Send extra headers
-
- extra_query: Add additional query parameters to the request
-
- extra_body: Add additional JSON properties to the request
-
- timeout: Override the client-level default timeout for this request, in seconds
- """
- if not zone_id:
- raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
- return self._get_api_list(
- f"/zones/{zone_id}/speed_api/pages",
- page=AsyncSinglePage[PageListResponse],
- options=make_request_options(
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
- ),
- model=PageListResponse,
- )
-
-
-class PagesResourceWithRawResponse:
- def __init__(self, pages: PagesResource) -> None:
- self._pages = pages
-
- self.list = to_raw_response_wrapper(
- pages.list,
- )
-
-
-class AsyncPagesResourceWithRawResponse:
- def __init__(self, pages: AsyncPagesResource) -> None:
- self._pages = pages
-
- self.list = async_to_raw_response_wrapper(
- pages.list,
- )
-
-
-class PagesResourceWithStreamingResponse:
- def __init__(self, pages: PagesResource) -> None:
- self._pages = pages
-
- self.list = to_streamed_response_wrapper(
- pages.list,
- )
-
-
-class AsyncPagesResourceWithStreamingResponse:
- def __init__(self, pages: AsyncPagesResource) -> None:
- self._pages = pages
-
- self.list = async_to_streamed_response_wrapper(
- pages.list,
- )
diff --git a/src/cloudflare/resources/speed/pages/__init__.py b/src/cloudflare/resources/speed/pages/__init__.py
new file mode 100644
index 00000000000..4c4bb43a6b6
--- /dev/null
+++ b/src/cloudflare/resources/speed/pages/__init__.py
@@ -0,0 +1,33 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from .pages import (
+ PagesResource,
+ AsyncPagesResource,
+ PagesResourceWithRawResponse,
+ AsyncPagesResourceWithRawResponse,
+ PagesResourceWithStreamingResponse,
+ AsyncPagesResourceWithStreamingResponse,
+)
+from .tests import (
+ TestsResource,
+ AsyncTestsResource,
+ TestsResourceWithRawResponse,
+ AsyncTestsResourceWithRawResponse,
+ TestsResourceWithStreamingResponse,
+ AsyncTestsResourceWithStreamingResponse,
+)
+
+__all__ = [
+ "TestsResource",
+ "AsyncTestsResource",
+ "TestsResourceWithRawResponse",
+ "AsyncTestsResourceWithRawResponse",
+ "TestsResourceWithStreamingResponse",
+ "AsyncTestsResourceWithStreamingResponse",
+ "PagesResource",
+ "AsyncPagesResource",
+ "PagesResourceWithRawResponse",
+ "AsyncPagesResourceWithRawResponse",
+ "PagesResourceWithStreamingResponse",
+ "AsyncPagesResourceWithStreamingResponse",
+]
diff --git a/src/cloudflare/resources/speed/pages/pages.py b/src/cloudflare/resources/speed/pages/pages.py
new file mode 100644
index 00000000000..7eab8c6dcf9
--- /dev/null
+++ b/src/cloudflare/resources/speed/pages/pages.py
@@ -0,0 +1,388 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing import Type, Union, Optional, cast
+from datetime import datetime
+from typing_extensions import Literal
+
+import httpx
+
+from .tests import (
+ TestsResource,
+ AsyncTestsResource,
+ TestsResourceWithRawResponse,
+ AsyncTestsResourceWithRawResponse,
+ TestsResourceWithStreamingResponse,
+ AsyncTestsResourceWithStreamingResponse,
+)
+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 ....types.speed import page_trend_params
+from ...._base_client import (
+ AsyncPaginator,
+ make_request_options,
+)
+from ....types.speed.trend import Trend
+from ....types.speed.page_list_response import PageListResponse
+
+__all__ = ["PagesResource", "AsyncPagesResource"]
+
+
+class PagesResource(SyncAPIResource):
+ @cached_property
+ def tests(self) -> TestsResource:
+ return TestsResource(self._client)
+
+ @cached_property
+ def with_raw_response(self) -> PagesResourceWithRawResponse:
+ return PagesResourceWithRawResponse(self)
+
+ @cached_property
+ def with_streaming_response(self) -> PagesResourceWithStreamingResponse:
+ return PagesResourceWithStreamingResponse(self)
+
+ def list(
+ self,
+ *,
+ zone_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,
+ ) -> SyncSinglePage[PageListResponse]:
+ """
+ Lists all webpages which have been tested.
+
+ Args:
+ zone_id: Identifier
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not zone_id:
+ raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
+ return self._get_api_list(
+ f"/zones/{zone_id}/speed_api/pages",
+ page=SyncSinglePage[PageListResponse],
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ model=PageListResponse,
+ )
+
+ def trend(
+ self,
+ url: str,
+ *,
+ zone_id: str,
+ device_type: Literal["DESKTOP", "MOBILE"],
+ metrics: str,
+ region: Literal[
+ "asia-east1",
+ "asia-northeast1",
+ "asia-northeast2",
+ "asia-south1",
+ "asia-southeast1",
+ "australia-southeast1",
+ "europe-north1",
+ "europe-southwest1",
+ "europe-west1",
+ "europe-west2",
+ "europe-west3",
+ "europe-west4",
+ "europe-west8",
+ "europe-west9",
+ "me-west1",
+ "southamerica-east1",
+ "us-central1",
+ "us-east1",
+ "us-east4",
+ "us-south1",
+ "us-west1",
+ ],
+ start: Union[str, datetime],
+ tz: str,
+ end: Union[str, datetime] | 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[Trend]:
+ """
+ Lists the core web vital metrics trend over time for a specific page.
+
+ Args:
+ zone_id: Identifier
+
+ url: A URL.
+
+ device_type: The type of device.
+
+ metrics: A comma-separated list of metrics to include in the results.
+
+ region: A test region.
+
+ tz: The timezone of the start and end timestamps.
+
+ 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_id:
+ raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
+ if not url:
+ raise ValueError(f"Expected a non-empty value for `url` but received {url!r}")
+ return self._get(
+ f"/zones/{zone_id}/speed_api/pages/{url}/trend",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=maybe_transform(
+ {
+ "device_type": device_type,
+ "metrics": metrics,
+ "region": region,
+ "start": start,
+ "tz": tz,
+ "end": end,
+ },
+ page_trend_params.PageTrendParams,
+ ),
+ post_parser=ResultWrapper[Optional[Trend]]._unwrapper,
+ ),
+ cast_to=cast(Type[Optional[Trend]], ResultWrapper[Trend]),
+ )
+
+
+class AsyncPagesResource(AsyncAPIResource):
+ @cached_property
+ def tests(self) -> AsyncTestsResource:
+ return AsyncTestsResource(self._client)
+
+ @cached_property
+ def with_raw_response(self) -> AsyncPagesResourceWithRawResponse:
+ return AsyncPagesResourceWithRawResponse(self)
+
+ @cached_property
+ def with_streaming_response(self) -> AsyncPagesResourceWithStreamingResponse:
+ return AsyncPagesResourceWithStreamingResponse(self)
+
+ def list(
+ self,
+ *,
+ zone_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,
+ ) -> AsyncPaginator[PageListResponse, AsyncSinglePage[PageListResponse]]:
+ """
+ Lists all webpages which have been tested.
+
+ Args:
+ zone_id: Identifier
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not zone_id:
+ raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
+ return self._get_api_list(
+ f"/zones/{zone_id}/speed_api/pages",
+ page=AsyncSinglePage[PageListResponse],
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ model=PageListResponse,
+ )
+
+ async def trend(
+ self,
+ url: str,
+ *,
+ zone_id: str,
+ device_type: Literal["DESKTOP", "MOBILE"],
+ metrics: str,
+ region: Literal[
+ "asia-east1",
+ "asia-northeast1",
+ "asia-northeast2",
+ "asia-south1",
+ "asia-southeast1",
+ "australia-southeast1",
+ "europe-north1",
+ "europe-southwest1",
+ "europe-west1",
+ "europe-west2",
+ "europe-west3",
+ "europe-west4",
+ "europe-west8",
+ "europe-west9",
+ "me-west1",
+ "southamerica-east1",
+ "us-central1",
+ "us-east1",
+ "us-east4",
+ "us-south1",
+ "us-west1",
+ ],
+ start: Union[str, datetime],
+ tz: str,
+ end: Union[str, datetime] | 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[Trend]:
+ """
+ Lists the core web vital metrics trend over time for a specific page.
+
+ Args:
+ zone_id: Identifier
+
+ url: A URL.
+
+ device_type: The type of device.
+
+ metrics: A comma-separated list of metrics to include in the results.
+
+ region: A test region.
+
+ tz: The timezone of the start and end timestamps.
+
+ 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_id:
+ raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
+ if not url:
+ raise ValueError(f"Expected a non-empty value for `url` but received {url!r}")
+ return await self._get(
+ f"/zones/{zone_id}/speed_api/pages/{url}/trend",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=await async_maybe_transform(
+ {
+ "device_type": device_type,
+ "metrics": metrics,
+ "region": region,
+ "start": start,
+ "tz": tz,
+ "end": end,
+ },
+ page_trend_params.PageTrendParams,
+ ),
+ post_parser=ResultWrapper[Optional[Trend]]._unwrapper,
+ ),
+ cast_to=cast(Type[Optional[Trend]], ResultWrapper[Trend]),
+ )
+
+
+class PagesResourceWithRawResponse:
+ def __init__(self, pages: PagesResource) -> None:
+ self._pages = pages
+
+ self.list = to_raw_response_wrapper(
+ pages.list,
+ )
+ self.trend = to_raw_response_wrapper(
+ pages.trend,
+ )
+
+ @cached_property
+ def tests(self) -> TestsResourceWithRawResponse:
+ return TestsResourceWithRawResponse(self._pages.tests)
+
+
+class AsyncPagesResourceWithRawResponse:
+ def __init__(self, pages: AsyncPagesResource) -> None:
+ self._pages = pages
+
+ self.list = async_to_raw_response_wrapper(
+ pages.list,
+ )
+ self.trend = async_to_raw_response_wrapper(
+ pages.trend,
+ )
+
+ @cached_property
+ def tests(self) -> AsyncTestsResourceWithRawResponse:
+ return AsyncTestsResourceWithRawResponse(self._pages.tests)
+
+
+class PagesResourceWithStreamingResponse:
+ def __init__(self, pages: PagesResource) -> None:
+ self._pages = pages
+
+ self.list = to_streamed_response_wrapper(
+ pages.list,
+ )
+ self.trend = to_streamed_response_wrapper(
+ pages.trend,
+ )
+
+ @cached_property
+ def tests(self) -> TestsResourceWithStreamingResponse:
+ return TestsResourceWithStreamingResponse(self._pages.tests)
+
+
+class AsyncPagesResourceWithStreamingResponse:
+ def __init__(self, pages: AsyncPagesResource) -> None:
+ self._pages = pages
+
+ self.list = async_to_streamed_response_wrapper(
+ pages.list,
+ )
+ self.trend = async_to_streamed_response_wrapper(
+ pages.trend,
+ )
+
+ @cached_property
+ def tests(self) -> AsyncTestsResourceWithStreamingResponse:
+ return AsyncTestsResourceWithStreamingResponse(self._pages.tests)
diff --git a/src/cloudflare/resources/speed/tests.py b/src/cloudflare/resources/speed/pages/tests.py
similarity index 97%
rename from src/cloudflare/resources/speed/tests.py
rename to src/cloudflare/resources/speed/pages/tests.py
index 02a984f30a8..20a1a66f7af 100644
--- a/src/cloudflare/resources/speed/tests.py
+++ b/src/cloudflare/resources/speed/pages/tests.py
@@ -7,27 +7,27 @@
import httpx
-from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
-from ..._utils import (
+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 (
+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 ...types.speed import test_list_params, test_create_params, test_delete_params
-from ..._base_client import (
+from ...._wrappers import ResultWrapper
+from ...._base_client import (
make_request_options,
)
-from ...types.speed.test import Test
-from ...types.speed.test_list_response import TestListResponse
-from ...types.speed.test_delete_response import TestDeleteResponse
+from ....types.speed.pages import test_list_params, test_create_params, test_delete_params
+from ....types.speed.pages.test import Test
+from ....types.speed.pages.test_list_response import TestListResponse
+from ....types.speed.pages.test_delete_response import TestDeleteResponse
__all__ = ["TestsResource", "AsyncTestsResource"]
diff --git a/src/cloudflare/resources/speed/schedule.py b/src/cloudflare/resources/speed/schedule.py
index 44ab5e60ffc..1bc4cdf214a 100644
--- a/src/cloudflare/resources/speed/schedule.py
+++ b/src/cloudflare/resources/speed/schedule.py
@@ -21,11 +21,13 @@
async_to_streamed_response_wrapper,
)
from ..._wrappers import ResultWrapper
-from ...types.speed import schedule_create_params
+from ...types.speed import schedule_get_params, schedule_create_params, schedule_delete_params
from ..._base_client import (
make_request_options,
)
+from ...types.speed.schedule import Schedule
from ...types.speed.schedule_create_response import ScheduleCreateResponse
+from ...types.speed.schedule_delete_response import ScheduleDeleteResponse
__all__ = ["ScheduleResource", "AsyncScheduleResource"]
@@ -110,6 +112,148 @@ def create(
cast_to=cast(Type[Optional[ScheduleCreateResponse]], ResultWrapper[ScheduleCreateResponse]),
)
+ def delete(
+ self,
+ url: str,
+ *,
+ zone_id: str,
+ region: Literal[
+ "asia-east1",
+ "asia-northeast1",
+ "asia-northeast2",
+ "asia-south1",
+ "asia-southeast1",
+ "australia-southeast1",
+ "europe-north1",
+ "europe-southwest1",
+ "europe-west1",
+ "europe-west2",
+ "europe-west3",
+ "europe-west4",
+ "europe-west8",
+ "europe-west9",
+ "me-west1",
+ "southamerica-east1",
+ "us-central1",
+ "us-east1",
+ "us-east4",
+ "us-south1",
+ "us-west1",
+ ]
+ | 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[ScheduleDeleteResponse]:
+ """
+ Deletes a scheduled test for a page.
+
+ Args:
+ zone_id: Identifier
+
+ url: A URL.
+
+ region: A test region.
+
+ 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_id:
+ raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
+ if not url:
+ raise ValueError(f"Expected a non-empty value for `url` but received {url!r}")
+ return self._delete(
+ f"/zones/{zone_id}/speed_api/schedule/{url}",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=maybe_transform({"region": region}, schedule_delete_params.ScheduleDeleteParams),
+ post_parser=ResultWrapper[Optional[ScheduleDeleteResponse]]._unwrapper,
+ ),
+ cast_to=cast(Type[Optional[ScheduleDeleteResponse]], ResultWrapper[ScheduleDeleteResponse]),
+ )
+
+ def get(
+ self,
+ url: str,
+ *,
+ zone_id: str,
+ region: Literal[
+ "asia-east1",
+ "asia-northeast1",
+ "asia-northeast2",
+ "asia-south1",
+ "asia-southeast1",
+ "australia-southeast1",
+ "europe-north1",
+ "europe-southwest1",
+ "europe-west1",
+ "europe-west2",
+ "europe-west3",
+ "europe-west4",
+ "europe-west8",
+ "europe-west9",
+ "me-west1",
+ "southamerica-east1",
+ "us-central1",
+ "us-east1",
+ "us-east4",
+ "us-south1",
+ "us-west1",
+ ]
+ | 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[Schedule]:
+ """
+ Retrieves the test schedule for a page in a specific region.
+
+ Args:
+ zone_id: Identifier
+
+ url: A URL.
+
+ region: A test region.
+
+ 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_id:
+ raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
+ if not url:
+ raise ValueError(f"Expected a non-empty value for `url` but received {url!r}")
+ return self._get(
+ f"/zones/{zone_id}/speed_api/schedule/{url}",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=maybe_transform({"region": region}, schedule_get_params.ScheduleGetParams),
+ post_parser=ResultWrapper[Optional[Schedule]]._unwrapper,
+ ),
+ cast_to=cast(Type[Optional[Schedule]], ResultWrapper[Schedule]),
+ )
+
class AsyncScheduleResource(AsyncAPIResource):
@cached_property
@@ -191,6 +335,148 @@ async def create(
cast_to=cast(Type[Optional[ScheduleCreateResponse]], ResultWrapper[ScheduleCreateResponse]),
)
+ async def delete(
+ self,
+ url: str,
+ *,
+ zone_id: str,
+ region: Literal[
+ "asia-east1",
+ "asia-northeast1",
+ "asia-northeast2",
+ "asia-south1",
+ "asia-southeast1",
+ "australia-southeast1",
+ "europe-north1",
+ "europe-southwest1",
+ "europe-west1",
+ "europe-west2",
+ "europe-west3",
+ "europe-west4",
+ "europe-west8",
+ "europe-west9",
+ "me-west1",
+ "southamerica-east1",
+ "us-central1",
+ "us-east1",
+ "us-east4",
+ "us-south1",
+ "us-west1",
+ ]
+ | 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[ScheduleDeleteResponse]:
+ """
+ Deletes a scheduled test for a page.
+
+ Args:
+ zone_id: Identifier
+
+ url: A URL.
+
+ region: A test region.
+
+ 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_id:
+ raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
+ if not url:
+ raise ValueError(f"Expected a non-empty value for `url` but received {url!r}")
+ return await self._delete(
+ f"/zones/{zone_id}/speed_api/schedule/{url}",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=await async_maybe_transform({"region": region}, schedule_delete_params.ScheduleDeleteParams),
+ post_parser=ResultWrapper[Optional[ScheduleDeleteResponse]]._unwrapper,
+ ),
+ cast_to=cast(Type[Optional[ScheduleDeleteResponse]], ResultWrapper[ScheduleDeleteResponse]),
+ )
+
+ async def get(
+ self,
+ url: str,
+ *,
+ zone_id: str,
+ region: Literal[
+ "asia-east1",
+ "asia-northeast1",
+ "asia-northeast2",
+ "asia-south1",
+ "asia-southeast1",
+ "australia-southeast1",
+ "europe-north1",
+ "europe-southwest1",
+ "europe-west1",
+ "europe-west2",
+ "europe-west3",
+ "europe-west4",
+ "europe-west8",
+ "europe-west9",
+ "me-west1",
+ "southamerica-east1",
+ "us-central1",
+ "us-east1",
+ "us-east4",
+ "us-south1",
+ "us-west1",
+ ]
+ | 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[Schedule]:
+ """
+ Retrieves the test schedule for a page in a specific region.
+
+ Args:
+ zone_id: Identifier
+
+ url: A URL.
+
+ region: A test region.
+
+ 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_id:
+ raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
+ if not url:
+ raise ValueError(f"Expected a non-empty value for `url` but received {url!r}")
+ return await self._get(
+ f"/zones/{zone_id}/speed_api/schedule/{url}",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=await async_maybe_transform({"region": region}, schedule_get_params.ScheduleGetParams),
+ post_parser=ResultWrapper[Optional[Schedule]]._unwrapper,
+ ),
+ cast_to=cast(Type[Optional[Schedule]], ResultWrapper[Schedule]),
+ )
+
class ScheduleResourceWithRawResponse:
def __init__(self, schedule: ScheduleResource) -> None:
@@ -199,6 +485,12 @@ def __init__(self, schedule: ScheduleResource) -> None:
self.create = to_raw_response_wrapper(
schedule.create,
)
+ self.delete = to_raw_response_wrapper(
+ schedule.delete,
+ )
+ self.get = to_raw_response_wrapper(
+ schedule.get,
+ )
class AsyncScheduleResourceWithRawResponse:
@@ -208,6 +500,12 @@ def __init__(self, schedule: AsyncScheduleResource) -> None:
self.create = async_to_raw_response_wrapper(
schedule.create,
)
+ self.delete = async_to_raw_response_wrapper(
+ schedule.delete,
+ )
+ self.get = async_to_raw_response_wrapper(
+ schedule.get,
+ )
class ScheduleResourceWithStreamingResponse:
@@ -217,6 +515,12 @@ def __init__(self, schedule: ScheduleResource) -> None:
self.create = to_streamed_response_wrapper(
schedule.create,
)
+ self.delete = to_streamed_response_wrapper(
+ schedule.delete,
+ )
+ self.get = to_streamed_response_wrapper(
+ schedule.get,
+ )
class AsyncScheduleResourceWithStreamingResponse:
@@ -226,3 +530,9 @@ def __init__(self, schedule: AsyncScheduleResource) -> None:
self.create = async_to_streamed_response_wrapper(
schedule.create,
)
+ self.delete = async_to_streamed_response_wrapper(
+ schedule.delete,
+ )
+ self.get = async_to_streamed_response_wrapper(
+ schedule.get,
+ )
diff --git a/src/cloudflare/resources/speed/speed.py b/src/cloudflare/resources/speed/speed.py
index 478aad8507c..83abbebfa82 100644
--- a/src/cloudflare/resources/speed/speed.py
+++ b/src/cloudflare/resources/speed/speed.py
@@ -2,12 +2,6 @@
from __future__ import annotations
-from typing import Type, Union, Optional, cast
-from datetime import datetime
-from typing_extensions import Literal
-
-import httpx
-
from .pages import (
PagesResource,
AsyncPagesResource,
@@ -16,19 +10,6 @@
PagesResourceWithStreamingResponse,
AsyncPagesResourceWithStreamingResponse,
)
-from .tests import (
- TestsResource,
- AsyncTestsResource,
- TestsResourceWithRawResponse,
- AsyncTestsResourceWithRawResponse,
- TestsResourceWithStreamingResponse,
- AsyncTestsResourceWithStreamingResponse,
-)
-from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
-from ..._utils import (
- maybe_transform,
- async_maybe_transform,
-)
from .schedule import (
ScheduleResource,
AsyncScheduleResource,
@@ -39,17 +20,7 @@
)
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 ...types.speed import speed_delete_params, speed_trends_list_params, speed_schedule_get_params
-from ..._base_client import (
- make_request_options,
-)
+from .pages.pages import PagesResource, AsyncPagesResource
from .availabilities import (
AvailabilitiesResource,
AsyncAvailabilitiesResource,
@@ -58,18 +29,11 @@
AvailabilitiesResourceWithStreamingResponse,
AsyncAvailabilitiesResourceWithStreamingResponse,
)
-from ...types.speed.trend import Trend
-from ...types.speed.schedule import Schedule
-from ...types.speed.speed_delete_response import SpeedDeleteResponse
__all__ = ["SpeedResource", "AsyncSpeedResource"]
class SpeedResource(SyncAPIResource):
- @cached_property
- def tests(self) -> TestsResource:
- return TestsResource(self._client)
-
@cached_property
def schedule(self) -> ScheduleResource:
return ScheduleResource(self._client)
@@ -90,245 +54,8 @@ def with_raw_response(self) -> SpeedResourceWithRawResponse:
def with_streaming_response(self) -> SpeedResourceWithStreamingResponse:
return SpeedResourceWithStreamingResponse(self)
- def delete(
- self,
- url: str,
- *,
- zone_id: str,
- region: Literal[
- "asia-east1",
- "asia-northeast1",
- "asia-northeast2",
- "asia-south1",
- "asia-southeast1",
- "australia-southeast1",
- "europe-north1",
- "europe-southwest1",
- "europe-west1",
- "europe-west2",
- "europe-west3",
- "europe-west4",
- "europe-west8",
- "europe-west9",
- "me-west1",
- "southamerica-east1",
- "us-central1",
- "us-east1",
- "us-east4",
- "us-south1",
- "us-west1",
- ]
- | 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[SpeedDeleteResponse]:
- """
- Deletes a scheduled test for a page.
-
- Args:
- zone_id: Identifier
-
- url: A URL.
-
- region: A test region.
-
- 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_id:
- raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
- if not url:
- raise ValueError(f"Expected a non-empty value for `url` but received {url!r}")
- return self._delete(
- f"/zones/{zone_id}/speed_api/schedule/{url}",
- options=make_request_options(
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- query=maybe_transform({"region": region}, speed_delete_params.SpeedDeleteParams),
- post_parser=ResultWrapper[Optional[SpeedDeleteResponse]]._unwrapper,
- ),
- cast_to=cast(Type[Optional[SpeedDeleteResponse]], ResultWrapper[SpeedDeleteResponse]),
- )
-
- def schedule_get(
- self,
- url: str,
- *,
- zone_id: str,
- region: Literal[
- "asia-east1",
- "asia-northeast1",
- "asia-northeast2",
- "asia-south1",
- "asia-southeast1",
- "australia-southeast1",
- "europe-north1",
- "europe-southwest1",
- "europe-west1",
- "europe-west2",
- "europe-west3",
- "europe-west4",
- "europe-west8",
- "europe-west9",
- "me-west1",
- "southamerica-east1",
- "us-central1",
- "us-east1",
- "us-east4",
- "us-south1",
- "us-west1",
- ]
- | 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[Schedule]:
- """
- Retrieves the test schedule for a page in a specific region.
-
- Args:
- zone_id: Identifier
-
- url: A URL.
-
- region: A test region.
-
- 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_id:
- raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
- if not url:
- raise ValueError(f"Expected a non-empty value for `url` but received {url!r}")
- return self._get(
- f"/zones/{zone_id}/speed_api/schedule/{url}",
- options=make_request_options(
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- query=maybe_transform({"region": region}, speed_schedule_get_params.SpeedScheduleGetParams),
- post_parser=ResultWrapper[Optional[Schedule]]._unwrapper,
- ),
- cast_to=cast(Type[Optional[Schedule]], ResultWrapper[Schedule]),
- )
-
- def trends_list(
- self,
- url: str,
- *,
- zone_id: str,
- device_type: Literal["DESKTOP", "MOBILE"],
- metrics: str,
- region: Literal[
- "asia-east1",
- "asia-northeast1",
- "asia-northeast2",
- "asia-south1",
- "asia-southeast1",
- "australia-southeast1",
- "europe-north1",
- "europe-southwest1",
- "europe-west1",
- "europe-west2",
- "europe-west3",
- "europe-west4",
- "europe-west8",
- "europe-west9",
- "me-west1",
- "southamerica-east1",
- "us-central1",
- "us-east1",
- "us-east4",
- "us-south1",
- "us-west1",
- ],
- start: Union[str, datetime],
- tz: str,
- end: Union[str, datetime] | 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[Trend]:
- """
- Lists the core web vital metrics trend over time for a specific page.
-
- Args:
- zone_id: Identifier
-
- url: A URL.
-
- device_type: The type of device.
-
- metrics: A comma-separated list of metrics to include in the results.
-
- region: A test region.
-
- tz: The timezone of the start and end timestamps.
-
- 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_id:
- raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
- if not url:
- raise ValueError(f"Expected a non-empty value for `url` but received {url!r}")
- return self._get(
- f"/zones/{zone_id}/speed_api/pages/{url}/trend",
- options=make_request_options(
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- query=maybe_transform(
- {
- "device_type": device_type,
- "metrics": metrics,
- "region": region,
- "start": start,
- "tz": tz,
- "end": end,
- },
- speed_trends_list_params.SpeedTrendsListParams,
- ),
- post_parser=ResultWrapper[Optional[Trend]]._unwrapper,
- ),
- cast_to=cast(Type[Optional[Trend]], ResultWrapper[Trend]),
- )
-
class AsyncSpeedResource(AsyncAPIResource):
- @cached_property
- def tests(self) -> AsyncTestsResource:
- return AsyncTestsResource(self._client)
-
@cached_property
def schedule(self) -> AsyncScheduleResource:
return AsyncScheduleResource(self._client)
@@ -349,258 +76,11 @@ def with_raw_response(self) -> AsyncSpeedResourceWithRawResponse:
def with_streaming_response(self) -> AsyncSpeedResourceWithStreamingResponse:
return AsyncSpeedResourceWithStreamingResponse(self)
- async def delete(
- self,
- url: str,
- *,
- zone_id: str,
- region: Literal[
- "asia-east1",
- "asia-northeast1",
- "asia-northeast2",
- "asia-south1",
- "asia-southeast1",
- "australia-southeast1",
- "europe-north1",
- "europe-southwest1",
- "europe-west1",
- "europe-west2",
- "europe-west3",
- "europe-west4",
- "europe-west8",
- "europe-west9",
- "me-west1",
- "southamerica-east1",
- "us-central1",
- "us-east1",
- "us-east4",
- "us-south1",
- "us-west1",
- ]
- | 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[SpeedDeleteResponse]:
- """
- Deletes a scheduled test for a page.
-
- Args:
- zone_id: Identifier
-
- url: A URL.
-
- region: A test region.
-
- 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_id:
- raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
- if not url:
- raise ValueError(f"Expected a non-empty value for `url` but received {url!r}")
- return await self._delete(
- f"/zones/{zone_id}/speed_api/schedule/{url}",
- options=make_request_options(
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- query=await async_maybe_transform({"region": region}, speed_delete_params.SpeedDeleteParams),
- post_parser=ResultWrapper[Optional[SpeedDeleteResponse]]._unwrapper,
- ),
- cast_to=cast(Type[Optional[SpeedDeleteResponse]], ResultWrapper[SpeedDeleteResponse]),
- )
-
- async def schedule_get(
- self,
- url: str,
- *,
- zone_id: str,
- region: Literal[
- "asia-east1",
- "asia-northeast1",
- "asia-northeast2",
- "asia-south1",
- "asia-southeast1",
- "australia-southeast1",
- "europe-north1",
- "europe-southwest1",
- "europe-west1",
- "europe-west2",
- "europe-west3",
- "europe-west4",
- "europe-west8",
- "europe-west9",
- "me-west1",
- "southamerica-east1",
- "us-central1",
- "us-east1",
- "us-east4",
- "us-south1",
- "us-west1",
- ]
- | 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[Schedule]:
- """
- Retrieves the test schedule for a page in a specific region.
-
- Args:
- zone_id: Identifier
-
- url: A URL.
-
- region: A test region.
-
- 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_id:
- raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
- if not url:
- raise ValueError(f"Expected a non-empty value for `url` but received {url!r}")
- return await self._get(
- f"/zones/{zone_id}/speed_api/schedule/{url}",
- options=make_request_options(
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- query=await async_maybe_transform({"region": region}, speed_schedule_get_params.SpeedScheduleGetParams),
- post_parser=ResultWrapper[Optional[Schedule]]._unwrapper,
- ),
- cast_to=cast(Type[Optional[Schedule]], ResultWrapper[Schedule]),
- )
-
- async def trends_list(
- self,
- url: str,
- *,
- zone_id: str,
- device_type: Literal["DESKTOP", "MOBILE"],
- metrics: str,
- region: Literal[
- "asia-east1",
- "asia-northeast1",
- "asia-northeast2",
- "asia-south1",
- "asia-southeast1",
- "australia-southeast1",
- "europe-north1",
- "europe-southwest1",
- "europe-west1",
- "europe-west2",
- "europe-west3",
- "europe-west4",
- "europe-west8",
- "europe-west9",
- "me-west1",
- "southamerica-east1",
- "us-central1",
- "us-east1",
- "us-east4",
- "us-south1",
- "us-west1",
- ],
- start: Union[str, datetime],
- tz: str,
- end: Union[str, datetime] | 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[Trend]:
- """
- Lists the core web vital metrics trend over time for a specific page.
-
- Args:
- zone_id: Identifier
-
- url: A URL.
-
- device_type: The type of device.
-
- metrics: A comma-separated list of metrics to include in the results.
-
- region: A test region.
-
- tz: The timezone of the start and end timestamps.
-
- 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_id:
- raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
- if not url:
- raise ValueError(f"Expected a non-empty value for `url` but received {url!r}")
- return await self._get(
- f"/zones/{zone_id}/speed_api/pages/{url}/trend",
- options=make_request_options(
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- query=await async_maybe_transform(
- {
- "device_type": device_type,
- "metrics": metrics,
- "region": region,
- "start": start,
- "tz": tz,
- "end": end,
- },
- speed_trends_list_params.SpeedTrendsListParams,
- ),
- post_parser=ResultWrapper[Optional[Trend]]._unwrapper,
- ),
- cast_to=cast(Type[Optional[Trend]], ResultWrapper[Trend]),
- )
-
class SpeedResourceWithRawResponse:
def __init__(self, speed: SpeedResource) -> None:
self._speed = speed
- self.delete = to_raw_response_wrapper(
- speed.delete,
- )
- self.schedule_get = to_raw_response_wrapper(
- speed.schedule_get,
- )
- self.trends_list = to_raw_response_wrapper(
- speed.trends_list,
- )
-
- @cached_property
- def tests(self) -> TestsResourceWithRawResponse:
- return TestsResourceWithRawResponse(self._speed.tests)
-
@cached_property
def schedule(self) -> ScheduleResourceWithRawResponse:
return ScheduleResourceWithRawResponse(self._speed.schedule)
@@ -618,20 +98,6 @@ class AsyncSpeedResourceWithRawResponse:
def __init__(self, speed: AsyncSpeedResource) -> None:
self._speed = speed
- self.delete = async_to_raw_response_wrapper(
- speed.delete,
- )
- self.schedule_get = async_to_raw_response_wrapper(
- speed.schedule_get,
- )
- self.trends_list = async_to_raw_response_wrapper(
- speed.trends_list,
- )
-
- @cached_property
- def tests(self) -> AsyncTestsResourceWithRawResponse:
- return AsyncTestsResourceWithRawResponse(self._speed.tests)
-
@cached_property
def schedule(self) -> AsyncScheduleResourceWithRawResponse:
return AsyncScheduleResourceWithRawResponse(self._speed.schedule)
@@ -649,20 +115,6 @@ class SpeedResourceWithStreamingResponse:
def __init__(self, speed: SpeedResource) -> None:
self._speed = speed
- self.delete = to_streamed_response_wrapper(
- speed.delete,
- )
- self.schedule_get = to_streamed_response_wrapper(
- speed.schedule_get,
- )
- self.trends_list = to_streamed_response_wrapper(
- speed.trends_list,
- )
-
- @cached_property
- def tests(self) -> TestsResourceWithStreamingResponse:
- return TestsResourceWithStreamingResponse(self._speed.tests)
-
@cached_property
def schedule(self) -> ScheduleResourceWithStreamingResponse:
return ScheduleResourceWithStreamingResponse(self._speed.schedule)
@@ -680,20 +132,6 @@ class AsyncSpeedResourceWithStreamingResponse:
def __init__(self, speed: AsyncSpeedResource) -> None:
self._speed = speed
- self.delete = async_to_streamed_response_wrapper(
- speed.delete,
- )
- self.schedule_get = async_to_streamed_response_wrapper(
- speed.schedule_get,
- )
- self.trends_list = async_to_streamed_response_wrapper(
- speed.trends_list,
- )
-
- @cached_property
- def tests(self) -> AsyncTestsResourceWithStreamingResponse:
- return AsyncTestsResourceWithStreamingResponse(self._speed.tests)
-
@cached_property
def schedule(self) -> AsyncScheduleResourceWithStreamingResponse:
return AsyncScheduleResourceWithStreamingResponse(self._speed.schedule)
diff --git a/src/cloudflare/types/speed/__init__.py b/src/cloudflare/types/speed/__init__.py
index 679415b426a..8ee5e2e8845 100644
--- a/src/cloudflare/types/speed/__init__.py
+++ b/src/cloudflare/types/speed/__init__.py
@@ -2,21 +2,15 @@
from __future__ import annotations
-from .test import Test as Test
from .trend import Trend as Trend
from .schedule import Schedule as Schedule
from .availability import Availability as Availability
from .labeled_region import LabeledRegion as LabeledRegion
-from .test_list_params import TestListParams as TestListParams
from .lighthouse_report import LighthouseReport as LighthouseReport
+from .page_trend_params import PageTrendParams as PageTrendParams
from .page_list_response import PageListResponse as PageListResponse
-from .test_create_params import TestCreateParams as TestCreateParams
-from .test_delete_params import TestDeleteParams as TestDeleteParams
-from .test_list_response import TestListResponse as TestListResponse
-from .speed_delete_params import SpeedDeleteParams as SpeedDeleteParams
-from .test_delete_response import TestDeleteResponse as TestDeleteResponse
-from .speed_delete_response import SpeedDeleteResponse as SpeedDeleteResponse
+from .schedule_get_params import ScheduleGetParams as ScheduleGetParams
from .schedule_create_params import ScheduleCreateParams as ScheduleCreateParams
+from .schedule_delete_params import ScheduleDeleteParams as ScheduleDeleteParams
from .schedule_create_response import ScheduleCreateResponse as ScheduleCreateResponse
-from .speed_trends_list_params import SpeedTrendsListParams as SpeedTrendsListParams
-from .speed_schedule_get_params import SpeedScheduleGetParams as SpeedScheduleGetParams
+from .schedule_delete_response import ScheduleDeleteResponse as ScheduleDeleteResponse
diff --git a/src/cloudflare/types/speed/page_list_response.py b/src/cloudflare/types/speed/page_list_response.py
index e90c0dc3704..a6a058277b7 100644
--- a/src/cloudflare/types/speed/page_list_response.py
+++ b/src/cloudflare/types/speed/page_list_response.py
@@ -5,8 +5,8 @@
from pydantic import Field as FieldInfo
-from .test import Test
from ..._models import BaseModel
+from .pages.test import Test
from .labeled_region import LabeledRegion
__all__ = ["PageListResponse"]
diff --git a/src/cloudflare/types/speed/speed_trends_list_params.py b/src/cloudflare/types/speed/page_trend_params.py
similarity index 94%
rename from src/cloudflare/types/speed/speed_trends_list_params.py
rename to src/cloudflare/types/speed/page_trend_params.py
index 2af594b00dc..c3df698ca13 100644
--- a/src/cloudflare/types/speed/speed_trends_list_params.py
+++ b/src/cloudflare/types/speed/page_trend_params.py
@@ -8,10 +8,10 @@
from ..._utils import PropertyInfo
-__all__ = ["SpeedTrendsListParams"]
+__all__ = ["PageTrendParams"]
-class SpeedTrendsListParams(TypedDict, total=False):
+class PageTrendParams(TypedDict, total=False):
zone_id: Required[str]
"""Identifier"""
diff --git a/src/cloudflare/types/speed/pages/__init__.py b/src/cloudflare/types/speed/pages/__init__.py
new file mode 100644
index 00000000000..870ef29d6d4
--- /dev/null
+++ b/src/cloudflare/types/speed/pages/__init__.py
@@ -0,0 +1,10 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from .test import Test as Test
+from .test_list_params import TestListParams as TestListParams
+from .test_create_params import TestCreateParams as TestCreateParams
+from .test_delete_params import TestDeleteParams as TestDeleteParams
+from .test_list_response import TestListResponse as TestListResponse
+from .test_delete_response import TestDeleteResponse as TestDeleteResponse
diff --git a/src/cloudflare/types/speed/test.py b/src/cloudflare/types/speed/pages/test.py
similarity index 87%
rename from src/cloudflare/types/speed/test.py
rename to src/cloudflare/types/speed/pages/test.py
index 7bb5951eb72..11667f87e5d 100644
--- a/src/cloudflare/types/speed/test.py
+++ b/src/cloudflare/types/speed/pages/test.py
@@ -6,9 +6,9 @@
from pydantic import Field as FieldInfo
-from ..._models import BaseModel
-from .labeled_region import LabeledRegion
-from .lighthouse_report import LighthouseReport
+from ...._models import BaseModel
+from ..labeled_region import LabeledRegion
+from ..lighthouse_report import LighthouseReport
__all__ = ["Test"]
diff --git a/src/cloudflare/types/speed/test_create_params.py b/src/cloudflare/types/speed/pages/test_create_params.py
similarity index 100%
rename from src/cloudflare/types/speed/test_create_params.py
rename to src/cloudflare/types/speed/pages/test_create_params.py
diff --git a/src/cloudflare/types/speed/test_delete_params.py b/src/cloudflare/types/speed/pages/test_delete_params.py
similarity index 100%
rename from src/cloudflare/types/speed/test_delete_params.py
rename to src/cloudflare/types/speed/pages/test_delete_params.py
diff --git a/src/cloudflare/types/speed/test_delete_response.py b/src/cloudflare/types/speed/pages/test_delete_response.py
similarity index 89%
rename from src/cloudflare/types/speed/test_delete_response.py
rename to src/cloudflare/types/speed/pages/test_delete_response.py
index 9e375ef09b7..728079ebc28 100644
--- a/src/cloudflare/types/speed/test_delete_response.py
+++ b/src/cloudflare/types/speed/pages/test_delete_response.py
@@ -2,7 +2,7 @@
from typing import Optional
-from ..._models import BaseModel
+from ...._models import BaseModel
__all__ = ["TestDeleteResponse"]
diff --git a/src/cloudflare/types/speed/test_list_params.py b/src/cloudflare/types/speed/pages/test_list_params.py
similarity index 100%
rename from src/cloudflare/types/speed/test_list_params.py
rename to src/cloudflare/types/speed/pages/test_list_params.py
diff --git a/src/cloudflare/types/speed/test_list_response.py b/src/cloudflare/types/speed/pages/test_list_response.py
similarity index 87%
rename from src/cloudflare/types/speed/test_list_response.py
rename to src/cloudflare/types/speed/pages/test_list_response.py
index 122df70f30f..7433af9070e 100644
--- a/src/cloudflare/types/speed/test_list_response.py
+++ b/src/cloudflare/types/speed/pages/test_list_response.py
@@ -2,8 +2,8 @@
from typing import List, Optional
-from ..._models import BaseModel
-from ..shared.response_info import ResponseInfo
+from ...._models import BaseModel
+from ...shared.response_info import ResponseInfo
__all__ = ["TestListResponse", "ResultInfo"]
diff --git a/src/cloudflare/types/speed/schedule_create_response.py b/src/cloudflare/types/speed/schedule_create_response.py
index 50ef4d668ed..5fe02042ea6 100644
--- a/src/cloudflare/types/speed/schedule_create_response.py
+++ b/src/cloudflare/types/speed/schedule_create_response.py
@@ -2,9 +2,9 @@
from typing import Optional
-from .test import Test
from .schedule import Schedule
from ..._models import BaseModel
+from .pages.test import Test
__all__ = ["ScheduleCreateResponse"]
diff --git a/src/cloudflare/types/speed/speed_schedule_get_params.py b/src/cloudflare/types/speed/schedule_delete_params.py
similarity index 89%
rename from src/cloudflare/types/speed/speed_schedule_get_params.py
rename to src/cloudflare/types/speed/schedule_delete_params.py
index 403ed349a61..4ac243958a3 100644
--- a/src/cloudflare/types/speed/speed_schedule_get_params.py
+++ b/src/cloudflare/types/speed/schedule_delete_params.py
@@ -4,10 +4,10 @@
from typing_extensions import Literal, Required, TypedDict
-__all__ = ["SpeedScheduleGetParams"]
+__all__ = ["ScheduleDeleteParams"]
-class SpeedScheduleGetParams(TypedDict, total=False):
+class ScheduleDeleteParams(TypedDict, total=False):
zone_id: Required[str]
"""Identifier"""
diff --git a/src/cloudflare/types/speed/speed_delete_response.py b/src/cloudflare/types/speed/schedule_delete_response.py
similarity index 74%
rename from src/cloudflare/types/speed/speed_delete_response.py
rename to src/cloudflare/types/speed/schedule_delete_response.py
index 71d39113616..1449d733066 100644
--- a/src/cloudflare/types/speed/speed_delete_response.py
+++ b/src/cloudflare/types/speed/schedule_delete_response.py
@@ -4,9 +4,9 @@
from ..._models import BaseModel
-__all__ = ["SpeedDeleteResponse"]
+__all__ = ["ScheduleDeleteResponse"]
-class SpeedDeleteResponse(BaseModel):
+class ScheduleDeleteResponse(BaseModel):
count: Optional[float] = None
"""Number of items affected."""
diff --git a/src/cloudflare/types/speed/speed_delete_params.py b/src/cloudflare/types/speed/schedule_get_params.py
similarity index 90%
rename from src/cloudflare/types/speed/speed_delete_params.py
rename to src/cloudflare/types/speed/schedule_get_params.py
index 130cab3ecd4..e9c75fdf435 100644
--- a/src/cloudflare/types/speed/speed_delete_params.py
+++ b/src/cloudflare/types/speed/schedule_get_params.py
@@ -4,10 +4,10 @@
from typing_extensions import Literal, Required, TypedDict
-__all__ = ["SpeedDeleteParams"]
+__all__ = ["ScheduleGetParams"]
-class SpeedDeleteParams(TypedDict, total=False):
+class ScheduleGetParams(TypedDict, total=False):
zone_id: Required[str]
"""Identifier"""
diff --git a/tests/api_resources/speed/pages/__init__.py b/tests/api_resources/speed/pages/__init__.py
new file mode 100644
index 00000000000..fd8019a9a1a
--- /dev/null
+++ b/tests/api_resources/speed/pages/__init__.py
@@ -0,0 +1 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
diff --git a/tests/api_resources/speed/test_tests.py b/tests/api_resources/speed/pages/test_tests.py
similarity index 83%
rename from tests/api_resources/speed/test_tests.py
rename to tests/api_resources/speed/pages/test_tests.py
index 1bc60889e66..5d768ba427c 100644
--- a/tests/api_resources/speed/test_tests.py
+++ b/tests/api_resources/speed/pages/test_tests.py
@@ -9,7 +9,7 @@
from cloudflare import Cloudflare, AsyncCloudflare
from tests.utils import assert_matches_type
-from cloudflare.types.speed import (
+from cloudflare.types.speed.pages import (
Test,
TestListResponse,
TestDeleteResponse,
@@ -23,7 +23,7 @@ class TestTests:
@parametrize
def test_method_create(self, client: Cloudflare) -> None:
- test = client.speed.tests.create(
+ test = client.speed.pages.tests.create(
"example.com",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
@@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None:
@parametrize
def test_method_create_with_all_params(self, client: Cloudflare) -> None:
- test = client.speed.tests.create(
+ test = client.speed.pages.tests.create(
"example.com",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
region="us-central1",
@@ -40,7 +40,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None:
@parametrize
def test_raw_response_create(self, client: Cloudflare) -> None:
- response = client.speed.tests.with_raw_response.create(
+ response = client.speed.pages.tests.with_raw_response.create(
"example.com",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
@@ -52,7 +52,7 @@ def test_raw_response_create(self, client: Cloudflare) -> None:
@parametrize
def test_streaming_response_create(self, client: Cloudflare) -> None:
- with client.speed.tests.with_streaming_response.create(
+ with client.speed.pages.tests.with_streaming_response.create(
"example.com",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
) as response:
@@ -67,20 +67,20 @@ def test_streaming_response_create(self, client: Cloudflare) -> None:
@parametrize
def test_path_params_create(self, client: Cloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
- client.speed.tests.with_raw_response.create(
+ client.speed.pages.tests.with_raw_response.create(
"example.com",
zone_id="",
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `url` but received ''"):
- client.speed.tests.with_raw_response.create(
+ client.speed.pages.tests.with_raw_response.create(
"",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
@parametrize
def test_method_list(self, client: Cloudflare) -> None:
- test = client.speed.tests.list(
+ test = client.speed.pages.tests.list(
"example.com",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
@@ -88,7 +88,7 @@ def test_method_list(self, client: Cloudflare) -> None:
@parametrize
def test_method_list_with_all_params(self, client: Cloudflare) -> None:
- test = client.speed.tests.list(
+ test = client.speed.pages.tests.list(
"example.com",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
page=1,
@@ -99,7 +99,7 @@ def test_method_list_with_all_params(self, client: Cloudflare) -> None:
@parametrize
def test_raw_response_list(self, client: Cloudflare) -> None:
- response = client.speed.tests.with_raw_response.list(
+ response = client.speed.pages.tests.with_raw_response.list(
"example.com",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
@@ -111,7 +111,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None:
@parametrize
def test_streaming_response_list(self, client: Cloudflare) -> None:
- with client.speed.tests.with_streaming_response.list(
+ with client.speed.pages.tests.with_streaming_response.list(
"example.com",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
) as response:
@@ -126,20 +126,20 @@ def test_streaming_response_list(self, client: Cloudflare) -> None:
@parametrize
def test_path_params_list(self, client: Cloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
- client.speed.tests.with_raw_response.list(
+ client.speed.pages.tests.with_raw_response.list(
"example.com",
zone_id="",
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `url` but received ''"):
- client.speed.tests.with_raw_response.list(
+ client.speed.pages.tests.with_raw_response.list(
"",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
@parametrize
def test_method_delete(self, client: Cloudflare) -> None:
- test = client.speed.tests.delete(
+ test = client.speed.pages.tests.delete(
"example.com",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
@@ -147,7 +147,7 @@ def test_method_delete(self, client: Cloudflare) -> None:
@parametrize
def test_method_delete_with_all_params(self, client: Cloudflare) -> None:
- test = client.speed.tests.delete(
+ test = client.speed.pages.tests.delete(
"example.com",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
region="us-central1",
@@ -156,7 +156,7 @@ def test_method_delete_with_all_params(self, client: Cloudflare) -> None:
@parametrize
def test_raw_response_delete(self, client: Cloudflare) -> None:
- response = client.speed.tests.with_raw_response.delete(
+ response = client.speed.pages.tests.with_raw_response.delete(
"example.com",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
@@ -168,7 +168,7 @@ def test_raw_response_delete(self, client: Cloudflare) -> None:
@parametrize
def test_streaming_response_delete(self, client: Cloudflare) -> None:
- with client.speed.tests.with_streaming_response.delete(
+ with client.speed.pages.tests.with_streaming_response.delete(
"example.com",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
) as response:
@@ -183,20 +183,20 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None:
@parametrize
def test_path_params_delete(self, client: Cloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
- client.speed.tests.with_raw_response.delete(
+ client.speed.pages.tests.with_raw_response.delete(
"example.com",
zone_id="",
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `url` but received ''"):
- client.speed.tests.with_raw_response.delete(
+ client.speed.pages.tests.with_raw_response.delete(
"",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
@parametrize
def test_method_get(self, client: Cloudflare) -> None:
- test = client.speed.tests.get(
+ test = client.speed.pages.tests.get(
"string",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
url="example.com",
@@ -205,7 +205,7 @@ def test_method_get(self, client: Cloudflare) -> None:
@parametrize
def test_raw_response_get(self, client: Cloudflare) -> None:
- response = client.speed.tests.with_raw_response.get(
+ response = client.speed.pages.tests.with_raw_response.get(
"string",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
url="example.com",
@@ -218,7 +218,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None:
@parametrize
def test_streaming_response_get(self, client: Cloudflare) -> None:
- with client.speed.tests.with_streaming_response.get(
+ with client.speed.pages.tests.with_streaming_response.get(
"string",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
url="example.com",
@@ -234,21 +234,21 @@ def test_streaming_response_get(self, client: Cloudflare) -> None:
@parametrize
def test_path_params_get(self, client: Cloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
- client.speed.tests.with_raw_response.get(
+ client.speed.pages.tests.with_raw_response.get(
"string",
zone_id="",
url="example.com",
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `url` but received ''"):
- client.speed.tests.with_raw_response.get(
+ client.speed.pages.tests.with_raw_response.get(
"string",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
url="",
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"):
- client.speed.tests.with_raw_response.get(
+ client.speed.pages.tests.with_raw_response.get(
"",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
url="example.com",
@@ -260,7 +260,7 @@ class TestAsyncTests:
@parametrize
async def test_method_create(self, async_client: AsyncCloudflare) -> None:
- test = await async_client.speed.tests.create(
+ test = await async_client.speed.pages.tests.create(
"example.com",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
@@ -268,7 +268,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None:
@parametrize
async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None:
- test = await async_client.speed.tests.create(
+ test = await async_client.speed.pages.tests.create(
"example.com",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
region="us-central1",
@@ -277,7 +277,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare
@parametrize
async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
- response = await async_client.speed.tests.with_raw_response.create(
+ response = await async_client.speed.pages.tests.with_raw_response.create(
"example.com",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
@@ -289,7 +289,7 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
@parametrize
async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None:
- async with async_client.speed.tests.with_streaming_response.create(
+ async with async_client.speed.pages.tests.with_streaming_response.create(
"example.com",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
) as response:
@@ -304,20 +304,20 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) ->
@parametrize
async def test_path_params_create(self, async_client: AsyncCloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
- await async_client.speed.tests.with_raw_response.create(
+ await async_client.speed.pages.tests.with_raw_response.create(
"example.com",
zone_id="",
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `url` but received ''"):
- await async_client.speed.tests.with_raw_response.create(
+ await async_client.speed.pages.tests.with_raw_response.create(
"",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
@parametrize
async def test_method_list(self, async_client: AsyncCloudflare) -> None:
- test = await async_client.speed.tests.list(
+ test = await async_client.speed.pages.tests.list(
"example.com",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
@@ -325,7 +325,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None:
@parametrize
async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None:
- test = await async_client.speed.tests.list(
+ test = await async_client.speed.pages.tests.list(
"example.com",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
page=1,
@@ -336,7 +336,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare)
@parametrize
async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None:
- response = await async_client.speed.tests.with_raw_response.list(
+ response = await async_client.speed.pages.tests.with_raw_response.list(
"example.com",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
@@ -348,7 +348,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None:
@parametrize
async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None:
- async with async_client.speed.tests.with_streaming_response.list(
+ async with async_client.speed.pages.tests.with_streaming_response.list(
"example.com",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
) as response:
@@ -363,20 +363,20 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N
@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_id` but received ''"):
- await async_client.speed.tests.with_raw_response.list(
+ await async_client.speed.pages.tests.with_raw_response.list(
"example.com",
zone_id="",
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `url` but received ''"):
- await async_client.speed.tests.with_raw_response.list(
+ await async_client.speed.pages.tests.with_raw_response.list(
"",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
@parametrize
async def test_method_delete(self, async_client: AsyncCloudflare) -> None:
- test = await async_client.speed.tests.delete(
+ test = await async_client.speed.pages.tests.delete(
"example.com",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
@@ -384,7 +384,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None:
@parametrize
async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare) -> None:
- test = await async_client.speed.tests.delete(
+ test = await async_client.speed.pages.tests.delete(
"example.com",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
region="us-central1",
@@ -393,7 +393,7 @@ async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare
@parametrize
async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None:
- response = await async_client.speed.tests.with_raw_response.delete(
+ response = await async_client.speed.pages.tests.with_raw_response.delete(
"example.com",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
@@ -405,7 +405,7 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None:
@parametrize
async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None:
- async with async_client.speed.tests.with_streaming_response.delete(
+ async with async_client.speed.pages.tests.with_streaming_response.delete(
"example.com",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
) as response:
@@ -420,20 +420,20 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) ->
@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_id` but received ''"):
- await async_client.speed.tests.with_raw_response.delete(
+ await async_client.speed.pages.tests.with_raw_response.delete(
"example.com",
zone_id="",
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `url` but received ''"):
- await async_client.speed.tests.with_raw_response.delete(
+ await async_client.speed.pages.tests.with_raw_response.delete(
"",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
@parametrize
async def test_method_get(self, async_client: AsyncCloudflare) -> None:
- test = await async_client.speed.tests.get(
+ test = await async_client.speed.pages.tests.get(
"string",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
url="example.com",
@@ -442,7 +442,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None:
@parametrize
async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None:
- response = await async_client.speed.tests.with_raw_response.get(
+ response = await async_client.speed.pages.tests.with_raw_response.get(
"string",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
url="example.com",
@@ -455,7 +455,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None:
@parametrize
async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None:
- async with async_client.speed.tests.with_streaming_response.get(
+ async with async_client.speed.pages.tests.with_streaming_response.get(
"string",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
url="example.com",
@@ -471,21 +471,21 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No
@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_id` but received ''"):
- await async_client.speed.tests.with_raw_response.get(
+ await async_client.speed.pages.tests.with_raw_response.get(
"string",
zone_id="",
url="example.com",
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `url` but received ''"):
- await async_client.speed.tests.with_raw_response.get(
+ await async_client.speed.pages.tests.with_raw_response.get(
"string",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
url="",
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"):
- await async_client.speed.tests.with_raw_response.get(
+ await async_client.speed.pages.tests.with_raw_response.get(
"",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
url="example.com",
diff --git a/tests/api_resources/speed/test_pages.py b/tests/api_resources/speed/test_pages.py
index ac43092a2e3..0d259ddcb4a 100644
--- a/tests/api_resources/speed/test_pages.py
+++ b/tests/api_resources/speed/test_pages.py
@@ -3,14 +3,15 @@
from __future__ import annotations
import os
-from typing import Any, cast
+from typing import Any, Optional, cast
import pytest
from cloudflare import Cloudflare, AsyncCloudflare
from tests.utils import assert_matches_type
+from cloudflare._utils import parse_datetime
from cloudflare.pagination import SyncSinglePage, AsyncSinglePage
-from cloudflare.types.speed import PageListResponse
+from cloudflare.types.speed import Trend, PageListResponse
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -56,6 +57,98 @@ def test_path_params_list(self, client: Cloudflare) -> None:
zone_id="",
)
+ @pytest.mark.skip(reason="TODO: investigate broken test")
+ @parametrize
+ def test_method_trend(self, client: Cloudflare) -> None:
+ page = client.speed.pages.trend(
+ "example.com",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ device_type="DESKTOP",
+ metrics="performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls",
+ region="us-central1",
+ start=parse_datetime("2014-01-01T05:20:00.12345Z"),
+ tz="string",
+ )
+ assert_matches_type(Optional[Trend], page, path=["response"])
+
+ @pytest.mark.skip(reason="TODO: investigate broken test")
+ @parametrize
+ def test_method_trend_with_all_params(self, client: Cloudflare) -> None:
+ page = client.speed.pages.trend(
+ "example.com",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ device_type="DESKTOP",
+ metrics="performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls",
+ region="us-central1",
+ start=parse_datetime("2014-01-01T05:20:00.12345Z"),
+ tz="string",
+ end=parse_datetime("2014-01-01T05:20:00.12345Z"),
+ )
+ assert_matches_type(Optional[Trend], page, path=["response"])
+
+ @pytest.mark.skip(reason="TODO: investigate broken test")
+ @parametrize
+ def test_raw_response_trend(self, client: Cloudflare) -> None:
+ response = client.speed.pages.with_raw_response.trend(
+ "example.com",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ device_type="DESKTOP",
+ metrics="performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls",
+ region="us-central1",
+ start=parse_datetime("2014-01-01T05:20:00.12345Z"),
+ tz="string",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ page = response.parse()
+ assert_matches_type(Optional[Trend], page, path=["response"])
+
+ @pytest.mark.skip(reason="TODO: investigate broken test")
+ @parametrize
+ def test_streaming_response_trend(self, client: Cloudflare) -> None:
+ with client.speed.pages.with_streaming_response.trend(
+ "example.com",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ device_type="DESKTOP",
+ metrics="performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls",
+ region="us-central1",
+ start=parse_datetime("2014-01-01T05:20:00.12345Z"),
+ tz="string",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ page = response.parse()
+ assert_matches_type(Optional[Trend], page, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @pytest.mark.skip(reason="TODO: investigate broken test")
+ @parametrize
+ def test_path_params_trend(self, client: Cloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
+ client.speed.pages.with_raw_response.trend(
+ "example.com",
+ zone_id="",
+ device_type="DESKTOP",
+ metrics="performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls",
+ region="us-central1",
+ start=parse_datetime("2014-01-01T05:20:00.12345Z"),
+ tz="string",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `url` but received ''"):
+ client.speed.pages.with_raw_response.trend(
+ "",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ device_type="DESKTOP",
+ metrics="performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls",
+ region="us-central1",
+ start=parse_datetime("2014-01-01T05:20:00.12345Z"),
+ tz="string",
+ )
+
class TestAsyncPages:
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
@@ -97,3 +190,95 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None:
await async_client.speed.pages.with_raw_response.list(
zone_id="",
)
+
+ @pytest.mark.skip(reason="TODO: investigate broken test")
+ @parametrize
+ async def test_method_trend(self, async_client: AsyncCloudflare) -> None:
+ page = await async_client.speed.pages.trend(
+ "example.com",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ device_type="DESKTOP",
+ metrics="performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls",
+ region="us-central1",
+ start=parse_datetime("2014-01-01T05:20:00.12345Z"),
+ tz="string",
+ )
+ assert_matches_type(Optional[Trend], page, path=["response"])
+
+ @pytest.mark.skip(reason="TODO: investigate broken test")
+ @parametrize
+ async def test_method_trend_with_all_params(self, async_client: AsyncCloudflare) -> None:
+ page = await async_client.speed.pages.trend(
+ "example.com",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ device_type="DESKTOP",
+ metrics="performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls",
+ region="us-central1",
+ start=parse_datetime("2014-01-01T05:20:00.12345Z"),
+ tz="string",
+ end=parse_datetime("2014-01-01T05:20:00.12345Z"),
+ )
+ assert_matches_type(Optional[Trend], page, path=["response"])
+
+ @pytest.mark.skip(reason="TODO: investigate broken test")
+ @parametrize
+ async def test_raw_response_trend(self, async_client: AsyncCloudflare) -> None:
+ response = await async_client.speed.pages.with_raw_response.trend(
+ "example.com",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ device_type="DESKTOP",
+ metrics="performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls",
+ region="us-central1",
+ start=parse_datetime("2014-01-01T05:20:00.12345Z"),
+ tz="string",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ page = await response.parse()
+ assert_matches_type(Optional[Trend], page, path=["response"])
+
+ @pytest.mark.skip(reason="TODO: investigate broken test")
+ @parametrize
+ async def test_streaming_response_trend(self, async_client: AsyncCloudflare) -> None:
+ async with async_client.speed.pages.with_streaming_response.trend(
+ "example.com",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ device_type="DESKTOP",
+ metrics="performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls",
+ region="us-central1",
+ start=parse_datetime("2014-01-01T05:20:00.12345Z"),
+ tz="string",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ page = await response.parse()
+ assert_matches_type(Optional[Trend], page, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @pytest.mark.skip(reason="TODO: investigate broken test")
+ @parametrize
+ async def test_path_params_trend(self, async_client: AsyncCloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
+ await async_client.speed.pages.with_raw_response.trend(
+ "example.com",
+ zone_id="",
+ device_type="DESKTOP",
+ metrics="performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls",
+ region="us-central1",
+ start=parse_datetime("2014-01-01T05:20:00.12345Z"),
+ tz="string",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `url` but received ''"):
+ await async_client.speed.pages.with_raw_response.trend(
+ "",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ device_type="DESKTOP",
+ metrics="performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls",
+ region="us-central1",
+ start=parse_datetime("2014-01-01T05:20:00.12345Z"),
+ tz="string",
+ )
diff --git a/tests/api_resources/speed/test_schedule.py b/tests/api_resources/speed/test_schedule.py
index fad790c5fc2..4a20e89f851 100644
--- a/tests/api_resources/speed/test_schedule.py
+++ b/tests/api_resources/speed/test_schedule.py
@@ -9,7 +9,11 @@
from cloudflare import Cloudflare, AsyncCloudflare
from tests.utils import assert_matches_type
-from cloudflare.types.speed import ScheduleCreateResponse
+from cloudflare.types.speed import (
+ Schedule,
+ ScheduleCreateResponse,
+ ScheduleDeleteResponse,
+)
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -74,6 +78,120 @@ def test_path_params_create(self, client: Cloudflare) -> None:
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
+ @parametrize
+ def test_method_delete(self, client: Cloudflare) -> None:
+ schedule = client.speed.schedule.delete(
+ "example.com",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+ assert_matches_type(Optional[ScheduleDeleteResponse], schedule, path=["response"])
+
+ @parametrize
+ def test_method_delete_with_all_params(self, client: Cloudflare) -> None:
+ schedule = client.speed.schedule.delete(
+ "example.com",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ region="us-central1",
+ )
+ assert_matches_type(Optional[ScheduleDeleteResponse], schedule, path=["response"])
+
+ @parametrize
+ def test_raw_response_delete(self, client: Cloudflare) -> None:
+ response = client.speed.schedule.with_raw_response.delete(
+ "example.com",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ schedule = response.parse()
+ assert_matches_type(Optional[ScheduleDeleteResponse], schedule, path=["response"])
+
+ @parametrize
+ def test_streaming_response_delete(self, client: Cloudflare) -> None:
+ with client.speed.schedule.with_streaming_response.delete(
+ "example.com",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ schedule = response.parse()
+ assert_matches_type(Optional[ScheduleDeleteResponse], schedule, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_path_params_delete(self, client: Cloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
+ client.speed.schedule.with_raw_response.delete(
+ "example.com",
+ zone_id="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `url` but received ''"):
+ client.speed.schedule.with_raw_response.delete(
+ "",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ @parametrize
+ def test_method_get(self, client: Cloudflare) -> None:
+ schedule = client.speed.schedule.get(
+ "example.com",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+ assert_matches_type(Optional[Schedule], schedule, path=["response"])
+
+ @parametrize
+ def test_method_get_with_all_params(self, client: Cloudflare) -> None:
+ schedule = client.speed.schedule.get(
+ "example.com",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ region="us-central1",
+ )
+ assert_matches_type(Optional[Schedule], schedule, path=["response"])
+
+ @parametrize
+ def test_raw_response_get(self, client: Cloudflare) -> None:
+ response = client.speed.schedule.with_raw_response.get(
+ "example.com",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ schedule = response.parse()
+ assert_matches_type(Optional[Schedule], schedule, path=["response"])
+
+ @parametrize
+ def test_streaming_response_get(self, client: Cloudflare) -> None:
+ with client.speed.schedule.with_streaming_response.get(
+ "example.com",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ schedule = response.parse()
+ assert_matches_type(Optional[Schedule], schedule, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_path_params_get(self, client: Cloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
+ client.speed.schedule.with_raw_response.get(
+ "example.com",
+ zone_id="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `url` but received ''"):
+ client.speed.schedule.with_raw_response.get(
+ "",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
class TestAsyncSchedule:
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
@@ -134,3 +252,117 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None:
"",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
+
+ @parametrize
+ async def test_method_delete(self, async_client: AsyncCloudflare) -> None:
+ schedule = await async_client.speed.schedule.delete(
+ "example.com",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+ assert_matches_type(Optional[ScheduleDeleteResponse], schedule, path=["response"])
+
+ @parametrize
+ async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare) -> None:
+ schedule = await async_client.speed.schedule.delete(
+ "example.com",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ region="us-central1",
+ )
+ assert_matches_type(Optional[ScheduleDeleteResponse], schedule, path=["response"])
+
+ @parametrize
+ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None:
+ response = await async_client.speed.schedule.with_raw_response.delete(
+ "example.com",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ schedule = await response.parse()
+ assert_matches_type(Optional[ScheduleDeleteResponse], schedule, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None:
+ async with async_client.speed.schedule.with_streaming_response.delete(
+ "example.com",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ schedule = await response.parse()
+ assert_matches_type(Optional[ScheduleDeleteResponse], schedule, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @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_id` but received ''"):
+ await async_client.speed.schedule.with_raw_response.delete(
+ "example.com",
+ zone_id="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `url` but received ''"):
+ await async_client.speed.schedule.with_raw_response.delete(
+ "",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ @parametrize
+ async def test_method_get(self, async_client: AsyncCloudflare) -> None:
+ schedule = await async_client.speed.schedule.get(
+ "example.com",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+ assert_matches_type(Optional[Schedule], schedule, path=["response"])
+
+ @parametrize
+ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None:
+ schedule = await async_client.speed.schedule.get(
+ "example.com",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ region="us-central1",
+ )
+ assert_matches_type(Optional[Schedule], schedule, path=["response"])
+
+ @parametrize
+ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None:
+ response = await async_client.speed.schedule.with_raw_response.get(
+ "example.com",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ schedule = await response.parse()
+ assert_matches_type(Optional[Schedule], schedule, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None:
+ async with async_client.speed.schedule.with_streaming_response.get(
+ "example.com",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ schedule = await response.parse()
+ assert_matches_type(Optional[Schedule], schedule, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @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_id` but received ''"):
+ await async_client.speed.schedule.with_raw_response.get(
+ "example.com",
+ zone_id="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `url` but received ''"):
+ await async_client.speed.schedule.with_raw_response.get(
+ "",
+ zone_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
diff --git a/tests/api_resources/test_speed.py b/tests/api_resources/test_speed.py
deleted file mode 100644
index 5809f63ea3a..00000000000
--- a/tests/api_resources/test_speed.py
+++ /dev/null
@@ -1,439 +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, Optional, cast
-
-import pytest
-
-from cloudflare import Cloudflare, AsyncCloudflare
-from tests.utils import assert_matches_type
-from cloudflare._utils import parse_datetime
-from cloudflare.types.speed import (
- Trend,
- Schedule,
- SpeedDeleteResponse,
-)
-
-base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
-
-
-class TestSpeed:
- parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
-
- @parametrize
- def test_method_delete(self, client: Cloudflare) -> None:
- speed = client.speed.delete(
- "example.com",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- )
- assert_matches_type(Optional[SpeedDeleteResponse], speed, path=["response"])
-
- @parametrize
- def test_method_delete_with_all_params(self, client: Cloudflare) -> None:
- speed = client.speed.delete(
- "example.com",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- region="us-central1",
- )
- assert_matches_type(Optional[SpeedDeleteResponse], speed, path=["response"])
-
- @parametrize
- def test_raw_response_delete(self, client: Cloudflare) -> None:
- response = client.speed.with_raw_response.delete(
- "example.com",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- )
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- speed = response.parse()
- assert_matches_type(Optional[SpeedDeleteResponse], speed, path=["response"])
-
- @parametrize
- def test_streaming_response_delete(self, client: Cloudflare) -> None:
- with client.speed.with_streaming_response.delete(
- "example.com",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- ) as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- speed = response.parse()
- assert_matches_type(Optional[SpeedDeleteResponse], speed, path=["response"])
-
- assert cast(Any, response.is_closed) is True
-
- @parametrize
- def test_path_params_delete(self, client: Cloudflare) -> None:
- with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
- client.speed.with_raw_response.delete(
- "example.com",
- zone_id="",
- )
-
- with pytest.raises(ValueError, match=r"Expected a non-empty value for `url` but received ''"):
- client.speed.with_raw_response.delete(
- "",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- )
-
- @parametrize
- def test_method_schedule_get(self, client: Cloudflare) -> None:
- speed = client.speed.schedule_get(
- "example.com",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- )
- assert_matches_type(Optional[Schedule], speed, path=["response"])
-
- @parametrize
- def test_method_schedule_get_with_all_params(self, client: Cloudflare) -> None:
- speed = client.speed.schedule_get(
- "example.com",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- region="us-central1",
- )
- assert_matches_type(Optional[Schedule], speed, path=["response"])
-
- @parametrize
- def test_raw_response_schedule_get(self, client: Cloudflare) -> None:
- response = client.speed.with_raw_response.schedule_get(
- "example.com",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- )
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- speed = response.parse()
- assert_matches_type(Optional[Schedule], speed, path=["response"])
-
- @parametrize
- def test_streaming_response_schedule_get(self, client: Cloudflare) -> None:
- with client.speed.with_streaming_response.schedule_get(
- "example.com",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- ) as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- speed = response.parse()
- assert_matches_type(Optional[Schedule], speed, path=["response"])
-
- assert cast(Any, response.is_closed) is True
-
- @parametrize
- def test_path_params_schedule_get(self, client: Cloudflare) -> None:
- with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
- client.speed.with_raw_response.schedule_get(
- "example.com",
- zone_id="",
- )
-
- with pytest.raises(ValueError, match=r"Expected a non-empty value for `url` but received ''"):
- client.speed.with_raw_response.schedule_get(
- "",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- )
-
- @pytest.mark.skip(reason="TODO: investigate broken test")
- @parametrize
- def test_method_trends_list(self, client: Cloudflare) -> None:
- speed = client.speed.trends_list(
- "example.com",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- device_type="DESKTOP",
- metrics="performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls",
- region="us-central1",
- start=parse_datetime("2014-01-01T05:20:00.12345Z"),
- tz="string",
- )
- assert_matches_type(Optional[Trend], speed, path=["response"])
-
- @pytest.mark.skip(reason="TODO: investigate broken test")
- @parametrize
- def test_method_trends_list_with_all_params(self, client: Cloudflare) -> None:
- speed = client.speed.trends_list(
- "example.com",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- device_type="DESKTOP",
- metrics="performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls",
- region="us-central1",
- start=parse_datetime("2014-01-01T05:20:00.12345Z"),
- tz="string",
- end=parse_datetime("2014-01-01T05:20:00.12345Z"),
- )
- assert_matches_type(Optional[Trend], speed, path=["response"])
-
- @pytest.mark.skip(reason="TODO: investigate broken test")
- @parametrize
- def test_raw_response_trends_list(self, client: Cloudflare) -> None:
- response = client.speed.with_raw_response.trends_list(
- "example.com",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- device_type="DESKTOP",
- metrics="performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls",
- region="us-central1",
- start=parse_datetime("2014-01-01T05:20:00.12345Z"),
- tz="string",
- )
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- speed = response.parse()
- assert_matches_type(Optional[Trend], speed, path=["response"])
-
- @pytest.mark.skip(reason="TODO: investigate broken test")
- @parametrize
- def test_streaming_response_trends_list(self, client: Cloudflare) -> None:
- with client.speed.with_streaming_response.trends_list(
- "example.com",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- device_type="DESKTOP",
- metrics="performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls",
- region="us-central1",
- start=parse_datetime("2014-01-01T05:20:00.12345Z"),
- tz="string",
- ) as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- speed = response.parse()
- assert_matches_type(Optional[Trend], speed, path=["response"])
-
- assert cast(Any, response.is_closed) is True
-
- @pytest.mark.skip(reason="TODO: investigate broken test")
- @parametrize
- def test_path_params_trends_list(self, client: Cloudflare) -> None:
- with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
- client.speed.with_raw_response.trends_list(
- "example.com",
- zone_id="",
- device_type="DESKTOP",
- metrics="performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls",
- region="us-central1",
- start=parse_datetime("2014-01-01T05:20:00.12345Z"),
- tz="string",
- )
-
- with pytest.raises(ValueError, match=r"Expected a non-empty value for `url` but received ''"):
- client.speed.with_raw_response.trends_list(
- "",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- device_type="DESKTOP",
- metrics="performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls",
- region="us-central1",
- start=parse_datetime("2014-01-01T05:20:00.12345Z"),
- tz="string",
- )
-
-
-class TestAsyncSpeed:
- parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
-
- @parametrize
- async def test_method_delete(self, async_client: AsyncCloudflare) -> None:
- speed = await async_client.speed.delete(
- "example.com",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- )
- assert_matches_type(Optional[SpeedDeleteResponse], speed, path=["response"])
-
- @parametrize
- async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare) -> None:
- speed = await async_client.speed.delete(
- "example.com",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- region="us-central1",
- )
- assert_matches_type(Optional[SpeedDeleteResponse], speed, path=["response"])
-
- @parametrize
- async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None:
- response = await async_client.speed.with_raw_response.delete(
- "example.com",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- )
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- speed = await response.parse()
- assert_matches_type(Optional[SpeedDeleteResponse], speed, path=["response"])
-
- @parametrize
- async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None:
- async with async_client.speed.with_streaming_response.delete(
- "example.com",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- ) as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- speed = await response.parse()
- assert_matches_type(Optional[SpeedDeleteResponse], speed, path=["response"])
-
- assert cast(Any, response.is_closed) is True
-
- @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_id` but received ''"):
- await async_client.speed.with_raw_response.delete(
- "example.com",
- zone_id="",
- )
-
- with pytest.raises(ValueError, match=r"Expected a non-empty value for `url` but received ''"):
- await async_client.speed.with_raw_response.delete(
- "",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- )
-
- @parametrize
- async def test_method_schedule_get(self, async_client: AsyncCloudflare) -> None:
- speed = await async_client.speed.schedule_get(
- "example.com",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- )
- assert_matches_type(Optional[Schedule], speed, path=["response"])
-
- @parametrize
- async def test_method_schedule_get_with_all_params(self, async_client: AsyncCloudflare) -> None:
- speed = await async_client.speed.schedule_get(
- "example.com",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- region="us-central1",
- )
- assert_matches_type(Optional[Schedule], speed, path=["response"])
-
- @parametrize
- async def test_raw_response_schedule_get(self, async_client: AsyncCloudflare) -> None:
- response = await async_client.speed.with_raw_response.schedule_get(
- "example.com",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- )
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- speed = await response.parse()
- assert_matches_type(Optional[Schedule], speed, path=["response"])
-
- @parametrize
- async def test_streaming_response_schedule_get(self, async_client: AsyncCloudflare) -> None:
- async with async_client.speed.with_streaming_response.schedule_get(
- "example.com",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- ) as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- speed = await response.parse()
- assert_matches_type(Optional[Schedule], speed, path=["response"])
-
- assert cast(Any, response.is_closed) is True
-
- @parametrize
- async def test_path_params_schedule_get(self, async_client: AsyncCloudflare) -> None:
- with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
- await async_client.speed.with_raw_response.schedule_get(
- "example.com",
- zone_id="",
- )
-
- with pytest.raises(ValueError, match=r"Expected a non-empty value for `url` but received ''"):
- await async_client.speed.with_raw_response.schedule_get(
- "",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- )
-
- @pytest.mark.skip(reason="TODO: investigate broken test")
- @parametrize
- async def test_method_trends_list(self, async_client: AsyncCloudflare) -> None:
- speed = await async_client.speed.trends_list(
- "example.com",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- device_type="DESKTOP",
- metrics="performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls",
- region="us-central1",
- start=parse_datetime("2014-01-01T05:20:00.12345Z"),
- tz="string",
- )
- assert_matches_type(Optional[Trend], speed, path=["response"])
-
- @pytest.mark.skip(reason="TODO: investigate broken test")
- @parametrize
- async def test_method_trends_list_with_all_params(self, async_client: AsyncCloudflare) -> None:
- speed = await async_client.speed.trends_list(
- "example.com",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- device_type="DESKTOP",
- metrics="performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls",
- region="us-central1",
- start=parse_datetime("2014-01-01T05:20:00.12345Z"),
- tz="string",
- end=parse_datetime("2014-01-01T05:20:00.12345Z"),
- )
- assert_matches_type(Optional[Trend], speed, path=["response"])
-
- @pytest.mark.skip(reason="TODO: investigate broken test")
- @parametrize
- async def test_raw_response_trends_list(self, async_client: AsyncCloudflare) -> None:
- response = await async_client.speed.with_raw_response.trends_list(
- "example.com",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- device_type="DESKTOP",
- metrics="performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls",
- region="us-central1",
- start=parse_datetime("2014-01-01T05:20:00.12345Z"),
- tz="string",
- )
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- speed = await response.parse()
- assert_matches_type(Optional[Trend], speed, path=["response"])
-
- @pytest.mark.skip(reason="TODO: investigate broken test")
- @parametrize
- async def test_streaming_response_trends_list(self, async_client: AsyncCloudflare) -> None:
- async with async_client.speed.with_streaming_response.trends_list(
- "example.com",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- device_type="DESKTOP",
- metrics="performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls",
- region="us-central1",
- start=parse_datetime("2014-01-01T05:20:00.12345Z"),
- tz="string",
- ) as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- speed = await response.parse()
- assert_matches_type(Optional[Trend], speed, path=["response"])
-
- assert cast(Any, response.is_closed) is True
-
- @pytest.mark.skip(reason="TODO: investigate broken test")
- @parametrize
- async def test_path_params_trends_list(self, async_client: AsyncCloudflare) -> None:
- with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
- await async_client.speed.with_raw_response.trends_list(
- "example.com",
- zone_id="",
- device_type="DESKTOP",
- metrics="performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls",
- region="us-central1",
- start=parse_datetime("2014-01-01T05:20:00.12345Z"),
- tz="string",
- )
-
- with pytest.raises(ValueError, match=r"Expected a non-empty value for `url` but received ''"):
- await async_client.speed.with_raw_response.trends_list(
- "",
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- device_type="DESKTOP",
- metrics="performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls",
- region="us-central1",
- start=parse_datetime("2014-01-01T05:20:00.12345Z"),
- tz="string",
- )