diff --git a/.stats.yml b/.stats.yml index 7f7c7cf8f52..f959c2939b6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1267 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6229bf7c4bed6b9026088be8817d3c8111576b2d12ff5220d193f479f230e449.yml +configured_endpoints: 1268 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-7a581c61bc42c6e3e48c58c941255dca8f4b7b2e5aafd402a61c6438c2830071.yml diff --git a/api.md b/api.md index ec86aa26aa7..106dd9f22de 100644 --- a/api.md +++ b/api.md @@ -3631,9 +3631,13 @@ Methods: Types: ```python -from cloudflare.types.intel import Whois +from cloudflare.types.intel import Whois, WhoisGetResponse ``` +Methods: + +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse + ## IndicatorFeeds Types: diff --git a/src/cloudflare/resources/intel/__init__.py b/src/cloudflare/resources/intel/__init__.py index 90883d102cb..126ee686dad 100644 --- a/src/cloudflare/resources/intel/__init__.py +++ b/src/cloudflare/resources/intel/__init__.py @@ -32,6 +32,14 @@ IntelResourceWithStreamingResponse, AsyncIntelResourceWithStreamingResponse, ) +from .whois import ( + WhoisResource, + AsyncWhoisResource, + WhoisResourceWithRawResponse, + AsyncWhoisResourceWithRawResponse, + WhoisResourceWithStreamingResponse, + AsyncWhoisResourceWithStreamingResponse, +) from .domains import ( DomainsResource, AsyncDomainsResource, @@ -132,6 +140,12 @@ "AsyncMiscategorizationsResourceWithRawResponse", "MiscategorizationsResourceWithStreamingResponse", "AsyncMiscategorizationsResourceWithStreamingResponse", + "WhoisResource", + "AsyncWhoisResource", + "WhoisResourceWithRawResponse", + "AsyncWhoisResourceWithRawResponse", + "WhoisResourceWithStreamingResponse", + "AsyncWhoisResourceWithStreamingResponse", "IndicatorFeedsResource", "AsyncIndicatorFeedsResource", "IndicatorFeedsResourceWithRawResponse", diff --git a/src/cloudflare/resources/intel/intel.py b/src/cloudflare/resources/intel/intel.py index f0fd166bd7d..5dc3092ce45 100644 --- a/src/cloudflare/resources/intel/intel.py +++ b/src/cloudflare/resources/intel/intel.py @@ -26,6 +26,14 @@ IPsResourceWithStreamingResponse, AsyncIPsResourceWithStreamingResponse, ) +from .whois import ( + WhoisResource, + AsyncWhoisResource, + WhoisResourceWithRawResponse, + AsyncWhoisResourceWithRawResponse, + WhoisResourceWithStreamingResponse, + AsyncWhoisResourceWithStreamingResponse, +) from .asn.asn import ASNResource, AsyncASNResource from .domains import ( DomainsResource, @@ -121,6 +129,10 @@ def ip_lists(self) -> IPListsResource: def miscategorizations(self) -> MiscategorizationsResource: return MiscategorizationsResource(self._client) + @cached_property + def whois(self) -> WhoisResource: + return WhoisResource(self._client) + @cached_property def indicator_feeds(self) -> IndicatorFeedsResource: return IndicatorFeedsResource(self._client) @@ -171,6 +183,10 @@ def ip_lists(self) -> AsyncIPListsResource: def miscategorizations(self) -> AsyncMiscategorizationsResource: return AsyncMiscategorizationsResource(self._client) + @cached_property + def whois(self) -> AsyncWhoisResource: + return AsyncWhoisResource(self._client) + @cached_property def indicator_feeds(self) -> AsyncIndicatorFeedsResource: return AsyncIndicatorFeedsResource(self._client) @@ -224,6 +240,10 @@ def ip_lists(self) -> IPListsResourceWithRawResponse: def miscategorizations(self) -> MiscategorizationsResourceWithRawResponse: return MiscategorizationsResourceWithRawResponse(self._intel.miscategorizations) + @cached_property + def whois(self) -> WhoisResourceWithRawResponse: + return WhoisResourceWithRawResponse(self._intel.whois) + @cached_property def indicator_feeds(self) -> IndicatorFeedsResourceWithRawResponse: return IndicatorFeedsResourceWithRawResponse(self._intel.indicator_feeds) @@ -269,6 +289,10 @@ def ip_lists(self) -> AsyncIPListsResourceWithRawResponse: def miscategorizations(self) -> AsyncMiscategorizationsResourceWithRawResponse: return AsyncMiscategorizationsResourceWithRawResponse(self._intel.miscategorizations) + @cached_property + def whois(self) -> AsyncWhoisResourceWithRawResponse: + return AsyncWhoisResourceWithRawResponse(self._intel.whois) + @cached_property def indicator_feeds(self) -> AsyncIndicatorFeedsResourceWithRawResponse: return AsyncIndicatorFeedsResourceWithRawResponse(self._intel.indicator_feeds) @@ -314,6 +338,10 @@ def ip_lists(self) -> IPListsResourceWithStreamingResponse: def miscategorizations(self) -> MiscategorizationsResourceWithStreamingResponse: return MiscategorizationsResourceWithStreamingResponse(self._intel.miscategorizations) + @cached_property + def whois(self) -> WhoisResourceWithStreamingResponse: + return WhoisResourceWithStreamingResponse(self._intel.whois) + @cached_property def indicator_feeds(self) -> IndicatorFeedsResourceWithStreamingResponse: return IndicatorFeedsResourceWithStreamingResponse(self._intel.indicator_feeds) @@ -359,6 +387,10 @@ def ip_lists(self) -> AsyncIPListsResourceWithStreamingResponse: def miscategorizations(self) -> AsyncMiscategorizationsResourceWithStreamingResponse: return AsyncMiscategorizationsResourceWithStreamingResponse(self._intel.miscategorizations) + @cached_property + def whois(self) -> AsyncWhoisResourceWithStreamingResponse: + return AsyncWhoisResourceWithStreamingResponse(self._intel.whois) + @cached_property def indicator_feeds(self) -> AsyncIndicatorFeedsResourceWithStreamingResponse: return AsyncIndicatorFeedsResourceWithStreamingResponse(self._intel.indicator_feeds) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py new file mode 100644 index 00000000000..050da13d396 --- /dev/null +++ b/src/cloudflare/resources/intel/whois.py @@ -0,0 +1,167 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, 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 ...types.intel import whois_get_params +from ..._base_client import ( + make_request_options, +) +from ...types.intel.whois_get_response import WhoisGetResponse + +__all__ = ["WhoisResource", "AsyncWhoisResource"] + + +class WhoisResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> WhoisResourceWithRawResponse: + return WhoisResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> WhoisResourceWithStreamingResponse: + return WhoisResourceWithStreamingResponse(self) + + def get( + self, + *, + account_id: str, + domain: 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, + ) -> WhoisGetResponse: + """ + Get WHOIS Record + + Args: + account_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 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}/intel/whois", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + ), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + ) + + +class AsyncWhoisResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncWhoisResourceWithRawResponse: + return AsyncWhoisResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncWhoisResourceWithStreamingResponse: + return AsyncWhoisResourceWithStreamingResponse(self) + + async def get( + self, + *, + account_id: str, + domain: 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, + ) -> WhoisGetResponse: + """ + Get WHOIS Record + + Args: + account_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 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}/intel/whois", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + ), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + ) + + +class WhoisResourceWithRawResponse: + def __init__(self, whois: WhoisResource) -> None: + self._whois = whois + + self.get = to_raw_response_wrapper( + whois.get, + ) + + +class AsyncWhoisResourceWithRawResponse: + def __init__(self, whois: AsyncWhoisResource) -> None: + self._whois = whois + + self.get = async_to_raw_response_wrapper( + whois.get, + ) + + +class WhoisResourceWithStreamingResponse: + def __init__(self, whois: WhoisResource) -> None: + self._whois = whois + + self.get = to_streamed_response_wrapper( + whois.get, + ) + + +class AsyncWhoisResourceWithStreamingResponse: + def __init__(self, whois: AsyncWhoisResource) -> None: + self._whois = whois + + self.get = async_to_streamed_response_wrapper( + whois.get, + ) diff --git a/src/cloudflare/types/intel/__init__.py b/src/cloudflare/types/intel/__init__.py index 5143786f35e..42260a14d9c 100644 --- a/src/cloudflare/types/intel/__init__.py +++ b/src/cloudflare/types/intel/__init__.py @@ -11,8 +11,10 @@ from .domain_history import DomainHistory as DomainHistory from .dns_list_params import DNSListParams as DNSListParams from .ip_get_response import IPGetResponse as IPGetResponse +from .whois_get_params import WhoisGetParams as WhoisGetParams from .dns_list_response import DNSListResponse as DNSListResponse from .domain_get_params import DomainGetParams as DomainGetParams +from .whois_get_response import WhoisGetResponse as WhoisGetResponse from .ip_list_get_response import IPListGetResponse as IPListGetResponse from .domain_history_get_params import DomainHistoryGetParams as DomainHistoryGetParams from .domain_history_get_response import DomainHistoryGetResponse as DomainHistoryGetResponse diff --git a/src/cloudflare/types/intel/whois_get_params.py b/src/cloudflare/types/intel/whois_get_params.py new file mode 100644 index 00000000000..d4069d2a7a0 --- /dev/null +++ b/src/cloudflare/types/intel/whois_get_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__ = ["WhoisGetParams"] + + +class WhoisGetParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + domain: str diff --git a/src/cloudflare/types/intel/whois_get_response.py b/src/cloudflare/types/intel/whois_get_response.py new file mode 100644 index 00000000000..0b740372876 --- /dev/null +++ b/src/cloudflare/types/intel/whois_get_response.py @@ -0,0 +1,186 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime + +from ..._models import BaseModel + +__all__ = ["WhoisGetResponse"] + + +class WhoisGetResponse(BaseModel): + dnnsec: object + + domain: str + + extension: str + + found: bool + + nameservers: List[str] + + punycode: str + + registrant: str + + registrar: str + + id: Optional[str] = None + + administrative_city: Optional[str] = None + + administrative_country: Optional[str] = None + + administrative_email: Optional[str] = None + + administrative_fax: Optional[str] = None + + administrative_fax_ext: Optional[str] = None + + administrative_id: Optional[str] = None + + administrative_name: Optional[str] = None + + administrative_org: Optional[str] = None + + administrative_phone: Optional[str] = None + + administrative_phone_ext: Optional[str] = None + + administrative_postal_code: Optional[str] = None + + administrative_province: Optional[str] = None + + administrative_referral_url: Optional[str] = None + + administrative_street: Optional[str] = None + + billing_city: Optional[str] = None + + billing_country: Optional[str] = None + + billing_email: Optional[str] = None + + billing_fax: Optional[str] = None + + billing_fax_ext: Optional[str] = None + + billing_id: Optional[str] = None + + billing_name: Optional[str] = None + + billing_org: Optional[str] = None + + billing_phone: Optional[str] = None + + billing_phone_ext: Optional[str] = None + + billing_postal_code: Optional[str] = None + + billing_province: Optional[str] = None + + billing_referral_url: Optional[str] = None + + billing_street: Optional[str] = None + + created_date: Optional[datetime] = None + + created_date_raw: Optional[str] = None + + dnssec: Optional[bool] = None + + expiration_date: Optional[datetime] = None + + expiration_date_raw: Optional[str] = None + + registrant_city: Optional[str] = None + + registrant_country: Optional[str] = None + + registrant_email: Optional[str] = None + + registrant_fax: Optional[str] = None + + registrant_fax_ext: Optional[str] = None + + registrant_id: Optional[str] = None + + registrant_name: Optional[str] = None + + registrant_org: Optional[str] = None + + registrant_phone: Optional[str] = None + + registrant_phone_ext: Optional[str] = None + + registrant_postal_code: Optional[str] = None + + registrant_province: Optional[str] = None + + registrant_referral_url: Optional[str] = None + + registrant_street: Optional[str] = None + + registrar_city: Optional[str] = None + + registrar_country: Optional[str] = None + + registrar_email: Optional[str] = None + + registrar_fax: Optional[str] = None + + registrar_fax_ext: Optional[str] = None + + registrar_id: Optional[str] = None + + registrar_name: Optional[str] = None + + registrar_org: Optional[str] = None + + registrar_phone: Optional[str] = None + + registrar_phone_ext: Optional[str] = None + + registrar_postal_code: Optional[str] = None + + registrar_province: Optional[str] = None + + registrar_referral_url: Optional[str] = None + + registrar_street: Optional[str] = None + + status: Optional[List[str]] = None + + technical_city: Optional[str] = None + + technical_country: Optional[str] = None + + technical_email: Optional[str] = None + + technical_fax: Optional[str] = None + + technical_fax_ext: Optional[str] = None + + technical_id: Optional[str] = None + + technical_name: Optional[str] = None + + technical_org: Optional[str] = None + + technical_phone: Optional[str] = None + + technical_phone_ext: Optional[str] = None + + technical_postal_code: Optional[str] = None + + technical_province: Optional[str] = None + + technical_referral_url: Optional[str] = None + + technical_street: Optional[str] = None + + updated_date: Optional[datetime] = None + + updated_date_raw: Optional[str] = None + + whois_server: Optional[str] = None diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py new file mode 100644 index 00000000000..215bb9b2e3f --- /dev/null +++ b/tests/api_resources/intel/test_whois.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, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.intel import WhoisGetResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestWhois: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + whois = client.intel.whois.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) + + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + whois = client.intel.whois.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + domain="string", + ) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.intel.whois.with_raw_response.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + whois = response.parse() + assert_matches_type(WhoisGetResponse, whois, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.intel.whois.with_streaming_response.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + whois = response.parse() + assert_matches_type(WhoisGetResponse, whois, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.intel.whois.with_raw_response.get( + account_id="", + ) + + +class TestAsyncWhois: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + whois = await async_client.intel.whois.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) + + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + whois = await async_client.intel.whois.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + domain="string", + ) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.intel.whois.with_raw_response.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + whois = await response.parse() + assert_matches_type(WhoisGetResponse, whois, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.intel.whois.with_streaming_response.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + whois = await response.parse() + assert_matches_type(WhoisGetResponse, whois, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.intel.whois.with_raw_response.get( + account_id="", + )