From 878ae25e6b05626f0b9fc97ecb37728cb54279fd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 9 Jan 2025 22:20:07 +0000 Subject: [PATCH] feat(api): manual updates (#2349) --- .stats.yml | 2 +- api.md | 44 +- src/cloudflare/_client.py | 38 ++ src/cloudflare/resources/abuse_reports.py | 492 ++++++++++++++++++ .../api_gateway/operations/operations.py | 114 +++- .../origin_post_quantum_encryption.py | 127 +++++ .../zero_trust/dex/commands/__init__.py | 28 + .../zero_trust/dex/commands/commands.py | 64 +++ .../zero_trust/dex/commands/devices.py | 212 ++++++++ .../zero_trust/dex/commands/users.py | 189 +++++++ .../types/abuse_reports/__init__.py | 3 + .../abuse_report_create_params.py | 140 +++++ .../abuse_report_create_response.py | 7 + src/cloudflare/types/api_gateway/__init__.py | 2 + .../operation_bulk_create_params.py | 31 ++ .../operation_bulk_create_response.py | 239 +++++++++ .../__init__.py | 6 + ...n_post_quantum_encryption_update_params.py | 15 + ...post_quantum_encryption_update_response.py | 23 + .../types/zero_trust/dex/commands/__init__.py | 4 + .../dex/commands/device_list_params.py | 20 + .../dex/commands/device_list_response.py | 37 ++ .../dex/commands/user_list_params.py | 14 + .../dex/commands/user_list_response.py | 14 + .../api_gateway/test_operations.py | 133 +++++ tests/api_resources/test_abuse_reports.py | 243 +++++++++ .../test_origin_post_quantum_encryption.py | 109 +++- .../zero_trust/dex/commands/test_devices.py | 135 +++++ .../zero_trust/dex/commands/test_users.py | 114 ++++ 29 files changed, 2594 insertions(+), 5 deletions(-) create mode 100644 src/cloudflare/resources/abuse_reports.py create mode 100644 src/cloudflare/resources/zero_trust/dex/commands/devices.py create mode 100644 src/cloudflare/resources/zero_trust/dex/commands/users.py create mode 100644 src/cloudflare/types/abuse_reports/abuse_report_create_params.py create mode 100644 src/cloudflare/types/abuse_reports/abuse_report_create_response.py create mode 100644 src/cloudflare/types/api_gateway/operation_bulk_create_params.py create mode 100644 src/cloudflare/types/api_gateway/operation_bulk_create_response.py create mode 100644 src/cloudflare/types/origin_post_quantum_encryption/origin_post_quantum_encryption_update_params.py create mode 100644 src/cloudflare/types/origin_post_quantum_encryption/origin_post_quantum_encryption_update_response.py create mode 100644 src/cloudflare/types/zero_trust/dex/commands/device_list_params.py create mode 100644 src/cloudflare/types/zero_trust/dex/commands/device_list_response.py create mode 100644 src/cloudflare/types/zero_trust/dex/commands/user_list_params.py create mode 100644 src/cloudflare/types/zero_trust/dex/commands/user_list_response.py create mode 100644 tests/api_resources/test_abuse_reports.py create mode 100644 tests/api_resources/zero_trust/dex/commands/test_devices.py create mode 100644 tests/api_resources/zero_trust/dex/commands/test_users.py diff --git a/.stats.yml b/.stats.yml index 6b0e8583be0..927707d9503 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1488 +configured_endpoints: 1493 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-de70b033c163b7a4d4a11c5c66a7bcf7162020c433006b0d6b2d3e43c5b24df4.yml diff --git a/api.md b/api.md index 0059bd1866e..05082cde748 100644 --- a/api.md +++ b/api.md @@ -2692,6 +2692,7 @@ from cloudflare.types.api_gateway import ( OperationCreateResponse, OperationListResponse, OperationDeleteResponse, + OperationBulkCreateResponse, OperationBulkDeleteResponse, OperationGetResponse, ) @@ -2702,6 +2703,7 @@ Methods: - client.api_gateway.operations.create(\*, zone_id, \*\*params) -> OperationCreateResponse - client.api_gateway.operations.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[OperationListResponse] - client.api_gateway.operations.delete(operation_id, \*, zone_id) -> OperationDeleteResponse +- client.api_gateway.operations.bulk_create(\*, zone_id, \*\*params) -> OperationBulkCreateResponse - client.api_gateway.operations.bulk_delete(\*, zone_id) -> OperationBulkDeleteResponse - client.api_gateway.operations.get(operation_id, \*, zone_id, \*\*params) -> OperationGetResponse @@ -5647,6 +5649,30 @@ Methods: - client.zero_trust.dex.commands.create(\*, account_id, \*\*params) -> Optional[CommandCreateResponse] - client.zero_trust.dex.commands.list(\*, account_id, \*\*params) -> SyncV4PagePagination[Optional[CommandListResponse]] +#### Users + +Types: + +```python +from cloudflare.types.zero_trust.dex.commands import UserListResponse +``` + +Methods: + +- client.zero_trust.dex.commands.users.list(\*, account_id, \*\*params) -> Optional[UserListResponse] + +#### Devices + +Types: + +```python +from cloudflare.types.zero_trust.dex.commands import DeviceListResponse +``` + +Methods: + +- client.zero_trust.dex.commands.devices.list(\*, account_id, \*\*params) -> SyncV4PagePagination[Optional[DeviceListResponse]] + #### Downloads Methods: @@ -7804,11 +7830,15 @@ Methods: Types: ```python -from cloudflare.types.origin_post_quantum_encryption import OriginPostQuantumEncryptionGetResponse +from cloudflare.types.origin_post_quantum_encryption import ( + OriginPostQuantumEncryptionUpdateResponse, + OriginPostQuantumEncryptionGetResponse, +) ``` Methods: +- client.origin_post_quantum_encryption.update(\*, zone_id, \*\*params) -> Optional[OriginPostQuantumEncryptionUpdateResponse] - client.origin_post_quantum_encryption.get(\*, zone_id) -> Optional[OriginPostQuantumEncryptionGetResponse] # Speed @@ -8484,6 +8514,18 @@ Methods: - client.content_scanning.settings.get(\*, zone_id) -> SettingGetResponse +# AbuseReports + +Types: + +```python +from cloudflare.types.abuse_reports import AbuseReportCreateResponse +``` + +Methods: + +- client.abuse_reports.create(report_type, \*, account_id, \*\*params) -> str + # AI Types: diff --git a/src/cloudflare/_client.py b/src/cloudflare/_client.py index 0a874fee17f..f48b5ae2359 100644 --- a/src/cloudflare/_client.py +++ b/src/cloudflare/_client.py @@ -92,6 +92,7 @@ dns_firewall, healthchecks, security_txt, + abuse_reports, email_routing, magic_transit, waiting_rooms, @@ -150,6 +151,7 @@ from .resources.speed.speed import SpeedResource, AsyncSpeedResource from .resources.zones.zones import ZonesResource, AsyncZonesResource from .resources.security_txt import SecurityTXTResource, AsyncSecurityTXTResource + from .resources.abuse_reports import AbuseReportsResource, AsyncAbuseReportsResource from .resources.images.images import ImagesResource, AsyncImagesResource from .resources.queues.queues import QueuesResource, AsyncQueuesResource from .resources.stream.stream import StreamResource, AsyncStreamResource @@ -818,6 +820,12 @@ def content_scanning(self) -> ContentScanningResource: return ContentScanningResource(self) + @cached_property + def abuse_reports(self) -> AbuseReportsResource: + from .resources.abuse_reports import AbuseReportsResource + + return AbuseReportsResource(self) + @cached_property def ai(self) -> AIResource: from .resources.ai import AIResource @@ -1583,6 +1591,12 @@ def content_scanning(self) -> AsyncContentScanningResource: return AsyncContentScanningResource(self) + @cached_property + def abuse_reports(self) -> AsyncAbuseReportsResource: + from .resources.abuse_reports import AsyncAbuseReportsResource + + return AsyncAbuseReportsResource(self) + @cached_property def ai(self) -> AsyncAIResource: from .resources.ai import AsyncAIResource @@ -2283,6 +2297,12 @@ def content_scanning(self) -> content_scanning.ContentScanningResourceWithRawRes return ContentScanningResourceWithRawResponse(self._client.content_scanning) + @cached_property + def abuse_reports(self) -> abuse_reports.AbuseReportsResourceWithRawResponse: + from .resources.abuse_reports import AbuseReportsResourceWithRawResponse + + return AbuseReportsResourceWithRawResponse(self._client.abuse_reports) + @cached_property def ai(self) -> ai.AIResourceWithRawResponse: from .resources.ai import AIResourceWithRawResponse @@ -2802,6 +2822,12 @@ def content_scanning(self) -> content_scanning.AsyncContentScanningResourceWithR return AsyncContentScanningResourceWithRawResponse(self._client.content_scanning) + @cached_property + def abuse_reports(self) -> abuse_reports.AsyncAbuseReportsResourceWithRawResponse: + from .resources.abuse_reports import AsyncAbuseReportsResourceWithRawResponse + + return AsyncAbuseReportsResourceWithRawResponse(self._client.abuse_reports) + @cached_property def ai(self) -> ai.AsyncAIResourceWithRawResponse: from .resources.ai import AsyncAIResourceWithRawResponse @@ -3321,6 +3347,12 @@ def content_scanning(self) -> content_scanning.ContentScanningResourceWithStream return ContentScanningResourceWithStreamingResponse(self._client.content_scanning) + @cached_property + def abuse_reports(self) -> abuse_reports.AbuseReportsResourceWithStreamingResponse: + from .resources.abuse_reports import AbuseReportsResourceWithStreamingResponse + + return AbuseReportsResourceWithStreamingResponse(self._client.abuse_reports) + @cached_property def ai(self) -> ai.AIResourceWithStreamingResponse: from .resources.ai import AIResourceWithStreamingResponse @@ -3850,6 +3882,12 @@ def content_scanning(self) -> content_scanning.AsyncContentScanningResourceWithS return AsyncContentScanningResourceWithStreamingResponse(self._client.content_scanning) + @cached_property + def abuse_reports(self) -> abuse_reports.AsyncAbuseReportsResourceWithStreamingResponse: + from .resources.abuse_reports import AsyncAbuseReportsResourceWithStreamingResponse + + return AsyncAbuseReportsResourceWithStreamingResponse(self._client.abuse_reports) + @cached_property def ai(self) -> ai.AsyncAIResourceWithStreamingResponse: from .resources.ai import AsyncAIResourceWithStreamingResponse diff --git a/src/cloudflare/resources/abuse_reports.py b/src/cloudflare/resources/abuse_reports.py new file mode 100644 index 00000000000..a81ce3c43a6 --- /dev/null +++ b/src/cloudflare/resources/abuse_reports.py @@ -0,0 +1,492 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast +from typing_extensions import Literal + +import httpx + +from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from .._utils import ( + maybe_transform, + async_maybe_transform, +) +from .._compat import cached_property +from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from .._wrappers import ResultWrapper +from .._base_client import make_request_options +from ..types.abuse_reports import abuse_report_create_params +from ..types.abuse_reports.abuse_report_create_response import AbuseReportCreateResponse + +__all__ = ["AbuseReportsResource", "AsyncAbuseReportsResource"] + + +class AbuseReportsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> AbuseReportsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return the + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AbuseReportsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AbuseReportsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AbuseReportsResourceWithStreamingResponse(self) + + def create( + self, + report_type: Literal[ + "abuse_dmca", + "abuse_trademark", + "abuse_general", + "abuse_phishing", + "abuse_children", + "abuse_threat", + "abuse_registrar_whois", + "abuse_ncsei", + ], + *, + account_id: str, + act: Literal[ + "abuse_dmca", + "abuse_trademark", + "abuse_general", + "abuse_phishing", + "abuse_children", + "abuse_threat", + "abuse_registrar_whois", + "abuse_ncsei", + ], + email: str, + email2: str, + host_notification: Literal["send", "send-anon", "none"], + ncmec_notification: Literal["send", "send-anon", "none"], + owner_notification: Literal["send", "send-anon", "none"], + urls: str, + address1: str | NotGiven = NOT_GIVEN, + agent_name: str | NotGiven = NOT_GIVEN, + agree: Literal[0, 1] | NotGiven = NOT_GIVEN, + city: str | NotGiven = NOT_GIVEN, + comments: str | NotGiven = NOT_GIVEN, + company: str | NotGiven = NOT_GIVEN, + country: str | NotGiven = NOT_GIVEN, + destination_ips: str | NotGiven = NOT_GIVEN, + justification: str | NotGiven = NOT_GIVEN, + name: str | NotGiven = NOT_GIVEN, + ncsei_subject_representation: bool | NotGiven = NOT_GIVEN, + original_work: str | NotGiven = NOT_GIVEN, + ports_protocols: str | NotGiven = NOT_GIVEN, + signature: str | NotGiven = NOT_GIVEN, + source_ips: str | NotGiven = NOT_GIVEN, + state: str | NotGiven = NOT_GIVEN, + tele: str | NotGiven = NOT_GIVEN, + title: str | NotGiven = NOT_GIVEN, + trademark_number: str | NotGiven = NOT_GIVEN, + trademark_office: str | NotGiven = NOT_GIVEN, + trademark_symbol: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> str: + """ + Submit the Abuse Report of a particular type + + Args: + report_type: The abuse report type + + act: The abuse report type + + email: A valid email of the abuse reporter + + email2: Should match the value provided in `email` + + host_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + ncmec_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + owner_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + urls: A list of valid URLs separated by ‘ ’ (new line character). The list of the URLs + should not exceed 250 URLs. All URLs should have the same hostname. Each URL + should be unique + + address1: Text not exceeding 100 characters + + agent_name: The name of the copyright holder. Text not exceeding 60 characters. + + agree: Can be 0 or 1 + + city: Text not exceeding 255 characters + + comments: Any additional comments about the infringement not exceeding 2000 characters + + company: Text not exceeding 100 characters + + country: Text not exceeding 255 characters + + destination_ips: A list of IP addresses separated by ‘ ’ (new line character). The list of + destination IPs should not exceed 30 IP addresses. Each one of the IP addresses + ought to be unique + + justification: A detailed description of the infringement, including any necessary access + details and the exact steps needed to view the content, not exceeding 5000 + characters + + name: Text not exceeding 255 characters + + ncsei_subject_representation: If the submitter is the target of NCSEI in the URLs of the abuse report + + original_work: Text not exceeding 255 characters + + ports_protocols: A comma separated list of ports and protocols e.g. 80/TCP, 22/UDP. The total + size of the field should not exceed 2000 characters. Each individual + port/protocol should not exceed 100 characters. The list should not have more + than 30 unique ports and protocols. + + signature: Required for DMCA reports, should be same as Name. An affirmation that all + information in the report is true and accurate while agreeing to the policies of + Cloudflare's abuse reports + + source_ips: A list of IP addresses separated by ‘ ’ (new line character). The list of source + IPs should not exceed 30 IP addresses. Each one of the IP addresses ought to be + unique + + state: Text not exceeding 255 characters + + tele: Text not exceeding 20 characters + + title: Text not exceeding 255 characters + + trademark_number: Text not exceeding 1000 characters + + trademark_office: Text not exceeding 1000 characters + + trademark_symbol: Text not exceeding 1000 characters + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not report_type: + raise ValueError(f"Expected a non-empty value for `report_type` but received {report_type!r}") + return self._post( + f"/accounts/{account_id}/abuse-reports/{report_type}", + body=maybe_transform( + { + "act": act, + "email": email, + "email2": email2, + "host_notification": host_notification, + "ncmec_notification": ncmec_notification, + "owner_notification": owner_notification, + "urls": urls, + "address1": address1, + "agent_name": agent_name, + "agree": agree, + "city": city, + "comments": comments, + "company": company, + "country": country, + "destination_ips": destination_ips, + "justification": justification, + "name": name, + "ncsei_subject_representation": ncsei_subject_representation, + "original_work": original_work, + "ports_protocols": ports_protocols, + "signature": signature, + "source_ips": source_ips, + "state": state, + "tele": tele, + "title": title, + "trademark_number": trademark_number, + "trademark_office": trademark_office, + "trademark_symbol": trademark_symbol, + }, + abuse_report_create_params.AbuseReportCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[AbuseReportCreateResponse]._unwrapper, + ), + cast_to=cast(Type[str], ResultWrapper[str]), + ) + + +class AsyncAbuseReportsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncAbuseReportsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return the + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncAbuseReportsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncAbuseReportsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncAbuseReportsResourceWithStreamingResponse(self) + + async def create( + self, + report_type: Literal[ + "abuse_dmca", + "abuse_trademark", + "abuse_general", + "abuse_phishing", + "abuse_children", + "abuse_threat", + "abuse_registrar_whois", + "abuse_ncsei", + ], + *, + account_id: str, + act: Literal[ + "abuse_dmca", + "abuse_trademark", + "abuse_general", + "abuse_phishing", + "abuse_children", + "abuse_threat", + "abuse_registrar_whois", + "abuse_ncsei", + ], + email: str, + email2: str, + host_notification: Literal["send", "send-anon", "none"], + ncmec_notification: Literal["send", "send-anon", "none"], + owner_notification: Literal["send", "send-anon", "none"], + urls: str, + address1: str | NotGiven = NOT_GIVEN, + agent_name: str | NotGiven = NOT_GIVEN, + agree: Literal[0, 1] | NotGiven = NOT_GIVEN, + city: str | NotGiven = NOT_GIVEN, + comments: str | NotGiven = NOT_GIVEN, + company: str | NotGiven = NOT_GIVEN, + country: str | NotGiven = NOT_GIVEN, + destination_ips: str | NotGiven = NOT_GIVEN, + justification: str | NotGiven = NOT_GIVEN, + name: str | NotGiven = NOT_GIVEN, + ncsei_subject_representation: bool | NotGiven = NOT_GIVEN, + original_work: str | NotGiven = NOT_GIVEN, + ports_protocols: str | NotGiven = NOT_GIVEN, + signature: str | NotGiven = NOT_GIVEN, + source_ips: str | NotGiven = NOT_GIVEN, + state: str | NotGiven = NOT_GIVEN, + tele: str | NotGiven = NOT_GIVEN, + title: str | NotGiven = NOT_GIVEN, + trademark_number: str | NotGiven = NOT_GIVEN, + trademark_office: str | NotGiven = NOT_GIVEN, + trademark_symbol: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> str: + """ + Submit the Abuse Report of a particular type + + Args: + report_type: The abuse report type + + act: The abuse report type + + email: A valid email of the abuse reporter + + email2: Should match the value provided in `email` + + host_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + ncmec_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + owner_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + urls: A list of valid URLs separated by ‘ ’ (new line character). The list of the URLs + should not exceed 250 URLs. All URLs should have the same hostname. Each URL + should be unique + + address1: Text not exceeding 100 characters + + agent_name: The name of the copyright holder. Text not exceeding 60 characters. + + agree: Can be 0 or 1 + + city: Text not exceeding 255 characters + + comments: Any additional comments about the infringement not exceeding 2000 characters + + company: Text not exceeding 100 characters + + country: Text not exceeding 255 characters + + destination_ips: A list of IP addresses separated by ‘ ’ (new line character). The list of + destination IPs should not exceed 30 IP addresses. Each one of the IP addresses + ought to be unique + + justification: A detailed description of the infringement, including any necessary access + details and the exact steps needed to view the content, not exceeding 5000 + characters + + name: Text not exceeding 255 characters + + ncsei_subject_representation: If the submitter is the target of NCSEI in the URLs of the abuse report + + original_work: Text not exceeding 255 characters + + ports_protocols: A comma separated list of ports and protocols e.g. 80/TCP, 22/UDP. The total + size of the field should not exceed 2000 characters. Each individual + port/protocol should not exceed 100 characters. The list should not have more + than 30 unique ports and protocols. + + signature: Required for DMCA reports, should be same as Name. An affirmation that all + information in the report is true and accurate while agreeing to the policies of + Cloudflare's abuse reports + + source_ips: A list of IP addresses separated by ‘ ’ (new line character). The list of source + IPs should not exceed 30 IP addresses. Each one of the IP addresses ought to be + unique + + state: Text not exceeding 255 characters + + tele: Text not exceeding 20 characters + + title: Text not exceeding 255 characters + + trademark_number: Text not exceeding 1000 characters + + trademark_office: Text not exceeding 1000 characters + + trademark_symbol: Text not exceeding 1000 characters + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not report_type: + raise ValueError(f"Expected a non-empty value for `report_type` but received {report_type!r}") + return await self._post( + f"/accounts/{account_id}/abuse-reports/{report_type}", + body=await async_maybe_transform( + { + "act": act, + "email": email, + "email2": email2, + "host_notification": host_notification, + "ncmec_notification": ncmec_notification, + "owner_notification": owner_notification, + "urls": urls, + "address1": address1, + "agent_name": agent_name, + "agree": agree, + "city": city, + "comments": comments, + "company": company, + "country": country, + "destination_ips": destination_ips, + "justification": justification, + "name": name, + "ncsei_subject_representation": ncsei_subject_representation, + "original_work": original_work, + "ports_protocols": ports_protocols, + "signature": signature, + "source_ips": source_ips, + "state": state, + "tele": tele, + "title": title, + "trademark_number": trademark_number, + "trademark_office": trademark_office, + "trademark_symbol": trademark_symbol, + }, + abuse_report_create_params.AbuseReportCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[AbuseReportCreateResponse]._unwrapper, + ), + cast_to=cast(Type[str], ResultWrapper[str]), + ) + + +class AbuseReportsResourceWithRawResponse: + def __init__(self, abuse_reports: AbuseReportsResource) -> None: + self._abuse_reports = abuse_reports + + self.create = to_raw_response_wrapper( + abuse_reports.create, + ) + + +class AsyncAbuseReportsResourceWithRawResponse: + def __init__(self, abuse_reports: AsyncAbuseReportsResource) -> None: + self._abuse_reports = abuse_reports + + self.create = async_to_raw_response_wrapper( + abuse_reports.create, + ) + + +class AbuseReportsResourceWithStreamingResponse: + def __init__(self, abuse_reports: AbuseReportsResource) -> None: + self._abuse_reports = abuse_reports + + self.create = to_streamed_response_wrapper( + abuse_reports.create, + ) + + +class AsyncAbuseReportsResourceWithStreamingResponse: + def __init__(self, abuse_reports: AsyncAbuseReportsResource) -> None: + self._abuse_reports = abuse_reports + + self.create = async_to_streamed_response_wrapper( + abuse_reports.create, + ) diff --git a/src/cloudflare/resources/api_gateway/operations/operations.py b/src/cloudflare/resources/api_gateway/operations/operations.py index d8bb975489f..2681b95f944 100644 --- a/src/cloudflare/resources/api_gateway/operations/operations.py +++ b/src/cloudflare/resources/api_gateway/operations/operations.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, cast +from typing import List, Type, Iterable, cast from typing_extensions import Literal import httpx @@ -31,11 +31,17 @@ SchemaValidationResourceWithStreamingResponse, AsyncSchemaValidationResourceWithStreamingResponse, ) -from ....types.api_gateway import operation_get_params, operation_list_params, operation_create_params +from ....types.api_gateway import ( + operation_get_params, + operation_list_params, + operation_create_params, + operation_bulk_create_params, +) from ....types.api_gateway.operation_get_response import OperationGetResponse from ....types.api_gateway.operation_list_response import OperationListResponse from ....types.api_gateway.operation_create_response import OperationCreateResponse from ....types.api_gateway.operation_delete_response import OperationDeleteResponse +from ....types.api_gateway.operation_bulk_create_response import OperationBulkCreateResponse from ....types.api_gateway.operation_bulk_delete_response import OperationBulkDeleteResponse __all__ = ["OperationsResource", "AsyncOperationsResource"] @@ -248,6 +254,52 @@ def delete( cast_to=OperationDeleteResponse, ) + def bulk_create( + self, + *, + zone_id: str, + body: Iterable[operation_bulk_create_params.Body], + # 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, + ) -> OperationBulkCreateResponse: + """Add one or more operations to a zone. + + Endpoints can contain path variables. + Host, method, endpoint will be normalized to a canoncial form when creating an + operation and must be unique on the zone. Inserting an operation that matches an + existing one will return the record of the already existing operation and update + its last_updated date. + + 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._post( + f"/zones/{zone_id}/api_gateway/operations", + body=maybe_transform(body, Iterable[operation_bulk_create_params.Body]), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[OperationBulkCreateResponse]._unwrapper, + ), + cast_to=cast(Type[OperationBulkCreateResponse], ResultWrapper[OperationBulkCreateResponse]), + ) + def bulk_delete( self, *, @@ -541,6 +593,52 @@ async def delete( cast_to=OperationDeleteResponse, ) + async def bulk_create( + self, + *, + zone_id: str, + body: Iterable[operation_bulk_create_params.Body], + # 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, + ) -> OperationBulkCreateResponse: + """Add one or more operations to a zone. + + Endpoints can contain path variables. + Host, method, endpoint will be normalized to a canoncial form when creating an + operation and must be unique on the zone. Inserting an operation that matches an + existing one will return the record of the already existing operation and update + its last_updated date. + + 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 await self._post( + f"/zones/{zone_id}/api_gateway/operations", + body=await async_maybe_transform(body, Iterable[operation_bulk_create_params.Body]), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[OperationBulkCreateResponse]._unwrapper, + ), + cast_to=cast(Type[OperationBulkCreateResponse], ResultWrapper[OperationBulkCreateResponse]), + ) + async def bulk_delete( self, *, @@ -640,6 +738,9 @@ def __init__(self, operations: OperationsResource) -> None: self.delete = to_raw_response_wrapper( operations.delete, ) + self.bulk_create = to_raw_response_wrapper( + operations.bulk_create, + ) self.bulk_delete = to_raw_response_wrapper( operations.bulk_delete, ) @@ -665,6 +766,9 @@ def __init__(self, operations: AsyncOperationsResource) -> None: self.delete = async_to_raw_response_wrapper( operations.delete, ) + self.bulk_create = async_to_raw_response_wrapper( + operations.bulk_create, + ) self.bulk_delete = async_to_raw_response_wrapper( operations.bulk_delete, ) @@ -690,6 +794,9 @@ def __init__(self, operations: OperationsResource) -> None: self.delete = to_streamed_response_wrapper( operations.delete, ) + self.bulk_create = to_streamed_response_wrapper( + operations.bulk_create, + ) self.bulk_delete = to_streamed_response_wrapper( operations.bulk_delete, ) @@ -715,6 +822,9 @@ def __init__(self, operations: AsyncOperationsResource) -> None: self.delete = async_to_streamed_response_wrapper( operations.delete, ) + self.bulk_create = async_to_streamed_response_wrapper( + operations.bulk_create, + ) self.bulk_delete = async_to_streamed_response_wrapper( operations.bulk_delete, ) diff --git a/src/cloudflare/resources/origin_post_quantum_encryption.py b/src/cloudflare/resources/origin_post_quantum_encryption.py index 496eaf5495f..ff991b49d4c 100644 --- a/src/cloudflare/resources/origin_post_quantum_encryption.py +++ b/src/cloudflare/resources/origin_post_quantum_encryption.py @@ -3,10 +3,15 @@ from __future__ import annotations from typing import Type, Optional, cast +from typing_extensions import Literal import httpx from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from .._utils import ( + maybe_transform, + async_maybe_transform, +) from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource from .._response import ( @@ -17,9 +22,13 @@ ) from .._wrappers import ResultWrapper from .._base_client import make_request_options +from ..types.origin_post_quantum_encryption import origin_post_quantum_encryption_update_params from ..types.origin_post_quantum_encryption.origin_post_quantum_encryption_get_response import ( OriginPostQuantumEncryptionGetResponse, ) +from ..types.origin_post_quantum_encryption.origin_post_quantum_encryption_update_response import ( + OriginPostQuantumEncryptionUpdateResponse, +) __all__ = ["OriginPostQuantumEncryptionResource", "AsyncOriginPostQuantumEncryptionResource"] @@ -44,6 +53,59 @@ def with_streaming_response(self) -> OriginPostQuantumEncryptionResourceWithStre """ return OriginPostQuantumEncryptionResourceWithStreamingResponse(self) + def update( + self, + *, + zone_id: str, + value: Literal["preferred", "supported", "off"], + # 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[OriginPostQuantumEncryptionUpdateResponse]: + """ + Instructs Cloudflare to use Post-Quantum (PQ) key agreement algorithms when + connecting to your origin. Preferred instructs Cloudflare to opportunistically + send a Post-Quantum keyshare in the first message to the origin (for fastest + connections when the origin supports and prefers PQ), supported means that PQ + algorithms are advertised but only used when requested by the origin, and off + means that PQ algorithms are not advertised + + Args: + zone_id: Identifier + + value: Value of the Origin Post Quantum Encryption Setting. + + 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}/cache/origin_post_quantum_encryption", + body=maybe_transform( + {"value": value}, origin_post_quantum_encryption_update_params.OriginPostQuantumEncryptionUpdateParams + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[OriginPostQuantumEncryptionUpdateResponse]]._unwrapper, + ), + cast_to=cast( + Type[Optional[OriginPostQuantumEncryptionUpdateResponse]], + ResultWrapper[OriginPostQuantumEncryptionUpdateResponse], + ), + ) + def get( self, *, @@ -112,6 +174,59 @@ def with_streaming_response(self) -> AsyncOriginPostQuantumEncryptionResourceWit """ return AsyncOriginPostQuantumEncryptionResourceWithStreamingResponse(self) + async def update( + self, + *, + zone_id: str, + value: Literal["preferred", "supported", "off"], + # 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[OriginPostQuantumEncryptionUpdateResponse]: + """ + Instructs Cloudflare to use Post-Quantum (PQ) key agreement algorithms when + connecting to your origin. Preferred instructs Cloudflare to opportunistically + send a Post-Quantum keyshare in the first message to the origin (for fastest + connections when the origin supports and prefers PQ), supported means that PQ + algorithms are advertised but only used when requested by the origin, and off + means that PQ algorithms are not advertised + + Args: + zone_id: Identifier + + value: Value of the Origin Post Quantum Encryption Setting. + + 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}/cache/origin_post_quantum_encryption", + body=await async_maybe_transform( + {"value": value}, origin_post_quantum_encryption_update_params.OriginPostQuantumEncryptionUpdateParams + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[OriginPostQuantumEncryptionUpdateResponse]]._unwrapper, + ), + cast_to=cast( + Type[Optional[OriginPostQuantumEncryptionUpdateResponse]], + ResultWrapper[OriginPostQuantumEncryptionUpdateResponse], + ), + ) + async def get( self, *, @@ -164,6 +279,9 @@ class OriginPostQuantumEncryptionResourceWithRawResponse: def __init__(self, origin_post_quantum_encryption: OriginPostQuantumEncryptionResource) -> None: self._origin_post_quantum_encryption = origin_post_quantum_encryption + self.update = to_raw_response_wrapper( + origin_post_quantum_encryption.update, + ) self.get = to_raw_response_wrapper( origin_post_quantum_encryption.get, ) @@ -173,6 +291,9 @@ class AsyncOriginPostQuantumEncryptionResourceWithRawResponse: def __init__(self, origin_post_quantum_encryption: AsyncOriginPostQuantumEncryptionResource) -> None: self._origin_post_quantum_encryption = origin_post_quantum_encryption + self.update = async_to_raw_response_wrapper( + origin_post_quantum_encryption.update, + ) self.get = async_to_raw_response_wrapper( origin_post_quantum_encryption.get, ) @@ -182,6 +303,9 @@ class OriginPostQuantumEncryptionResourceWithStreamingResponse: def __init__(self, origin_post_quantum_encryption: OriginPostQuantumEncryptionResource) -> None: self._origin_post_quantum_encryption = origin_post_quantum_encryption + self.update = to_streamed_response_wrapper( + origin_post_quantum_encryption.update, + ) self.get = to_streamed_response_wrapper( origin_post_quantum_encryption.get, ) @@ -191,6 +315,9 @@ class AsyncOriginPostQuantumEncryptionResourceWithStreamingResponse: def __init__(self, origin_post_quantum_encryption: AsyncOriginPostQuantumEncryptionResource) -> None: self._origin_post_quantum_encryption = origin_post_quantum_encryption + self.update = async_to_streamed_response_wrapper( + origin_post_quantum_encryption.update, + ) self.get = async_to_streamed_response_wrapper( origin_post_quantum_encryption.get, ) diff --git a/src/cloudflare/resources/zero_trust/dex/commands/__init__.py b/src/cloudflare/resources/zero_trust/dex/commands/__init__.py index 4566edefe96..1cf551c58ba 100644 --- a/src/cloudflare/resources/zero_trust/dex/commands/__init__.py +++ b/src/cloudflare/resources/zero_trust/dex/commands/__init__.py @@ -8,6 +8,22 @@ QuotaResourceWithStreamingResponse, AsyncQuotaResourceWithStreamingResponse, ) +from .users import ( + UsersResource, + AsyncUsersResource, + UsersResourceWithRawResponse, + AsyncUsersResourceWithRawResponse, + UsersResourceWithStreamingResponse, + AsyncUsersResourceWithStreamingResponse, +) +from .devices import ( + DevicesResource, + AsyncDevicesResource, + DevicesResourceWithRawResponse, + AsyncDevicesResourceWithRawResponse, + DevicesResourceWithStreamingResponse, + AsyncDevicesResourceWithStreamingResponse, +) from .commands import ( CommandsResource, AsyncCommandsResource, @@ -26,6 +42,18 @@ ) __all__ = [ + "UsersResource", + "AsyncUsersResource", + "UsersResourceWithRawResponse", + "AsyncUsersResourceWithRawResponse", + "UsersResourceWithStreamingResponse", + "AsyncUsersResourceWithStreamingResponse", + "DevicesResource", + "AsyncDevicesResource", + "DevicesResourceWithRawResponse", + "AsyncDevicesResourceWithRawResponse", + "DevicesResourceWithStreamingResponse", + "AsyncDevicesResourceWithStreamingResponse", "DownloadsResource", "AsyncDownloadsResource", "DownloadsResourceWithRawResponse", diff --git a/src/cloudflare/resources/zero_trust/dex/commands/commands.py b/src/cloudflare/resources/zero_trust/dex/commands/commands.py index f0041c4f8c9..7f887f8e617 100644 --- a/src/cloudflare/resources/zero_trust/dex/commands/commands.py +++ b/src/cloudflare/resources/zero_trust/dex/commands/commands.py @@ -16,6 +16,22 @@ QuotaResourceWithStreamingResponse, AsyncQuotaResourceWithStreamingResponse, ) +from .users import ( + UsersResource, + AsyncUsersResource, + UsersResourceWithRawResponse, + AsyncUsersResourceWithRawResponse, + UsersResourceWithStreamingResponse, + AsyncUsersResourceWithStreamingResponse, +) +from .devices import ( + DevicesResource, + AsyncDevicesResource, + DevicesResourceWithRawResponse, + AsyncDevicesResourceWithRawResponse, + DevicesResourceWithStreamingResponse, + AsyncDevicesResourceWithStreamingResponse, +) from .downloads import ( DownloadsResource, AsyncDownloadsResource, @@ -48,6 +64,14 @@ class CommandsResource(SyncAPIResource): + @cached_property + def users(self) -> UsersResource: + return UsersResource(self._client) + + @cached_property + def devices(self) -> DevicesResource: + return DevicesResource(self._client) + @cached_property def downloads(self) -> DownloadsResource: return DownloadsResource(self._client) @@ -193,6 +217,14 @@ def list( class AsyncCommandsResource(AsyncAPIResource): + @cached_property + def users(self) -> AsyncUsersResource: + return AsyncUsersResource(self._client) + + @cached_property + def devices(self) -> AsyncDevicesResource: + return AsyncDevicesResource(self._client) + @cached_property def downloads(self) -> AsyncDownloadsResource: return AsyncDownloadsResource(self._client) @@ -348,6 +380,14 @@ def __init__(self, commands: CommandsResource) -> None: commands.list, ) + @cached_property + def users(self) -> UsersResourceWithRawResponse: + return UsersResourceWithRawResponse(self._commands.users) + + @cached_property + def devices(self) -> DevicesResourceWithRawResponse: + return DevicesResourceWithRawResponse(self._commands.devices) + @cached_property def downloads(self) -> DownloadsResourceWithRawResponse: return DownloadsResourceWithRawResponse(self._commands.downloads) @@ -368,6 +408,14 @@ def __init__(self, commands: AsyncCommandsResource) -> None: commands.list, ) + @cached_property + def users(self) -> AsyncUsersResourceWithRawResponse: + return AsyncUsersResourceWithRawResponse(self._commands.users) + + @cached_property + def devices(self) -> AsyncDevicesResourceWithRawResponse: + return AsyncDevicesResourceWithRawResponse(self._commands.devices) + @cached_property def downloads(self) -> AsyncDownloadsResourceWithRawResponse: return AsyncDownloadsResourceWithRawResponse(self._commands.downloads) @@ -388,6 +436,14 @@ def __init__(self, commands: CommandsResource) -> None: commands.list, ) + @cached_property + def users(self) -> UsersResourceWithStreamingResponse: + return UsersResourceWithStreamingResponse(self._commands.users) + + @cached_property + def devices(self) -> DevicesResourceWithStreamingResponse: + return DevicesResourceWithStreamingResponse(self._commands.devices) + @cached_property def downloads(self) -> DownloadsResourceWithStreamingResponse: return DownloadsResourceWithStreamingResponse(self._commands.downloads) @@ -408,6 +464,14 @@ def __init__(self, commands: AsyncCommandsResource) -> None: commands.list, ) + @cached_property + def users(self) -> AsyncUsersResourceWithStreamingResponse: + return AsyncUsersResourceWithStreamingResponse(self._commands.users) + + @cached_property + def devices(self) -> AsyncDevicesResourceWithStreamingResponse: + return AsyncDevicesResourceWithStreamingResponse(self._commands.devices) + @cached_property def downloads(self) -> AsyncDownloadsResourceWithStreamingResponse: return AsyncDownloadsResourceWithStreamingResponse(self._commands.downloads) diff --git a/src/cloudflare/resources/zero_trust/dex/commands/devices.py b/src/cloudflare/resources/zero_trust/dex/commands/devices.py new file mode 100644 index 00000000000..4f3b3697c94 --- /dev/null +++ b/src/cloudflare/resources/zero_trust/dex/commands/devices.py @@ -0,0 +1,212 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional + +import httpx + +from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ....._utils import 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 .....pagination import SyncV4PagePagination, AsyncV4PagePagination +from ....._base_client import AsyncPaginator, make_request_options +from .....types.zero_trust.dex.commands import device_list_params +from .....types.zero_trust.dex.commands.device_list_response import DeviceListResponse + +__all__ = ["DevicesResource", "AsyncDevicesResource"] + + +class DevicesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> DevicesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return the + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return DevicesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> DevicesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return DevicesResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: str, + page: float, + per_page: float, + search: str | 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, + ) -> SyncV4PagePagination[Optional[DeviceListResponse]]: + """ + List devices with WARP client support for remote captures which have been + connected in the last 1 hour. + + Args: + page: Page number of paginated results + + per_page: Number of items per page + + search: Filter devices by name or email + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/dex/commands/devices", + page=SyncV4PagePagination[Optional[DeviceListResponse]], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "page": page, + "per_page": per_page, + "search": search, + }, + device_list_params.DeviceListParams, + ), + ), + model=DeviceListResponse, + ) + + +class AsyncDevicesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncDevicesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return the + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncDevicesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncDevicesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncDevicesResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: str, + page: float, + per_page: float, + search: str | 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, + ) -> AsyncPaginator[Optional[DeviceListResponse], AsyncV4PagePagination[Optional[DeviceListResponse]]]: + """ + List devices with WARP client support for remote captures which have been + connected in the last 1 hour. + + Args: + page: Page number of paginated results + + per_page: Number of items per page + + search: Filter devices by name or email + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/dex/commands/devices", + page=AsyncV4PagePagination[Optional[DeviceListResponse]], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "page": page, + "per_page": per_page, + "search": search, + }, + device_list_params.DeviceListParams, + ), + ), + model=DeviceListResponse, + ) + + +class DevicesResourceWithRawResponse: + def __init__(self, devices: DevicesResource) -> None: + self._devices = devices + + self.list = to_raw_response_wrapper( + devices.list, + ) + + +class AsyncDevicesResourceWithRawResponse: + def __init__(self, devices: AsyncDevicesResource) -> None: + self._devices = devices + + self.list = async_to_raw_response_wrapper( + devices.list, + ) + + +class DevicesResourceWithStreamingResponse: + def __init__(self, devices: DevicesResource) -> None: + self._devices = devices + + self.list = to_streamed_response_wrapper( + devices.list, + ) + + +class AsyncDevicesResourceWithStreamingResponse: + def __init__(self, devices: AsyncDevicesResource) -> None: + self._devices = devices + + self.list = async_to_streamed_response_wrapper( + devices.list, + ) diff --git a/src/cloudflare/resources/zero_trust/dex/commands/users.py b/src/cloudflare/resources/zero_trust/dex/commands/users.py new file mode 100644 index 00000000000..7c9308df318 --- /dev/null +++ b/src/cloudflare/resources/zero_trust/dex/commands/users.py @@ -0,0 +1,189 @@ +# 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 ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ....._utils import ( + maybe_transform, + async_maybe_transform, +) +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from ....._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ....._wrappers import ResultWrapper +from ....._base_client import make_request_options +from .....types.zero_trust.dex.commands import user_list_params +from .....types.zero_trust.dex.commands.user_list_response import UserListResponse + +__all__ = ["UsersResource", "AsyncUsersResource"] + + +class UsersResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> UsersResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return the + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return UsersResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> UsersResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return UsersResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: str, + search: str | 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[UserListResponse]: + """ + List users emails associated with devices with WARP client support for remote + captures which have been connected in the last 1 hour. + + Args: + search: filter user emails by search + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + f"/accounts/{account_id}/dex/commands/users", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform({"search": search}, user_list_params.UserListParams), + post_parser=ResultWrapper[Optional[UserListResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[UserListResponse]], ResultWrapper[UserListResponse]), + ) + + +class AsyncUsersResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncUsersResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return the + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncUsersResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncUsersResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncUsersResourceWithStreamingResponse(self) + + async def list( + self, + *, + account_id: str, + search: str | 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[UserListResponse]: + """ + List users emails associated with devices with WARP client support for remote + captures which have been connected in the last 1 hour. + + Args: + search: filter user emails by search + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + f"/accounts/{account_id}/dex/commands/users", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform({"search": search}, user_list_params.UserListParams), + post_parser=ResultWrapper[Optional[UserListResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[UserListResponse]], ResultWrapper[UserListResponse]), + ) + + +class UsersResourceWithRawResponse: + def __init__(self, users: UsersResource) -> None: + self._users = users + + self.list = to_raw_response_wrapper( + users.list, + ) + + +class AsyncUsersResourceWithRawResponse: + def __init__(self, users: AsyncUsersResource) -> None: + self._users = users + + self.list = async_to_raw_response_wrapper( + users.list, + ) + + +class UsersResourceWithStreamingResponse: + def __init__(self, users: UsersResource) -> None: + self._users = users + + self.list = to_streamed_response_wrapper( + users.list, + ) + + +class AsyncUsersResourceWithStreamingResponse: + def __init__(self, users: AsyncUsersResource) -> None: + self._users = users + + self.list = async_to_streamed_response_wrapper( + users.list, + ) diff --git a/src/cloudflare/types/abuse_reports/__init__.py b/src/cloudflare/types/abuse_reports/__init__.py index f8ee8b14b1c..c17465cb40c 100644 --- a/src/cloudflare/types/abuse_reports/__init__.py +++ b/src/cloudflare/types/abuse_reports/__init__.py @@ -1,3 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations + +from .abuse_report_create_params import AbuseReportCreateParams as AbuseReportCreateParams +from .abuse_report_create_response import AbuseReportCreateResponse as AbuseReportCreateResponse diff --git a/src/cloudflare/types/abuse_reports/abuse_report_create_params.py b/src/cloudflare/types/abuse_reports/abuse_report_create_params.py new file mode 100644 index 00000000000..ff19f93f7c5 --- /dev/null +++ b/src/cloudflare/types/abuse_reports/abuse_report_create_params.py @@ -0,0 +1,140 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["AbuseReportCreateParams"] + + +class AbuseReportCreateParams(TypedDict, total=False): + account_id: Required[str] + + act: Required[ + Literal[ + "abuse_dmca", + "abuse_trademark", + "abuse_general", + "abuse_phishing", + "abuse_children", + "abuse_threat", + "abuse_registrar_whois", + "abuse_ncsei", + ] + ] + """The abuse report type""" + + email: Required[str] + """A valid email of the abuse reporter""" + + email2: Required[str] + """Should match the value provided in `email`""" + + host_notification: Required[Literal["send", "send-anon", "none"]] + """Notification type based on the abuse type. + + NOTE: Copyright (DMCA) and Trademark reports cannot be anonymous. + """ + + ncmec_notification: Required[Literal["send", "send-anon", "none"]] + """Notification type based on the abuse type. + + NOTE: Copyright (DMCA) and Trademark reports cannot be anonymous. + """ + + owner_notification: Required[Literal["send", "send-anon", "none"]] + """Notification type based on the abuse type. + + NOTE: Copyright (DMCA) and Trademark reports cannot be anonymous. + """ + + urls: Required[str] + """A list of valid URLs separated by ‘ ’ (new line character). + + The list of the URLs should not exceed 250 URLs. All URLs should have the same + hostname. Each URL should be unique + """ + + address1: str + """Text not exceeding 100 characters""" + + agent_name: str + """The name of the copyright holder. Text not exceeding 60 characters.""" + + agree: Literal[0, 1] + """Can be 0 or 1""" + + city: str + """Text not exceeding 255 characters""" + + comments: str + """Any additional comments about the infringement not exceeding 2000 characters""" + + company: str + """Text not exceeding 100 characters""" + + country: str + """Text not exceeding 255 characters""" + + destination_ips: str + """A list of IP addresses separated by ‘ ’ (new line character). + + The list of destination IPs should not exceed 30 IP addresses. Each one of the + IP addresses ought to be unique + """ + + justification: str + """ + A detailed description of the infringement, including any necessary access + details and the exact steps needed to view the content, not exceeding 5000 + characters + """ + + name: str + """Text not exceeding 255 characters""" + + ncsei_subject_representation: bool + """If the submitter is the target of NCSEI in the URLs of the abuse report""" + + original_work: str + """Text not exceeding 255 characters""" + + ports_protocols: str + """A comma separated list of ports and protocols e.g. + + 80/TCP, 22/UDP. The total size of the field should not exceed 2000 characters. + Each individual port/protocol should not exceed 100 characters. The list should + not have more than 30 unique ports and protocols. + """ + + signature: str + """Required for DMCA reports, should be same as Name. + + An affirmation that all information in the report is true and accurate while + agreeing to the policies of Cloudflare's abuse reports + """ + + source_ips: str + """A list of IP addresses separated by ‘ ’ (new line character). + + The list of source IPs should not exceed 30 IP addresses. Each one of the IP + addresses ought to be unique + """ + + state: str + """Text not exceeding 255 characters""" + + tele: str + """Text not exceeding 20 characters""" + + title: str + """Text not exceeding 255 characters""" + + trademark_number: str + """Text not exceeding 1000 characters""" + + trademark_office: str + """Text not exceeding 1000 characters""" + + trademark_symbol: str + """Text not exceeding 1000 characters""" diff --git a/src/cloudflare/types/abuse_reports/abuse_report_create_response.py b/src/cloudflare/types/abuse_reports/abuse_report_create_response.py new file mode 100644 index 00000000000..03fc4011e68 --- /dev/null +++ b/src/cloudflare/types/abuse_reports/abuse_report_create_response.py @@ -0,0 +1,7 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing_extensions import TypeAlias + +__all__ = ["AbuseReportCreateResponse"] + +AbuseReportCreateResponse: TypeAlias = str diff --git a/src/cloudflare/types/api_gateway/__init__.py b/src/cloudflare/types/api_gateway/__init__.py index 7e68a9a9bb9..bb1373799ba 100644 --- a/src/cloudflare/types/api_gateway/__init__.py +++ b/src/cloudflare/types/api_gateway/__init__.py @@ -25,5 +25,7 @@ from .user_schema_create_params import UserSchemaCreateParams as UserSchemaCreateParams from .configuration_update_params import ConfigurationUpdateParams as ConfigurationUpdateParams from .user_schema_delete_response import UserSchemaDeleteResponse as UserSchemaDeleteResponse +from .operation_bulk_create_params import OperationBulkCreateParams as OperationBulkCreateParams from .configuration_update_response import ConfigurationUpdateResponse as ConfigurationUpdateResponse +from .operation_bulk_create_response import OperationBulkCreateResponse as OperationBulkCreateResponse from .operation_bulk_delete_response import OperationBulkDeleteResponse as OperationBulkDeleteResponse diff --git a/src/cloudflare/types/api_gateway/operation_bulk_create_params.py b/src/cloudflare/types/api_gateway/operation_bulk_create_params.py new file mode 100644 index 00000000000..8672ae972e9 --- /dev/null +++ b/src/cloudflare/types/api_gateway/operation_bulk_create_params.py @@ -0,0 +1,31 @@ +# 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 Literal, Required, TypedDict + +__all__ = ["OperationBulkCreateParams", "Body"] + + +class OperationBulkCreateParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + body: Required[Iterable[Body]] + + +class Body(TypedDict, total=False): + endpoint: Required[str] + """ + The endpoint which can contain path parameter templates in curly braces, each + will be replaced from left to right with {varN}, starting with {var1}, during + insertion. This will further be Cloudflare-normalized upon insertion. See: + https://developers.cloudflare.com/rules/normalization/how-it-works/. + """ + + host: Required[str] + """RFC3986-compliant host.""" + + method: Required[Literal["GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "CONNECT", "PATCH", "TRACE"]] + """The HTTP method used to access the endpoint.""" diff --git a/src/cloudflare/types/api_gateway/operation_bulk_create_response.py b/src/cloudflare/types/api_gateway/operation_bulk_create_response.py new file mode 100644 index 00000000000..cf7c4824a17 --- /dev/null +++ b/src/cloudflare/types/api_gateway/operation_bulk_create_response.py @@ -0,0 +1,239 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional +from datetime import datetime +from typing_extensions import Literal, TypeAlias + +from ..._models import BaseModel + +__all__ = [ + "OperationBulkCreateResponse", + "OperationBulkCreateResponseItem", + "OperationBulkCreateResponseItemFeatures", + "OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureThresholds", + "OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureThresholdsThresholds", + "OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureParameterSchemas", + "OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemas", + "OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas", + "OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureAPIRouting", + "OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureAPIRoutingAPIRouting", + "OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervals", + "OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervals", + "OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThreshold", + "OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervals", + "OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP90", + "OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP95", + "OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP99", + "OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureSchemaInfo", + "OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfo", + "OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfoActiveSchema", +] + + +class OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureThresholdsThresholds(BaseModel): + auth_id_tokens: Optional[int] = None + """The total number of auth-ids seen across this calculation.""" + + data_points: Optional[int] = None + """The number of data points used for the threshold suggestion calculation.""" + + last_updated: Optional[datetime] = None + + p50: Optional[int] = None + """The p50 quantile of requests (in period_seconds).""" + + p90: Optional[int] = None + """The p90 quantile of requests (in period_seconds).""" + + p99: Optional[int] = None + """The p99 quantile of requests (in period_seconds).""" + + period_seconds: Optional[int] = None + """The period over which this threshold is suggested.""" + + requests: Optional[int] = None + """The estimated number of requests covered by these calculations.""" + + suggested_threshold: Optional[int] = None + """The suggested threshold in requests done by the same auth_id or period_seconds.""" + + +class OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureThresholds(BaseModel): + thresholds: Optional[OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureThresholdsThresholds] = None + + +class OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas( + BaseModel +): + parameters: Optional[List[object]] = None + """An array containing the learned parameter schemas.""" + + responses: Optional[object] = None + """An empty response object. + + This field is required to yield a valid operation schema. + """ + + +class OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemas(BaseModel): + last_updated: Optional[datetime] = None + + parameter_schemas: Optional[ + OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas + ] = None + """An operation schema object containing a response.""" + + +class OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureParameterSchemas(BaseModel): + parameter_schemas: OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemas + + +class OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureAPIRoutingAPIRouting(BaseModel): + last_updated: Optional[datetime] = None + + route: Optional[str] = None + """Target route.""" + + +class OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureAPIRouting(BaseModel): + api_routing: Optional[OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureAPIRoutingAPIRouting] = None + """API Routing settings on endpoint.""" + + +class OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP90( + BaseModel +): + lower: Optional[float] = None + """Lower bound for percentile estimate""" + + upper: Optional[float] = None + """Upper bound for percentile estimate""" + + +class OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP95( + BaseModel +): + lower: Optional[float] = None + """Lower bound for percentile estimate""" + + upper: Optional[float] = None + """Upper bound for percentile estimate""" + + +class OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP99( + BaseModel +): + lower: Optional[float] = None + """Lower bound for percentile estimate""" + + upper: Optional[float] = None + """Upper bound for percentile estimate""" + + +class OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervals( + BaseModel +): + p90: Optional[ + OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP90 + ] = None + """Upper and lower bound for percentile estimate""" + + p95: Optional[ + OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP95 + ] = None + """Upper and lower bound for percentile estimate""" + + p99: Optional[ + OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP99 + ] = None + """Upper and lower bound for percentile estimate""" + + +class OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThreshold( + BaseModel +): + confidence_intervals: Optional[ + OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervals + ] = None + + mean: Optional[float] = None + """Suggested threshold.""" + + +class OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervals(BaseModel): + last_updated: Optional[datetime] = None + + suggested_threshold: Optional[ + OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThreshold + ] = None + + +class OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervals(BaseModel): + confidence_intervals: Optional[ + OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervals + ] = None + + +class OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfoActiveSchema(BaseModel): + id: Optional[str] = None + """UUID""" + + created_at: Optional[datetime] = None + + is_learned: Optional[bool] = None + """True if schema is Cloudflare-provided.""" + + name: Optional[str] = None + """Schema file name.""" + + +class OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfo(BaseModel): + active_schema: Optional[ + OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfoActiveSchema + ] = None + """Schema active on endpoint.""" + + learned_available: Optional[bool] = None + """True if a Cloudflare-provided learned schema is available for this endpoint.""" + + mitigation_action: Optional[Literal["none", "log", "block"]] = None + """Action taken on requests failing validation.""" + + +class OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureSchemaInfo(BaseModel): + schema_info: Optional[OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfo] = None + + +OperationBulkCreateResponseItemFeatures: TypeAlias = Union[ + OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureThresholds, + OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureParameterSchemas, + OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureAPIRouting, + OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervals, + OperationBulkCreateResponseItemFeaturesAPIShieldOperationFeatureSchemaInfo, +] + + +class OperationBulkCreateResponseItem(BaseModel): + endpoint: str + """ + The endpoint which can contain path parameter templates in curly braces, each + will be replaced from left to right with {varN}, starting with {var1}, during + insertion. This will further be Cloudflare-normalized upon insertion. See: + https://developers.cloudflare.com/rules/normalization/how-it-works/. + """ + + host: str + """RFC3986-compliant host.""" + + last_updated: datetime + + method: Literal["GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "CONNECT", "PATCH", "TRACE"] + """The HTTP method used to access the endpoint.""" + + operation_id: str + """UUID""" + + features: Optional[OperationBulkCreateResponseItemFeatures] = None + + +OperationBulkCreateResponse: TypeAlias = List[OperationBulkCreateResponseItem] diff --git a/src/cloudflare/types/origin_post_quantum_encryption/__init__.py b/src/cloudflare/types/origin_post_quantum_encryption/__init__.py index 273631df76f..31525d2b891 100644 --- a/src/cloudflare/types/origin_post_quantum_encryption/__init__.py +++ b/src/cloudflare/types/origin_post_quantum_encryption/__init__.py @@ -5,3 +5,9 @@ from .origin_post_quantum_encryption_get_response import ( OriginPostQuantumEncryptionGetResponse as OriginPostQuantumEncryptionGetResponse, ) +from .origin_post_quantum_encryption_update_params import ( + OriginPostQuantumEncryptionUpdateParams as OriginPostQuantumEncryptionUpdateParams, +) +from .origin_post_quantum_encryption_update_response import ( + OriginPostQuantumEncryptionUpdateResponse as OriginPostQuantumEncryptionUpdateResponse, +) diff --git a/src/cloudflare/types/origin_post_quantum_encryption/origin_post_quantum_encryption_update_params.py b/src/cloudflare/types/origin_post_quantum_encryption/origin_post_quantum_encryption_update_params.py new file mode 100644 index 00000000000..b059d4aee6a --- /dev/null +++ b/src/cloudflare/types/origin_post_quantum_encryption/origin_post_quantum_encryption_update_params.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["OriginPostQuantumEncryptionUpdateParams"] + + +class OriginPostQuantumEncryptionUpdateParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + value: Required[Literal["preferred", "supported", "off"]] + """Value of the Origin Post Quantum Encryption Setting.""" diff --git a/src/cloudflare/types/origin_post_quantum_encryption/origin_post_quantum_encryption_update_response.py b/src/cloudflare/types/origin_post_quantum_encryption/origin_post_quantum_encryption_update_response.py new file mode 100644 index 00000000000..f2ec8775f16 --- /dev/null +++ b/src/cloudflare/types/origin_post_quantum_encryption/origin_post_quantum_encryption_update_response.py @@ -0,0 +1,23 @@ +# 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__ = ["OriginPostQuantumEncryptionUpdateResponse"] + + +class OriginPostQuantumEncryptionUpdateResponse(BaseModel): + id: Literal["origin_pqe"] + """Value of the zone setting.""" + + editable: bool + """Whether the setting is editable""" + + value: Literal["preferred", "supported", "off"] + """The value of the feature""" + + modified_on: Optional[datetime] = None + """Last time this setting was modified.""" diff --git a/src/cloudflare/types/zero_trust/dex/commands/__init__.py b/src/cloudflare/types/zero_trust/dex/commands/__init__.py index 83304891f5e..cf51077364d 100644 --- a/src/cloudflare/types/zero_trust/dex/commands/__init__.py +++ b/src/cloudflare/types/zero_trust/dex/commands/__init__.py @@ -2,4 +2,8 @@ from __future__ import annotations +from .user_list_params import UserListParams as UserListParams +from .device_list_params import DeviceListParams as DeviceListParams from .quota_get_response import QuotaGetResponse as QuotaGetResponse +from .user_list_response import UserListResponse as UserListResponse +from .device_list_response import DeviceListResponse as DeviceListResponse diff --git a/src/cloudflare/types/zero_trust/dex/commands/device_list_params.py b/src/cloudflare/types/zero_trust/dex/commands/device_list_params.py new file mode 100644 index 00000000000..126d1a8cb20 --- /dev/null +++ b/src/cloudflare/types/zero_trust/dex/commands/device_list_params.py @@ -0,0 +1,20 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["DeviceListParams"] + + +class DeviceListParams(TypedDict, total=False): + account_id: Required[str] + + page: Required[float] + """Page number of paginated results""" + + per_page: Required[float] + """Number of items per page""" + + search: str + """Filter devices by name or email""" diff --git a/src/cloudflare/types/zero_trust/dex/commands/device_list_response.py b/src/cloudflare/types/zero_trust/dex/commands/device_list_response.py new file mode 100644 index 00000000000..5fb1c642279 --- /dev/null +++ b/src/cloudflare/types/zero_trust/dex/commands/device_list_response.py @@ -0,0 +1,37 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from pydantic import Field as FieldInfo + +from ....._models import BaseModel + +__all__ = ["DeviceListResponse", "Device"] + + +class Device(BaseModel): + device_id: Optional[str] = FieldInfo(alias="deviceId", default=None) + """Device identifier (UUID v4)""" + + device_name: Optional[str] = FieldInfo(alias="deviceName", default=None) + """Device identifier (human readable)""" + + person_email: Optional[str] = FieldInfo(alias="personEmail", default=None) + """User contact email address""" + + platform: Optional[str] = None + """Operating system""" + + status: Optional[str] = None + """Network status""" + + timestamp: Optional[str] = None + """Timestamp in ISO format""" + + version: Optional[str] = None + """WARP client version""" + + +class DeviceListResponse(BaseModel): + devices: Optional[List[Device]] = None + """List of eligible devices""" diff --git a/src/cloudflare/types/zero_trust/dex/commands/user_list_params.py b/src/cloudflare/types/zero_trust/dex/commands/user_list_params.py new file mode 100644 index 00000000000..753ca290284 --- /dev/null +++ b/src/cloudflare/types/zero_trust/dex/commands/user_list_params.py @@ -0,0 +1,14 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["UserListParams"] + + +class UserListParams(TypedDict, total=False): + account_id: Required[str] + + search: str + """filter user emails by search""" diff --git a/src/cloudflare/types/zero_trust/dex/commands/user_list_response.py b/src/cloudflare/types/zero_trust/dex/commands/user_list_response.py new file mode 100644 index 00000000000..d2394cc4a99 --- /dev/null +++ b/src/cloudflare/types/zero_trust/dex/commands/user_list_response.py @@ -0,0 +1,14 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from pydantic import Field as FieldInfo + +from ....._models import BaseModel + +__all__ = ["UserListResponse"] + + +class UserListResponse(BaseModel): + user_emails: Optional[List[str]] = FieldInfo(alias="userEmails", default=None) + """List of user emails""" diff --git a/tests/api_resources/api_gateway/test_operations.py b/tests/api_resources/api_gateway/test_operations.py index 03040c261cc..f61103adcc9 100644 --- a/tests/api_resources/api_gateway/test_operations.py +++ b/tests/api_resources/api_gateway/test_operations.py @@ -15,6 +15,7 @@ OperationListResponse, OperationCreateResponse, OperationDeleteResponse, + OperationBulkCreateResponse, OperationBulkDeleteResponse, ) @@ -175,6 +176,72 @@ def test_path_params_delete(self, client: Cloudflare) -> None: zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) + @parametrize + def test_method_bulk_create(self, client: Cloudflare) -> None: + operation = client.api_gateway.operations.bulk_create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + body=[ + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + } + ], + ) + assert_matches_type(OperationBulkCreateResponse, operation, path=["response"]) + + @parametrize + def test_raw_response_bulk_create(self, client: Cloudflare) -> None: + response = client.api_gateway.operations.with_raw_response.bulk_create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + body=[ + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + } + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + operation = response.parse() + assert_matches_type(OperationBulkCreateResponse, operation, path=["response"]) + + @parametrize + def test_streaming_response_bulk_create(self, client: Cloudflare) -> None: + with client.api_gateway.operations.with_streaming_response.bulk_create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + body=[ + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + } + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + operation = response.parse() + assert_matches_type(OperationBulkCreateResponse, operation, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_bulk_create(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.api_gateway.operations.with_raw_response.bulk_create( + zone_id="", + body=[ + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + } + ], + ) + @parametrize def test_method_bulk_delete(self, client: Cloudflare) -> None: operation = client.api_gateway.operations.bulk_delete( @@ -425,6 +492,72 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) + @parametrize + async def test_method_bulk_create(self, async_client: AsyncCloudflare) -> None: + operation = await async_client.api_gateway.operations.bulk_create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + body=[ + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + } + ], + ) + assert_matches_type(OperationBulkCreateResponse, operation, path=["response"]) + + @parametrize + async def test_raw_response_bulk_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.api_gateway.operations.with_raw_response.bulk_create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + body=[ + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + } + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + operation = await response.parse() + assert_matches_type(OperationBulkCreateResponse, operation, path=["response"]) + + @parametrize + async def test_streaming_response_bulk_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.api_gateway.operations.with_streaming_response.bulk_create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + body=[ + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + } + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + operation = await response.parse() + assert_matches_type(OperationBulkCreateResponse, operation, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_bulk_create(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.api_gateway.operations.with_raw_response.bulk_create( + zone_id="", + body=[ + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + } + ], + ) + @parametrize async def test_method_bulk_delete(self, async_client: AsyncCloudflare) -> None: operation = await async_client.api_gateway.operations.bulk_delete( diff --git a/tests/api_resources/test_abuse_reports.py b/tests/api_resources/test_abuse_reports.py new file mode 100644 index 00000000000..ff8d92dee38 --- /dev/null +++ b/tests/api_resources/test_abuse_reports.py @@ -0,0 +1,243 @@ +# 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 pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestAbuseReports: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="TODO: investigate unauthorized HTTP response") + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + abuse_report = client.abuse_reports.create( + report_type="abuse_dmca", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + act="abuse_dmca", + email="email", + email2="email2", + host_notification="send", + ncmec_notification="send", + owner_notification="send", + urls="urls", + ) + assert_matches_type(str, abuse_report, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate unauthorized HTTP response") + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + abuse_report = client.abuse_reports.create( + report_type="abuse_dmca", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + act="abuse_dmca", + email="email", + email2="email2", + host_notification="send", + ncmec_notification="send", + owner_notification="send", + urls="urls", + address1="x", + agent_name="x", + agree=0, + city="x", + comments="x", + company="x", + country="x", + destination_ips="destination_ips", + justification="x", + name="x", + ncsei_subject_representation=True, + original_work="x", + ports_protocols="ports_protocols", + signature="signature", + source_ips="source_ips", + state="x", + tele="x", + title="x", + trademark_number="x", + trademark_office="x", + trademark_symbol="x", + ) + assert_matches_type(str, abuse_report, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate unauthorized HTTP response") + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.abuse_reports.with_raw_response.create( + report_type="abuse_dmca", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + act="abuse_dmca", + email="email", + email2="email2", + host_notification="send", + ncmec_notification="send", + owner_notification="send", + urls="urls", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + abuse_report = response.parse() + assert_matches_type(str, abuse_report, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate unauthorized HTTP response") + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.abuse_reports.with_streaming_response.create( + report_type="abuse_dmca", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + act="abuse_dmca", + email="email", + email2="email2", + host_notification="send", + ncmec_notification="send", + owner_notification="send", + urls="urls", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + abuse_report = response.parse() + assert_matches_type(str, abuse_report, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate unauthorized HTTP response") + @parametrize + def test_path_params_create(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.abuse_reports.with_raw_response.create( + report_type="abuse_dmca", + account_id="", + act="abuse_dmca", + email="email", + email2="email2", + host_notification="send", + ncmec_notification="send", + owner_notification="send", + urls="urls", + ) + + +class TestAsyncAbuseReports: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="TODO: investigate unauthorized HTTP response") + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + abuse_report = await async_client.abuse_reports.create( + report_type="abuse_dmca", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + act="abuse_dmca", + email="email", + email2="email2", + host_notification="send", + ncmec_notification="send", + owner_notification="send", + urls="urls", + ) + assert_matches_type(str, abuse_report, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate unauthorized HTTP response") + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + abuse_report = await async_client.abuse_reports.create( + report_type="abuse_dmca", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + act="abuse_dmca", + email="email", + email2="email2", + host_notification="send", + ncmec_notification="send", + owner_notification="send", + urls="urls", + address1="x", + agent_name="x", + agree=0, + city="x", + comments="x", + company="x", + country="x", + destination_ips="destination_ips", + justification="x", + name="x", + ncsei_subject_representation=True, + original_work="x", + ports_protocols="ports_protocols", + signature="signature", + source_ips="source_ips", + state="x", + tele="x", + title="x", + trademark_number="x", + trademark_office="x", + trademark_symbol="x", + ) + assert_matches_type(str, abuse_report, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate unauthorized HTTP response") + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.abuse_reports.with_raw_response.create( + report_type="abuse_dmca", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + act="abuse_dmca", + email="email", + email2="email2", + host_notification="send", + ncmec_notification="send", + owner_notification="send", + urls="urls", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + abuse_report = await response.parse() + assert_matches_type(str, abuse_report, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate unauthorized HTTP response") + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.abuse_reports.with_streaming_response.create( + report_type="abuse_dmca", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + act="abuse_dmca", + email="email", + email2="email2", + host_notification="send", + ncmec_notification="send", + owner_notification="send", + urls="urls", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + abuse_report = await response.parse() + assert_matches_type(str, abuse_report, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate unauthorized HTTP response") + @parametrize + async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.abuse_reports.with_raw_response.create( + report_type="abuse_dmca", + account_id="", + act="abuse_dmca", + email="email", + email2="email2", + host_notification="send", + ncmec_notification="send", + owner_notification="send", + urls="urls", + ) diff --git a/tests/api_resources/test_origin_post_quantum_encryption.py b/tests/api_resources/test_origin_post_quantum_encryption.py index 68dff01d3e0..5be62d7556c 100644 --- a/tests/api_resources/test_origin_post_quantum_encryption.py +++ b/tests/api_resources/test_origin_post_quantum_encryption.py @@ -9,7 +9,10 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type -from cloudflare.types.origin_post_quantum_encryption import OriginPostQuantumEncryptionGetResponse +from cloudflare.types.origin_post_quantum_encryption import ( + OriginPostQuantumEncryptionGetResponse, + OriginPostQuantumEncryptionUpdateResponse, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -17,6 +20,58 @@ class TestOriginPostQuantumEncryption: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + origin_post_quantum_encryption = client.origin_post_quantum_encryption.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + value="preferred", + ) + assert_matches_type( + Optional[OriginPostQuantumEncryptionUpdateResponse], origin_post_quantum_encryption, path=["response"] + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.origin_post_quantum_encryption.with_raw_response.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + value="preferred", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + origin_post_quantum_encryption = response.parse() + assert_matches_type( + Optional[OriginPostQuantumEncryptionUpdateResponse], origin_post_quantum_encryption, path=["response"] + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.origin_post_quantum_encryption.with_streaming_response.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + value="preferred", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + origin_post_quantum_encryption = response.parse() + assert_matches_type( + Optional[OriginPostQuantumEncryptionUpdateResponse], origin_post_quantum_encryption, path=["response"] + ) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @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.origin_post_quantum_encryption.with_raw_response.update( + zone_id="", + value="preferred", + ) + @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_get(self, client: Cloudflare) -> None: @@ -69,6 +124,58 @@ def test_path_params_get(self, client: Cloudflare) -> None: class TestAsyncOriginPostQuantumEncryption: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + origin_post_quantum_encryption = await async_client.origin_post_quantum_encryption.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + value="preferred", + ) + assert_matches_type( + Optional[OriginPostQuantumEncryptionUpdateResponse], origin_post_quantum_encryption, path=["response"] + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.origin_post_quantum_encryption.with_raw_response.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + value="preferred", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + origin_post_quantum_encryption = await response.parse() + assert_matches_type( + Optional[OriginPostQuantumEncryptionUpdateResponse], origin_post_quantum_encryption, path=["response"] + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.origin_post_quantum_encryption.with_streaming_response.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + value="preferred", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + origin_post_quantum_encryption = await response.parse() + assert_matches_type( + Optional[OriginPostQuantumEncryptionUpdateResponse], origin_post_quantum_encryption, path=["response"] + ) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @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.origin_post_quantum_encryption.with_raw_response.update( + zone_id="", + value="preferred", + ) + @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: diff --git a/tests/api_resources/zero_trust/dex/commands/test_devices.py b/tests/api_resources/zero_trust/dex/commands/test_devices.py new file mode 100644 index 00000000000..be6707c9e2a --- /dev/null +++ b/tests/api_resources/zero_trust/dex/commands/test_devices.py @@ -0,0 +1,135 @@ +# 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 SyncV4PagePagination, AsyncV4PagePagination +from cloudflare.types.zero_trust.dex.commands import DeviceListResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestDevices: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + device = client.zero_trust.dex.commands.devices.list( + account_id="01a7362d577a6c3019a474fd6f485823", + page=1, + per_page=1, + ) + assert_matches_type(SyncV4PagePagination[Optional[DeviceListResponse]], device, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + device = client.zero_trust.dex.commands.devices.list( + account_id="01a7362d577a6c3019a474fd6f485823", + page=1, + per_page=1, + search="search", + ) + assert_matches_type(SyncV4PagePagination[Optional[DeviceListResponse]], device, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.zero_trust.dex.commands.devices.with_raw_response.list( + account_id="01a7362d577a6c3019a474fd6f485823", + page=1, + per_page=1, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + device = response.parse() + assert_matches_type(SyncV4PagePagination[Optional[DeviceListResponse]], device, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.zero_trust.dex.commands.devices.with_streaming_response.list( + account_id="01a7362d577a6c3019a474fd6f485823", + page=1, + per_page=1, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + device = response.parse() + assert_matches_type(SyncV4PagePagination[Optional[DeviceListResponse]], device, 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 `account_id` but received ''"): + client.zero_trust.dex.commands.devices.with_raw_response.list( + account_id="", + page=1, + per_page=1, + ) + + +class TestAsyncDevices: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + device = await async_client.zero_trust.dex.commands.devices.list( + account_id="01a7362d577a6c3019a474fd6f485823", + page=1, + per_page=1, + ) + assert_matches_type(AsyncV4PagePagination[Optional[DeviceListResponse]], device, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + device = await async_client.zero_trust.dex.commands.devices.list( + account_id="01a7362d577a6c3019a474fd6f485823", + page=1, + per_page=1, + search="search", + ) + assert_matches_type(AsyncV4PagePagination[Optional[DeviceListResponse]], device, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.dex.commands.devices.with_raw_response.list( + account_id="01a7362d577a6c3019a474fd6f485823", + page=1, + per_page=1, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + device = await response.parse() + assert_matches_type(AsyncV4PagePagination[Optional[DeviceListResponse]], device, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.dex.commands.devices.with_streaming_response.list( + account_id="01a7362d577a6c3019a474fd6f485823", + page=1, + per_page=1, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + device = await response.parse() + assert_matches_type(AsyncV4PagePagination[Optional[DeviceListResponse]], device, 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 `account_id` but received ''"): + await async_client.zero_trust.dex.commands.devices.with_raw_response.list( + account_id="", + page=1, + per_page=1, + ) diff --git a/tests/api_resources/zero_trust/dex/commands/test_users.py b/tests/api_resources/zero_trust/dex/commands/test_users.py new file mode 100644 index 00000000000..0f8b674a2d6 --- /dev/null +++ b/tests/api_resources/zero_trust/dex/commands/test_users.py @@ -0,0 +1,114 @@ +# 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.types.zero_trust.dex.commands import UserListResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestUsers: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + user = client.zero_trust.dex.commands.users.list( + account_id="01a7362d577a6c3019a474fd6f485823", + ) + assert_matches_type(Optional[UserListResponse], user, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + user = client.zero_trust.dex.commands.users.list( + account_id="01a7362d577a6c3019a474fd6f485823", + search="search", + ) + assert_matches_type(Optional[UserListResponse], user, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.zero_trust.dex.commands.users.with_raw_response.list( + account_id="01a7362d577a6c3019a474fd6f485823", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + user = response.parse() + assert_matches_type(Optional[UserListResponse], user, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.zero_trust.dex.commands.users.with_streaming_response.list( + account_id="01a7362d577a6c3019a474fd6f485823", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + user = response.parse() + assert_matches_type(Optional[UserListResponse], user, 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 `account_id` but received ''"): + client.zero_trust.dex.commands.users.with_raw_response.list( + account_id="", + ) + + +class TestAsyncUsers: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + user = await async_client.zero_trust.dex.commands.users.list( + account_id="01a7362d577a6c3019a474fd6f485823", + ) + assert_matches_type(Optional[UserListResponse], user, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + user = await async_client.zero_trust.dex.commands.users.list( + account_id="01a7362d577a6c3019a474fd6f485823", + search="search", + ) + assert_matches_type(Optional[UserListResponse], user, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.dex.commands.users.with_raw_response.list( + account_id="01a7362d577a6c3019a474fd6f485823", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + user = await response.parse() + assert_matches_type(Optional[UserListResponse], user, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.dex.commands.users.with_streaming_response.list( + account_id="01a7362d577a6c3019a474fd6f485823", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + user = await response.parse() + assert_matches_type(Optional[UserListResponse], user, 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 `account_id` but received ''"): + await async_client.zero_trust.dex.commands.users.with_raw_response.list( + account_id="", + )