|
| 1 | +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +from __future__ import annotations |
| 4 | + |
| 5 | +from typing import Type, cast |
| 6 | + |
| 7 | +import httpx |
| 8 | + |
| 9 | +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven |
| 10 | +from ..._utils import ( |
| 11 | + maybe_transform, |
| 12 | + async_maybe_transform, |
| 13 | +) |
| 14 | +from ..._compat import cached_property |
| 15 | +from ..._resource import SyncAPIResource, AsyncAPIResource |
| 16 | +from ..._response import ( |
| 17 | + to_raw_response_wrapper, |
| 18 | + to_streamed_response_wrapper, |
| 19 | + async_to_raw_response_wrapper, |
| 20 | + async_to_streamed_response_wrapper, |
| 21 | +) |
| 22 | +from ..._wrappers import ResultWrapper |
| 23 | +from ...types.intel import whois_get_params |
| 24 | +from ..._base_client import ( |
| 25 | + make_request_options, |
| 26 | +) |
| 27 | +from ...types.intel.whois_get_response import WhoisGetResponse |
| 28 | + |
| 29 | +__all__ = ["WhoisResource", "AsyncWhoisResource"] |
| 30 | + |
| 31 | + |
| 32 | +class WhoisResource(SyncAPIResource): |
| 33 | + @cached_property |
| 34 | + def with_raw_response(self) -> WhoisResourceWithRawResponse: |
| 35 | + return WhoisResourceWithRawResponse(self) |
| 36 | + |
| 37 | + @cached_property |
| 38 | + def with_streaming_response(self) -> WhoisResourceWithStreamingResponse: |
| 39 | + return WhoisResourceWithStreamingResponse(self) |
| 40 | + |
| 41 | + def get( |
| 42 | + self, |
| 43 | + *, |
| 44 | + account_id: str, |
| 45 | + domain: str | NotGiven = NOT_GIVEN, |
| 46 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 47 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 48 | + extra_headers: Headers | None = None, |
| 49 | + extra_query: Query | None = None, |
| 50 | + extra_body: Body | None = None, |
| 51 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 52 | + ) -> WhoisGetResponse: |
| 53 | + """ |
| 54 | + Get WHOIS Record |
| 55 | +
|
| 56 | + Args: |
| 57 | + account_id: Identifier |
| 58 | +
|
| 59 | + extra_headers: Send extra headers |
| 60 | +
|
| 61 | + extra_query: Add additional query parameters to the request |
| 62 | +
|
| 63 | + extra_body: Add additional JSON properties to the request |
| 64 | +
|
| 65 | + timeout: Override the client-level default timeout for this request, in seconds |
| 66 | + """ |
| 67 | + if not account_id: |
| 68 | + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") |
| 69 | + return self._get( |
| 70 | + f"/accounts/{account_id}/intel/whois", |
| 71 | + options=make_request_options( |
| 72 | + extra_headers=extra_headers, |
| 73 | + extra_query=extra_query, |
| 74 | + extra_body=extra_body, |
| 75 | + timeout=timeout, |
| 76 | + query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), |
| 77 | + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, |
| 78 | + ), |
| 79 | + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), |
| 80 | + ) |
| 81 | + |
| 82 | + |
| 83 | +class AsyncWhoisResource(AsyncAPIResource): |
| 84 | + @cached_property |
| 85 | + def with_raw_response(self) -> AsyncWhoisResourceWithRawResponse: |
| 86 | + return AsyncWhoisResourceWithRawResponse(self) |
| 87 | + |
| 88 | + @cached_property |
| 89 | + def with_streaming_response(self) -> AsyncWhoisResourceWithStreamingResponse: |
| 90 | + return AsyncWhoisResourceWithStreamingResponse(self) |
| 91 | + |
| 92 | + async def get( |
| 93 | + self, |
| 94 | + *, |
| 95 | + account_id: str, |
| 96 | + domain: str | NotGiven = NOT_GIVEN, |
| 97 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 98 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 99 | + extra_headers: Headers | None = None, |
| 100 | + extra_query: Query | None = None, |
| 101 | + extra_body: Body | None = None, |
| 102 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 103 | + ) -> WhoisGetResponse: |
| 104 | + """ |
| 105 | + Get WHOIS Record |
| 106 | +
|
| 107 | + Args: |
| 108 | + account_id: Identifier |
| 109 | +
|
| 110 | + extra_headers: Send extra headers |
| 111 | +
|
| 112 | + extra_query: Add additional query parameters to the request |
| 113 | +
|
| 114 | + extra_body: Add additional JSON properties to the request |
| 115 | +
|
| 116 | + timeout: Override the client-level default timeout for this request, in seconds |
| 117 | + """ |
| 118 | + if not account_id: |
| 119 | + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") |
| 120 | + return await self._get( |
| 121 | + f"/accounts/{account_id}/intel/whois", |
| 122 | + options=make_request_options( |
| 123 | + extra_headers=extra_headers, |
| 124 | + extra_query=extra_query, |
| 125 | + extra_body=extra_body, |
| 126 | + timeout=timeout, |
| 127 | + query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), |
| 128 | + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, |
| 129 | + ), |
| 130 | + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), |
| 131 | + ) |
| 132 | + |
| 133 | + |
| 134 | +class WhoisResourceWithRawResponse: |
| 135 | + def __init__(self, whois: WhoisResource) -> None: |
| 136 | + self._whois = whois |
| 137 | + |
| 138 | + self.get = to_raw_response_wrapper( |
| 139 | + whois.get, |
| 140 | + ) |
| 141 | + |
| 142 | + |
| 143 | +class AsyncWhoisResourceWithRawResponse: |
| 144 | + def __init__(self, whois: AsyncWhoisResource) -> None: |
| 145 | + self._whois = whois |
| 146 | + |
| 147 | + self.get = async_to_raw_response_wrapper( |
| 148 | + whois.get, |
| 149 | + ) |
| 150 | + |
| 151 | + |
| 152 | +class WhoisResourceWithStreamingResponse: |
| 153 | + def __init__(self, whois: WhoisResource) -> None: |
| 154 | + self._whois = whois |
| 155 | + |
| 156 | + self.get = to_streamed_response_wrapper( |
| 157 | + whois.get, |
| 158 | + ) |
| 159 | + |
| 160 | + |
| 161 | +class AsyncWhoisResourceWithStreamingResponse: |
| 162 | + def __init__(self, whois: AsyncWhoisResource) -> None: |
| 163 | + self._whois = whois |
| 164 | + |
| 165 | + self.get = async_to_streamed_response_wrapper( |
| 166 | + whois.get, |
| 167 | + ) |
0 commit comments