# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from typing import Dict, List, Type, Iterable, 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 json_create_params from ...types.browser_rendering.json_create_response import JsonCreateResponse __all__ = ["JsonResource", "AsyncJsonResource"] class JsonResource(SyncAPIResource): @cached_property def with_raw_response(self) -> JsonResourceWithRawResponse: """ 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 JsonResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> JsonResourceWithStreamingResponse: """ 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 JsonResourceWithStreamingResponse(self) def create( self, *, account_id: str, cache_ttl: float | NotGiven = NOT_GIVEN, action_timeout: float | NotGiven = NOT_GIVEN, add_script_tag: Iterable[json_create_params.AddScriptTag] | NotGiven = NOT_GIVEN, add_style_tag: Iterable[json_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: json_create_params.Authenticate | NotGiven = NOT_GIVEN, best_attempt: bool | NotGiven = NOT_GIVEN, cookies: Iterable[json_create_params.Cookie] | NotGiven = NOT_GIVEN, emulate_media_type: str | NotGiven = NOT_GIVEN, goto_options: json_create_params.GotoOptions | NotGiven = NOT_GIVEN, html: str | NotGiven = NOT_GIVEN, prompt: 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, response_format: json_create_params.ResponseFormat | 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: json_create_params.Viewport | NotGiven = NOT_GIVEN, wait_for_selector: json_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, ) -> JsonCreateResponse: """Gets json from a webpage from a provided URL or HTML. Pass `prompt` or `schema` in the body. Control page loading with `gotoOptions` and `waitFor*` options. Args: account_id: Account ID. cache_ttl: Cache TTL default is 5s. Set to 0 to disable. action_timeout: The maximum duration allowed for the browser action to complete after the page has loaded (such as taking screenshots, extracting content, or generating PDFs). If this time limit is exceeded, the action stops and returns a timeout error. add_script_tag: Adds a `