diff --git a/.stats.yml b/.stats.yml index 8e24892581e..da267080c99 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1565 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-27941e10b3625856a9a697f78b5a2c01e8d653d642cf5fa35a1ba8cac52974fa.yml +configured_endpoints: 1571 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-49794d21f9c5b1d528a53fc9c10d5d9de6eed9bd412a262d1cad78fa453be1b4.yml diff --git a/api.md b/api.md index 58371e76d1f..c92acbc286a 100644 --- a/api.md +++ b/api.md @@ -4693,22 +4693,13 @@ Methods: Types: ```python -from cloudflare.types.r2.buckets.domains import ( - CustomCreateResponse, - CustomUpdateResponse, - CustomListResponse, - CustomDeleteResponse, - CustomGetResponse, -) +from cloudflare.types.r2.buckets.domains import CustomCreateResponse, CustomListResponse ``` Methods: - client.r2.buckets.domains.custom.create(bucket_name, \*, account_id, \*\*params) -> CustomCreateResponse -- client.r2.buckets.domains.custom.update(domain_name, \*, account_id, bucket_name, \*\*params) -> CustomUpdateResponse - client.r2.buckets.domains.custom.list(bucket_name, \*, account_id) -> CustomListResponse -- client.r2.buckets.domains.custom.delete(domain_name, \*, account_id, bucket_name) -> CustomDeleteResponse -- client.r2.buckets.domains.custom.get(domain_name, \*, account_id, bucket_name) -> CustomGetResponse #### Managed @@ -8354,6 +8345,38 @@ Methods: # CloudforceOne +## Scans + +### Results + +Types: + +```python +from cloudflare.types.cloudforce_one.scans import ScanResult, ResultListResponse +``` + +Methods: + +- client.cloudforce_one.scans.results.list(\*, account_id) -> ResultListResponse + +### Config + +Types: + +```python +from cloudflare.types.cloudforce_one.scans import ( + ConfigCreateResponse, + ConfigListResponse, + ConfigDeleteResponse, +) +``` + +Methods: + +- client.cloudforce_one.scans.config.create(\*, account_id, \*\*params) -> Optional[ConfigCreateResponse] +- client.cloudforce_one.scans.config.list(\*, account_id) -> Optional[ConfigListResponse] +- client.cloudforce_one.scans.config.delete(\*, account_id) -> object + ## Requests Types: @@ -9003,3 +9026,59 @@ from cloudflare.types.security_center.insights import TypeGetResponse Methods: - client.security_center.insights.type.get(\*, account_id, zone_id, \*\*params) -> Optional[TypeGetResponse] + +# BrowserRendering + +## Content + +Types: + +```python +from cloudflare.types.browser_rendering import ContentCreateResponse +``` + +Methods: + +- client.browser_rendering.content.create(\*, account_id, \*\*params) -> str + +## PDF + +Methods: + +- client.browser_rendering.pdf.create(\*, account_id, \*\*params) -> BinaryAPIResponse + +## Scrape + +Types: + +```python +from cloudflare.types.browser_rendering import ScrapeCreateResponse +``` + +Methods: + +- client.browser_rendering.scrape.create(\*, account_id, \*\*params) -> ScrapeCreateResponse + +## Screenshot + +Types: + +```python +from cloudflare.types.browser_rendering import ScreenshotCreateResponse +``` + +Methods: + +- client.browser_rendering.screenshot.create(\*, account_id, \*\*params) -> ScreenshotCreateResponse + +## Snapshot + +Types: + +```python +from cloudflare.types.browser_rendering import SnapshotCreateResponse +``` + +Methods: + +- client.browser_rendering.snapshot.create(\*, account_id, \*\*params) -> Optional[SnapshotCreateResponse] diff --git a/src/cloudflare/_client.py b/src/cloudflare/_client.py index 751377aa1a7..23e31591b77 100644 --- a/src/cloudflare/_client.py +++ b/src/cloudflare/_client.py @@ -110,6 +110,7 @@ content_scanning, custom_hostnames, resource_sharing, + browser_rendering, mtls_certificates, url_normalization, custom_nameservers, @@ -210,6 +211,7 @@ from .resources.content_scanning.content_scanning import ContentScanningResource, AsyncContentScanningResource from .resources.custom_hostnames.custom_hostnames import CustomHostnamesResource, AsyncCustomHostnamesResource from .resources.resource_sharing.resource_sharing import ResourceSharingResource, AsyncResourceSharingResource + from .resources.browser_rendering.browser_rendering import BrowserRenderingResource, AsyncBrowserRenderingResource from .resources.mtls_certificates.mtls_certificates import MTLSCertificatesResource, AsyncMTLSCertificatesResource from .resources.custom_certificates.custom_certificates import ( CustomCertificatesResource, @@ -859,6 +861,12 @@ def security_center(self) -> SecurityCenterResource: return SecurityCenterResource(self) + @cached_property + def browser_rendering(self) -> BrowserRenderingResource: + from .resources.browser_rendering import BrowserRenderingResource + + return BrowserRenderingResource(self) + @cached_property def with_raw_response(self) -> CloudflareWithRawResponse: return CloudflareWithRawResponse(self) @@ -1648,6 +1656,12 @@ def security_center(self) -> AsyncSecurityCenterResource: return AsyncSecurityCenterResource(self) + @cached_property + def browser_rendering(self) -> AsyncBrowserRenderingResource: + from .resources.browser_rendering import AsyncBrowserRenderingResource + + return AsyncBrowserRenderingResource(self) + @cached_property def with_raw_response(self) -> AsyncCloudflareWithRawResponse: return AsyncCloudflareWithRawResponse(self) @@ -2372,6 +2386,12 @@ def security_center(self) -> security_center.SecurityCenterResourceWithRawRespon return SecurityCenterResourceWithRawResponse(self._client.security_center) + @cached_property + def browser_rendering(self) -> browser_rendering.BrowserRenderingResourceWithRawResponse: + from .resources.browser_rendering import BrowserRenderingResourceWithRawResponse + + return BrowserRenderingResourceWithRawResponse(self._client.browser_rendering) + class AsyncCloudflareWithRawResponse: _client: AsyncCloudflare @@ -2915,6 +2935,12 @@ def security_center(self) -> security_center.AsyncSecurityCenterResourceWithRawR return AsyncSecurityCenterResourceWithRawResponse(self._client.security_center) + @cached_property + def browser_rendering(self) -> browser_rendering.AsyncBrowserRenderingResourceWithRawResponse: + from .resources.browser_rendering import AsyncBrowserRenderingResourceWithRawResponse + + return AsyncBrowserRenderingResourceWithRawResponse(self._client.browser_rendering) + class CloudflareWithStreamedResponse: _client: Cloudflare @@ -3458,6 +3484,12 @@ def security_center(self) -> security_center.SecurityCenterResourceWithStreaming return SecurityCenterResourceWithStreamingResponse(self._client.security_center) + @cached_property + def browser_rendering(self) -> browser_rendering.BrowserRenderingResourceWithStreamingResponse: + from .resources.browser_rendering import BrowserRenderingResourceWithStreamingResponse + + return BrowserRenderingResourceWithStreamingResponse(self._client.browser_rendering) + class AsyncCloudflareWithStreamedResponse: _client: AsyncCloudflare @@ -4011,6 +4043,12 @@ def security_center(self) -> security_center.AsyncSecurityCenterResourceWithStre return AsyncSecurityCenterResourceWithStreamingResponse(self._client.security_center) + @cached_property + def browser_rendering(self) -> browser_rendering.AsyncBrowserRenderingResourceWithStreamingResponse: + from .resources.browser_rendering import AsyncBrowserRenderingResourceWithStreamingResponse + + return AsyncBrowserRenderingResourceWithStreamingResponse(self._client.browser_rendering) + Client = Cloudflare diff --git a/src/cloudflare/resources/browser_rendering/__init__.py b/src/cloudflare/resources/browser_rendering/__init__.py new file mode 100644 index 00000000000..d42a51797d4 --- /dev/null +++ b/src/cloudflare/resources/browser_rendering/__init__.py @@ -0,0 +1,89 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .pdf import ( + PDFResource, + AsyncPDFResource, + PDFResourceWithRawResponse, + AsyncPDFResourceWithRawResponse, + PDFResourceWithStreamingResponse, + AsyncPDFResourceWithStreamingResponse, +) +from .scrape import ( + ScrapeResource, + AsyncScrapeResource, + ScrapeResourceWithRawResponse, + AsyncScrapeResourceWithRawResponse, + ScrapeResourceWithStreamingResponse, + AsyncScrapeResourceWithStreamingResponse, +) +from .content import ( + ContentResource, + AsyncContentResource, + ContentResourceWithRawResponse, + AsyncContentResourceWithRawResponse, + ContentResourceWithStreamingResponse, + AsyncContentResourceWithStreamingResponse, +) +from .snapshot import ( + SnapshotResource, + AsyncSnapshotResource, + SnapshotResourceWithRawResponse, + AsyncSnapshotResourceWithRawResponse, + SnapshotResourceWithStreamingResponse, + AsyncSnapshotResourceWithStreamingResponse, +) +from .screenshot import ( + ScreenshotResource, + AsyncScreenshotResource, + ScreenshotResourceWithRawResponse, + AsyncScreenshotResourceWithRawResponse, + ScreenshotResourceWithStreamingResponse, + AsyncScreenshotResourceWithStreamingResponse, +) +from .browser_rendering import ( + BrowserRenderingResource, + AsyncBrowserRenderingResource, + BrowserRenderingResourceWithRawResponse, + AsyncBrowserRenderingResourceWithRawResponse, + BrowserRenderingResourceWithStreamingResponse, + AsyncBrowserRenderingResourceWithStreamingResponse, +) + +__all__ = [ + "ContentResource", + "AsyncContentResource", + "ContentResourceWithRawResponse", + "AsyncContentResourceWithRawResponse", + "ContentResourceWithStreamingResponse", + "AsyncContentResourceWithStreamingResponse", + "PDFResource", + "AsyncPDFResource", + "PDFResourceWithRawResponse", + "AsyncPDFResourceWithRawResponse", + "PDFResourceWithStreamingResponse", + "AsyncPDFResourceWithStreamingResponse", + "ScrapeResource", + "AsyncScrapeResource", + "ScrapeResourceWithRawResponse", + "AsyncScrapeResourceWithRawResponse", + "ScrapeResourceWithStreamingResponse", + "AsyncScrapeResourceWithStreamingResponse", + "ScreenshotResource", + "AsyncScreenshotResource", + "ScreenshotResourceWithRawResponse", + "AsyncScreenshotResourceWithRawResponse", + "ScreenshotResourceWithStreamingResponse", + "AsyncScreenshotResourceWithStreamingResponse", + "SnapshotResource", + "AsyncSnapshotResource", + "SnapshotResourceWithRawResponse", + "AsyncSnapshotResourceWithRawResponse", + "SnapshotResourceWithStreamingResponse", + "AsyncSnapshotResourceWithStreamingResponse", + "BrowserRenderingResource", + "AsyncBrowserRenderingResource", + "BrowserRenderingResourceWithRawResponse", + "AsyncBrowserRenderingResourceWithRawResponse", + "BrowserRenderingResourceWithStreamingResponse", + "AsyncBrowserRenderingResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/browser_rendering/browser_rendering.py b/src/cloudflare/resources/browser_rendering/browser_rendering.py new file mode 100644 index 00000000000..b597be3813f --- /dev/null +++ b/src/cloudflare/resources/browser_rendering/browser_rendering.py @@ -0,0 +1,230 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .pdf import ( + PDFResource, + AsyncPDFResource, + PDFResourceWithRawResponse, + AsyncPDFResourceWithRawResponse, + PDFResourceWithStreamingResponse, + AsyncPDFResourceWithStreamingResponse, +) +from .scrape import ( + ScrapeResource, + AsyncScrapeResource, + ScrapeResourceWithRawResponse, + AsyncScrapeResourceWithRawResponse, + ScrapeResourceWithStreamingResponse, + AsyncScrapeResourceWithStreamingResponse, +) +from .content import ( + ContentResource, + AsyncContentResource, + ContentResourceWithRawResponse, + AsyncContentResourceWithRawResponse, + ContentResourceWithStreamingResponse, + AsyncContentResourceWithStreamingResponse, +) +from .snapshot import ( + SnapshotResource, + AsyncSnapshotResource, + SnapshotResourceWithRawResponse, + AsyncSnapshotResourceWithRawResponse, + SnapshotResourceWithStreamingResponse, + AsyncSnapshotResourceWithStreamingResponse, +) +from ..._compat import cached_property +from .screenshot import ( + ScreenshotResource, + AsyncScreenshotResource, + ScreenshotResourceWithRawResponse, + AsyncScreenshotResourceWithRawResponse, + ScreenshotResourceWithStreamingResponse, + AsyncScreenshotResourceWithStreamingResponse, +) +from ..._resource import SyncAPIResource, AsyncAPIResource + +__all__ = ["BrowserRenderingResource", "AsyncBrowserRenderingResource"] + + +class BrowserRenderingResource(SyncAPIResource): + @cached_property + def content(self) -> ContentResource: + return ContentResource(self._client) + + @cached_property + def pdf(self) -> PDFResource: + return PDFResource(self._client) + + @cached_property + def scrape(self) -> ScrapeResource: + return ScrapeResource(self._client) + + @cached_property + def screenshot(self) -> ScreenshotResource: + return ScreenshotResource(self._client) + + @cached_property + def snapshot(self) -> SnapshotResource: + return SnapshotResource(self._client) + + @cached_property + def with_raw_response(self) -> BrowserRenderingResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return BrowserRenderingResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> BrowserRenderingResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return BrowserRenderingResourceWithStreamingResponse(self) + + +class AsyncBrowserRenderingResource(AsyncAPIResource): + @cached_property + def content(self) -> AsyncContentResource: + return AsyncContentResource(self._client) + + @cached_property + def pdf(self) -> AsyncPDFResource: + return AsyncPDFResource(self._client) + + @cached_property + def scrape(self) -> AsyncScrapeResource: + return AsyncScrapeResource(self._client) + + @cached_property + def screenshot(self) -> AsyncScreenshotResource: + return AsyncScreenshotResource(self._client) + + @cached_property + def snapshot(self) -> AsyncSnapshotResource: + return AsyncSnapshotResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncBrowserRenderingResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncBrowserRenderingResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncBrowserRenderingResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncBrowserRenderingResourceWithStreamingResponse(self) + + +class BrowserRenderingResourceWithRawResponse: + def __init__(self, browser_rendering: BrowserRenderingResource) -> None: + self._browser_rendering = browser_rendering + + @cached_property + def content(self) -> ContentResourceWithRawResponse: + return ContentResourceWithRawResponse(self._browser_rendering.content) + + @cached_property + def pdf(self) -> PDFResourceWithRawResponse: + return PDFResourceWithRawResponse(self._browser_rendering.pdf) + + @cached_property + def scrape(self) -> ScrapeResourceWithRawResponse: + return ScrapeResourceWithRawResponse(self._browser_rendering.scrape) + + @cached_property + def screenshot(self) -> ScreenshotResourceWithRawResponse: + return ScreenshotResourceWithRawResponse(self._browser_rendering.screenshot) + + @cached_property + def snapshot(self) -> SnapshotResourceWithRawResponse: + return SnapshotResourceWithRawResponse(self._browser_rendering.snapshot) + + +class AsyncBrowserRenderingResourceWithRawResponse: + def __init__(self, browser_rendering: AsyncBrowserRenderingResource) -> None: + self._browser_rendering = browser_rendering + + @cached_property + def content(self) -> AsyncContentResourceWithRawResponse: + return AsyncContentResourceWithRawResponse(self._browser_rendering.content) + + @cached_property + def pdf(self) -> AsyncPDFResourceWithRawResponse: + return AsyncPDFResourceWithRawResponse(self._browser_rendering.pdf) + + @cached_property + def scrape(self) -> AsyncScrapeResourceWithRawResponse: + return AsyncScrapeResourceWithRawResponse(self._browser_rendering.scrape) + + @cached_property + def screenshot(self) -> AsyncScreenshotResourceWithRawResponse: + return AsyncScreenshotResourceWithRawResponse(self._browser_rendering.screenshot) + + @cached_property + def snapshot(self) -> AsyncSnapshotResourceWithRawResponse: + return AsyncSnapshotResourceWithRawResponse(self._browser_rendering.snapshot) + + +class BrowserRenderingResourceWithStreamingResponse: + def __init__(self, browser_rendering: BrowserRenderingResource) -> None: + self._browser_rendering = browser_rendering + + @cached_property + def content(self) -> ContentResourceWithStreamingResponse: + return ContentResourceWithStreamingResponse(self._browser_rendering.content) + + @cached_property + def pdf(self) -> PDFResourceWithStreamingResponse: + return PDFResourceWithStreamingResponse(self._browser_rendering.pdf) + + @cached_property + def scrape(self) -> ScrapeResourceWithStreamingResponse: + return ScrapeResourceWithStreamingResponse(self._browser_rendering.scrape) + + @cached_property + def screenshot(self) -> ScreenshotResourceWithStreamingResponse: + return ScreenshotResourceWithStreamingResponse(self._browser_rendering.screenshot) + + @cached_property + def snapshot(self) -> SnapshotResourceWithStreamingResponse: + return SnapshotResourceWithStreamingResponse(self._browser_rendering.snapshot) + + +class AsyncBrowserRenderingResourceWithStreamingResponse: + def __init__(self, browser_rendering: AsyncBrowserRenderingResource) -> None: + self._browser_rendering = browser_rendering + + @cached_property + def content(self) -> AsyncContentResourceWithStreamingResponse: + return AsyncContentResourceWithStreamingResponse(self._browser_rendering.content) + + @cached_property + def pdf(self) -> AsyncPDFResourceWithStreamingResponse: + return AsyncPDFResourceWithStreamingResponse(self._browser_rendering.pdf) + + @cached_property + def scrape(self) -> AsyncScrapeResourceWithStreamingResponse: + return AsyncScrapeResourceWithStreamingResponse(self._browser_rendering.scrape) + + @cached_property + def screenshot(self) -> AsyncScreenshotResourceWithStreamingResponse: + return AsyncScreenshotResourceWithStreamingResponse(self._browser_rendering.screenshot) + + @cached_property + def snapshot(self) -> AsyncSnapshotResourceWithStreamingResponse: + return AsyncSnapshotResourceWithStreamingResponse(self._browser_rendering.snapshot) diff --git a/src/cloudflare/resources/browser_rendering/content.py b/src/cloudflare/resources/browser_rendering/content.py new file mode 100644 index 00000000000..45a438dcb8f --- /dev/null +++ b/src/cloudflare/resources/browser_rendering/content.py @@ -0,0 +1,442 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, List, Type, Iterable, Optional, cast +from typing_extensions import Literal + +import httpx + +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._utils import ( + maybe_transform, + async_maybe_transform, +) +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ..._base_client import make_request_options +from ...types.browser_rendering import content_create_params +from ...types.browser_rendering.content_create_response import ContentCreateResponse + +__all__ = ["ContentResource", "AsyncContentResource"] + + +class ContentResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ContentResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return ContentResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ContentResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return ContentResourceWithStreamingResponse(self) + + def create( + self, + *, + account_id: str, + cache_ttl: float | NotGiven = NOT_GIVEN, + add_script_tag: Iterable[content_create_params.AddScriptTag] | NotGiven = NOT_GIVEN, + add_style_tag: Iterable[content_create_params.AddStyleTag] | NotGiven = NOT_GIVEN, + allow_request_pattern: List[str] | NotGiven = NOT_GIVEN, + allow_resource_types: List[ + Literal[ + "document", + "stylesheet", + "image", + "media", + "font", + "script", + "texttrack", + "xhr", + "fetch", + "prefetch", + "eventsource", + "websocket", + "manifest", + "signedexchange", + "ping", + "cspviolationreport", + "preflight", + "other", + ] + ] + | NotGiven = NOT_GIVEN, + authenticate: content_create_params.Authenticate | NotGiven = NOT_GIVEN, + best_attempt: bool | NotGiven = NOT_GIVEN, + cookies: Iterable[content_create_params.Cookie] | NotGiven = NOT_GIVEN, + emulate_media_type: str | NotGiven = NOT_GIVEN, + goto_options: content_create_params.GotoOptions | NotGiven = NOT_GIVEN, + html: str | NotGiven = NOT_GIVEN, + reject_request_pattern: List[str] | NotGiven = NOT_GIVEN, + reject_resource_types: List[ + Literal[ + "document", + "stylesheet", + "image", + "media", + "font", + "script", + "texttrack", + "xhr", + "fetch", + "prefetch", + "eventsource", + "websocket", + "manifest", + "signedexchange", + "ping", + "cspviolationreport", + "preflight", + "other", + ] + ] + | NotGiven = NOT_GIVEN, + set_extra_http_headers: Dict[str, str] | NotGiven = NOT_GIVEN, + set_java_script_enabled: bool | NotGiven = NOT_GIVEN, + url: str | NotGiven = NOT_GIVEN, + user_agent: str | NotGiven = NOT_GIVEN, + viewport: content_create_params.Viewport | NotGiven = NOT_GIVEN, + wait_for_selector: content_create_params.WaitForSelector | NotGiven = NOT_GIVEN, + wait_for_timeout: float | 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, + ) -> str: + """Fetches rendered HTML content from provided URL or HTML. + + Check available options + like `gotoOptions` and `waitFor*` to control page load behaviour. + + Args: + account_id: Account ID. + + cache_ttl: Cache TTL default is 5s. Set to 0 to disable. + + add_script_tag: Adds a `