diff --git a/.stats.yml b/.stats.yml index f189017b7651..81d08c8bc196 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1258 +configured_endpoints: 1267 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5f1479806ff9a382d425b33f45765681c248cf0895cd4fb79eec5b51a55ea23a.yml diff --git a/api.md b/api.md index 59a85841e416..cab0bc68d500 100644 --- a/api.md +++ b/api.md @@ -2559,22 +2559,16 @@ Methods: Types: ```python -from cloudflare.types.web3 import ( - HostnameCreateResponse, - HostnameListResponse, - HostnameDeleteResponse, - HostnameEditResponse, - HostnameGetResponse, -) +from cloudflare.types.web3 import Hostname, HostnameDeleteResponse ``` Methods: -- client.web3.hostnames.create(zone_identifier, \*\*params) -> HostnameCreateResponse -- client.web3.hostnames.list(zone_identifier) -> SyncSinglePage[HostnameListResponse] +- client.web3.hostnames.create(zone_identifier, \*\*params) -> Hostname +- client.web3.hostnames.list(zone_identifier) -> SyncSinglePage[Hostname] - client.web3.hostnames.delete(identifier, \*, zone_identifier) -> Optional -- client.web3.hostnames.edit(identifier, \*, zone_identifier, \*\*params) -> HostnameEditResponse -- client.web3.hostnames.get(identifier, \*, zone_identifier) -> HostnameGetResponse +- client.web3.hostnames.edit(identifier, \*, zone_identifier, \*\*params) -> Hostname +- client.web3.hostnames.get(identifier, \*, zone_identifier) -> Hostname ### IPFSUniversalPaths @@ -2583,16 +2577,13 @@ Methods: Types: ```python -from cloudflare.types.web3.hostnames.ipfs_universal_paths import ( - ContentListUpdateResponse, - ContentListGetResponse, -) +from cloudflare.types.web3.hostnames.ipfs_universal_paths import ContentList ``` Methods: -- client.web3.hostnames.ipfs_universal_paths.content_lists.update(identifier, \*, zone_identifier, \*\*params) -> ContentListUpdateResponse -- client.web3.hostnames.ipfs_universal_paths.content_lists.get(identifier, \*, zone_identifier) -> ContentListGetResponse +- client.web3.hostnames.ipfs_universal_paths.content_lists.update(identifier, \*, zone_identifier, \*\*params) -> ContentList +- client.web3.hostnames.ipfs_universal_paths.content_lists.get(identifier, \*, zone_identifier) -> ContentList ##### Entries @@ -7006,6 +6997,7 @@ from cloudflare.types.radar.http import ( SummaryHTTPVersionResponse, SummaryIPVersionResponse, SummaryOSResponse, + SummaryPostQuantumResponse, SummaryTLSVersionResponse, ) ``` @@ -7018,6 +7010,7 @@ Methods: - client.radar.http.summary.http_version(\*\*params) -> SummaryHTTPVersionResponse - client.radar.http.summary.ip_version(\*\*params) -> SummaryIPVersionResponse - client.radar.http.summary.os(\*\*params) -> SummaryOSResponse +- client.radar.http.summary.post_quantum(\*\*params) -> SummaryPostQuantumResponse - client.radar.http.summary.tls_version(\*\*params) -> SummaryTLSVersionResponse ### TimeseriesGroups @@ -7034,6 +7027,7 @@ from cloudflare.types.radar.http import ( TimeseriesGroupHTTPVersionResponse, TimeseriesGroupIPVersionResponse, TimeseriesGroupOSResponse, + TimeseriesGroupPostQuantumResponse, TimeseriesGroupTLSVersionResponse, ) ``` @@ -7048,6 +7042,7 @@ Methods: - client.radar.http.timeseries_groups.http_version(\*\*params) -> TimeseriesGroupHTTPVersionResponse - client.radar.http.timeseries_groups.ip_version(\*\*params) -> TimeseriesGroupIPVersionResponse - client.radar.http.timeseries_groups.os(\*\*params) -> TimeseriesGroupOSResponse +- client.radar.http.timeseries_groups.post_quantum(\*\*params) -> TimeseriesGroupPostQuantumResponse - client.radar.http.timeseries_groups.tls_version(\*\*params) -> TimeseriesGroupTLSVersionResponse ## Quality @@ -7278,6 +7273,40 @@ Methods: - client.hostnames.settings.tls.delete(hostname, \*, zone_id, setting_id) -> TLSDeleteResponse - client.hostnames.settings.tls.get(setting_id, \*, zone_id) -> Optional +# Snippets + +Types: + +```python +from cloudflare.types.snippets import Snippet, SnippetDeleteResponse +``` + +Methods: + +- client.snippets.update(snippet_name, \*, zone_id, \*\*params) -> Optional +- client.snippets.list(\*, zone_id) -> SyncSinglePage[Snippet] +- client.snippets.delete(snippet_name, \*, zone_id) -> SnippetDeleteResponse +- client.snippets.get(snippet_name, \*, zone_id) -> Optional + +## Content + +Methods: + +- client.snippets.content.get(snippet_name, \*, zone_id) -> BinaryAPIResponse + +## Rules + +Types: + +```python +from cloudflare.types.snippets import RuleUpdateResponse, RuleListResponse +``` + +Methods: + +- client.snippets.rules.update(\*, zone_id, \*\*params) -> Optional +- client.snippets.rules.list(\*, zone_id) -> SyncSinglePage[RuleListResponse] + # Calls Types: diff --git a/src/cloudflare/_client.py b/src/cloudflare/_client.py index 402f7e5097b4..41a4fcfac22d 100644 --- a/src/cloudflare/_client.py +++ b/src/cloudflare/_client.py @@ -124,6 +124,7 @@ class Cloudflare(SyncAPIClient): speed: resources.SpeedResource dcv_delegation: resources.DCVDelegationResource hostnames: resources.HostnamesResource + snippets: resources.SnippetsResource calls: resources.CallsResource cloudforce_one: resources.CloudforceOneResource event_notifications: resources.EventNotificationsResource @@ -279,6 +280,7 @@ def __init__( self.speed = resources.SpeedResource(self) self.dcv_delegation = resources.DCVDelegationResource(self) self.hostnames = resources.HostnamesResource(self) + self.snippets = resources.SnippetsResource(self) self.calls = resources.CallsResource(self) self.cloudforce_one = resources.CloudforceOneResource(self) self.event_notifications = resources.EventNotificationsResource(self) @@ -537,6 +539,7 @@ class AsyncCloudflare(AsyncAPIClient): speed: resources.AsyncSpeedResource dcv_delegation: resources.AsyncDCVDelegationResource hostnames: resources.AsyncHostnamesResource + snippets: resources.AsyncSnippetsResource calls: resources.AsyncCallsResource cloudforce_one: resources.AsyncCloudforceOneResource event_notifications: resources.AsyncEventNotificationsResource @@ -692,6 +695,7 @@ def __init__( self.speed = resources.AsyncSpeedResource(self) self.dcv_delegation = resources.AsyncDCVDelegationResource(self) self.hostnames = resources.AsyncHostnamesResource(self) + self.snippets = resources.AsyncSnippetsResource(self) self.calls = resources.AsyncCallsResource(self) self.cloudforce_one = resources.AsyncCloudforceOneResource(self) self.event_notifications = resources.AsyncEventNotificationsResource(self) @@ -961,6 +965,7 @@ def __init__(self, client: Cloudflare) -> None: self.speed = resources.SpeedResourceWithRawResponse(client.speed) self.dcv_delegation = resources.DCVDelegationResourceWithRawResponse(client.dcv_delegation) self.hostnames = resources.HostnamesResourceWithRawResponse(client.hostnames) + self.snippets = resources.SnippetsResourceWithRawResponse(client.snippets) self.calls = resources.CallsResourceWithRawResponse(client.calls) self.cloudforce_one = resources.CloudforceOneResourceWithRawResponse(client.cloudforce_one) self.event_notifications = resources.EventNotificationsResourceWithRawResponse(client.event_notifications) @@ -1059,6 +1064,7 @@ def __init__(self, client: AsyncCloudflare) -> None: self.speed = resources.AsyncSpeedResourceWithRawResponse(client.speed) self.dcv_delegation = resources.AsyncDCVDelegationResourceWithRawResponse(client.dcv_delegation) self.hostnames = resources.AsyncHostnamesResourceWithRawResponse(client.hostnames) + self.snippets = resources.AsyncSnippetsResourceWithRawResponse(client.snippets) self.calls = resources.AsyncCallsResourceWithRawResponse(client.calls) self.cloudforce_one = resources.AsyncCloudforceOneResourceWithRawResponse(client.cloudforce_one) self.event_notifications = resources.AsyncEventNotificationsResourceWithRawResponse(client.event_notifications) @@ -1157,6 +1163,7 @@ def __init__(self, client: Cloudflare) -> None: self.speed = resources.SpeedResourceWithStreamingResponse(client.speed) self.dcv_delegation = resources.DCVDelegationResourceWithStreamingResponse(client.dcv_delegation) self.hostnames = resources.HostnamesResourceWithStreamingResponse(client.hostnames) + self.snippets = resources.SnippetsResourceWithStreamingResponse(client.snippets) self.calls = resources.CallsResourceWithStreamingResponse(client.calls) self.cloudforce_one = resources.CloudforceOneResourceWithStreamingResponse(client.cloudforce_one) self.event_notifications = resources.EventNotificationsResourceWithStreamingResponse(client.event_notifications) @@ -1261,6 +1268,7 @@ def __init__(self, client: AsyncCloudflare) -> None: self.speed = resources.AsyncSpeedResourceWithStreamingResponse(client.speed) self.dcv_delegation = resources.AsyncDCVDelegationResourceWithStreamingResponse(client.dcv_delegation) self.hostnames = resources.AsyncHostnamesResourceWithStreamingResponse(client.hostnames) + self.snippets = resources.AsyncSnippetsResourceWithStreamingResponse(client.snippets) self.calls = resources.AsyncCallsResourceWithStreamingResponse(client.calls) self.cloudforce_one = resources.AsyncCloudforceOneResourceWithStreamingResponse(client.cloudforce_one) self.event_notifications = resources.AsyncEventNotificationsResourceWithStreamingResponse( diff --git a/src/cloudflare/resources/__init__.py b/src/cloudflare/resources/__init__.py index 7f73728a7bb3..e4d0f926f5dc 100644 --- a/src/cloudflare/resources/__init__.py +++ b/src/cloudflare/resources/__init__.py @@ -280,6 +280,14 @@ RulesetsResourceWithStreamingResponse, AsyncRulesetsResourceWithStreamingResponse, ) +from .snippets import ( + SnippetsResource, + AsyncSnippetsResource, + SnippetsResourceWithRawResponse, + AsyncSnippetsResourceWithRawResponse, + SnippetsResourceWithStreamingResponse, + AsyncSnippetsResourceWithStreamingResponse, +) from .spectrum import ( SpectrumResource, AsyncSpectrumResource, @@ -1104,6 +1112,12 @@ "AsyncHostnamesResourceWithRawResponse", "HostnamesResourceWithStreamingResponse", "AsyncHostnamesResourceWithStreamingResponse", + "SnippetsResource", + "AsyncSnippetsResource", + "SnippetsResourceWithRawResponse", + "AsyncSnippetsResourceWithRawResponse", + "SnippetsResourceWithStreamingResponse", + "AsyncSnippetsResourceWithStreamingResponse", "CallsResource", "AsyncCallsResource", "CallsResourceWithRawResponse", diff --git a/src/cloudflare/resources/radar/http/summary.py b/src/cloudflare/resources/radar/http/summary.py index 7e71b2aa987b..12defd73b00f 100644 --- a/src/cloudflare/resources/radar/http/summary.py +++ b/src/cloudflare/resources/radar/http/summary.py @@ -32,6 +32,7 @@ summary_device_type_params, summary_tls_version_params, summary_http_version_params, + summary_post_quantum_params, summary_http_protocol_params, ) from ....types.radar.http.summary_os_response import SummaryOSResponse @@ -40,6 +41,7 @@ from ....types.radar.http.summary_device_type_response import SummaryDeviceTypeResponse from ....types.radar.http.summary_tls_version_response import SummaryTLSVersionResponse from ....types.radar.http.summary_http_version_response import SummaryHTTPVersionResponse +from ....types.radar.http.summary_post_quantum_response import SummaryPostQuantumResponse from ....types.radar.http.summary_http_protocol_response import SummaryHTTPProtocolResponse __all__ = ["SummaryResource", "AsyncSummaryResource"] @@ -803,6 +805,135 @@ def os( cast_to=cast(Type[SummaryOSResponse], ResultWrapper[SummaryOSResponse]), ) + def post_quantum( + self, + *, + asn: List[str] | NotGiven = NOT_GIVEN, + bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + continent: List[str] | NotGiven = NOT_GIVEN, + date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, + date_range: List[ + Literal[ + "1d", + "2d", + "7d", + "14d", + "28d", + "12w", + "24w", + "52w", + "1dControl", + "2dControl", + "7dControl", + "14dControl", + "28dControl", + "12wControl", + "24wControl", + ] + ] + | NotGiven = NOT_GIVEN, + date_start: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, + device_type: List[Literal["DESKTOP", "MOBILE", "OTHER"]] | NotGiven = NOT_GIVEN, + format: Literal["JSON", "CSV"] | NotGiven = NOT_GIVEN, + http_protocol: List[Literal["HTTP", "HTTPS"]] | NotGiven = NOT_GIVEN, + http_version: List[Literal["HTTPv1", "HTTPv2", "HTTPv3"]] | NotGiven = NOT_GIVEN, + ip_version: List[Literal["IPv4", "IPv6"]] | NotGiven = NOT_GIVEN, + location: List[str] | NotGiven = NOT_GIVEN, + name: List[str] | NotGiven = NOT_GIVEN, + os: List[Literal["WINDOWS", "MACOSX", "IOS", "ANDROID", "CHROMEOS", "LINUX", "SMART_TV"]] + | NotGiven = NOT_GIVEN, + tls_version: List[Literal["TLSv1_0", "TLSv1_1", "TLSv1_2", "TLSv1_3", "TLSvQUIC"]] | 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, + ) -> SummaryPostQuantumResponse: + """ + Percentage distribution of traffic per Post Quantum support over a given time + period. + + Args: + asn: Array of comma separated list of ASNs, start with `-` to exclude from results. + For example, `-174, 3356` excludes results from AS174, but includes results from + AS3356. + + bot_class: Filter for bot class. Refer to + [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + + continent: Array of comma separated list of continents (alpha-2 continent codes). Start + with `-` to exclude from results. For example, `-EU,NA` excludes results from + Europe, but includes results from North America. + + date_end: End of the date range (inclusive). + + date_range: For example, use `7d` and `7dControl` to compare this week with the previous + week. Use this parameter or set specific start and end dates (`dateStart` and + `dateEnd` parameters). + + date_start: Array of datetimes to filter the start of a series. + + device_type: Filter for device type. + + format: Format results are returned in. + + http_protocol: Filter for http protocol. + + http_version: Filter for http version. + + ip_version: Filter for ip version. + + location: Array of comma separated list of locations (alpha-2 country codes). Start with + `-` to exclude from results. For example, `-US,PT` excludes results from the US, + but includes results from PT. + + name: Array of names that will be used to name the series in responses. + + os: Filter for os name. + + tls_version: Filter for tls version. + + 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 + """ + return self._get( + "/radar/http/summary/post_quantum", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "asn": asn, + "bot_class": bot_class, + "continent": continent, + "date_end": date_end, + "date_range": date_range, + "date_start": date_start, + "device_type": device_type, + "format": format, + "http_protocol": http_protocol, + "http_version": http_version, + "ip_version": ip_version, + "location": location, + "name": name, + "os": os, + "tls_version": tls_version, + }, + summary_post_quantum_params.SummaryPostQuantumParams, + ), + post_parser=ResultWrapper[SummaryPostQuantumResponse]._unwrapper, + ), + cast_to=cast(Type[SummaryPostQuantumResponse], ResultWrapper[SummaryPostQuantumResponse]), + ) + def tls_version( self, *, @@ -1687,6 +1818,135 @@ async def os( cast_to=cast(Type[SummaryOSResponse], ResultWrapper[SummaryOSResponse]), ) + async def post_quantum( + self, + *, + asn: List[str] | NotGiven = NOT_GIVEN, + bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + continent: List[str] | NotGiven = NOT_GIVEN, + date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, + date_range: List[ + Literal[ + "1d", + "2d", + "7d", + "14d", + "28d", + "12w", + "24w", + "52w", + "1dControl", + "2dControl", + "7dControl", + "14dControl", + "28dControl", + "12wControl", + "24wControl", + ] + ] + | NotGiven = NOT_GIVEN, + date_start: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, + device_type: List[Literal["DESKTOP", "MOBILE", "OTHER"]] | NotGiven = NOT_GIVEN, + format: Literal["JSON", "CSV"] | NotGiven = NOT_GIVEN, + http_protocol: List[Literal["HTTP", "HTTPS"]] | NotGiven = NOT_GIVEN, + http_version: List[Literal["HTTPv1", "HTTPv2", "HTTPv3"]] | NotGiven = NOT_GIVEN, + ip_version: List[Literal["IPv4", "IPv6"]] | NotGiven = NOT_GIVEN, + location: List[str] | NotGiven = NOT_GIVEN, + name: List[str] | NotGiven = NOT_GIVEN, + os: List[Literal["WINDOWS", "MACOSX", "IOS", "ANDROID", "CHROMEOS", "LINUX", "SMART_TV"]] + | NotGiven = NOT_GIVEN, + tls_version: List[Literal["TLSv1_0", "TLSv1_1", "TLSv1_2", "TLSv1_3", "TLSvQUIC"]] | 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, + ) -> SummaryPostQuantumResponse: + """ + Percentage distribution of traffic per Post Quantum support over a given time + period. + + Args: + asn: Array of comma separated list of ASNs, start with `-` to exclude from results. + For example, `-174, 3356` excludes results from AS174, but includes results from + AS3356. + + bot_class: Filter for bot class. Refer to + [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + + continent: Array of comma separated list of continents (alpha-2 continent codes). Start + with `-` to exclude from results. For example, `-EU,NA` excludes results from + Europe, but includes results from North America. + + date_end: End of the date range (inclusive). + + date_range: For example, use `7d` and `7dControl` to compare this week with the previous + week. Use this parameter or set specific start and end dates (`dateStart` and + `dateEnd` parameters). + + date_start: Array of datetimes to filter the start of a series. + + device_type: Filter for device type. + + format: Format results are returned in. + + http_protocol: Filter for http protocol. + + http_version: Filter for http version. + + ip_version: Filter for ip version. + + location: Array of comma separated list of locations (alpha-2 country codes). Start with + `-` to exclude from results. For example, `-US,PT` excludes results from the US, + but includes results from PT. + + name: Array of names that will be used to name the series in responses. + + os: Filter for os name. + + tls_version: Filter for tls version. + + 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 + """ + return await self._get( + "/radar/http/summary/post_quantum", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "asn": asn, + "bot_class": bot_class, + "continent": continent, + "date_end": date_end, + "date_range": date_range, + "date_start": date_start, + "device_type": device_type, + "format": format, + "http_protocol": http_protocol, + "http_version": http_version, + "ip_version": ip_version, + "location": location, + "name": name, + "os": os, + "tls_version": tls_version, + }, + summary_post_quantum_params.SummaryPostQuantumParams, + ), + post_parser=ResultWrapper[SummaryPostQuantumResponse]._unwrapper, + ), + cast_to=cast(Type[SummaryPostQuantumResponse], ResultWrapper[SummaryPostQuantumResponse]), + ) + async def tls_version( self, *, @@ -1835,6 +2095,9 @@ def __init__(self, summary: SummaryResource) -> None: self.os = to_raw_response_wrapper( summary.os, ) + self.post_quantum = to_raw_response_wrapper( + summary.post_quantum, + ) self.tls_version = to_raw_response_wrapper( summary.tls_version, ) @@ -1862,6 +2125,9 @@ def __init__(self, summary: AsyncSummaryResource) -> None: self.os = async_to_raw_response_wrapper( summary.os, ) + self.post_quantum = async_to_raw_response_wrapper( + summary.post_quantum, + ) self.tls_version = async_to_raw_response_wrapper( summary.tls_version, ) @@ -1889,6 +2155,9 @@ def __init__(self, summary: SummaryResource) -> None: self.os = to_streamed_response_wrapper( summary.os, ) + self.post_quantum = to_streamed_response_wrapper( + summary.post_quantum, + ) self.tls_version = to_streamed_response_wrapper( summary.tls_version, ) @@ -1916,6 +2185,9 @@ def __init__(self, summary: AsyncSummaryResource) -> None: self.os = async_to_streamed_response_wrapper( summary.os, ) + self.post_quantum = async_to_streamed_response_wrapper( + summary.post_quantum, + ) self.tls_version = async_to_streamed_response_wrapper( summary.tls_version, ) diff --git a/src/cloudflare/resources/radar/http/timeseries_groups.py b/src/cloudflare/resources/radar/http/timeseries_groups.py index 4ba8bea28f90..6dcf5fd060de 100644 --- a/src/cloudflare/resources/radar/http/timeseries_groups.py +++ b/src/cloudflare/resources/radar/http/timeseries_groups.py @@ -33,6 +33,7 @@ timeseries_group_device_type_params, timeseries_group_tls_version_params, timeseries_group_http_version_params, + timeseries_group_post_quantum_params, timeseries_group_http_protocol_params, timeseries_group_browser_family_params, ) @@ -43,6 +44,7 @@ from ....types.radar.http.timeseries_group_device_type_response import TimeseriesGroupDeviceTypeResponse from ....types.radar.http.timeseries_group_tls_version_response import TimeseriesGroupTLSVersionResponse from ....types.radar.http.timeseries_group_http_version_response import TimeseriesGroupHTTPVersionResponse +from ....types.radar.http.timeseries_group_post_quantum_response import TimeseriesGroupPostQuantumResponse from ....types.radar.http.timeseries_group_http_protocol_response import TimeseriesGroupHTTPProtocolResponse from ....types.radar.http.timeseries_group_browser_family_response import TimeseriesGroupBrowserFamilyResponse @@ -1119,6 +1121,141 @@ def os( cast_to=cast(Type[TimeseriesGroupOSResponse], ResultWrapper[TimeseriesGroupOSResponse]), ) + def post_quantum( + self, + *, + agg_interval: Literal["15m", "1h", "1d", "1w"] | NotGiven = NOT_GIVEN, + asn: List[str] | NotGiven = NOT_GIVEN, + bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + continent: List[str] | NotGiven = NOT_GIVEN, + date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, + date_range: List[ + Literal[ + "1d", + "2d", + "7d", + "14d", + "28d", + "12w", + "24w", + "52w", + "1dControl", + "2dControl", + "7dControl", + "14dControl", + "28dControl", + "12wControl", + "24wControl", + ] + ] + | NotGiven = NOT_GIVEN, + date_start: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, + device_type: List[Literal["DESKTOP", "MOBILE", "OTHER"]] | NotGiven = NOT_GIVEN, + format: Literal["JSON", "CSV"] | NotGiven = NOT_GIVEN, + http_protocol: List[Literal["HTTP", "HTTPS"]] | NotGiven = NOT_GIVEN, + http_version: List[Literal["HTTPv1", "HTTPv2", "HTTPv3"]] | NotGiven = NOT_GIVEN, + ip_version: List[Literal["IPv4", "IPv6"]] | NotGiven = NOT_GIVEN, + location: List[str] | NotGiven = NOT_GIVEN, + name: List[str] | NotGiven = NOT_GIVEN, + os: List[Literal["WINDOWS", "MACOSX", "IOS", "ANDROID", "CHROMEOS", "LINUX", "SMART_TV"]] + | NotGiven = NOT_GIVEN, + tls_version: List[Literal["TLSv1_0", "TLSv1_1", "TLSv1_2", "TLSv1_3", "TLSvQUIC"]] | 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, + ) -> TimeseriesGroupPostQuantumResponse: + """ + Get a time series of the percentage distribution of traffic per Post Quantum + suport. + + Args: + agg_interval: Aggregation interval results should be returned in (for example, in 15 minutes + or 1 hour intervals). Refer to + [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + + asn: Array of comma separated list of ASNs, start with `-` to exclude from results. + For example, `-174, 3356` excludes results from AS174, but includes results from + AS3356. + + bot_class: Filter for bot class. Refer to + [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + + continent: Array of comma separated list of continents (alpha-2 continent codes). Start + with `-` to exclude from results. For example, `-EU,NA` excludes results from + Europe, but includes results from North America. + + date_end: End of the date range (inclusive). + + date_range: For example, use `7d` and `7dControl` to compare this week with the previous + week. Use this parameter or set specific start and end dates (`dateStart` and + `dateEnd` parameters). + + date_start: Array of datetimes to filter the start of a series. + + device_type: Filter for device type. + + format: Format results are returned in. + + http_protocol: Filter for http protocol. + + http_version: Filter for http version. + + ip_version: Filter for ip version. + + location: Array of comma separated list of locations (alpha-2 country codes). Start with + `-` to exclude from results. For example, `-US,PT` excludes results from the US, + but includes results from PT. + + name: Array of names that will be used to name the series in responses. + + os: Filter for os name. + + tls_version: Filter for tls version. + + 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 + """ + return self._get( + "/radar/http/timeseries_groups/post_quantum", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "agg_interval": agg_interval, + "asn": asn, + "bot_class": bot_class, + "continent": continent, + "date_end": date_end, + "date_range": date_range, + "date_start": date_start, + "device_type": device_type, + "format": format, + "http_protocol": http_protocol, + "http_version": http_version, + "ip_version": ip_version, + "location": location, + "name": name, + "os": os, + "tls_version": tls_version, + }, + timeseries_group_post_quantum_params.TimeseriesGroupPostQuantumParams, + ), + post_parser=ResultWrapper[TimeseriesGroupPostQuantumResponse]._unwrapper, + ), + cast_to=cast(Type[TimeseriesGroupPostQuantumResponse], ResultWrapper[TimeseriesGroupPostQuantumResponse]), + ) + def tls_version( self, *, @@ -2321,6 +2458,141 @@ async def os( cast_to=cast(Type[TimeseriesGroupOSResponse], ResultWrapper[TimeseriesGroupOSResponse]), ) + async def post_quantum( + self, + *, + agg_interval: Literal["15m", "1h", "1d", "1w"] | NotGiven = NOT_GIVEN, + asn: List[str] | NotGiven = NOT_GIVEN, + bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + continent: List[str] | NotGiven = NOT_GIVEN, + date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, + date_range: List[ + Literal[ + "1d", + "2d", + "7d", + "14d", + "28d", + "12w", + "24w", + "52w", + "1dControl", + "2dControl", + "7dControl", + "14dControl", + "28dControl", + "12wControl", + "24wControl", + ] + ] + | NotGiven = NOT_GIVEN, + date_start: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, + device_type: List[Literal["DESKTOP", "MOBILE", "OTHER"]] | NotGiven = NOT_GIVEN, + format: Literal["JSON", "CSV"] | NotGiven = NOT_GIVEN, + http_protocol: List[Literal["HTTP", "HTTPS"]] | NotGiven = NOT_GIVEN, + http_version: List[Literal["HTTPv1", "HTTPv2", "HTTPv3"]] | NotGiven = NOT_GIVEN, + ip_version: List[Literal["IPv4", "IPv6"]] | NotGiven = NOT_GIVEN, + location: List[str] | NotGiven = NOT_GIVEN, + name: List[str] | NotGiven = NOT_GIVEN, + os: List[Literal["WINDOWS", "MACOSX", "IOS", "ANDROID", "CHROMEOS", "LINUX", "SMART_TV"]] + | NotGiven = NOT_GIVEN, + tls_version: List[Literal["TLSv1_0", "TLSv1_1", "TLSv1_2", "TLSv1_3", "TLSvQUIC"]] | 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, + ) -> TimeseriesGroupPostQuantumResponse: + """ + Get a time series of the percentage distribution of traffic per Post Quantum + suport. + + Args: + agg_interval: Aggregation interval results should be returned in (for example, in 15 minutes + or 1 hour intervals). Refer to + [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + + asn: Array of comma separated list of ASNs, start with `-` to exclude from results. + For example, `-174, 3356` excludes results from AS174, but includes results from + AS3356. + + bot_class: Filter for bot class. Refer to + [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + + continent: Array of comma separated list of continents (alpha-2 continent codes). Start + with `-` to exclude from results. For example, `-EU,NA` excludes results from + Europe, but includes results from North America. + + date_end: End of the date range (inclusive). + + date_range: For example, use `7d` and `7dControl` to compare this week with the previous + week. Use this parameter or set specific start and end dates (`dateStart` and + `dateEnd` parameters). + + date_start: Array of datetimes to filter the start of a series. + + device_type: Filter for device type. + + format: Format results are returned in. + + http_protocol: Filter for http protocol. + + http_version: Filter for http version. + + ip_version: Filter for ip version. + + location: Array of comma separated list of locations (alpha-2 country codes). Start with + `-` to exclude from results. For example, `-US,PT` excludes results from the US, + but includes results from PT. + + name: Array of names that will be used to name the series in responses. + + os: Filter for os name. + + tls_version: Filter for tls version. + + 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 + """ + return await self._get( + "/radar/http/timeseries_groups/post_quantum", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "agg_interval": agg_interval, + "asn": asn, + "bot_class": bot_class, + "continent": continent, + "date_end": date_end, + "date_range": date_range, + "date_start": date_start, + "device_type": device_type, + "format": format, + "http_protocol": http_protocol, + "http_version": http_version, + "ip_version": ip_version, + "location": location, + "name": name, + "os": os, + "tls_version": tls_version, + }, + timeseries_group_post_quantum_params.TimeseriesGroupPostQuantumParams, + ), + post_parser=ResultWrapper[TimeseriesGroupPostQuantumResponse]._unwrapper, + ), + cast_to=cast(Type[TimeseriesGroupPostQuantumResponse], ResultWrapper[TimeseriesGroupPostQuantumResponse]), + ) + async def tls_version( self, *, @@ -2481,6 +2753,9 @@ def __init__(self, timeseries_groups: TimeseriesGroupsResource) -> None: self.os = to_raw_response_wrapper( timeseries_groups.os, ) + self.post_quantum = to_raw_response_wrapper( + timeseries_groups.post_quantum, + ) self.tls_version = to_raw_response_wrapper( timeseries_groups.tls_version, ) @@ -2514,6 +2789,9 @@ def __init__(self, timeseries_groups: AsyncTimeseriesGroupsResource) -> None: self.os = async_to_raw_response_wrapper( timeseries_groups.os, ) + self.post_quantum = async_to_raw_response_wrapper( + timeseries_groups.post_quantum, + ) self.tls_version = async_to_raw_response_wrapper( timeseries_groups.tls_version, ) @@ -2547,6 +2825,9 @@ def __init__(self, timeseries_groups: TimeseriesGroupsResource) -> None: self.os = to_streamed_response_wrapper( timeseries_groups.os, ) + self.post_quantum = to_streamed_response_wrapper( + timeseries_groups.post_quantum, + ) self.tls_version = to_streamed_response_wrapper( timeseries_groups.tls_version, ) @@ -2580,6 +2861,9 @@ def __init__(self, timeseries_groups: AsyncTimeseriesGroupsResource) -> None: self.os = async_to_streamed_response_wrapper( timeseries_groups.os, ) + self.post_quantum = async_to_streamed_response_wrapper( + timeseries_groups.post_quantum, + ) self.tls_version = async_to_streamed_response_wrapper( timeseries_groups.tls_version, ) diff --git a/src/cloudflare/resources/snippets/__init__.py b/src/cloudflare/resources/snippets/__init__.py new file mode 100644 index 000000000000..e3270af6c0a9 --- /dev/null +++ b/src/cloudflare/resources/snippets/__init__.py @@ -0,0 +1,47 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .rules import ( + RulesResource, + AsyncRulesResource, + RulesResourceWithRawResponse, + AsyncRulesResourceWithRawResponse, + RulesResourceWithStreamingResponse, + AsyncRulesResourceWithStreamingResponse, +) +from .content import ( + ContentResource, + AsyncContentResource, + ContentResourceWithRawResponse, + AsyncContentResourceWithRawResponse, + ContentResourceWithStreamingResponse, + AsyncContentResourceWithStreamingResponse, +) +from .snippets import ( + SnippetsResource, + AsyncSnippetsResource, + SnippetsResourceWithRawResponse, + AsyncSnippetsResourceWithRawResponse, + SnippetsResourceWithStreamingResponse, + AsyncSnippetsResourceWithStreamingResponse, +) + +__all__ = [ + "ContentResource", + "AsyncContentResource", + "ContentResourceWithRawResponse", + "AsyncContentResourceWithRawResponse", + "ContentResourceWithStreamingResponse", + "AsyncContentResourceWithStreamingResponse", + "RulesResource", + "AsyncRulesResource", + "RulesResourceWithRawResponse", + "AsyncRulesResourceWithRawResponse", + "RulesResourceWithStreamingResponse", + "AsyncRulesResourceWithStreamingResponse", + "SnippetsResource", + "AsyncSnippetsResource", + "SnippetsResourceWithRawResponse", + "AsyncSnippetsResourceWithRawResponse", + "SnippetsResourceWithStreamingResponse", + "AsyncSnippetsResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/snippets/content.py b/src/cloudflare/resources/snippets/content.py new file mode 100644 index 000000000000..a0b6d8f5a283 --- /dev/null +++ b/src/cloudflare/resources/snippets/content.py @@ -0,0 +1,166 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + BinaryAPIResponse, + AsyncBinaryAPIResponse, + StreamedBinaryAPIResponse, + AsyncStreamedBinaryAPIResponse, + to_custom_raw_response_wrapper, + to_custom_streamed_response_wrapper, + async_to_custom_raw_response_wrapper, + async_to_custom_streamed_response_wrapper, +) +from ..._base_client import ( + make_request_options, +) + +__all__ = ["ContentResource", "AsyncContentResource"] + + +class ContentResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ContentResourceWithRawResponse: + return ContentResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ContentResourceWithStreamingResponse: + return ContentResourceWithStreamingResponse(self) + + def get( + self, + snippet_name: str, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> BinaryAPIResponse: + """ + Snippet Content + + Args: + zone_id: Identifier + + snippet_name: Snippet identifying name + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not snippet_name: + raise ValueError(f"Expected a non-empty value for `snippet_name` but received {snippet_name!r}") + extra_headers = {"Accept": "multipart/form-data", **(extra_headers or {})} + return self._get( + f"/zones/{zone_id}/snippets/{snippet_name}/content", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=BinaryAPIResponse, + ) + + +class AsyncContentResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncContentResourceWithRawResponse: + return AsyncContentResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncContentResourceWithStreamingResponse: + return AsyncContentResourceWithStreamingResponse(self) + + async def get( + self, + snippet_name: str, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AsyncBinaryAPIResponse: + """ + Snippet Content + + Args: + zone_id: Identifier + + snippet_name: Snippet identifying name + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not snippet_name: + raise ValueError(f"Expected a non-empty value for `snippet_name` but received {snippet_name!r}") + extra_headers = {"Accept": "multipart/form-data", **(extra_headers or {})} + return await self._get( + f"/zones/{zone_id}/snippets/{snippet_name}/content", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=AsyncBinaryAPIResponse, + ) + + +class ContentResourceWithRawResponse: + def __init__(self, content: ContentResource) -> None: + self._content = content + + self.get = to_custom_raw_response_wrapper( + content.get, + BinaryAPIResponse, + ) + + +class AsyncContentResourceWithRawResponse: + def __init__(self, content: AsyncContentResource) -> None: + self._content = content + + self.get = async_to_custom_raw_response_wrapper( + content.get, + AsyncBinaryAPIResponse, + ) + + +class ContentResourceWithStreamingResponse: + def __init__(self, content: ContentResource) -> None: + self._content = content + + self.get = to_custom_streamed_response_wrapper( + content.get, + StreamedBinaryAPIResponse, + ) + + +class AsyncContentResourceWithStreamingResponse: + def __init__(self, content: AsyncContentResource) -> None: + self._content = content + + self.get = async_to_custom_streamed_response_wrapper( + content.get, + AsyncStreamedBinaryAPIResponse, + ) diff --git a/src/cloudflare/resources/snippets/rules.py b/src/cloudflare/resources/snippets/rules.py new file mode 100644 index 000000000000..5405a709a12d --- /dev/null +++ b/src/cloudflare/resources/snippets/rules.py @@ -0,0 +1,258 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Iterable, Optional, cast + +import httpx + +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._utils import ( + maybe_transform, + async_maybe_transform, +) +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ...pagination import SyncSinglePage, AsyncSinglePage +from ..._base_client import ( + AsyncPaginator, + make_request_options, +) +from ...types.snippets import rule_update_params +from ...types.snippets.rule_list_response import RuleListResponse +from ...types.snippets.rule_update_response import RuleUpdateResponse + +__all__ = ["RulesResource", "AsyncRulesResource"] + + +class RulesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> RulesResourceWithRawResponse: + return RulesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> RulesResourceWithStreamingResponse: + return RulesResourceWithStreamingResponse(self) + + def update( + self, + *, + zone_id: str, + rules: Iterable[rule_update_params.Rule] | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[RuleUpdateResponse]: + """ + Put Rules + + Args: + zone_id: Identifier + + rules: List of snippet rules + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._put( + f"/zones/{zone_id}/snippets/snippet_rules", + body=maybe_transform({"rules": rules}, rule_update_params.RuleUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[RuleUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[RuleUpdateResponse]], ResultWrapper[RuleUpdateResponse]), + ) + + def list( + self, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SyncSinglePage[RuleListResponse]: + """ + Rules + + Args: + zone_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/snippets/snippet_rules", + page=SyncSinglePage[RuleListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=RuleListResponse, + ) + + +class AsyncRulesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncRulesResourceWithRawResponse: + return AsyncRulesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncRulesResourceWithStreamingResponse: + return AsyncRulesResourceWithStreamingResponse(self) + + async def update( + self, + *, + zone_id: str, + rules: Iterable[rule_update_params.Rule] | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[RuleUpdateResponse]: + """ + Put Rules + + Args: + zone_id: Identifier + + rules: List of snippet rules + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return await self._put( + f"/zones/{zone_id}/snippets/snippet_rules", + body=await async_maybe_transform({"rules": rules}, rule_update_params.RuleUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[RuleUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[RuleUpdateResponse]], ResultWrapper[RuleUpdateResponse]), + ) + + def list( + self, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AsyncPaginator[RuleListResponse, AsyncSinglePage[RuleListResponse]]: + """ + Rules + + Args: + zone_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/snippets/snippet_rules", + page=AsyncSinglePage[RuleListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=RuleListResponse, + ) + + +class RulesResourceWithRawResponse: + def __init__(self, rules: RulesResource) -> None: + self._rules = rules + + self.update = to_raw_response_wrapper( + rules.update, + ) + self.list = to_raw_response_wrapper( + rules.list, + ) + + +class AsyncRulesResourceWithRawResponse: + def __init__(self, rules: AsyncRulesResource) -> None: + self._rules = rules + + self.update = async_to_raw_response_wrapper( + rules.update, + ) + self.list = async_to_raw_response_wrapper( + rules.list, + ) + + +class RulesResourceWithStreamingResponse: + def __init__(self, rules: RulesResource) -> None: + self._rules = rules + + self.update = to_streamed_response_wrapper( + rules.update, + ) + self.list = to_streamed_response_wrapper( + rules.list, + ) + + +class AsyncRulesResourceWithStreamingResponse: + def __init__(self, rules: AsyncRulesResource) -> None: + self._rules = rules + + self.update = async_to_streamed_response_wrapper( + rules.update, + ) + self.list = async_to_streamed_response_wrapper( + rules.list, + ) diff --git a/src/cloudflare/resources/snippets/snippets.py b/src/cloudflare/resources/snippets/snippets.py new file mode 100644 index 000000000000..5c1a0bb75b07 --- /dev/null +++ b/src/cloudflare/resources/snippets/snippets.py @@ -0,0 +1,538 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Optional, cast + +import httpx + +from .rules import ( + RulesResource, + AsyncRulesResource, + RulesResourceWithRawResponse, + AsyncRulesResourceWithRawResponse, + RulesResourceWithStreamingResponse, + AsyncRulesResourceWithStreamingResponse, +) +from .content import ( + ContentResource, + AsyncContentResource, + ContentResourceWithRawResponse, + AsyncContentResourceWithRawResponse, + ContentResourceWithStreamingResponse, + AsyncContentResourceWithStreamingResponse, +) +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._utils import ( + maybe_transform, + async_maybe_transform, +) +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ...pagination import SyncSinglePage, AsyncSinglePage +from ..._base_client import ( + AsyncPaginator, + make_request_options, +) +from ...types.snippets import snippet_update_params +from ...types.snippets.snippet import Snippet +from ...types.snippets.snippet_delete_response import SnippetDeleteResponse + +__all__ = ["SnippetsResource", "AsyncSnippetsResource"] + + +class SnippetsResource(SyncAPIResource): + @cached_property + def content(self) -> ContentResource: + return ContentResource(self._client) + + @cached_property + def rules(self) -> RulesResource: + return RulesResource(self._client) + + @cached_property + def with_raw_response(self) -> SnippetsResourceWithRawResponse: + return SnippetsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> SnippetsResourceWithStreamingResponse: + return SnippetsResourceWithStreamingResponse(self) + + def update( + self, + snippet_name: str, + *, + zone_id: str, + files: str | NotGiven = NOT_GIVEN, + metadata: snippet_update_params.Metadata | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[Snippet]: + """ + Put Snippet + + Args: + zone_id: Identifier + + snippet_name: Snippet identifying name + + files: Content files of uploaded snippet + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not snippet_name: + raise ValueError(f"Expected a non-empty value for `snippet_name` but received {snippet_name!r}") + return self._put( + f"/zones/{zone_id}/snippets/{snippet_name}", + body=maybe_transform( + { + "files": files, + "metadata": metadata, + }, + snippet_update_params.SnippetUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Snippet]]._unwrapper, + ), + cast_to=cast(Type[Optional[Snippet]], ResultWrapper[Snippet]), + ) + + def list( + self, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SyncSinglePage[Snippet]: + """ + All Snippets + + Args: + zone_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/snippets", + page=SyncSinglePage[Snippet], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=Snippet, + ) + + def delete( + self, + snippet_name: str, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SnippetDeleteResponse: + """ + Delete Snippet + + Args: + zone_id: Identifier + + snippet_name: Snippet identifying name + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not snippet_name: + raise ValueError(f"Expected a non-empty value for `snippet_name` but received {snippet_name!r}") + return self._delete( + f"/zones/{zone_id}/snippets/{snippet_name}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SnippetDeleteResponse, + ) + + def get( + self, + snippet_name: str, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[Snippet]: + """ + Snippet + + Args: + zone_id: Identifier + + snippet_name: Snippet identifying name + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not snippet_name: + raise ValueError(f"Expected a non-empty value for `snippet_name` but received {snippet_name!r}") + return self._get( + f"/zones/{zone_id}/snippets/{snippet_name}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Snippet]]._unwrapper, + ), + cast_to=cast(Type[Optional[Snippet]], ResultWrapper[Snippet]), + ) + + +class AsyncSnippetsResource(AsyncAPIResource): + @cached_property + def content(self) -> AsyncContentResource: + return AsyncContentResource(self._client) + + @cached_property + def rules(self) -> AsyncRulesResource: + return AsyncRulesResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncSnippetsResourceWithRawResponse: + return AsyncSnippetsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncSnippetsResourceWithStreamingResponse: + return AsyncSnippetsResourceWithStreamingResponse(self) + + async def update( + self, + snippet_name: str, + *, + zone_id: str, + files: str | NotGiven = NOT_GIVEN, + metadata: snippet_update_params.Metadata | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[Snippet]: + """ + Put Snippet + + Args: + zone_id: Identifier + + snippet_name: Snippet identifying name + + files: Content files of uploaded snippet + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not snippet_name: + raise ValueError(f"Expected a non-empty value for `snippet_name` but received {snippet_name!r}") + return await self._put( + f"/zones/{zone_id}/snippets/{snippet_name}", + body=await async_maybe_transform( + { + "files": files, + "metadata": metadata, + }, + snippet_update_params.SnippetUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Snippet]]._unwrapper, + ), + cast_to=cast(Type[Optional[Snippet]], ResultWrapper[Snippet]), + ) + + def list( + self, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AsyncPaginator[Snippet, AsyncSinglePage[Snippet]]: + """ + All Snippets + + Args: + zone_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/snippets", + page=AsyncSinglePage[Snippet], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=Snippet, + ) + + async def delete( + self, + snippet_name: str, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SnippetDeleteResponse: + """ + Delete Snippet + + Args: + zone_id: Identifier + + snippet_name: Snippet identifying name + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not snippet_name: + raise ValueError(f"Expected a non-empty value for `snippet_name` but received {snippet_name!r}") + return await self._delete( + f"/zones/{zone_id}/snippets/{snippet_name}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SnippetDeleteResponse, + ) + + async def get( + self, + snippet_name: str, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[Snippet]: + """ + Snippet + + Args: + zone_id: Identifier + + snippet_name: Snippet identifying name + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not snippet_name: + raise ValueError(f"Expected a non-empty value for `snippet_name` but received {snippet_name!r}") + return await self._get( + f"/zones/{zone_id}/snippets/{snippet_name}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Snippet]]._unwrapper, + ), + cast_to=cast(Type[Optional[Snippet]], ResultWrapper[Snippet]), + ) + + +class SnippetsResourceWithRawResponse: + def __init__(self, snippets: SnippetsResource) -> None: + self._snippets = snippets + + self.update = to_raw_response_wrapper( + snippets.update, + ) + self.list = to_raw_response_wrapper( + snippets.list, + ) + self.delete = to_raw_response_wrapper( + snippets.delete, + ) + self.get = to_raw_response_wrapper( + snippets.get, + ) + + @cached_property + def content(self) -> ContentResourceWithRawResponse: + return ContentResourceWithRawResponse(self._snippets.content) + + @cached_property + def rules(self) -> RulesResourceWithRawResponse: + return RulesResourceWithRawResponse(self._snippets.rules) + + +class AsyncSnippetsResourceWithRawResponse: + def __init__(self, snippets: AsyncSnippetsResource) -> None: + self._snippets = snippets + + self.update = async_to_raw_response_wrapper( + snippets.update, + ) + self.list = async_to_raw_response_wrapper( + snippets.list, + ) + self.delete = async_to_raw_response_wrapper( + snippets.delete, + ) + self.get = async_to_raw_response_wrapper( + snippets.get, + ) + + @cached_property + def content(self) -> AsyncContentResourceWithRawResponse: + return AsyncContentResourceWithRawResponse(self._snippets.content) + + @cached_property + def rules(self) -> AsyncRulesResourceWithRawResponse: + return AsyncRulesResourceWithRawResponse(self._snippets.rules) + + +class SnippetsResourceWithStreamingResponse: + def __init__(self, snippets: SnippetsResource) -> None: + self._snippets = snippets + + self.update = to_streamed_response_wrapper( + snippets.update, + ) + self.list = to_streamed_response_wrapper( + snippets.list, + ) + self.delete = to_streamed_response_wrapper( + snippets.delete, + ) + self.get = to_streamed_response_wrapper( + snippets.get, + ) + + @cached_property + def content(self) -> ContentResourceWithStreamingResponse: + return ContentResourceWithStreamingResponse(self._snippets.content) + + @cached_property + def rules(self) -> RulesResourceWithStreamingResponse: + return RulesResourceWithStreamingResponse(self._snippets.rules) + + +class AsyncSnippetsResourceWithStreamingResponse: + def __init__(self, snippets: AsyncSnippetsResource) -> None: + self._snippets = snippets + + self.update = async_to_streamed_response_wrapper( + snippets.update, + ) + self.list = async_to_streamed_response_wrapper( + snippets.list, + ) + self.delete = async_to_streamed_response_wrapper( + snippets.delete, + ) + self.get = async_to_streamed_response_wrapper( + snippets.get, + ) + + @cached_property + def content(self) -> AsyncContentResourceWithStreamingResponse: + return AsyncContentResourceWithStreamingResponse(self._snippets.content) + + @cached_property + def rules(self) -> AsyncRulesResourceWithStreamingResponse: + return AsyncRulesResourceWithStreamingResponse(self._snippets.rules) diff --git a/src/cloudflare/resources/web3/hostnames/hostnames.py b/src/cloudflare/resources/web3/hostnames/hostnames.py index d0dcae89c920..9bf5ac86e9a4 100644 --- a/src/cloudflare/resources/web3/hostnames/hostnames.py +++ b/src/cloudflare/resources/web3/hostnames/hostnames.py @@ -35,10 +35,7 @@ IPFSUniversalPathsResourceWithStreamingResponse, AsyncIPFSUniversalPathsResourceWithStreamingResponse, ) -from ....types.web3.hostname_get_response import HostnameGetResponse -from ....types.web3.hostname_edit_response import HostnameEditResponse -from ....types.web3.hostname_list_response import HostnameListResponse -from ....types.web3.hostname_create_response import HostnameCreateResponse +from ....types.web3.hostname import Hostname from ....types.web3.hostname_delete_response import HostnameDeleteResponse from .ipfs_universal_paths.ipfs_universal_paths import IPFSUniversalPathsResource, AsyncIPFSUniversalPathsResource @@ -71,7 +68,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> HostnameCreateResponse: + ) -> Hostname: """ Create Web3 Hostname @@ -109,9 +106,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[HostnameCreateResponse]._unwrapper, + post_parser=ResultWrapper[Hostname]._unwrapper, ), - cast_to=cast(Type[HostnameCreateResponse], ResultWrapper[HostnameCreateResponse]), + cast_to=cast(Type[Hostname], ResultWrapper[Hostname]), ) def list( @@ -124,7 +121,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncSinglePage[HostnameListResponse]: + ) -> SyncSinglePage[Hostname]: """ List Web3 Hostnames @@ -143,11 +140,11 @@ def list( raise ValueError(f"Expected a non-empty value for `zone_identifier` but received {zone_identifier!r}") return self._get_api_list( f"/zones/{zone_identifier}/web3/hostnames", - page=SyncSinglePage[HostnameListResponse], + page=SyncSinglePage[Hostname], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - model=HostnameListResponse, + model=Hostname, ) def delete( @@ -207,7 +204,7 @@ def edit( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> HostnameEditResponse: + ) -> Hostname: """ Edit Web3 Hostname @@ -246,9 +243,9 @@ def edit( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[HostnameEditResponse]._unwrapper, + post_parser=ResultWrapper[Hostname]._unwrapper, ), - cast_to=cast(Type[HostnameEditResponse], ResultWrapper[HostnameEditResponse]), + cast_to=cast(Type[Hostname], ResultWrapper[Hostname]), ) def get( @@ -262,7 +259,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> HostnameGetResponse: + ) -> Hostname: """ Web3 Hostname Details @@ -290,9 +287,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[HostnameGetResponse]._unwrapper, + post_parser=ResultWrapper[Hostname]._unwrapper, ), - cast_to=cast(Type[HostnameGetResponse], ResultWrapper[HostnameGetResponse]), + cast_to=cast(Type[Hostname], ResultWrapper[Hostname]), ) @@ -322,7 +319,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> HostnameCreateResponse: + ) -> Hostname: """ Create Web3 Hostname @@ -360,9 +357,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[HostnameCreateResponse]._unwrapper, + post_parser=ResultWrapper[Hostname]._unwrapper, ), - cast_to=cast(Type[HostnameCreateResponse], ResultWrapper[HostnameCreateResponse]), + cast_to=cast(Type[Hostname], ResultWrapper[Hostname]), ) def list( @@ -375,7 +372,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[HostnameListResponse, AsyncSinglePage[HostnameListResponse]]: + ) -> AsyncPaginator[Hostname, AsyncSinglePage[Hostname]]: """ List Web3 Hostnames @@ -394,11 +391,11 @@ def list( raise ValueError(f"Expected a non-empty value for `zone_identifier` but received {zone_identifier!r}") return self._get_api_list( f"/zones/{zone_identifier}/web3/hostnames", - page=AsyncSinglePage[HostnameListResponse], + page=AsyncSinglePage[Hostname], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - model=HostnameListResponse, + model=Hostname, ) async def delete( @@ -458,7 +455,7 @@ async def edit( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> HostnameEditResponse: + ) -> Hostname: """ Edit Web3 Hostname @@ -497,9 +494,9 @@ async def edit( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[HostnameEditResponse]._unwrapper, + post_parser=ResultWrapper[Hostname]._unwrapper, ), - cast_to=cast(Type[HostnameEditResponse], ResultWrapper[HostnameEditResponse]), + cast_to=cast(Type[Hostname], ResultWrapper[Hostname]), ) async def get( @@ -513,7 +510,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> HostnameGetResponse: + ) -> Hostname: """ Web3 Hostname Details @@ -541,9 +538,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[HostnameGetResponse]._unwrapper, + post_parser=ResultWrapper[Hostname]._unwrapper, ), - cast_to=cast(Type[HostnameGetResponse], ResultWrapper[HostnameGetResponse]), + cast_to=cast(Type[Hostname], ResultWrapper[Hostname]), ) diff --git a/src/cloudflare/resources/web3/hostnames/ipfs_universal_paths/content_lists/content_lists.py b/src/cloudflare/resources/web3/hostnames/ipfs_universal_paths/content_lists/content_lists.py index 75f6abaee0bb..d8c028bfc325 100644 --- a/src/cloudflare/resources/web3/hostnames/ipfs_universal_paths/content_lists/content_lists.py +++ b/src/cloudflare/resources/web3/hostnames/ipfs_universal_paths/content_lists/content_lists.py @@ -33,8 +33,7 @@ make_request_options, ) from ......types.web3.hostnames.ipfs_universal_paths import content_list_update_params -from ......types.web3.hostnames.ipfs_universal_paths.content_list_get_response import ContentListGetResponse -from ......types.web3.hostnames.ipfs_universal_paths.content_list_update_response import ContentListUpdateResponse +from ......types.web3.hostnames.ipfs_universal_paths.content_list import ContentList __all__ = ["ContentListsResource", "AsyncContentListsResource"] @@ -65,7 +64,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> ContentListUpdateResponse: + ) -> ContentList: """ Update IPFS Universal Path Gateway Content List @@ -104,9 +103,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[ContentListUpdateResponse]._unwrapper, + post_parser=ResultWrapper[ContentList]._unwrapper, ), - cast_to=cast(Type[ContentListUpdateResponse], ResultWrapper[ContentListUpdateResponse]), + cast_to=cast(Type[ContentList], ResultWrapper[ContentList]), ) def get( @@ -120,7 +119,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> ContentListGetResponse: + ) -> ContentList: """ IPFS Universal Path Gateway Content List Details @@ -148,9 +147,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[ContentListGetResponse]._unwrapper, + post_parser=ResultWrapper[ContentList]._unwrapper, ), - cast_to=cast(Type[ContentListGetResponse], ResultWrapper[ContentListGetResponse]), + cast_to=cast(Type[ContentList], ResultWrapper[ContentList]), ) @@ -180,7 +179,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> ContentListUpdateResponse: + ) -> ContentList: """ Update IPFS Universal Path Gateway Content List @@ -219,9 +218,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[ContentListUpdateResponse]._unwrapper, + post_parser=ResultWrapper[ContentList]._unwrapper, ), - cast_to=cast(Type[ContentListUpdateResponse], ResultWrapper[ContentListUpdateResponse]), + cast_to=cast(Type[ContentList], ResultWrapper[ContentList]), ) async def get( @@ -235,7 +234,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> ContentListGetResponse: + ) -> ContentList: """ IPFS Universal Path Gateway Content List Details @@ -263,9 +262,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[ContentListGetResponse]._unwrapper, + post_parser=ResultWrapper[ContentList]._unwrapper, ), - cast_to=cast(Type[ContentListGetResponse], ResultWrapper[ContentListGetResponse]), + cast_to=cast(Type[ContentList], ResultWrapper[ContentList]), ) diff --git a/src/cloudflare/types/radar/http/__init__.py b/src/cloudflare/types/radar/http/__init__.py index 69bf6aa60745..16be548d604f 100644 --- a/src/cloudflare/types/radar/http/__init__.py +++ b/src/cloudflare/types/radar/http/__init__.py @@ -19,12 +19,14 @@ from .timeseries_group_os_params import TimeseriesGroupOSParams as TimeseriesGroupOSParams from .summary_http_version_params import SummaryHTTPVersionParams as SummaryHTTPVersionParams from .summary_ip_version_response import SummaryIPVersionResponse as SummaryIPVersionResponse +from .summary_post_quantum_params import SummaryPostQuantumParams as SummaryPostQuantumParams from .top_browser_families_params import TopBrowserFamiliesParams as TopBrowserFamiliesParams from .summary_device_type_response import SummaryDeviceTypeResponse as SummaryDeviceTypeResponse from .summary_http_protocol_params import SummaryHTTPProtocolParams as SummaryHTTPProtocolParams from .summary_tls_version_response import SummaryTLSVersionResponse as SummaryTLSVersionResponse from .timeseries_group_os_response import TimeseriesGroupOSResponse as TimeseriesGroupOSResponse from .summary_http_version_response import SummaryHTTPVersionResponse as SummaryHTTPVersionResponse +from .summary_post_quantum_response import SummaryPostQuantumResponse as SummaryPostQuantumResponse from .top_browser_families_response import TopBrowserFamiliesResponse as TopBrowserFamiliesResponse from .summary_http_protocol_response import SummaryHTTPProtocolResponse as SummaryHTTPProtocolResponse from .timeseries_group_browser_params import TimeseriesGroupBrowserParams as TimeseriesGroupBrowserParams @@ -36,6 +38,7 @@ from .timeseries_group_tls_version_params import TimeseriesGroupTLSVersionParams as TimeseriesGroupTLSVersionParams from .timeseries_group_http_version_params import TimeseriesGroupHTTPVersionParams as TimeseriesGroupHTTPVersionParams from .timeseries_group_ip_version_response import TimeseriesGroupIPVersionResponse as TimeseriesGroupIPVersionResponse +from .timeseries_group_post_quantum_params import TimeseriesGroupPostQuantumParams as TimeseriesGroupPostQuantumParams from .timeseries_group_device_type_response import ( TimeseriesGroupDeviceTypeResponse as TimeseriesGroupDeviceTypeResponse, ) @@ -51,6 +54,9 @@ from .timeseries_group_http_version_response import ( TimeseriesGroupHTTPVersionResponse as TimeseriesGroupHTTPVersionResponse, ) +from .timeseries_group_post_quantum_response import ( + TimeseriesGroupPostQuantumResponse as TimeseriesGroupPostQuantumResponse, +) from .timeseries_group_http_protocol_response import ( TimeseriesGroupHTTPProtocolResponse as TimeseriesGroupHTTPProtocolResponse, ) diff --git a/src/cloudflare/types/radar/http/summary_post_quantum_params.py b/src/cloudflare/types/radar/http/summary_post_quantum_params.py new file mode 100644 index 000000000000..d62ab293bb9f --- /dev/null +++ b/src/cloudflare/types/radar/http/summary_post_quantum_params.py @@ -0,0 +1,101 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Union +from datetime import datetime +from typing_extensions import Literal, Annotated, TypedDict + +from ...._utils import PropertyInfo + +__all__ = ["SummaryPostQuantumParams"] + + +class SummaryPostQuantumParams(TypedDict, total=False): + asn: List[str] + """Array of comma separated list of ASNs, start with `-` to exclude from results. + + For example, `-174, 3356` excludes results from AS174, but includes results from + AS3356. + """ + + bot_class: Annotated[List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]], PropertyInfo(alias="botClass")] + """Filter for bot class. + + Refer to + [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + """ + + continent: List[str] + """Array of comma separated list of continents (alpha-2 continent codes). + + Start with `-` to exclude from results. For example, `-EU,NA` excludes results + from Europe, but includes results from North America. + """ + + date_end: Annotated[List[Union[str, datetime]], PropertyInfo(alias="dateEnd", format="iso8601")] + """End of the date range (inclusive).""" + + date_range: Annotated[ + List[ + Literal[ + "1d", + "2d", + "7d", + "14d", + "28d", + "12w", + "24w", + "52w", + "1dControl", + "2dControl", + "7dControl", + "14dControl", + "28dControl", + "12wControl", + "24wControl", + ] + ], + PropertyInfo(alias="dateRange"), + ] + """ + For example, use `7d` and `7dControl` to compare this week with the previous + week. Use this parameter or set specific start and end dates (`dateStart` and + `dateEnd` parameters). + """ + + date_start: Annotated[List[Union[str, datetime]], PropertyInfo(alias="dateStart", format="iso8601")] + """Array of datetimes to filter the start of a series.""" + + device_type: Annotated[List[Literal["DESKTOP", "MOBILE", "OTHER"]], PropertyInfo(alias="deviceType")] + """Filter for device type.""" + + format: Literal["JSON", "CSV"] + """Format results are returned in.""" + + http_protocol: Annotated[List[Literal["HTTP", "HTTPS"]], PropertyInfo(alias="httpProtocol")] + """Filter for http protocol.""" + + http_version: Annotated[List[Literal["HTTPv1", "HTTPv2", "HTTPv3"]], PropertyInfo(alias="httpVersion")] + """Filter for http version.""" + + ip_version: Annotated[List[Literal["IPv4", "IPv6"]], PropertyInfo(alias="ipVersion")] + """Filter for ip version.""" + + location: List[str] + """Array of comma separated list of locations (alpha-2 country codes). + + Start with `-` to exclude from results. For example, `-US,PT` excludes results + from the US, but includes results from PT. + """ + + name: List[str] + """Array of names that will be used to name the series in responses.""" + + os: List[Literal["WINDOWS", "MACOSX", "IOS", "ANDROID", "CHROMEOS", "LINUX", "SMART_TV"]] + """Filter for os name.""" + + tls_version: Annotated[ + List[Literal["TLSv1_0", "TLSv1_1", "TLSv1_2", "TLSv1_3", "TLSvQUIC"]], PropertyInfo(alias="tlsVersion") + ] + """Filter for tls version.""" diff --git a/src/cloudflare/types/radar/http/summary_post_quantum_response.py b/src/cloudflare/types/radar/http/summary_post_quantum_response.py new file mode 100644 index 000000000000..5a0ef8618f47 --- /dev/null +++ b/src/cloudflare/types/radar/http/summary_post_quantum_response.py @@ -0,0 +1,69 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel + +__all__ = [ + "SummaryPostQuantumResponse", + "Meta", + "MetaDateRange", + "MetaConfidenceInfo", + "MetaConfidenceInfoAnnotation", + "Summary0", +] + + +class MetaDateRange(BaseModel): + end_time: datetime = FieldInfo(alias="endTime") + """Adjusted end of date range.""" + + start_time: datetime = FieldInfo(alias="startTime") + """Adjusted start of date range.""" + + +class MetaConfidenceInfoAnnotation(BaseModel): + data_source: str = FieldInfo(alias="dataSource") + + description: str + + event_type: str = FieldInfo(alias="eventType") + + is_instantaneous: object = FieldInfo(alias="isInstantaneous") + + end_time: Optional[datetime] = FieldInfo(alias="endTime", default=None) + + linked_url: Optional[str] = FieldInfo(alias="linkedUrl", default=None) + + start_time: Optional[datetime] = FieldInfo(alias="startTime", default=None) + + +class MetaConfidenceInfo(BaseModel): + annotations: Optional[List[MetaConfidenceInfoAnnotation]] = None + + level: Optional[int] = None + + +class Meta(BaseModel): + date_range: List[MetaDateRange] = FieldInfo(alias="dateRange") + + last_updated: str = FieldInfo(alias="lastUpdated") + + normalization: str + + confidence_info: Optional[MetaConfidenceInfo] = FieldInfo(alias="confidenceInfo", default=None) + + +class Summary0(BaseModel): + not_supported: str = FieldInfo(alias="NOT_SUPPORTED") + + supported: str = FieldInfo(alias="SUPPORTED") + + +class SummaryPostQuantumResponse(BaseModel): + meta: Meta + + summary_0: Summary0 diff --git a/src/cloudflare/types/radar/http/timeseries_group_post_quantum_params.py b/src/cloudflare/types/radar/http/timeseries_group_post_quantum_params.py new file mode 100644 index 000000000000..09fa9317b8dc --- /dev/null +++ b/src/cloudflare/types/radar/http/timeseries_group_post_quantum_params.py @@ -0,0 +1,108 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Union +from datetime import datetime +from typing_extensions import Literal, Annotated, TypedDict + +from ...._utils import PropertyInfo + +__all__ = ["TimeseriesGroupPostQuantumParams"] + + +class TimeseriesGroupPostQuantumParams(TypedDict, total=False): + agg_interval: Annotated[Literal["15m", "1h", "1d", "1w"], PropertyInfo(alias="aggInterval")] + """ + Aggregation interval results should be returned in (for example, in 15 minutes + or 1 hour intervals). Refer to + [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + """ + + asn: List[str] + """Array of comma separated list of ASNs, start with `-` to exclude from results. + + For example, `-174, 3356` excludes results from AS174, but includes results from + AS3356. + """ + + bot_class: Annotated[List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]], PropertyInfo(alias="botClass")] + """Filter for bot class. + + Refer to + [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + """ + + continent: List[str] + """Array of comma separated list of continents (alpha-2 continent codes). + + Start with `-` to exclude from results. For example, `-EU,NA` excludes results + from Europe, but includes results from North America. + """ + + date_end: Annotated[List[Union[str, datetime]], PropertyInfo(alias="dateEnd", format="iso8601")] + """End of the date range (inclusive).""" + + date_range: Annotated[ + List[ + Literal[ + "1d", + "2d", + "7d", + "14d", + "28d", + "12w", + "24w", + "52w", + "1dControl", + "2dControl", + "7dControl", + "14dControl", + "28dControl", + "12wControl", + "24wControl", + ] + ], + PropertyInfo(alias="dateRange"), + ] + """ + For example, use `7d` and `7dControl` to compare this week with the previous + week. Use this parameter or set specific start and end dates (`dateStart` and + `dateEnd` parameters). + """ + + date_start: Annotated[List[Union[str, datetime]], PropertyInfo(alias="dateStart", format="iso8601")] + """Array of datetimes to filter the start of a series.""" + + device_type: Annotated[List[Literal["DESKTOP", "MOBILE", "OTHER"]], PropertyInfo(alias="deviceType")] + """Filter for device type.""" + + format: Literal["JSON", "CSV"] + """Format results are returned in.""" + + http_protocol: Annotated[List[Literal["HTTP", "HTTPS"]], PropertyInfo(alias="httpProtocol")] + """Filter for http protocol.""" + + http_version: Annotated[List[Literal["HTTPv1", "HTTPv2", "HTTPv3"]], PropertyInfo(alias="httpVersion")] + """Filter for http version.""" + + ip_version: Annotated[List[Literal["IPv4", "IPv6"]], PropertyInfo(alias="ipVersion")] + """Filter for ip version.""" + + location: List[str] + """Array of comma separated list of locations (alpha-2 country codes). + + Start with `-` to exclude from results. For example, `-US,PT` excludes results + from the US, but includes results from PT. + """ + + name: List[str] + """Array of names that will be used to name the series in responses.""" + + os: List[Literal["WINDOWS", "MACOSX", "IOS", "ANDROID", "CHROMEOS", "LINUX", "SMART_TV"]] + """Filter for os name.""" + + tls_version: Annotated[ + List[Literal["TLSv1_0", "TLSv1_1", "TLSv1_2", "TLSv1_3", "TLSvQUIC"]], PropertyInfo(alias="tlsVersion") + ] + """Filter for tls version.""" diff --git a/src/cloudflare/types/radar/http/timeseries_group_post_quantum_response.py b/src/cloudflare/types/radar/http/timeseries_group_post_quantum_response.py new file mode 100644 index 000000000000..17c145551b46 --- /dev/null +++ b/src/cloudflare/types/radar/http/timeseries_group_post_quantum_response.py @@ -0,0 +1,23 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel + +__all__ = ["TimeseriesGroupPostQuantumResponse", "Serie0"] + + +class Serie0(BaseModel): + not_supported: List[str] = FieldInfo(alias="NOT_SUPPORTED") + + supported: List[str] = FieldInfo(alias="SUPPORTED") + + timestamps: List[str] + + +class TimeseriesGroupPostQuantumResponse(BaseModel): + meta: object + + serie_0: Serie0 diff --git a/src/cloudflare/types/snippets/__init__.py b/src/cloudflare/types/snippets/__init__.py index f8ee8b14b1c9..2084aa6e7bb0 100644 --- a/src/cloudflare/types/snippets/__init__.py +++ b/src/cloudflare/types/snippets/__init__.py @@ -1,3 +1,10 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations + +from .snippet import Snippet as Snippet +from .rule_list_response import RuleListResponse as RuleListResponse +from .rule_update_params import RuleUpdateParams as RuleUpdateParams +from .rule_update_response import RuleUpdateResponse as RuleUpdateResponse +from .snippet_update_params import SnippetUpdateParams as SnippetUpdateParams +from .snippet_delete_response import SnippetDeleteResponse as SnippetDeleteResponse diff --git a/src/cloudflare/types/snippets/rule_list_response.py b/src/cloudflare/types/snippets/rule_list_response.py new file mode 100644 index 000000000000..63c540e55c78 --- /dev/null +++ b/src/cloudflare/types/snippets/rule_list_response.py @@ -0,0 +1,18 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["RuleListResponse"] + + +class RuleListResponse(BaseModel): + description: Optional[str] = None + + enabled: Optional[bool] = None + + expression: Optional[str] = None + + snippet_name: Optional[str] = None + """Snippet identifying name""" diff --git a/src/cloudflare/types/snippets/rule_update_params.py b/src/cloudflare/types/snippets/rule_update_params.py new file mode 100644 index 000000000000..a539ccf82139 --- /dev/null +++ b/src/cloudflare/types/snippets/rule_update_params.py @@ -0,0 +1,27 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Iterable +from typing_extensions import Required, TypedDict + +__all__ = ["RuleUpdateParams", "Rule"] + + +class RuleUpdateParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + rules: Iterable[Rule] + """List of snippet rules""" + + +class Rule(TypedDict, total=False): + description: str + + enabled: bool + + expression: str + + snippet_name: str + """Snippet identifying name""" diff --git a/src/cloudflare/types/snippets/rule_update_response.py b/src/cloudflare/types/snippets/rule_update_response.py new file mode 100644 index 000000000000..2abc8f16900b --- /dev/null +++ b/src/cloudflare/types/snippets/rule_update_response.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from ..._models import BaseModel + +__all__ = ["RuleUpdateResponse", "RuleUpdateResponseItem"] + + +class RuleUpdateResponseItem(BaseModel): + description: Optional[str] = None + + enabled: Optional[bool] = None + + expression: Optional[str] = None + + snippet_name: Optional[str] = None + """Snippet identifying name""" + + +RuleUpdateResponse = List[RuleUpdateResponseItem] diff --git a/src/cloudflare/types/snippets/snippet.py b/src/cloudflare/types/snippets/snippet.py new file mode 100644 index 000000000000..69dc660896e9 --- /dev/null +++ b/src/cloudflare/types/snippets/snippet.py @@ -0,0 +1,18 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["Snippet"] + + +class Snippet(BaseModel): + created_on: Optional[str] = None + """Creation time of the snippet""" + + modified_on: Optional[str] = None + """Modification time of the snippet""" + + snippet_name: Optional[str] = None + """Snippet identifying name""" diff --git a/src/cloudflare/types/snippets/snippet_delete_response.py b/src/cloudflare/types/snippets/snippet_delete_response.py new file mode 100644 index 000000000000..6a1b4806d1b6 --- /dev/null +++ b/src/cloudflare/types/snippets/snippet_delete_response.py @@ -0,0 +1,18 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo + +__all__ = ["SnippetDeleteResponse"] + + +class SnippetDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/snippets/snippet_update_params.py b/src/cloudflare/types/snippets/snippet_update_params.py new file mode 100644 index 000000000000..7f1e3894a009 --- /dev/null +++ b/src/cloudflare/types/snippets/snippet_update_params.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["SnippetUpdateParams", "Metadata"] + + +class SnippetUpdateParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + files: str + """Content files of uploaded snippet""" + + metadata: Metadata + + +class Metadata(TypedDict, total=False): + main_module: str + """Main module name of uploaded snippet""" diff --git a/src/cloudflare/types/web3/__init__.py b/src/cloudflare/types/web3/__init__.py index 36227fdbc21b..020395070ff7 100644 --- a/src/cloudflare/types/web3/__init__.py +++ b/src/cloudflare/types/web3/__init__.py @@ -2,10 +2,7 @@ from __future__ import annotations +from .hostname import Hostname as Hostname from .hostname_edit_params import HostnameEditParams as HostnameEditParams -from .hostname_get_response import HostnameGetResponse as HostnameGetResponse from .hostname_create_params import HostnameCreateParams as HostnameCreateParams -from .hostname_edit_response import HostnameEditResponse as HostnameEditResponse -from .hostname_list_response import HostnameListResponse as HostnameListResponse -from .hostname_create_response import HostnameCreateResponse as HostnameCreateResponse from .hostname_delete_response import HostnameDeleteResponse as HostnameDeleteResponse diff --git a/src/cloudflare/types/web3/hostname_get_response.py b/src/cloudflare/types/web3/hostname.py similarity index 92% rename from src/cloudflare/types/web3/hostname_get_response.py rename to src/cloudflare/types/web3/hostname.py index f74ddcd7029b..befb6b79bf1a 100644 --- a/src/cloudflare/types/web3/hostname_get_response.py +++ b/src/cloudflare/types/web3/hostname.py @@ -6,10 +6,10 @@ from ..._models import BaseModel -__all__ = ["HostnameGetResponse"] +__all__ = ["Hostname"] -class HostnameGetResponse(BaseModel): +class Hostname(BaseModel): id: Optional[str] = None """Identifier""" diff --git a/src/cloudflare/types/web3/hostname_create_response.py b/src/cloudflare/types/web3/hostname_create_response.py deleted file mode 100644 index f3a47f5991b3..000000000000 --- a/src/cloudflare/types/web3/hostname_create_response.py +++ /dev/null @@ -1,33 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional -from datetime import datetime -from typing_extensions import Literal - -from ..._models import BaseModel - -__all__ = ["HostnameCreateResponse"] - - -class HostnameCreateResponse(BaseModel): - id: Optional[str] = None - """Identifier""" - - created_on: Optional[datetime] = None - - description: Optional[str] = None - """An optional description of the hostname.""" - - dnslink: Optional[str] = None - """DNSLink value used if the target is ipfs.""" - - modified_on: Optional[datetime] = None - - name: Optional[str] = None - """The hostname that will point to the target gateway via CNAME.""" - - status: Optional[Literal["active", "pending", "deleting", "error"]] = None - """Status of the hostname's activation.""" - - target: Optional[Literal["ethereum", "ipfs", "ipfs_universal_path"]] = None - """Target gateway of the hostname.""" diff --git a/src/cloudflare/types/web3/hostname_edit_response.py b/src/cloudflare/types/web3/hostname_edit_response.py deleted file mode 100644 index 08f3c68b7948..000000000000 --- a/src/cloudflare/types/web3/hostname_edit_response.py +++ /dev/null @@ -1,33 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional -from datetime import datetime -from typing_extensions import Literal - -from ..._models import BaseModel - -__all__ = ["HostnameEditResponse"] - - -class HostnameEditResponse(BaseModel): - id: Optional[str] = None - """Identifier""" - - created_on: Optional[datetime] = None - - description: Optional[str] = None - """An optional description of the hostname.""" - - dnslink: Optional[str] = None - """DNSLink value used if the target is ipfs.""" - - modified_on: Optional[datetime] = None - - name: Optional[str] = None - """The hostname that will point to the target gateway via CNAME.""" - - status: Optional[Literal["active", "pending", "deleting", "error"]] = None - """Status of the hostname's activation.""" - - target: Optional[Literal["ethereum", "ipfs", "ipfs_universal_path"]] = None - """Target gateway of the hostname.""" diff --git a/src/cloudflare/types/web3/hostname_list_response.py b/src/cloudflare/types/web3/hostname_list_response.py deleted file mode 100644 index bd9672b46878..000000000000 --- a/src/cloudflare/types/web3/hostname_list_response.py +++ /dev/null @@ -1,33 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional -from datetime import datetime -from typing_extensions import Literal - -from ..._models import BaseModel - -__all__ = ["HostnameListResponse"] - - -class HostnameListResponse(BaseModel): - id: Optional[str] = None - """Identifier""" - - created_on: Optional[datetime] = None - - description: Optional[str] = None - """An optional description of the hostname.""" - - dnslink: Optional[str] = None - """DNSLink value used if the target is ipfs.""" - - modified_on: Optional[datetime] = None - - name: Optional[str] = None - """The hostname that will point to the target gateway via CNAME.""" - - status: Optional[Literal["active", "pending", "deleting", "error"]] = None - """Status of the hostname's activation.""" - - target: Optional[Literal["ethereum", "ipfs", "ipfs_universal_path"]] = None - """Target gateway of the hostname.""" diff --git a/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/__init__.py b/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/__init__.py index 24bd3fc782fa..c97af8e96194 100644 --- a/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/__init__.py +++ b/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/__init__.py @@ -2,6 +2,5 @@ from __future__ import annotations -from .content_list_get_response import ContentListGetResponse as ContentListGetResponse +from .content_list import ContentList as ContentList from .content_list_update_params import ContentListUpdateParams as ContentListUpdateParams -from .content_list_update_response import ContentListUpdateResponse as ContentListUpdateResponse diff --git a/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_list_get_response.py b/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_list.py similarity index 78% rename from src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_list_get_response.py rename to src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_list.py index 6cf7e420bf54..3585768a6177 100644 --- a/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_list_get_response.py +++ b/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_list.py @@ -5,9 +5,9 @@ from ....._models import BaseModel -__all__ = ["ContentListGetResponse"] +__all__ = ["ContentList"] -class ContentListGetResponse(BaseModel): +class ContentList(BaseModel): action: Optional[Literal["block"]] = None """Behavior of the content list.""" diff --git a/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_list_update_response.py b/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_list_update_response.py deleted file mode 100644 index d8948d62941f..000000000000 --- a/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_list_update_response.py +++ /dev/null @@ -1,13 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional -from typing_extensions import Literal - -from ....._models import BaseModel - -__all__ = ["ContentListUpdateResponse"] - - -class ContentListUpdateResponse(BaseModel): - action: Optional[Literal["block"]] = None - """Behavior of the content list.""" diff --git a/tests/api_resources/radar/http/test_summary.py b/tests/api_resources/radar/http/test_summary.py index 95bce001b6fd..fa84618dafe2 100644 --- a/tests/api_resources/radar/http/test_summary.py +++ b/tests/api_resources/radar/http/test_summary.py @@ -17,6 +17,7 @@ SummaryDeviceTypeResponse, SummaryTLSVersionResponse, SummaryHTTPVersionResponse, + SummaryPostQuantumResponse, SummaryHTTPProtocolResponse, ) @@ -344,6 +345,60 @@ def test_streaming_response_os(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_method_post_quantum(self, client: Cloudflare) -> None: + summary = client.radar.http.summary.post_quantum() + assert_matches_type(SummaryPostQuantumResponse, summary, path=["response"]) + + @parametrize + def test_method_post_quantum_with_all_params(self, client: Cloudflare) -> None: + summary = client.radar.http.summary.post_quantum( + asn=["string", "string", "string"], + bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + continent=["string", "string", "string"], + date_end=[ + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + ], + date_range=["1d", "2d", "7d"], + date_start=[ + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + ], + device_type=["DESKTOP", "MOBILE", "OTHER"], + format="JSON", + http_protocol=["HTTP", "HTTPS"], + http_version=["HTTPv1", "HTTPv2", "HTTPv3"], + ip_version=["IPv4", "IPv6"], + location=["string", "string", "string"], + name=["string", "string", "string"], + os=["WINDOWS", "MACOSX", "IOS"], + tls_version=["TLSv1_0", "TLSv1_1", "TLSv1_2"], + ) + assert_matches_type(SummaryPostQuantumResponse, summary, path=["response"]) + + @parametrize + def test_raw_response_post_quantum(self, client: Cloudflare) -> None: + response = client.radar.http.summary.with_raw_response.post_quantum() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + summary = response.parse() + assert_matches_type(SummaryPostQuantumResponse, summary, path=["response"]) + + @parametrize + def test_streaming_response_post_quantum(self, client: Cloudflare) -> None: + with client.radar.http.summary.with_streaming_response.post_quantum() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + summary = response.parse() + assert_matches_type(SummaryPostQuantumResponse, summary, path=["response"]) + + assert cast(Any, response.is_closed) is True + @parametrize def test_method_tls_version(self, client: Cloudflare) -> None: summary = client.radar.http.summary.tls_version() @@ -719,6 +774,60 @@ async def test_streaming_response_os(self, async_client: AsyncCloudflare) -> Non assert cast(Any, response.is_closed) is True + @parametrize + async def test_method_post_quantum(self, async_client: AsyncCloudflare) -> None: + summary = await async_client.radar.http.summary.post_quantum() + assert_matches_type(SummaryPostQuantumResponse, summary, path=["response"]) + + @parametrize + async def test_method_post_quantum_with_all_params(self, async_client: AsyncCloudflare) -> None: + summary = await async_client.radar.http.summary.post_quantum( + asn=["string", "string", "string"], + bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + continent=["string", "string", "string"], + date_end=[ + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + ], + date_range=["1d", "2d", "7d"], + date_start=[ + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + ], + device_type=["DESKTOP", "MOBILE", "OTHER"], + format="JSON", + http_protocol=["HTTP", "HTTPS"], + http_version=["HTTPv1", "HTTPv2", "HTTPv3"], + ip_version=["IPv4", "IPv6"], + location=["string", "string", "string"], + name=["string", "string", "string"], + os=["WINDOWS", "MACOSX", "IOS"], + tls_version=["TLSv1_0", "TLSv1_1", "TLSv1_2"], + ) + assert_matches_type(SummaryPostQuantumResponse, summary, path=["response"]) + + @parametrize + async def test_raw_response_post_quantum(self, async_client: AsyncCloudflare) -> None: + response = await async_client.radar.http.summary.with_raw_response.post_quantum() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + summary = await response.parse() + assert_matches_type(SummaryPostQuantumResponse, summary, path=["response"]) + + @parametrize + async def test_streaming_response_post_quantum(self, async_client: AsyncCloudflare) -> None: + async with async_client.radar.http.summary.with_streaming_response.post_quantum() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + summary = await response.parse() + assert_matches_type(SummaryPostQuantumResponse, summary, path=["response"]) + + assert cast(Any, response.is_closed) is True + @parametrize async def test_method_tls_version(self, async_client: AsyncCloudflare) -> None: summary = await async_client.radar.http.summary.tls_version() diff --git a/tests/api_resources/radar/http/test_timeseries_groups.py b/tests/api_resources/radar/http/test_timeseries_groups.py index bc8e856458b9..0371f0081713 100644 --- a/tests/api_resources/radar/http/test_timeseries_groups.py +++ b/tests/api_resources/radar/http/test_timeseries_groups.py @@ -18,6 +18,7 @@ TimeseriesGroupDeviceTypeResponse, TimeseriesGroupTLSVersionResponse, TimeseriesGroupHTTPVersionResponse, + TimeseriesGroupPostQuantumResponse, TimeseriesGroupHTTPProtocolResponse, TimeseriesGroupBrowserFamilyResponse, ) @@ -463,6 +464,61 @@ def test_streaming_response_os(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_method_post_quantum(self, client: Cloudflare) -> None: + timeseries_group = client.radar.http.timeseries_groups.post_quantum() + assert_matches_type(TimeseriesGroupPostQuantumResponse, timeseries_group, path=["response"]) + + @parametrize + def test_method_post_quantum_with_all_params(self, client: Cloudflare) -> None: + timeseries_group = client.radar.http.timeseries_groups.post_quantum( + agg_interval="1h", + asn=["string", "string", "string"], + bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + continent=["string", "string", "string"], + date_end=[ + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + ], + date_range=["1d", "2d", "7d"], + date_start=[ + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + ], + device_type=["DESKTOP", "MOBILE", "OTHER"], + format="JSON", + http_protocol=["HTTP", "HTTPS"], + http_version=["HTTPv1", "HTTPv2", "HTTPv3"], + ip_version=["IPv4", "IPv6"], + location=["string", "string", "string"], + name=["string", "string", "string"], + os=["WINDOWS", "MACOSX", "IOS"], + tls_version=["TLSv1_0", "TLSv1_1", "TLSv1_2"], + ) + assert_matches_type(TimeseriesGroupPostQuantumResponse, timeseries_group, path=["response"]) + + @parametrize + def test_raw_response_post_quantum(self, client: Cloudflare) -> None: + response = client.radar.http.timeseries_groups.with_raw_response.post_quantum() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + timeseries_group = response.parse() + assert_matches_type(TimeseriesGroupPostQuantumResponse, timeseries_group, path=["response"]) + + @parametrize + def test_streaming_response_post_quantum(self, client: Cloudflare) -> None: + with client.radar.http.timeseries_groups.with_streaming_response.post_quantum() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + timeseries_group = response.parse() + assert_matches_type(TimeseriesGroupPostQuantumResponse, timeseries_group, path=["response"]) + + assert cast(Any, response.is_closed) is True + @parametrize def test_method_tls_version(self, client: Cloudflare) -> None: timeseries_group = client.radar.http.timeseries_groups.tls_version() @@ -956,6 +1012,61 @@ async def test_streaming_response_os(self, async_client: AsyncCloudflare) -> Non assert cast(Any, response.is_closed) is True + @parametrize + async def test_method_post_quantum(self, async_client: AsyncCloudflare) -> None: + timeseries_group = await async_client.radar.http.timeseries_groups.post_quantum() + assert_matches_type(TimeseriesGroupPostQuantumResponse, timeseries_group, path=["response"]) + + @parametrize + async def test_method_post_quantum_with_all_params(self, async_client: AsyncCloudflare) -> None: + timeseries_group = await async_client.radar.http.timeseries_groups.post_quantum( + agg_interval="1h", + asn=["string", "string", "string"], + bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + continent=["string", "string", "string"], + date_end=[ + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + ], + date_range=["1d", "2d", "7d"], + date_start=[ + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + ], + device_type=["DESKTOP", "MOBILE", "OTHER"], + format="JSON", + http_protocol=["HTTP", "HTTPS"], + http_version=["HTTPv1", "HTTPv2", "HTTPv3"], + ip_version=["IPv4", "IPv6"], + location=["string", "string", "string"], + name=["string", "string", "string"], + os=["WINDOWS", "MACOSX", "IOS"], + tls_version=["TLSv1_0", "TLSv1_1", "TLSv1_2"], + ) + assert_matches_type(TimeseriesGroupPostQuantumResponse, timeseries_group, path=["response"]) + + @parametrize + async def test_raw_response_post_quantum(self, async_client: AsyncCloudflare) -> None: + response = await async_client.radar.http.timeseries_groups.with_raw_response.post_quantum() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + timeseries_group = await response.parse() + assert_matches_type(TimeseriesGroupPostQuantumResponse, timeseries_group, path=["response"]) + + @parametrize + async def test_streaming_response_post_quantum(self, async_client: AsyncCloudflare) -> None: + async with async_client.radar.http.timeseries_groups.with_streaming_response.post_quantum() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + timeseries_group = await response.parse() + assert_matches_type(TimeseriesGroupPostQuantumResponse, timeseries_group, path=["response"]) + + assert cast(Any, response.is_closed) is True + @parametrize async def test_method_tls_version(self, async_client: AsyncCloudflare) -> None: timeseries_group = await async_client.radar.http.timeseries_groups.tls_version() diff --git a/tests/api_resources/snippets/__init__.py b/tests/api_resources/snippets/__init__.py new file mode 100644 index 000000000000..fd8019a9a1ae --- /dev/null +++ b/tests/api_resources/snippets/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/snippets/test_content.py b/tests/api_resources/snippets/test_content.py new file mode 100644 index 000000000000..30f01990a8e4 --- /dev/null +++ b/tests/api_resources/snippets/test_content.py @@ -0,0 +1,160 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import httpx +import pytest +from respx import MockRouter + +from cloudflare import Cloudflare, AsyncCloudflare +from cloudflare._response import ( + BinaryAPIResponse, + AsyncBinaryAPIResponse, + StreamedBinaryAPIResponse, + AsyncStreamedBinaryAPIResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestContent: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + @pytest.mark.respx(base_url=base_url) + def test_method_get(self, client: Cloudflare, respx_mock: MockRouter) -> None: + respx_mock.get("/zones/023e105f4ecef8ad9ca31a8372d0c353/snippets/snippet_name_01/content").mock( + return_value=httpx.Response(200, json={"foo": "bar"}) + ) + content = client.snippets.content.get( + "snippet_name_01", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert content.is_closed + assert content.json() == {"foo": "bar"} + assert cast(Any, content.is_closed) is True + assert isinstance(content, BinaryAPIResponse) + + @parametrize + @pytest.mark.respx(base_url=base_url) + def test_raw_response_get(self, client: Cloudflare, respx_mock: MockRouter) -> None: + respx_mock.get("/zones/023e105f4ecef8ad9ca31a8372d0c353/snippets/snippet_name_01/content").mock( + return_value=httpx.Response(200, json={"foo": "bar"}) + ) + + content = client.snippets.content.with_raw_response.get( + "snippet_name_01", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert content.is_closed is True + assert content.http_request.headers.get("X-Stainless-Lang") == "python" + assert content.json() == {"foo": "bar"} + assert isinstance(content, BinaryAPIResponse) + + @parametrize + @pytest.mark.respx(base_url=base_url) + def test_streaming_response_get(self, client: Cloudflare, respx_mock: MockRouter) -> None: + respx_mock.get("/zones/023e105f4ecef8ad9ca31a8372d0c353/snippets/snippet_name_01/content").mock( + return_value=httpx.Response(200, json={"foo": "bar"}) + ) + with client.snippets.content.with_streaming_response.get( + "snippet_name_01", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as content: + assert not content.is_closed + assert content.http_request.headers.get("X-Stainless-Lang") == "python" + + assert content.json() == {"foo": "bar"} + assert cast(Any, content.is_closed) is True + assert isinstance(content, StreamedBinaryAPIResponse) + + assert cast(Any, content.is_closed) is True + + @parametrize + @pytest.mark.respx(base_url=base_url) + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.snippets.content.with_raw_response.get( + "snippet_name_01", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `snippet_name` but received ''"): + client.snippets.content.with_raw_response.get( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncContent: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + @pytest.mark.respx(base_url=base_url) + async def test_method_get(self, async_client: AsyncCloudflare, respx_mock: MockRouter) -> None: + respx_mock.get("/zones/023e105f4ecef8ad9ca31a8372d0c353/snippets/snippet_name_01/content").mock( + return_value=httpx.Response(200, json={"foo": "bar"}) + ) + content = await async_client.snippets.content.get( + "snippet_name_01", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert content.is_closed + assert await content.json() == {"foo": "bar"} + assert cast(Any, content.is_closed) is True + assert isinstance(content, AsyncBinaryAPIResponse) + + @parametrize + @pytest.mark.respx(base_url=base_url) + async def test_raw_response_get(self, async_client: AsyncCloudflare, respx_mock: MockRouter) -> None: + respx_mock.get("/zones/023e105f4ecef8ad9ca31a8372d0c353/snippets/snippet_name_01/content").mock( + return_value=httpx.Response(200, json={"foo": "bar"}) + ) + + content = await async_client.snippets.content.with_raw_response.get( + "snippet_name_01", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert content.is_closed is True + assert content.http_request.headers.get("X-Stainless-Lang") == "python" + assert await content.json() == {"foo": "bar"} + assert isinstance(content, AsyncBinaryAPIResponse) + + @parametrize + @pytest.mark.respx(base_url=base_url) + async def test_streaming_response_get(self, async_client: AsyncCloudflare, respx_mock: MockRouter) -> None: + respx_mock.get("/zones/023e105f4ecef8ad9ca31a8372d0c353/snippets/snippet_name_01/content").mock( + return_value=httpx.Response(200, json={"foo": "bar"}) + ) + async with async_client.snippets.content.with_streaming_response.get( + "snippet_name_01", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as content: + assert not content.is_closed + assert content.http_request.headers.get("X-Stainless-Lang") == "python" + + assert await content.json() == {"foo": "bar"} + assert cast(Any, content.is_closed) is True + assert isinstance(content, AsyncStreamedBinaryAPIResponse) + + assert cast(Any, content.is_closed) is True + + @parametrize + @pytest.mark.respx(base_url=base_url) + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.snippets.content.with_raw_response.get( + "snippet_name_01", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `snippet_name` but received ''"): + await async_client.snippets.content.with_raw_response.get( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/snippets/test_rules.py b/tests/api_resources/snippets/test_rules.py new file mode 100644 index 000000000000..83e021043b6a --- /dev/null +++ b/tests/api_resources/snippets/test_rules.py @@ -0,0 +1,229 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.snippets import RuleListResponse, RuleUpdateResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestRules: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + rule = client.snippets.rules.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[RuleUpdateResponse], rule, path=["response"]) + + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + rule = client.snippets.rules.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + rules=[ + { + "description": "Rule description", + "enabled": True, + "expression": 'http.cookie eq "a=b"', + "snippet_name": "snippet_name_01", + }, + { + "description": "Rule description", + "enabled": True, + "expression": 'http.cookie eq "a=b"', + "snippet_name": "snippet_name_01", + }, + { + "description": "Rule description", + "enabled": True, + "expression": 'http.cookie eq "a=b"', + "snippet_name": "snippet_name_01", + }, + ], + ) + assert_matches_type(Optional[RuleUpdateResponse], rule, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.snippets.rules.with_raw_response.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(Optional[RuleUpdateResponse], rule, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.snippets.rules.with_streaming_response.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(Optional[RuleUpdateResponse], rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.snippets.rules.with_raw_response.update( + zone_id="", + ) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + rule = client.snippets.rules.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncSinglePage[RuleListResponse], rule, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.snippets.rules.with_raw_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(SyncSinglePage[RuleListResponse], rule, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.snippets.rules.with_streaming_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(SyncSinglePage[RuleListResponse], rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.snippets.rules.with_raw_response.list( + zone_id="", + ) + + +class TestAsyncRules: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.snippets.rules.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[RuleUpdateResponse], rule, path=["response"]) + + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.snippets.rules.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + rules=[ + { + "description": "Rule description", + "enabled": True, + "expression": 'http.cookie eq "a=b"', + "snippet_name": "snippet_name_01", + }, + { + "description": "Rule description", + "enabled": True, + "expression": 'http.cookie eq "a=b"', + "snippet_name": "snippet_name_01", + }, + { + "description": "Rule description", + "enabled": True, + "expression": 'http.cookie eq "a=b"', + "snippet_name": "snippet_name_01", + }, + ], + ) + assert_matches_type(Optional[RuleUpdateResponse], rule, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.snippets.rules.with_raw_response.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(Optional[RuleUpdateResponse], rule, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.snippets.rules.with_streaming_response.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(Optional[RuleUpdateResponse], rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.snippets.rules.with_raw_response.update( + zone_id="", + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.snippets.rules.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncSinglePage[RuleListResponse], rule, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.snippets.rules.with_raw_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(AsyncSinglePage[RuleListResponse], rule, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.snippets.rules.with_streaming_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(AsyncSinglePage[RuleListResponse], rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.snippets.rules.with_raw_response.list( + zone_id="", + ) diff --git a/tests/api_resources/test_snippets.py b/tests/api_resources/test_snippets.py new file mode 100644 index 000000000000..779597259f95 --- /dev/null +++ b/tests/api_resources/test_snippets.py @@ -0,0 +1,407 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.snippets import Snippet, SnippetDeleteResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestSnippets: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + snippet = client.snippets.update( + "snippet_name_01", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[Snippet], snippet, path=["response"]) + + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + snippet = client.snippets.update( + "snippet_name_01", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + files="export { async function fetch(request, env) {return new Response('some_response') } }", + metadata={"main_module": "main.js"}, + ) + assert_matches_type(Optional[Snippet], snippet, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.snippets.with_raw_response.update( + "snippet_name_01", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + snippet = response.parse() + assert_matches_type(Optional[Snippet], snippet, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.snippets.with_streaming_response.update( + "snippet_name_01", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + snippet = response.parse() + assert_matches_type(Optional[Snippet], snippet, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.snippets.with_raw_response.update( + "snippet_name_01", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `snippet_name` but received ''"): + client.snippets.with_raw_response.update( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + snippet = client.snippets.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncSinglePage[Snippet], snippet, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.snippets.with_raw_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + snippet = response.parse() + assert_matches_type(SyncSinglePage[Snippet], snippet, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.snippets.with_streaming_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + snippet = response.parse() + assert_matches_type(SyncSinglePage[Snippet], snippet, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.snippets.with_raw_response.list( + zone_id="", + ) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + snippet = client.snippets.delete( + "snippet_name_01", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SnippetDeleteResponse, snippet, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.snippets.with_raw_response.delete( + "snippet_name_01", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + snippet = response.parse() + assert_matches_type(SnippetDeleteResponse, snippet, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.snippets.with_streaming_response.delete( + "snippet_name_01", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + snippet = response.parse() + assert_matches_type(SnippetDeleteResponse, snippet, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.snippets.with_raw_response.delete( + "snippet_name_01", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `snippet_name` but received ''"): + client.snippets.with_raw_response.delete( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + snippet = client.snippets.get( + "snippet_name_01", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[Snippet], snippet, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.snippets.with_raw_response.get( + "snippet_name_01", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + snippet = response.parse() + assert_matches_type(Optional[Snippet], snippet, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.snippets.with_streaming_response.get( + "snippet_name_01", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + snippet = response.parse() + assert_matches_type(Optional[Snippet], snippet, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.snippets.with_raw_response.get( + "snippet_name_01", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `snippet_name` but received ''"): + client.snippets.with_raw_response.get( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncSnippets: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + snippet = await async_client.snippets.update( + "snippet_name_01", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[Snippet], snippet, path=["response"]) + + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + snippet = await async_client.snippets.update( + "snippet_name_01", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + files="export { async function fetch(request, env) {return new Response('some_response') } }", + metadata={"main_module": "main.js"}, + ) + assert_matches_type(Optional[Snippet], snippet, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.snippets.with_raw_response.update( + "snippet_name_01", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + snippet = await response.parse() + assert_matches_type(Optional[Snippet], snippet, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.snippets.with_streaming_response.update( + "snippet_name_01", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + snippet = await response.parse() + assert_matches_type(Optional[Snippet], snippet, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.snippets.with_raw_response.update( + "snippet_name_01", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `snippet_name` but received ''"): + await async_client.snippets.with_raw_response.update( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + snippet = await async_client.snippets.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncSinglePage[Snippet], snippet, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.snippets.with_raw_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + snippet = await response.parse() + assert_matches_type(AsyncSinglePage[Snippet], snippet, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.snippets.with_streaming_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + snippet = await response.parse() + assert_matches_type(AsyncSinglePage[Snippet], snippet, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.snippets.with_raw_response.list( + zone_id="", + ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + snippet = await async_client.snippets.delete( + "snippet_name_01", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SnippetDeleteResponse, snippet, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.snippets.with_raw_response.delete( + "snippet_name_01", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + snippet = await response.parse() + assert_matches_type(SnippetDeleteResponse, snippet, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.snippets.with_streaming_response.delete( + "snippet_name_01", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + snippet = await response.parse() + assert_matches_type(SnippetDeleteResponse, snippet, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.snippets.with_raw_response.delete( + "snippet_name_01", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `snippet_name` but received ''"): + await async_client.snippets.with_raw_response.delete( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + snippet = await async_client.snippets.get( + "snippet_name_01", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[Snippet], snippet, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.snippets.with_raw_response.get( + "snippet_name_01", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + snippet = await response.parse() + assert_matches_type(Optional[Snippet], snippet, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.snippets.with_streaming_response.get( + "snippet_name_01", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + snippet = await response.parse() + assert_matches_type(Optional[Snippet], snippet, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.snippets.with_raw_response.get( + "snippet_name_01", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `snippet_name` but received ''"): + await async_client.snippets.with_raw_response.get( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/web3/hostnames/ipfs_universal_paths/test_content_lists.py b/tests/api_resources/web3/hostnames/ipfs_universal_paths/test_content_lists.py index f077db0339ba..9c682cddb810 100644 --- a/tests/api_resources/web3/hostnames/ipfs_universal_paths/test_content_lists.py +++ b/tests/api_resources/web3/hostnames/ipfs_universal_paths/test_content_lists.py @@ -9,10 +9,7 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type -from cloudflare.types.web3.hostnames.ipfs_universal_paths import ( - ContentListGetResponse, - ContentListUpdateResponse, -) +from cloudflare.types.web3.hostnames.ipfs_universal_paths import ContentList base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -28,7 +25,7 @@ def test_method_update(self, client: Cloudflare) -> None: action="block", entries=[{}, {}, {}], ) - assert_matches_type(ContentListUpdateResponse, content_list, path=["response"]) + assert_matches_type(ContentList, content_list, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -42,7 +39,7 @@ def test_raw_response_update(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" content_list = response.parse() - assert_matches_type(ContentListUpdateResponse, content_list, path=["response"]) + assert_matches_type(ContentList, content_list, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -56,7 +53,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" content_list = response.parse() - assert_matches_type(ContentListUpdateResponse, content_list, path=["response"]) + assert_matches_type(ContentList, content_list, path=["response"]) assert cast(Any, response.is_closed) is True @@ -84,7 +81,7 @@ def test_method_get(self, client: Cloudflare) -> None: "023e105f4ecef8ad9ca31a8372d0c353", zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(ContentListGetResponse, content_list, path=["response"]) + assert_matches_type(ContentList, content_list, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -96,7 +93,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" content_list = response.parse() - assert_matches_type(ContentListGetResponse, content_list, path=["response"]) + assert_matches_type(ContentList, content_list, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -108,7 +105,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" content_list = response.parse() - assert_matches_type(ContentListGetResponse, content_list, path=["response"]) + assert_matches_type(ContentList, content_list, path=["response"]) assert cast(Any, response.is_closed) is True @@ -138,7 +135,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: action="block", entries=[{}, {}, {}], ) - assert_matches_type(ContentListUpdateResponse, content_list, path=["response"]) + assert_matches_type(ContentList, content_list, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -152,7 +149,7 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" content_list = await response.parse() - assert_matches_type(ContentListUpdateResponse, content_list, path=["response"]) + assert_matches_type(ContentList, content_list, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -166,7 +163,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" content_list = await response.parse() - assert_matches_type(ContentListUpdateResponse, content_list, path=["response"]) + assert_matches_type(ContentList, content_list, path=["response"]) assert cast(Any, response.is_closed) is True @@ -194,7 +191,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "023e105f4ecef8ad9ca31a8372d0c353", zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(ContentListGetResponse, content_list, path=["response"]) + assert_matches_type(ContentList, content_list, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -206,7 +203,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" content_list = await response.parse() - assert_matches_type(ContentListGetResponse, content_list, path=["response"]) + assert_matches_type(ContentList, content_list, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -218,7 +215,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" content_list = await response.parse() - assert_matches_type(ContentListGetResponse, content_list, path=["response"]) + assert_matches_type(ContentList, content_list, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/web3/test_hostnames.py b/tests/api_resources/web3/test_hostnames.py index 632648b6bda9..d12712ea809e 100644 --- a/tests/api_resources/web3/test_hostnames.py +++ b/tests/api_resources/web3/test_hostnames.py @@ -10,13 +10,7 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.web3 import ( - HostnameGetResponse, - HostnameEditResponse, - HostnameListResponse, - HostnameCreateResponse, - HostnameDeleteResponse, -) +from cloudflare.types.web3 import Hostname, HostnameDeleteResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -30,7 +24,7 @@ def test_method_create(self, client: Cloudflare) -> None: "023e105f4ecef8ad9ca31a8372d0c353", target="ipfs", ) - assert_matches_type(HostnameCreateResponse, hostname, path=["response"]) + assert_matches_type(Hostname, hostname, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -40,7 +34,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: description="This is my IPFS gateway.", dnslink="/ipns/onboarding.ipfs.cloudflare.com", ) - assert_matches_type(HostnameCreateResponse, hostname, path=["response"]) + assert_matches_type(Hostname, hostname, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -52,7 +46,7 @@ def test_raw_response_create(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = response.parse() - assert_matches_type(HostnameCreateResponse, hostname, path=["response"]) + assert_matches_type(Hostname, hostname, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -64,7 +58,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = response.parse() - assert_matches_type(HostnameCreateResponse, hostname, path=["response"]) + assert_matches_type(Hostname, hostname, path=["response"]) assert cast(Any, response.is_closed) is True @@ -81,7 +75,7 @@ def test_method_list(self, client: Cloudflare) -> None: hostname = client.web3.hostnames.list( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(SyncSinglePage[HostnameListResponse], hostname, path=["response"]) + assert_matches_type(SyncSinglePage[Hostname], hostname, path=["response"]) @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: @@ -92,7 +86,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = response.parse() - assert_matches_type(SyncSinglePage[HostnameListResponse], hostname, path=["response"]) + assert_matches_type(SyncSinglePage[Hostname], hostname, path=["response"]) @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: @@ -103,7 +97,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = response.parse() - assert_matches_type(SyncSinglePage[HostnameListResponse], hostname, path=["response"]) + assert_matches_type(SyncSinglePage[Hostname], hostname, path=["response"]) assert cast(Any, response.is_closed) is True @@ -168,7 +162,7 @@ def test_method_edit(self, client: Cloudflare) -> None: "023e105f4ecef8ad9ca31a8372d0c353", zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(HostnameEditResponse, hostname, path=["response"]) + assert_matches_type(Hostname, hostname, path=["response"]) @parametrize def test_method_edit_with_all_params(self, client: Cloudflare) -> None: @@ -178,7 +172,7 @@ def test_method_edit_with_all_params(self, client: Cloudflare) -> None: description="This is my IPFS gateway.", dnslink="/ipns/onboarding.ipfs.cloudflare.com", ) - assert_matches_type(HostnameEditResponse, hostname, path=["response"]) + assert_matches_type(Hostname, hostname, path=["response"]) @parametrize def test_raw_response_edit(self, client: Cloudflare) -> None: @@ -190,7 +184,7 @@ def test_raw_response_edit(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = response.parse() - assert_matches_type(HostnameEditResponse, hostname, path=["response"]) + assert_matches_type(Hostname, hostname, path=["response"]) @parametrize def test_streaming_response_edit(self, client: Cloudflare) -> None: @@ -202,7 +196,7 @@ def test_streaming_response_edit(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = response.parse() - assert_matches_type(HostnameEditResponse, hostname, path=["response"]) + assert_matches_type(Hostname, hostname, path=["response"]) assert cast(Any, response.is_closed) is True @@ -226,7 +220,7 @@ def test_method_get(self, client: Cloudflare) -> None: "023e105f4ecef8ad9ca31a8372d0c353", zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(HostnameGetResponse, hostname, path=["response"]) + assert_matches_type(Hostname, hostname, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -238,7 +232,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = response.parse() - assert_matches_type(HostnameGetResponse, hostname, path=["response"]) + assert_matches_type(Hostname, hostname, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -250,7 +244,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = response.parse() - assert_matches_type(HostnameGetResponse, hostname, path=["response"]) + assert_matches_type(Hostname, hostname, path=["response"]) assert cast(Any, response.is_closed) is True @@ -278,7 +272,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "023e105f4ecef8ad9ca31a8372d0c353", target="ipfs", ) - assert_matches_type(HostnameCreateResponse, hostname, path=["response"]) + assert_matches_type(Hostname, hostname, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -288,7 +282,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare description="This is my IPFS gateway.", dnslink="/ipns/onboarding.ipfs.cloudflare.com", ) - assert_matches_type(HostnameCreateResponse, hostname, path=["response"]) + assert_matches_type(Hostname, hostname, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -300,7 +294,7 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = await response.parse() - assert_matches_type(HostnameCreateResponse, hostname, path=["response"]) + assert_matches_type(Hostname, hostname, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -312,7 +306,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = await response.parse() - assert_matches_type(HostnameCreateResponse, hostname, path=["response"]) + assert_matches_type(Hostname, hostname, path=["response"]) assert cast(Any, response.is_closed) is True @@ -329,7 +323,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: hostname = await async_client.web3.hostnames.list( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(AsyncSinglePage[HostnameListResponse], hostname, path=["response"]) + assert_matches_type(AsyncSinglePage[Hostname], hostname, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: @@ -340,7 +334,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = await response.parse() - assert_matches_type(AsyncSinglePage[HostnameListResponse], hostname, path=["response"]) + assert_matches_type(AsyncSinglePage[Hostname], hostname, path=["response"]) @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: @@ -351,7 +345,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = await response.parse() - assert_matches_type(AsyncSinglePage[HostnameListResponse], hostname, path=["response"]) + assert_matches_type(AsyncSinglePage[Hostname], hostname, path=["response"]) assert cast(Any, response.is_closed) is True @@ -416,7 +410,7 @@ async def test_method_edit(self, async_client: AsyncCloudflare) -> None: "023e105f4ecef8ad9ca31a8372d0c353", zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(HostnameEditResponse, hostname, path=["response"]) + assert_matches_type(Hostname, hostname, path=["response"]) @parametrize async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -426,7 +420,7 @@ async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) description="This is my IPFS gateway.", dnslink="/ipns/onboarding.ipfs.cloudflare.com", ) - assert_matches_type(HostnameEditResponse, hostname, path=["response"]) + assert_matches_type(Hostname, hostname, path=["response"]) @parametrize async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: @@ -438,7 +432,7 @@ async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = await response.parse() - assert_matches_type(HostnameEditResponse, hostname, path=["response"]) + assert_matches_type(Hostname, hostname, path=["response"]) @parametrize async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: @@ -450,7 +444,7 @@ async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = await response.parse() - assert_matches_type(HostnameEditResponse, hostname, path=["response"]) + assert_matches_type(Hostname, hostname, path=["response"]) assert cast(Any, response.is_closed) is True @@ -474,7 +468,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "023e105f4ecef8ad9ca31a8372d0c353", zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(HostnameGetResponse, hostname, path=["response"]) + assert_matches_type(Hostname, hostname, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -486,7 +480,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = await response.parse() - assert_matches_type(HostnameGetResponse, hostname, path=["response"]) + assert_matches_type(Hostname, hostname, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -498,7 +492,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = await response.parse() - assert_matches_type(HostnameGetResponse, hostname, path=["response"]) + assert_matches_type(Hostname, hostname, path=["response"]) assert cast(Any, response.is_closed) is True