diff --git a/.stats.yml b/.stats.yml index 025f3a2867d..e80bdcaedd5 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,4 @@ -configured_endpoints: 1655 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0ed9f898b31619623e50d660d04beca50e44987bfd3eb3a6ff98d3bca2a9c569.yml +configured_endpoints: 1681 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ebd614e2846013ff79e8f66c43b84b968723b58d84ca042c8f9b51c4918c3c1c.yml +openapi_spec_hash: af577a5ccd99c2a220e4e214da0b36f0 +config_hash: 5f546b68dc187cd0f2fea2d9ae061b3b diff --git a/api.md b/api.md index 50bdbfeb44b..445c8f29721 100644 --- a/api.md +++ b/api.md @@ -985,18 +985,13 @@ Methods: Types: ```python -from cloudflare.types.custom_nameservers import ( - CustomNameserver, - CustomNameserverDeleteResponse, - CustomNameserverAvailabiltyResponse, -) +from cloudflare.types.custom_nameservers import CustomNameserver, CustomNameserverDeleteResponse ``` Methods: - client.custom_nameservers.create(\*, account_id, \*\*params) -> Optional[CustomNameserver] - client.custom_nameservers.delete(custom_ns_id, \*, account_id) -> SyncSinglePage[CustomNameserverDeleteResponse] -- client.custom_nameservers.availabilty(\*, account_id) -> SyncSinglePage[CustomNameserverAvailabiltyResponse] - client.custom_nameservers.get(\*, account_id) -> SyncSinglePage[CustomNameserver] # DNSFirewall @@ -2115,7 +2110,7 @@ Methods: Types: ```python -from cloudflare.types.rate_limits import Action, Methods, RateLimit, RateLimitDeleteResponse +from cloudflare.types.rate_limits import Action, RateLimit, RateLimitDeleteResponse ``` Methods: @@ -2479,6 +2474,22 @@ Methods: - client.workers.scripts.secrets.delete(secret_name, \*, account_id, script_name) -> object - client.workers.scripts.secrets.get(secret_name, \*, account_id, script_name) -> Optional[SecretGetResponse] +### ScriptAndVersionSettings + +Types: + +```python +from cloudflare.types.workers.scripts import ( + ScriptAndVersionSettingEditResponse, + ScriptAndVersionSettingGetResponse, +) +``` + +Methods: + +- client.workers.scripts.script_and_version_settings.edit(script_name, \*, account_id, \*\*params) -> Optional[ScriptAndVersionSettingEditResponse] +- client.workers.scripts.script_and_version_settings.get(script_name, \*, account_id) -> Optional[ScriptAndVersionSettingGetResponse] + ## AccountSettings Types: @@ -2527,13 +2538,7 @@ Methods: Types: ```python -from cloudflare.types.kv import ( - Namespace, - NamespaceUpdateResponse, - NamespaceDeleteResponse, - NamespaceBulkDeleteResponse, - NamespaceBulkUpdateResponse, -) +from cloudflare.types.kv import Namespace, NamespaceUpdateResponse, NamespaceDeleteResponse ``` Methods: @@ -2542,34 +2547,27 @@ Methods: - client.kv.namespaces.update(namespace_id, \*, account_id, \*\*params) -> Optional[NamespaceUpdateResponse] - client.kv.namespaces.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Namespace] - client.kv.namespaces.delete(namespace_id, \*, account_id) -> Optional[NamespaceDeleteResponse] -- client.kv.namespaces.bulk_delete(namespace_id, \*, account_id, \*\*params) -> Optional[NamespaceBulkDeleteResponse] -- client.kv.namespaces.bulk_update(namespace_id, \*, account_id, \*\*params) -> Optional[NamespaceBulkUpdateResponse] - client.kv.namespaces.get(namespace_id, \*, account_id) -> Optional[Namespace] -### Analytics - -Types: - -```python -from cloudflare.types.kv.namespaces import Components, Schema -``` - -Methods: - -- client.kv.namespaces.analytics.list(\*, account_id, \*\*params) -> Optional[Schema] -- client.kv.namespaces.analytics.stored(\*, account_id, \*\*params) -> Optional[Components] - ### Keys Types: ```python -from cloudflare.types.kv.namespaces import Key +from cloudflare.types.kv.namespaces import ( + Key, + KeyBulkDeleteResponse, + KeyBulkGetResponse, + KeyBulkUpdateResponse, +) ``` Methods: - client.kv.namespaces.keys.list(namespace_id, \*, account_id, \*\*params) -> SyncCursorLimitPagination[Key] +- client.kv.namespaces.keys.bulk_delete(namespace_id, \*, account_id, \*\*params) -> Optional[KeyBulkDeleteResponse] +- client.kv.namespaces.keys.bulk_get(namespace_id, \*, account_id, \*\*params) -> Optional[KeyBulkGetResponse] +- client.kv.namespaces.keys.bulk_update(namespace_id, \*, account_id, \*\*params) -> Optional[KeyBulkUpdateResponse] ### Metadata @@ -2637,6 +2635,7 @@ Methods: - client.queues.update(queue_id, \*, account_id, \*\*params) -> Optional[Queue] - client.queues.list(\*, account_id) -> SyncSinglePage[Queue] - client.queues.delete(queue_id, \*, account_id) -> QueueDeleteResponse +- client.queues.edit(queue_id, \*, account_id, \*\*params) -> Optional[Queue] - client.queues.get(queue_id, \*, account_id) -> Optional[Queue] ## Consumers @@ -2667,6 +2666,19 @@ Methods: - client.queues.messages.ack(queue_id, \*, account_id, \*\*params) -> Optional[MessageAckResponse] - client.queues.messages.pull(queue_id, \*, account_id, \*\*params) -> SyncSinglePage[MessagePullResponse] +## Purge + +Types: + +```python +from cloudflare.types.queues import PurgeStatusResponse +``` + +Methods: + +- client.queues.purge.start(queue_id, \*, account_id, \*\*params) -> Optional[Queue] +- client.queues.purge.status(queue_id, \*, account_id) -> Optional[PurgeStatusResponse] + # APIGateway ## Configurations @@ -4969,6 +4981,64 @@ Methods: - client.r2.temporary_credentials.create(\*, account_id, \*\*params) -> TemporaryCredentialCreateResponse +## SuperSlurper + +### Jobs + +Types: + +```python +from cloudflare.types.r2.super_slurper import ( + JobCreateResponse, + JobListResponse, + JobAbortResponse, + JobAbortAllResponse, + JobGetResponse, + JobPauseResponse, + JobProgressResponse, + JobResumeResponse, +) +``` + +Methods: + +- client.r2.super_slurper.jobs.create(\*, account_id, \*\*params) -> Optional[JobCreateResponse] +- client.r2.super_slurper.jobs.list(\*, account_id, \*\*params) -> SyncSinglePage[JobListResponse] +- client.r2.super_slurper.jobs.abort(job_id, \*, account_id) -> str +- client.r2.super_slurper.jobs.abort_all(\*, account_id) -> str +- client.r2.super_slurper.jobs.get(job_id, \*, account_id) -> Optional[JobGetResponse] +- client.r2.super_slurper.jobs.pause(job_id, \*, account_id) -> str +- client.r2.super_slurper.jobs.progress(job_id, \*, account_id) -> Optional[JobProgressResponse] +- client.r2.super_slurper.jobs.resume(job_id, \*, account_id) -> str + +#### Logs + +Types: + +```python +from cloudflare.types.r2.super_slurper.jobs import LogListResponse +``` + +Methods: + +- client.r2.super_slurper.jobs.logs.list(job_id, \*, account_id, \*\*params) -> SyncSinglePage[LogListResponse] + +### ConnectivityPrecheck + +Types: + +```python +from cloudflare.types.r2.super_slurper import ( + ConnectivityPrecheckSourceResponse, + ConnectivityPrecheckTargetResponse, +) +``` + +Methods: + +- client.r2.super_slurper.connectivity_precheck.source(\*, account_id, \*\*params) -> Optional[ConnectivityPrecheckSourceResponse] +- client.r2.super_slurper.connectivity_precheck.target(\*, account_id, \*\*params) -> Optional[ConnectivityPrecheckTargetResponse] + # WorkersForPlatforms ## Dispatch @@ -5109,6 +5179,24 @@ Methods: - client.zero_trust.devices.list(\*, account_id) -> SyncSinglePage[Device] - client.zero_trust.devices.get(device_id, \*, account_id) -> Optional[DeviceGetResponse] +### Resilience + +#### GlobalWARPOverride + +Types: + +```python +from cloudflare.types.zero_trust.devices.resilience import ( + GlobalWARPOverrideCreateResponse, + GlobalWARPOverrideGetResponse, +) +``` + +Methods: + +- client.zero_trust.devices.resilience.global_warp_override.create(\*, account_id, \*\*params) -> Optional[GlobalWARPOverrideCreateResponse] +- client.zero_trust.devices.resilience.global_warp_override.get(\*, account_id) -> Optional[GlobalWARPOverrideGetResponse] + ### DEXTests Types: @@ -6951,6 +7039,18 @@ Methods: ## AI +### ToMarkdown + +Types: + +```python +from cloudflare.types.radar.ai import ToMarkdownCreateResponse +``` + +Methods: + +- client.radar.ai.to_markdown.create(\*, account_id, \*\*params) -> SyncSinglePage[ToMarkdownCreateResponse] + ### Inference #### Summary @@ -7109,6 +7209,7 @@ from cloudflare.types.radar.bgp import ( RouteAsesResponse, RouteMoasResponse, RoutePfx2asResponse, + RouteRealtimeResponse, RouteStatsResponse, ) ``` @@ -7118,6 +7219,7 @@ Methods: - client.radar.bgp.routes.ases(\*\*params) -> RouteAsesResponse - client.radar.bgp.routes.moas(\*\*params) -> RouteMoasResponse - client.radar.bgp.routes.pfx2as(\*\*params) -> RoutePfx2asResponse +- client.radar.bgp.routes.realtime(\*\*params) -> RouteRealtimeResponse - client.radar.bgp.routes.stats(\*\*params) -> RouteStatsResponse ### IPs @@ -7560,9 +7662,11 @@ Types: from cloudflare.types.radar.attacks.layer3 import ( SummaryBitrateResponse, SummaryDurationResponse, + SummaryIndustryResponse, SummaryIPVersionResponse, SummaryProtocolResponse, SummaryVectorResponse, + SummaryVerticalResponse, ) ``` @@ -7570,9 +7674,11 @@ Methods: - client.radar.attacks.layer3.summary.bitrate(\*\*params) -> SummaryBitrateResponse - client.radar.attacks.layer3.summary.duration(\*\*params) -> SummaryDurationResponse +- client.radar.attacks.layer3.summary.industry(\*\*params) -> SummaryIndustryResponse - client.radar.attacks.layer3.summary.ip_version(\*\*params) -> SummaryIPVersionResponse - client.radar.attacks.layer3.summary.protocol(\*\*params) -> SummaryProtocolResponse - client.radar.attacks.layer3.summary.vector(\*\*params) -> SummaryVectorResponse +- client.radar.attacks.layer3.summary.vertical(\*\*params) -> SummaryVerticalResponse #### TimeseriesGroups @@ -7651,9 +7757,11 @@ Types: from cloudflare.types.radar.attacks.layer7 import ( SummaryHTTPMethodResponse, SummaryHTTPVersionResponse, + SummaryIndustryResponse, SummaryIPVersionResponse, SummaryManagedRulesResponse, SummaryMitigationProductResponse, + SummaryVerticalResponse, ) ``` @@ -7661,9 +7769,11 @@ Methods: - client.radar.attacks.layer7.summary.http_method(\*\*params) -> SummaryHTTPMethodResponse - client.radar.attacks.layer7.summary.http_version(\*\*params) -> SummaryHTTPVersionResponse +- client.radar.attacks.layer7.summary.industry(\*\*params) -> SummaryIndustryResponse - client.radar.attacks.layer7.summary.ip_version(\*\*params) -> SummaryIPVersionResponse - client.radar.attacks.layer7.summary.managed_rules(\*\*params) -> SummaryManagedRulesResponse - client.radar.attacks.layer7.summary.mitigation_product(\*\*params) -> SummaryMitigationProductResponse +- client.radar.attacks.layer7.summary.vertical(\*\*params) -> SummaryVerticalResponse #### TimeseriesGroups @@ -9145,6 +9255,18 @@ Methods: - client.workflows.instances.status.edit(instance_id, \*, account_id, workflow_name, \*\*params) -> StatusEditResponse +### Events + +Types: + +```python +from cloudflare.types.workflows.instances import EventCreateResponse +``` + +Methods: + +- client.workflows.instances.events.create(event_type, \*, account_id, workflow_name, instance_id, \*\*params) -> object + ## Versions Types: @@ -9520,6 +9642,42 @@ Methods: - client.browser_rendering.snapshot.create(\*, account_id, \*\*params) -> Optional[SnapshotCreateResponse] +## Json + +Types: + +```python +from cloudflare.types.browser_rendering import JsonCreateResponse +``` + +Methods: + +- client.browser_rendering.json.create(\*, account_id, \*\*params) -> JsonCreateResponse + +## Links + +Types: + +```python +from cloudflare.types.browser_rendering import LinkCreateResponse +``` + +Methods: + +- client.browser_rendering.links.create(\*, account_id, \*\*params) -> LinkCreateResponse + +## Markdown + +Types: + +```python +from cloudflare.types.browser_rendering import MarkdownCreateResponse +``` + +Methods: + +- client.browser_rendering.markdown.create(\*, account_id, \*\*params) -> str + # CustomPages Types: diff --git a/src/cloudflare/_base_client.py b/src/cloudflare/_base_client.py index 649c86dfde8..0fb2eb6f87d 100644 --- a/src/cloudflare/_base_client.py +++ b/src/cloudflare/_base_client.py @@ -54,11 +54,13 @@ PostParser, RequestFiles, HttpxSendArgs, + HttpxFileTypes, RequestOptions, + MultipartSyntax, HttpxRequestFiles, ModelBuilderProtocol, ) -from ._utils import is_dict, is_list, asyncify, is_given, lru_cache, is_mapping +from ._utils import is_dict, is_list, asyncify, is_given, is_tuple, lru_cache, is_mapping, is_mapping_t, is_sequence_t from ._compat import PYDANTIC_V2, model_copy, model_dump from ._models import GenericModel, FinalRequestOptions, validate_type, construct_type from ._response import ( @@ -484,7 +486,24 @@ def _build_request( raise TypeError( f"Expected query input to be a dictionary for multipart requests but got {type(json_data)} instead." ) - kwargs["data"] = self._serialize_multipartform(json_data) + + if options.multipart_syntax == 'json': + json_data = cast("Mapping[str, object]", json_data) + if is_mapping_t(files): + files = { + **files, + **self._serialize_multiapartform_json(json_data), + } + elif is_sequence_t(files): + files = [ + *files, + *self._serialize_multiapartform_json(json_data).items(), + ] + else: + assert not files, "this case should only be hit when there are no files" + files = self._serialize_multiapartform_json(json_data) + else: + kwargs["data"] = self._serialize_multipartform(json_data) # httpx determines whether or not to send a "multipart/form-data" # request based on the truthiness of the "files" argument. @@ -516,6 +535,22 @@ def _build_request( **kwargs, ) + def _serialize_multiapartform_json(self, data: Mapping[str, object]) -> dict[str, HttpxFileTypes]: + serialized: dict[str, HttpxFileTypes] = {} + for key, value in data.items(): + if isinstance(value, Mapping) or is_list(value) or is_tuple(value): + serialized[key] = (None, json.dumps(value).encode("utf-8"), "application/json") + else: + serialized[key] = ( + None, + self.qs._primitive_value_to_str( + value # type: ignore + ).encode("utf-8"), + "text/plain", + ) + + return serialized + def _serialize_multipartform(self, data: Mapping[object, object]) -> dict[str, object]: items = self.qs.stringify_items( # TODO: type ignore is required as stringify_items is well typed but we can't be @@ -1794,6 +1829,7 @@ def make_request_options( idempotency_key: str | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, post_parser: PostParser | NotGiven = NOT_GIVEN, + multipart_syntax: MultipartSyntax | None = None, ) -> RequestOptions: """Create a dict of type RequestOptions without keys of NotGiven values.""" options: RequestOptions = {} @@ -1819,6 +1855,9 @@ def make_request_options( # internal options["post_parser"] = post_parser # type: ignore + if multipart_syntax is not None: + options["multipart_syntax"] = multipart_syntax + return options diff --git a/src/cloudflare/_models.py b/src/cloudflare/_models.py index b51a1bf5f94..8b5d2648486 100644 --- a/src/cloudflare/_models.py +++ b/src/cloudflare/_models.py @@ -31,6 +31,7 @@ Timeout, NotGiven, AnyMapping, + MultipartSyntax, HttpxRequestFiles, ) from ._utils import ( @@ -681,7 +682,7 @@ def set_pydantic_config(typ: Any, config: pydantic.ConfigDict) -> None: setattr(typ, "__pydantic_config__", config) # noqa: B010 -# our use of subclasssing here causes weirdness for type checkers, +# our use of subclassing here causes weirdness for type checkers, # so we just pretend that we don't subclass if TYPE_CHECKING: GenericModel = BaseModel @@ -738,6 +739,7 @@ class FinalRequestOptionsInput(TypedDict, total=False): idempotency_key: str json_data: Body extra_json: AnyMapping + multipart_syntax: MultipartSyntax @final @@ -750,6 +752,7 @@ class FinalRequestOptions(pydantic.BaseModel): timeout: Union[float, Timeout, None, NotGiven] = NotGiven() files: Union[HttpxRequestFiles, None] = None idempotency_key: Union[str, None] = None + multipart_syntax: Union[MultipartSyntax, None] = None post_parser: Union[Callable[[Any], Any], NotGiven] = NotGiven() # It should be noted that we cannot use `json` here as that would override diff --git a/src/cloudflare/_types.py b/src/cloudflare/_types.py index 0d42772c5b6..81cd5757e17 100644 --- a/src/cloudflare/_types.py +++ b/src/cloudflare/_types.py @@ -71,6 +71,8 @@ ] HttpxRequestFiles = Union[Mapping[str, HttpxFileTypes], Sequence[Tuple[str, HttpxFileTypes]]] +MultipartSyntax = Literal["query", "json"] + # Workaround to support (cast_to: Type[ResponseT]) -> ResponseT # where ResponseT includes `None`. In order to support directly # passing `None`, overloads would have to be defined for every @@ -100,6 +102,7 @@ class RequestOptions(TypedDict, total=False): params: Query extra_json: AnyMapping idempotency_key: str + multipart_syntax: MultipartSyntax # Sentinel class used until PEP 0661 is accepted diff --git a/src/cloudflare/_utils/_transform.py b/src/cloudflare/_utils/_transform.py index 18afd9d8bd5..7ac2e17fbbd 100644 --- a/src/cloudflare/_utils/_transform.py +++ b/src/cloudflare/_utils/_transform.py @@ -126,7 +126,7 @@ def _get_annotated_type(type_: type) -> type | None: def _maybe_transform_key(key: str, type_: type) -> str: """Transform the given `data` based on the annotations provided in `type_`. - Note: this function only looks at `Annotated` types that contain `PropertInfo` metadata. + Note: this function only looks at `Annotated` types that contain `PropertyInfo` metadata. """ annotated_type = _get_annotated_type(type_) if annotated_type is None: diff --git a/src/cloudflare/resources/abuse_reports.py b/src/cloudflare/resources/abuse_reports.py index 09f63ae53af..76ee29e3266 100644 --- a/src/cloudflare/resources/abuse_reports.py +++ b/src/cloudflare/resources/abuse_reports.py @@ -95,6 +95,8 @@ def create( ncmec_notification: Literal["send", "send-anon", "none"] | NotGiven = NOT_GIVEN, ncsei_subject_representation: bool | NotGiven = NOT_GIVEN, ports_protocols: str | NotGiven = NOT_GIVEN, + reported_country: str | NotGiven = NOT_GIVEN, + reported_user_agent: str | NotGiven = NOT_GIVEN, source_ips: str | NotGiven = NOT_GIVEN, tele: str | NotGiven = NOT_GIVEN, title: str | NotGiven = NOT_GIVEN, @@ -179,6 +181,10 @@ def create( port/protocol should not exceed 100 characters. The list should not have more than 30 unique ports and protocols. + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + source_ips: A list of IP addresses separated by ‘ ’ (new line character). The list of source IPs should not exceed 30 IP addresses. Each one of the IP addresses ought to be unique @@ -256,6 +262,8 @@ def create( ncsei_subject_representation: bool | NotGiven = NOT_GIVEN, original_work: str | NotGiven = NOT_GIVEN, ports_protocols: str | NotGiven = NOT_GIVEN, + reported_country: str | NotGiven = NOT_GIVEN, + reported_user_agent: str | NotGiven = NOT_GIVEN, signature: str | NotGiven = NOT_GIVEN, source_ips: str | NotGiven = NOT_GIVEN, state: str | NotGiven = NOT_GIVEN, @@ -338,6 +346,10 @@ def create( port/protocol should not exceed 100 characters. The list should not have more than 30 unique ports and protocols. + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + signature: Required for DMCA reports, should be same as Name. An affirmation that all information in the report is true and accurate while agreeing to the policies of Cloudflare's abuse reports @@ -413,6 +425,8 @@ def create( ncsei_subject_representation: bool | NotGiven = NOT_GIVEN, original_work: str | NotGiven = NOT_GIVEN, ports_protocols: str | NotGiven = NOT_GIVEN, + reported_country: str | NotGiven = NOT_GIVEN, + reported_user_agent: str | NotGiven = NOT_GIVEN, signature: str | NotGiven = NOT_GIVEN, source_ips: str | NotGiven = NOT_GIVEN, state: str | NotGiven = NOT_GIVEN, @@ -492,6 +506,10 @@ def create( port/protocol should not exceed 100 characters. The list should not have more than 30 unique ports and protocols. + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + signature: Required for DMCA reports, should be same as Name. An affirmation that all information in the report is true and accurate while agreeing to the policies of Cloudflare's abuse reports @@ -573,6 +591,8 @@ def create( ncsei_subject_representation: bool | NotGiven = NOT_GIVEN, original_work: str | NotGiven = NOT_GIVEN, ports_protocols: str | NotGiven = NOT_GIVEN, + reported_country: str | NotGiven = NOT_GIVEN, + reported_user_agent: str | NotGiven = NOT_GIVEN, signature: str | NotGiven = NOT_GIVEN, source_ips: str | NotGiven = NOT_GIVEN, state: str | NotGiven = NOT_GIVEN, @@ -652,6 +672,10 @@ def create( port/protocol should not exceed 100 characters. The list should not have more than 30 unique ports and protocols. + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + signature: Required for DMCA reports, should be same as Name. An affirmation that all information in the report is true and accurate while agreeing to the policies of Cloudflare's abuse reports @@ -733,6 +757,8 @@ def create( ncsei_subject_representation: bool | NotGiven = NOT_GIVEN, original_work: str | NotGiven = NOT_GIVEN, ports_protocols: str | NotGiven = NOT_GIVEN, + reported_country: str | NotGiven = NOT_GIVEN, + reported_user_agent: str | NotGiven = NOT_GIVEN, signature: str | NotGiven = NOT_GIVEN, source_ips: str | NotGiven = NOT_GIVEN, state: str | NotGiven = NOT_GIVEN, @@ -812,6 +838,10 @@ def create( port/protocol should not exceed 100 characters. The list should not have more than 30 unique ports and protocols. + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + signature: Required for DMCA reports, should be same as Name. An affirmation that all information in the report is true and accurate while agreeing to the policies of Cloudflare's abuse reports @@ -893,6 +923,8 @@ def create( ncsei_subject_representation: bool | NotGiven = NOT_GIVEN, original_work: str | NotGiven = NOT_GIVEN, ports_protocols: str | NotGiven = NOT_GIVEN, + reported_country: str | NotGiven = NOT_GIVEN, + reported_user_agent: str | NotGiven = NOT_GIVEN, signature: str | NotGiven = NOT_GIVEN, source_ips: str | NotGiven = NOT_GIVEN, state: str | NotGiven = NOT_GIVEN, @@ -972,6 +1004,10 @@ def create( port/protocol should not exceed 100 characters. The list should not have more than 30 unique ports and protocols. + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + signature: Required for DMCA reports, should be same as Name. An affirmation that all information in the report is true and accurate while agreeing to the policies of Cloudflare's abuse reports @@ -1053,6 +1089,8 @@ def create( ncsei_subject_representation: bool | NotGiven = NOT_GIVEN, original_work: str | NotGiven = NOT_GIVEN, ports_protocols: str | NotGiven = NOT_GIVEN, + reported_country: str | NotGiven = NOT_GIVEN, + reported_user_agent: str | NotGiven = NOT_GIVEN, signature: str | NotGiven = NOT_GIVEN, source_ips: str | NotGiven = NOT_GIVEN, state: str | NotGiven = NOT_GIVEN, @@ -1132,6 +1170,10 @@ def create( port/protocol should not exceed 100 characters. The list should not have more than 30 unique ports and protocols. + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + signature: Required for DMCA reports, should be same as Name. An affirmation that all information in the report is true and accurate while agreeing to the policies of Cloudflare's abuse reports @@ -1213,6 +1255,8 @@ def create( ncmec_notification: Literal["send", "send-anon", "none"] | NotGiven = NOT_GIVEN, original_work: str | NotGiven = NOT_GIVEN, ports_protocols: str | NotGiven = NOT_GIVEN, + reported_country: str | NotGiven = NOT_GIVEN, + reported_user_agent: str | NotGiven = NOT_GIVEN, signature: str | NotGiven = NOT_GIVEN, source_ips: str | NotGiven = NOT_GIVEN, state: str | NotGiven = NOT_GIVEN, @@ -1292,6 +1336,10 @@ def create( port/protocol should not exceed 100 characters. The list should not have more than 30 unique ports and protocols. + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + signature: Required for DMCA reports, should be same as Name. An affirmation that all information in the report is true and accurate while agreeing to the policies of Cloudflare's abuse reports @@ -1402,6 +1450,8 @@ def create( ncmec_notification: Literal["send", "send-anon", "none"] | NotGiven = NOT_GIVEN, ncsei_subject_representation: bool | NotGiven = NOT_GIVEN, ports_protocols: str | NotGiven = NOT_GIVEN, + reported_country: str | NotGiven = NOT_GIVEN, + reported_user_agent: str | NotGiven = NOT_GIVEN, source_ips: str | NotGiven = NOT_GIVEN, tele: str | NotGiven = NOT_GIVEN, title: str | NotGiven = NOT_GIVEN, @@ -1445,6 +1495,8 @@ def create( "ncmec_notification": ncmec_notification, "ncsei_subject_representation": ncsei_subject_representation, "ports_protocols": ports_protocols, + "reported_country": reported_country, + "reported_user_agent": reported_user_agent, "source_ips": source_ips, "tele": tele, "title": title, @@ -1532,6 +1584,8 @@ async def create( ncmec_notification: Literal["send", "send-anon", "none"] | NotGiven = NOT_GIVEN, ncsei_subject_representation: bool | NotGiven = NOT_GIVEN, ports_protocols: str | NotGiven = NOT_GIVEN, + reported_country: str | NotGiven = NOT_GIVEN, + reported_user_agent: str | NotGiven = NOT_GIVEN, source_ips: str | NotGiven = NOT_GIVEN, tele: str | NotGiven = NOT_GIVEN, title: str | NotGiven = NOT_GIVEN, @@ -1616,6 +1670,10 @@ async def create( port/protocol should not exceed 100 characters. The list should not have more than 30 unique ports and protocols. + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + source_ips: A list of IP addresses separated by ‘ ’ (new line character). The list of source IPs should not exceed 30 IP addresses. Each one of the IP addresses ought to be unique @@ -1693,6 +1751,8 @@ async def create( ncsei_subject_representation: bool | NotGiven = NOT_GIVEN, original_work: str | NotGiven = NOT_GIVEN, ports_protocols: str | NotGiven = NOT_GIVEN, + reported_country: str | NotGiven = NOT_GIVEN, + reported_user_agent: str | NotGiven = NOT_GIVEN, signature: str | NotGiven = NOT_GIVEN, source_ips: str | NotGiven = NOT_GIVEN, state: str | NotGiven = NOT_GIVEN, @@ -1775,6 +1835,10 @@ async def create( port/protocol should not exceed 100 characters. The list should not have more than 30 unique ports and protocols. + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + signature: Required for DMCA reports, should be same as Name. An affirmation that all information in the report is true and accurate while agreeing to the policies of Cloudflare's abuse reports @@ -1850,6 +1914,8 @@ async def create( ncsei_subject_representation: bool | NotGiven = NOT_GIVEN, original_work: str | NotGiven = NOT_GIVEN, ports_protocols: str | NotGiven = NOT_GIVEN, + reported_country: str | NotGiven = NOT_GIVEN, + reported_user_agent: str | NotGiven = NOT_GIVEN, signature: str | NotGiven = NOT_GIVEN, source_ips: str | NotGiven = NOT_GIVEN, state: str | NotGiven = NOT_GIVEN, @@ -1929,6 +1995,10 @@ async def create( port/protocol should not exceed 100 characters. The list should not have more than 30 unique ports and protocols. + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + signature: Required for DMCA reports, should be same as Name. An affirmation that all information in the report is true and accurate while agreeing to the policies of Cloudflare's abuse reports @@ -2010,6 +2080,8 @@ async def create( ncsei_subject_representation: bool | NotGiven = NOT_GIVEN, original_work: str | NotGiven = NOT_GIVEN, ports_protocols: str | NotGiven = NOT_GIVEN, + reported_country: str | NotGiven = NOT_GIVEN, + reported_user_agent: str | NotGiven = NOT_GIVEN, signature: str | NotGiven = NOT_GIVEN, source_ips: str | NotGiven = NOT_GIVEN, state: str | NotGiven = NOT_GIVEN, @@ -2089,6 +2161,10 @@ async def create( port/protocol should not exceed 100 characters. The list should not have more than 30 unique ports and protocols. + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + signature: Required for DMCA reports, should be same as Name. An affirmation that all information in the report is true and accurate while agreeing to the policies of Cloudflare's abuse reports @@ -2170,6 +2246,8 @@ async def create( ncsei_subject_representation: bool | NotGiven = NOT_GIVEN, original_work: str | NotGiven = NOT_GIVEN, ports_protocols: str | NotGiven = NOT_GIVEN, + reported_country: str | NotGiven = NOT_GIVEN, + reported_user_agent: str | NotGiven = NOT_GIVEN, signature: str | NotGiven = NOT_GIVEN, source_ips: str | NotGiven = NOT_GIVEN, state: str | NotGiven = NOT_GIVEN, @@ -2249,6 +2327,10 @@ async def create( port/protocol should not exceed 100 characters. The list should not have more than 30 unique ports and protocols. + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + signature: Required for DMCA reports, should be same as Name. An affirmation that all information in the report is true and accurate while agreeing to the policies of Cloudflare's abuse reports @@ -2330,6 +2412,8 @@ async def create( ncsei_subject_representation: bool | NotGiven = NOT_GIVEN, original_work: str | NotGiven = NOT_GIVEN, ports_protocols: str | NotGiven = NOT_GIVEN, + reported_country: str | NotGiven = NOT_GIVEN, + reported_user_agent: str | NotGiven = NOT_GIVEN, signature: str | NotGiven = NOT_GIVEN, source_ips: str | NotGiven = NOT_GIVEN, state: str | NotGiven = NOT_GIVEN, @@ -2409,6 +2493,10 @@ async def create( port/protocol should not exceed 100 characters. The list should not have more than 30 unique ports and protocols. + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + signature: Required for DMCA reports, should be same as Name. An affirmation that all information in the report is true and accurate while agreeing to the policies of Cloudflare's abuse reports @@ -2490,6 +2578,8 @@ async def create( ncsei_subject_representation: bool | NotGiven = NOT_GIVEN, original_work: str | NotGiven = NOT_GIVEN, ports_protocols: str | NotGiven = NOT_GIVEN, + reported_country: str | NotGiven = NOT_GIVEN, + reported_user_agent: str | NotGiven = NOT_GIVEN, signature: str | NotGiven = NOT_GIVEN, source_ips: str | NotGiven = NOT_GIVEN, state: str | NotGiven = NOT_GIVEN, @@ -2569,6 +2659,10 @@ async def create( port/protocol should not exceed 100 characters. The list should not have more than 30 unique ports and protocols. + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + signature: Required for DMCA reports, should be same as Name. An affirmation that all information in the report is true and accurate while agreeing to the policies of Cloudflare's abuse reports @@ -2650,6 +2744,8 @@ async def create( ncmec_notification: Literal["send", "send-anon", "none"] | NotGiven = NOT_GIVEN, original_work: str | NotGiven = NOT_GIVEN, ports_protocols: str | NotGiven = NOT_GIVEN, + reported_country: str | NotGiven = NOT_GIVEN, + reported_user_agent: str | NotGiven = NOT_GIVEN, signature: str | NotGiven = NOT_GIVEN, source_ips: str | NotGiven = NOT_GIVEN, state: str | NotGiven = NOT_GIVEN, @@ -2729,6 +2825,10 @@ async def create( port/protocol should not exceed 100 characters. The list should not have more than 30 unique ports and protocols. + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + signature: Required for DMCA reports, should be same as Name. An affirmation that all information in the report is true and accurate while agreeing to the policies of Cloudflare's abuse reports @@ -2839,6 +2939,8 @@ async def create( ncmec_notification: Literal["send", "send-anon", "none"] | NotGiven = NOT_GIVEN, ncsei_subject_representation: bool | NotGiven = NOT_GIVEN, ports_protocols: str | NotGiven = NOT_GIVEN, + reported_country: str | NotGiven = NOT_GIVEN, + reported_user_agent: str | NotGiven = NOT_GIVEN, source_ips: str | NotGiven = NOT_GIVEN, tele: str | NotGiven = NOT_GIVEN, title: str | NotGiven = NOT_GIVEN, @@ -2882,6 +2984,8 @@ async def create( "ncmec_notification": ncmec_notification, "ncsei_subject_representation": ncsei_subject_representation, "ports_protocols": ports_protocols, + "reported_country": reported_country, + "reported_user_agent": reported_user_agent, "source_ips": source_ips, "tele": tele, "title": title, diff --git a/src/cloudflare/resources/addressing/prefixes/service_bindings.py b/src/cloudflare/resources/addressing/prefixes/service_bindings.py index 053cdd351c4..cdcd528951e 100644 --- a/src/cloudflare/resources/addressing/prefixes/service_bindings.py +++ b/src/cloudflare/resources/addressing/prefixes/service_bindings.py @@ -66,8 +66,9 @@ def create( """ Creates a new Service Binding, routing traffic to IPs within the given CIDR to a service running on Cloudflare's network. **Note:** This API may only be used on - prefixes currently configured with a Magic Transit service binding, and only - allows creating service bindings for the Cloudflare CDN or Cloudflare Spectrum. + prefixes currently configured with a Magic Transit/Cloudflare CDN/Cloudflare + Spectrum service binding, and only allows creating upgrade service bindings for + the Cloudflare CDN or Cloudflare Spectrum. Args: account_id: Identifier of a Cloudflare account. @@ -289,8 +290,9 @@ async def create( """ Creates a new Service Binding, routing traffic to IPs within the given CIDR to a service running on Cloudflare's network. **Note:** This API may only be used on - prefixes currently configured with a Magic Transit service binding, and only - allows creating service bindings for the Cloudflare CDN or Cloudflare Spectrum. + prefixes currently configured with a Magic Transit/Cloudflare CDN/Cloudflare + Spectrum service binding, and only allows creating upgrade service bindings for + the Cloudflare CDN or Cloudflare Spectrum. Args: account_id: Identifier of a Cloudflare account. diff --git a/src/cloudflare/resources/ai/ai.py b/src/cloudflare/resources/ai/ai.py index bbc218bb3ab..a69623d3eba 100644 --- a/src/cloudflare/resources/ai/ai.py +++ b/src/cloudflare/resources/ai/ai.py @@ -234,7 +234,7 @@ def run( [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). Args: - prompt: A text description of the image you want to generate + prompt: A text description of the audio you want to generate lang: The speech language (e.g., 'en' for English, 'fr' for French). Defaults to 'en' if not specified @@ -501,6 +501,7 @@ def run( functions: Iterable[ai_run_params.MessagesFunction] | NotGiven = NOT_GIVEN, max_tokens: int | NotGiven = NOT_GIVEN, presence_penalty: float | NotGiven = NOT_GIVEN, + raw: bool | NotGiven = NOT_GIVEN, repetition_penalty: float | NotGiven = NOT_GIVEN, response_format: ai_run_params.MessagesResponseFormat | NotGiven = NOT_GIVEN, seed: int | NotGiven = NOT_GIVEN, @@ -536,11 +537,15 @@ def run( presence_penalty: Increases the likelihood of the model introducing new topics. + raw: If true, a chat template is not applied and you must adhere to the specific + model's expected formatting. + repetition_penalty: Penalty for repeated tokens; higher values discourage repetition. seed: Random seed for reproducibility of the generation. - stream: If true, the response will be streamed back incrementally. + stream: If true, the response will be streamed back incrementally using SSE, Server Sent + Events. temperature: Controls the randomness of the output; higher values produce more random results. @@ -551,7 +556,7 @@ def run( responses more focused; higher values introduce more variety and potential surprises. - top_p: Controls the creativity of the AI's responses by adjusting how many possible + top_p: Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. @@ -726,6 +731,154 @@ def run( """ ... + @overload + def run( + self, + model_name: str, + *, + account_id: str, + image: str, + prompt: str, + frequency_penalty: float | NotGiven = NOT_GIVEN, + ignore_eos: bool | NotGiven = NOT_GIVEN, + max_tokens: int | NotGiven = NOT_GIVEN, + presence_penalty: float | NotGiven = NOT_GIVEN, + repetition_penalty: float | NotGiven = NOT_GIVEN, + seed: float | NotGiven = NOT_GIVEN, + temperature: float | NotGiven = NOT_GIVEN, + top_k: float | NotGiven = NOT_GIVEN, + top_p: 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, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + image: Image in base64 encoded format. + + prompt: The input text prompt for the model to generate a response. + + frequency_penalty: Decreases the likelihood of the model repeating the same lines verbatim. + + ignore_eos: Whether to ignore the EOS token and continue generating tokens after the EOS + token is generated. + + max_tokens: The maximum number of tokens to generate in the response. + + presence_penalty: Increases the likelihood of the model introducing new topics. + + repetition_penalty: Penalty for repeated tokens; higher values discourage repetition. + + seed: Random seed for reproducibility of the generation. + + temperature: Controls the randomness of the output; higher values produce more random + results. + + top_k: Limits the AI to choose from the top 'k' most probable words. Lower values make + responses more focused; higher values introduce more variety and potential + surprises. + + top_p: Controls the creativity of the AI's responses by adjusting how many possible + words it considers. Lower values make outputs more predictable; higher values + allow for more varied and creative responses. + + 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 + """ + ... + + @overload + def run( + self, + model_name: str, + *, + account_id: str, + image: str, + messages: Iterable[ai_run_params.Variant13Message], + frequency_penalty: float | NotGiven = NOT_GIVEN, + ignore_eos: bool | NotGiven = NOT_GIVEN, + max_tokens: int | NotGiven = NOT_GIVEN, + presence_penalty: float | NotGiven = NOT_GIVEN, + repetition_penalty: float | NotGiven = NOT_GIVEN, + seed: float | NotGiven = NOT_GIVEN, + temperature: float | NotGiven = NOT_GIVEN, + top_k: float | NotGiven = NOT_GIVEN, + top_p: 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, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + image: Image in base64 encoded format. + + messages: An array of message objects representing the conversation history. + + frequency_penalty: Decreases the likelihood of the model repeating the same lines verbatim. + + ignore_eos: Whether to ignore the EOS token and continue generating tokens after the EOS + token is generated. + + max_tokens: The maximum number of tokens to generate in the response. + + presence_penalty: Increases the likelihood of the model introducing new topics. + + repetition_penalty: Penalty for repeated tokens; higher values discourage repetition. + + seed: Random seed for reproducibility of the generation. + + temperature: Controls the randomness of the output; higher values produce more random + results. + + top_k: Limits the AI to choose from the top 'k' most probable words. Lower values make + responses more focused; higher values introduce more variety and potential + surprises. + + top_p: Controls the creativity of the AI's responses by adjusting how many possible + words it considers. Lower values make outputs more predictable; higher values + allow for more varied and creative responses. + + 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 + """ + ... + @required_args( ["account_id", "text"], ["account_id", "prompt"], @@ -735,6 +888,8 @@ def run( ["account_id", "messages"], ["account_id", "target_lang", "text"], ["account_id", "input_text"], + ["account_id", "image", "prompt"], + ["account_id", "image", "messages"], ) def run( self, @@ -745,7 +900,7 @@ def run( prompt: str | NotGiven = NOT_GIVEN, guidance: float | NotGiven = NOT_GIVEN, height: int | NotGiven = NOT_GIVEN, - image: Iterable[float] | NotGiven = NOT_GIVEN, + image: Iterable[float] | str | NotGiven = NOT_GIVEN, image_b64: str | NotGiven = NOT_GIVEN, mask: Iterable[float] | NotGiven = NOT_GIVEN, negative_prompt: str | NotGiven = NOT_GIVEN, @@ -773,6 +928,7 @@ def run( tools: Iterable[ai_run_params.MessagesTool] | NotGiven = NOT_GIVEN, input_text: str | NotGiven = NOT_GIVEN, max_length: int | NotGiven = NOT_GIVEN, + ignore_eos: bool | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -822,6 +978,7 @@ def run( "tools": tools, "input_text": input_text, "max_length": max_length, + "ignore_eos": ignore_eos, }, ai_run_params.AIRunParams, ), @@ -1012,7 +1169,7 @@ async def run( [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). Args: - prompt: A text description of the image you want to generate + prompt: A text description of the audio you want to generate lang: The speech language (e.g., 'en' for English, 'fr' for French). Defaults to 'en' if not specified @@ -1279,6 +1436,7 @@ async def run( functions: Iterable[ai_run_params.MessagesFunction] | NotGiven = NOT_GIVEN, max_tokens: int | NotGiven = NOT_GIVEN, presence_penalty: float | NotGiven = NOT_GIVEN, + raw: bool | NotGiven = NOT_GIVEN, repetition_penalty: float | NotGiven = NOT_GIVEN, response_format: ai_run_params.MessagesResponseFormat | NotGiven = NOT_GIVEN, seed: int | NotGiven = NOT_GIVEN, @@ -1314,11 +1472,15 @@ async def run( presence_penalty: Increases the likelihood of the model introducing new topics. + raw: If true, a chat template is not applied and you must adhere to the specific + model's expected formatting. + repetition_penalty: Penalty for repeated tokens; higher values discourage repetition. seed: Random seed for reproducibility of the generation. - stream: If true, the response will be streamed back incrementally. + stream: If true, the response will be streamed back incrementally using SSE, Server Sent + Events. temperature: Controls the randomness of the output; higher values produce more random results. @@ -1329,7 +1491,7 @@ async def run( responses more focused; higher values introduce more variety and potential surprises. - top_p: Controls the creativity of the AI's responses by adjusting how many possible + top_p: Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. @@ -1504,6 +1666,154 @@ async def run( """ ... + @overload + async def run( + self, + model_name: str, + *, + account_id: str, + image: str, + prompt: str, + frequency_penalty: float | NotGiven = NOT_GIVEN, + ignore_eos: bool | NotGiven = NOT_GIVEN, + max_tokens: int | NotGiven = NOT_GIVEN, + presence_penalty: float | NotGiven = NOT_GIVEN, + repetition_penalty: float | NotGiven = NOT_GIVEN, + seed: float | NotGiven = NOT_GIVEN, + temperature: float | NotGiven = NOT_GIVEN, + top_k: float | NotGiven = NOT_GIVEN, + top_p: 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, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + image: Image in base64 encoded format. + + prompt: The input text prompt for the model to generate a response. + + frequency_penalty: Decreases the likelihood of the model repeating the same lines verbatim. + + ignore_eos: Whether to ignore the EOS token and continue generating tokens after the EOS + token is generated. + + max_tokens: The maximum number of tokens to generate in the response. + + presence_penalty: Increases the likelihood of the model introducing new topics. + + repetition_penalty: Penalty for repeated tokens; higher values discourage repetition. + + seed: Random seed for reproducibility of the generation. + + temperature: Controls the randomness of the output; higher values produce more random + results. + + top_k: Limits the AI to choose from the top 'k' most probable words. Lower values make + responses more focused; higher values introduce more variety and potential + surprises. + + top_p: Controls the creativity of the AI's responses by adjusting how many possible + words it considers. Lower values make outputs more predictable; higher values + allow for more varied and creative responses. + + 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 + """ + ... + + @overload + async def run( + self, + model_name: str, + *, + account_id: str, + image: str, + messages: Iterable[ai_run_params.Variant13Message], + frequency_penalty: float | NotGiven = NOT_GIVEN, + ignore_eos: bool | NotGiven = NOT_GIVEN, + max_tokens: int | NotGiven = NOT_GIVEN, + presence_penalty: float | NotGiven = NOT_GIVEN, + repetition_penalty: float | NotGiven = NOT_GIVEN, + seed: float | NotGiven = NOT_GIVEN, + temperature: float | NotGiven = NOT_GIVEN, + top_k: float | NotGiven = NOT_GIVEN, + top_p: 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, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + image: Image in base64 encoded format. + + messages: An array of message objects representing the conversation history. + + frequency_penalty: Decreases the likelihood of the model repeating the same lines verbatim. + + ignore_eos: Whether to ignore the EOS token and continue generating tokens after the EOS + token is generated. + + max_tokens: The maximum number of tokens to generate in the response. + + presence_penalty: Increases the likelihood of the model introducing new topics. + + repetition_penalty: Penalty for repeated tokens; higher values discourage repetition. + + seed: Random seed for reproducibility of the generation. + + temperature: Controls the randomness of the output; higher values produce more random + results. + + top_k: Limits the AI to choose from the top 'k' most probable words. Lower values make + responses more focused; higher values introduce more variety and potential + surprises. + + top_p: Controls the creativity of the AI's responses by adjusting how many possible + words it considers. Lower values make outputs more predictable; higher values + allow for more varied and creative responses. + + 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 + """ + ... + @required_args( ["account_id", "text"], ["account_id", "prompt"], @@ -1513,6 +1823,8 @@ async def run( ["account_id", "messages"], ["account_id", "target_lang", "text"], ["account_id", "input_text"], + ["account_id", "image", "prompt"], + ["account_id", "image", "messages"], ) async def run( self, @@ -1523,7 +1835,7 @@ async def run( prompt: str | NotGiven = NOT_GIVEN, guidance: float | NotGiven = NOT_GIVEN, height: int | NotGiven = NOT_GIVEN, - image: Iterable[float] | NotGiven = NOT_GIVEN, + image: Iterable[float] | str | NotGiven = NOT_GIVEN, image_b64: str | NotGiven = NOT_GIVEN, mask: Iterable[float] | NotGiven = NOT_GIVEN, negative_prompt: str | NotGiven = NOT_GIVEN, @@ -1551,6 +1863,7 @@ async def run( tools: Iterable[ai_run_params.MessagesTool] | NotGiven = NOT_GIVEN, input_text: str | NotGiven = NOT_GIVEN, max_length: int | NotGiven = NOT_GIVEN, + ignore_eos: bool | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -1600,6 +1913,7 @@ async def run( "tools": tools, "input_text": input_text, "max_length": max_length, + "ignore_eos": ignore_eos, }, ai_run_params.AIRunParams, ), diff --git a/src/cloudflare/resources/api_gateway/discovery/operations.py b/src/cloudflare/resources/api_gateway/discovery/operations.py index f7a8556479a..c2b1d48523b 100644 --- a/src/cloudflare/resources/api_gateway/discovery/operations.py +++ b/src/cloudflare/resources/api_gateway/discovery/operations.py @@ -62,7 +62,7 @@ def list( method: List[str] | NotGiven = NOT_GIVEN, order: Literal["host", "method", "endpoint", "traffic_stats.requests", "traffic_stats.last_updated"] | NotGiven = NOT_GIVEN, - origin: Literal["ML", "SessionIdentifier"] | NotGiven = NOT_GIVEN, + origin: Literal["ML", "SessionIdentifier", "LabelDiscovery"] | NotGiven = NOT_GIVEN, page: int | NotGiven = NOT_GIVEN, per_page: int | NotGiven = NOT_GIVEN, state: Literal["review", "saved", "ignored"] | NotGiven = NOT_GIVEN, @@ -273,7 +273,7 @@ def list( method: List[str] | NotGiven = NOT_GIVEN, order: Literal["host", "method", "endpoint", "traffic_stats.requests", "traffic_stats.last_updated"] | NotGiven = NOT_GIVEN, - origin: Literal["ML", "SessionIdentifier"] | NotGiven = NOT_GIVEN, + origin: Literal["ML", "SessionIdentifier", "LabelDiscovery"] | NotGiven = NOT_GIVEN, page: int | NotGiven = NOT_GIVEN, per_page: int | NotGiven = NOT_GIVEN, state: Literal["review", "saved", "ignored"] | NotGiven = NOT_GIVEN, diff --git a/src/cloudflare/resources/bot_management.py b/src/cloudflare/resources/bot_management.py index f9875019fe6..afb17b3d06b 100644 --- a/src/cloudflare/resources/bot_management.py +++ b/src/cloudflare/resources/bot_management.py @@ -56,6 +56,7 @@ def update( *, zone_id: str, ai_bots_protection: Literal["block", "disabled"] | NotGiven = NOT_GIVEN, + crawler_protection: Literal["enabled", "disabled"] | NotGiven = NOT_GIVEN, enable_js: bool | NotGiven = NOT_GIVEN, fight_mode: bool | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -133,6 +134,8 @@ def update( ai_bots_protection: Enable rule to block AI Scrapers and Crawlers. + crawler_protection: Enable rule to punish AI Scrapers and Crawlers via a link maze. + enable_js: Use lightweight, invisible JavaScript detections to improve Bot Management. [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). @@ -154,6 +157,7 @@ def update( *, zone_id: str, ai_bots_protection: Literal["block", "disabled"] | NotGiven = NOT_GIVEN, + crawler_protection: Literal["enabled", "disabled"] | NotGiven = NOT_GIVEN, enable_js: bool | NotGiven = NOT_GIVEN, optimize_wordpress: bool | NotGiven = NOT_GIVEN, sbfm_definitely_automated: Literal["allow", "block", "managed_challenge"] | NotGiven = NOT_GIVEN, @@ -234,6 +238,8 @@ def update( ai_bots_protection: Enable rule to block AI Scrapers and Crawlers. + crawler_protection: Enable rule to punish AI Scrapers and Crawlers via a link maze. + enable_js: Use lightweight, invisible JavaScript detections to improve Bot Management. [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). @@ -263,6 +269,7 @@ def update( *, zone_id: str, ai_bots_protection: Literal["block", "disabled"] | NotGiven = NOT_GIVEN, + crawler_protection: Literal["enabled", "disabled"] | NotGiven = NOT_GIVEN, enable_js: bool | NotGiven = NOT_GIVEN, optimize_wordpress: bool | NotGiven = NOT_GIVEN, sbfm_definitely_automated: Literal["allow", "block", "managed_challenge"] | NotGiven = NOT_GIVEN, @@ -344,6 +351,8 @@ def update( ai_bots_protection: Enable rule to block AI Scrapers and Crawlers. + crawler_protection: Enable rule to punish AI Scrapers and Crawlers via a link maze. + enable_js: Use lightweight, invisible JavaScript detections to improve Bot Management. [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). @@ -376,6 +385,7 @@ def update( zone_id: str, ai_bots_protection: Literal["block", "disabled"] | NotGiven = NOT_GIVEN, auto_update_model: bool | NotGiven = NOT_GIVEN, + crawler_protection: Literal["enabled", "disabled"] | NotGiven = NOT_GIVEN, enable_js: bool | NotGiven = NOT_GIVEN, suppress_session_score: bool | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -457,6 +467,8 @@ def update( they are released. [Learn more.](https://developers.cloudflare.com/bots/reference/machine-learning-models#model-versions-and-release-notes) + crawler_protection: Enable rule to punish AI Scrapers and Crawlers via a link maze. + enable_js: Use lightweight, invisible JavaScript detections to improve Bot Management. [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). @@ -479,6 +491,7 @@ def update( *, zone_id: str, ai_bots_protection: Literal["block", "disabled"] | NotGiven = NOT_GIVEN, + crawler_protection: Literal["enabled", "disabled"] | NotGiven = NOT_GIVEN, enable_js: bool | NotGiven = NOT_GIVEN, fight_mode: bool | NotGiven = NOT_GIVEN, optimize_wordpress: bool | NotGiven = NOT_GIVEN, @@ -504,6 +517,7 @@ def update( body=maybe_transform( { "ai_bots_protection": ai_bots_protection, + "crawler_protection": crawler_protection, "enable_js": enable_js, "fight_mode": fight_mode, "optimize_wordpress": optimize_wordpress, @@ -600,6 +614,7 @@ async def update( *, zone_id: str, ai_bots_protection: Literal["block", "disabled"] | NotGiven = NOT_GIVEN, + crawler_protection: Literal["enabled", "disabled"] | NotGiven = NOT_GIVEN, enable_js: bool | NotGiven = NOT_GIVEN, fight_mode: bool | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -677,6 +692,8 @@ async def update( ai_bots_protection: Enable rule to block AI Scrapers and Crawlers. + crawler_protection: Enable rule to punish AI Scrapers and Crawlers via a link maze. + enable_js: Use lightweight, invisible JavaScript detections to improve Bot Management. [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). @@ -698,6 +715,7 @@ async def update( *, zone_id: str, ai_bots_protection: Literal["block", "disabled"] | NotGiven = NOT_GIVEN, + crawler_protection: Literal["enabled", "disabled"] | NotGiven = NOT_GIVEN, enable_js: bool | NotGiven = NOT_GIVEN, optimize_wordpress: bool | NotGiven = NOT_GIVEN, sbfm_definitely_automated: Literal["allow", "block", "managed_challenge"] | NotGiven = NOT_GIVEN, @@ -778,6 +796,8 @@ async def update( ai_bots_protection: Enable rule to block AI Scrapers and Crawlers. + crawler_protection: Enable rule to punish AI Scrapers and Crawlers via a link maze. + enable_js: Use lightweight, invisible JavaScript detections to improve Bot Management. [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). @@ -807,6 +827,7 @@ async def update( *, zone_id: str, ai_bots_protection: Literal["block", "disabled"] | NotGiven = NOT_GIVEN, + crawler_protection: Literal["enabled", "disabled"] | NotGiven = NOT_GIVEN, enable_js: bool | NotGiven = NOT_GIVEN, optimize_wordpress: bool | NotGiven = NOT_GIVEN, sbfm_definitely_automated: Literal["allow", "block", "managed_challenge"] | NotGiven = NOT_GIVEN, @@ -888,6 +909,8 @@ async def update( ai_bots_protection: Enable rule to block AI Scrapers and Crawlers. + crawler_protection: Enable rule to punish AI Scrapers and Crawlers via a link maze. + enable_js: Use lightweight, invisible JavaScript detections to improve Bot Management. [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). @@ -920,6 +943,7 @@ async def update( zone_id: str, ai_bots_protection: Literal["block", "disabled"] | NotGiven = NOT_GIVEN, auto_update_model: bool | NotGiven = NOT_GIVEN, + crawler_protection: Literal["enabled", "disabled"] | NotGiven = NOT_GIVEN, enable_js: bool | NotGiven = NOT_GIVEN, suppress_session_score: bool | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -1001,6 +1025,8 @@ async def update( they are released. [Learn more.](https://developers.cloudflare.com/bots/reference/machine-learning-models#model-versions-and-release-notes) + crawler_protection: Enable rule to punish AI Scrapers and Crawlers via a link maze. + enable_js: Use lightweight, invisible JavaScript detections to improve Bot Management. [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). @@ -1023,6 +1049,7 @@ async def update( *, zone_id: str, ai_bots_protection: Literal["block", "disabled"] | NotGiven = NOT_GIVEN, + crawler_protection: Literal["enabled", "disabled"] | NotGiven = NOT_GIVEN, enable_js: bool | NotGiven = NOT_GIVEN, fight_mode: bool | NotGiven = NOT_GIVEN, optimize_wordpress: bool | NotGiven = NOT_GIVEN, @@ -1048,6 +1075,7 @@ async def update( body=await async_maybe_transform( { "ai_bots_protection": ai_bots_protection, + "crawler_protection": crawler_protection, "enable_js": enable_js, "fight_mode": fight_mode, "optimize_wordpress": optimize_wordpress, diff --git a/src/cloudflare/resources/browser_rendering/__init__.py b/src/cloudflare/resources/browser_rendering/__init__.py index d42a51797d4..ca6102ced41 100644 --- a/src/cloudflare/resources/browser_rendering/__init__.py +++ b/src/cloudflare/resources/browser_rendering/__init__.py @@ -8,6 +8,22 @@ PDFResourceWithStreamingResponse, AsyncPDFResourceWithStreamingResponse, ) +from .json import ( + JsonResource, + AsyncJsonResource, + JsonResourceWithRawResponse, + AsyncJsonResourceWithRawResponse, + JsonResourceWithStreamingResponse, + AsyncJsonResourceWithStreamingResponse, +) +from .links import ( + LinksResource, + AsyncLinksResource, + LinksResourceWithRawResponse, + AsyncLinksResourceWithRawResponse, + LinksResourceWithStreamingResponse, + AsyncLinksResourceWithStreamingResponse, +) from .scrape import ( ScrapeResource, AsyncScrapeResource, @@ -24,6 +40,14 @@ ContentResourceWithStreamingResponse, AsyncContentResourceWithStreamingResponse, ) +from .markdown import ( + MarkdownResource, + AsyncMarkdownResource, + MarkdownResourceWithRawResponse, + AsyncMarkdownResourceWithRawResponse, + MarkdownResourceWithStreamingResponse, + AsyncMarkdownResourceWithStreamingResponse, +) from .snapshot import ( SnapshotResource, AsyncSnapshotResource, @@ -80,6 +104,24 @@ "AsyncSnapshotResourceWithRawResponse", "SnapshotResourceWithStreamingResponse", "AsyncSnapshotResourceWithStreamingResponse", + "JsonResource", + "AsyncJsonResource", + "JsonResourceWithRawResponse", + "AsyncJsonResourceWithRawResponse", + "JsonResourceWithStreamingResponse", + "AsyncJsonResourceWithStreamingResponse", + "LinksResource", + "AsyncLinksResource", + "LinksResourceWithRawResponse", + "AsyncLinksResourceWithRawResponse", + "LinksResourceWithStreamingResponse", + "AsyncLinksResourceWithStreamingResponse", + "MarkdownResource", + "AsyncMarkdownResource", + "MarkdownResourceWithRawResponse", + "AsyncMarkdownResourceWithRawResponse", + "MarkdownResourceWithStreamingResponse", + "AsyncMarkdownResourceWithStreamingResponse", "BrowserRenderingResource", "AsyncBrowserRenderingResource", "BrowserRenderingResourceWithRawResponse", diff --git a/src/cloudflare/resources/browser_rendering/browser_rendering.py b/src/cloudflare/resources/browser_rendering/browser_rendering.py index b597be3813f..bee931f57df 100644 --- a/src/cloudflare/resources/browser_rendering/browser_rendering.py +++ b/src/cloudflare/resources/browser_rendering/browser_rendering.py @@ -10,6 +10,22 @@ PDFResourceWithStreamingResponse, AsyncPDFResourceWithStreamingResponse, ) +from .json import ( + JsonResource, + AsyncJsonResource, + JsonResourceWithRawResponse, + AsyncJsonResourceWithRawResponse, + JsonResourceWithStreamingResponse, + AsyncJsonResourceWithStreamingResponse, +) +from .links import ( + LinksResource, + AsyncLinksResource, + LinksResourceWithRawResponse, + AsyncLinksResourceWithRawResponse, + LinksResourceWithStreamingResponse, + AsyncLinksResourceWithStreamingResponse, +) from .scrape import ( ScrapeResource, AsyncScrapeResource, @@ -26,6 +42,14 @@ ContentResourceWithStreamingResponse, AsyncContentResourceWithStreamingResponse, ) +from .markdown import ( + MarkdownResource, + AsyncMarkdownResource, + MarkdownResourceWithRawResponse, + AsyncMarkdownResourceWithRawResponse, + MarkdownResourceWithStreamingResponse, + AsyncMarkdownResourceWithStreamingResponse, +) from .snapshot import ( SnapshotResource, AsyncSnapshotResource, @@ -69,6 +93,18 @@ def screenshot(self) -> ScreenshotResource: def snapshot(self) -> SnapshotResource: return SnapshotResource(self._client) + @cached_property + def json(self) -> JsonResource: + return JsonResource(self._client) + + @cached_property + def links(self) -> LinksResource: + return LinksResource(self._client) + + @cached_property + def markdown(self) -> MarkdownResource: + return MarkdownResource(self._client) + @cached_property def with_raw_response(self) -> BrowserRenderingResourceWithRawResponse: """ @@ -110,6 +146,18 @@ def screenshot(self) -> AsyncScreenshotResource: def snapshot(self) -> AsyncSnapshotResource: return AsyncSnapshotResource(self._client) + @cached_property + def json(self) -> AsyncJsonResource: + return AsyncJsonResource(self._client) + + @cached_property + def links(self) -> AsyncLinksResource: + return AsyncLinksResource(self._client) + + @cached_property + def markdown(self) -> AsyncMarkdownResource: + return AsyncMarkdownResource(self._client) + @cached_property def with_raw_response(self) -> AsyncBrowserRenderingResourceWithRawResponse: """ @@ -154,6 +202,18 @@ def screenshot(self) -> ScreenshotResourceWithRawResponse: def snapshot(self) -> SnapshotResourceWithRawResponse: return SnapshotResourceWithRawResponse(self._browser_rendering.snapshot) + @cached_property + def json(self) -> JsonResourceWithRawResponse: + return JsonResourceWithRawResponse(self._browser_rendering.json) + + @cached_property + def links(self) -> LinksResourceWithRawResponse: + return LinksResourceWithRawResponse(self._browser_rendering.links) + + @cached_property + def markdown(self) -> MarkdownResourceWithRawResponse: + return MarkdownResourceWithRawResponse(self._browser_rendering.markdown) + class AsyncBrowserRenderingResourceWithRawResponse: def __init__(self, browser_rendering: AsyncBrowserRenderingResource) -> None: @@ -179,6 +239,18 @@ def screenshot(self) -> AsyncScreenshotResourceWithRawResponse: def snapshot(self) -> AsyncSnapshotResourceWithRawResponse: return AsyncSnapshotResourceWithRawResponse(self._browser_rendering.snapshot) + @cached_property + def json(self) -> AsyncJsonResourceWithRawResponse: + return AsyncJsonResourceWithRawResponse(self._browser_rendering.json) + + @cached_property + def links(self) -> AsyncLinksResourceWithRawResponse: + return AsyncLinksResourceWithRawResponse(self._browser_rendering.links) + + @cached_property + def markdown(self) -> AsyncMarkdownResourceWithRawResponse: + return AsyncMarkdownResourceWithRawResponse(self._browser_rendering.markdown) + class BrowserRenderingResourceWithStreamingResponse: def __init__(self, browser_rendering: BrowserRenderingResource) -> None: @@ -204,6 +276,18 @@ def screenshot(self) -> ScreenshotResourceWithStreamingResponse: def snapshot(self) -> SnapshotResourceWithStreamingResponse: return SnapshotResourceWithStreamingResponse(self._browser_rendering.snapshot) + @cached_property + def json(self) -> JsonResourceWithStreamingResponse: + return JsonResourceWithStreamingResponse(self._browser_rendering.json) + + @cached_property + def links(self) -> LinksResourceWithStreamingResponse: + return LinksResourceWithStreamingResponse(self._browser_rendering.links) + + @cached_property + def markdown(self) -> MarkdownResourceWithStreamingResponse: + return MarkdownResourceWithStreamingResponse(self._browser_rendering.markdown) + class AsyncBrowserRenderingResourceWithStreamingResponse: def __init__(self, browser_rendering: AsyncBrowserRenderingResource) -> None: @@ -228,3 +312,15 @@ def screenshot(self) -> AsyncScreenshotResourceWithStreamingResponse: @cached_property def snapshot(self) -> AsyncSnapshotResourceWithStreamingResponse: return AsyncSnapshotResourceWithStreamingResponse(self._browser_rendering.snapshot) + + @cached_property + def json(self) -> AsyncJsonResourceWithStreamingResponse: + return AsyncJsonResourceWithStreamingResponse(self._browser_rendering.json) + + @cached_property + def links(self) -> AsyncLinksResourceWithStreamingResponse: + return AsyncLinksResourceWithStreamingResponse(self._browser_rendering.links) + + @cached_property + def markdown(self) -> AsyncMarkdownResourceWithStreamingResponse: + return AsyncMarkdownResourceWithStreamingResponse(self._browser_rendering.markdown) diff --git a/src/cloudflare/resources/browser_rendering/json.py b/src/cloudflare/resources/browser_rendering/json.py new file mode 100644 index 00000000000..270a5479323 --- /dev/null +++ b/src/cloudflare/resources/browser_rendering/json.py @@ -0,0 +1,450 @@ +# 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, + 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. + + add_script_tag: Adds a `