2
2
3
3
from __future__ import annotations
4
4
5
- from typing import Type , cast
6
-
7
5
import httpx
8
6
9
7
from ..._types import NOT_GIVEN , Body , Query , Headers , NotGiven
10
- from ..._utils import (
11
- maybe_transform ,
12
- async_maybe_transform ,
13
- )
8
+ from ..._utils import maybe_transform
14
9
from ..._compat import cached_property
15
10
from ..._resource import SyncAPIResource , AsyncAPIResource
16
11
from ..._response import (
19
14
async_to_raw_response_wrapper ,
20
15
async_to_streamed_response_wrapper ,
21
16
)
22
- from ..._wrappers import ResultWrapper
23
- from ...types .intel import dns , dns_get_params
17
+ from ...pagination import SyncV4PagePagination , AsyncV4PagePagination
18
+ from ...types .intel import DNSListResponse , dns_list_params
24
19
from ..._base_client import (
20
+ AsyncPaginator ,
25
21
make_request_options ,
26
22
)
27
23
@@ -37,21 +33,21 @@ def with_raw_response(self) -> DNSWithRawResponse:
37
33
def with_streaming_response (self ) -> DNSWithStreamingResponse :
38
34
return DNSWithStreamingResponse (self )
39
35
40
- def get (
36
+ def list (
41
37
self ,
42
38
* ,
43
39
account_id : str ,
44
40
ipv4 : str | NotGiven = NOT_GIVEN ,
45
41
page : float | NotGiven = NOT_GIVEN ,
46
42
per_page : float | NotGiven = NOT_GIVEN ,
47
- start_end_params : dns_get_params .StartEndParams | NotGiven = NOT_GIVEN ,
43
+ start_end_params : dns_list_params .StartEndParams | NotGiven = NOT_GIVEN ,
48
44
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
49
45
# The extra values given here take precedence over values defined on the client or passed to this method.
50
46
extra_headers : Headers | None = None ,
51
47
extra_query : Query | None = None ,
52
48
extra_body : Body | None = None ,
53
49
timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
54
- ) -> dns . DNS :
50
+ ) -> SyncV4PagePagination [ DNSListResponse ] :
55
51
"""
56
52
Get Passive DNS by IP
57
53
@@ -72,8 +68,9 @@ def get(
72
68
"""
73
69
if not account_id :
74
70
raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
75
- return self ._get (
71
+ return self ._get_api_list (
76
72
f"/accounts/{ account_id } /intel/dns" ,
73
+ page = SyncV4PagePagination [DNSListResponse ],
77
74
options = make_request_options (
78
75
extra_headers = extra_headers ,
79
76
extra_query = extra_query ,
@@ -86,11 +83,10 @@ def get(
86
83
"per_page" : per_page ,
87
84
"start_end_params" : start_end_params ,
88
85
},
89
- dns_get_params . DNSGetParams ,
86
+ dns_list_params . DNSListParams ,
90
87
),
91
- post_parser = ResultWrapper ._unwrapper ,
92
88
),
93
- cast_to = cast ( Type [ dns . DNS ], ResultWrapper [ dns . DNS ]) ,
89
+ model = DNSListResponse ,
94
90
)
95
91
96
92
@@ -103,21 +99,21 @@ def with_raw_response(self) -> AsyncDNSWithRawResponse:
103
99
def with_streaming_response (self ) -> AsyncDNSWithStreamingResponse :
104
100
return AsyncDNSWithStreamingResponse (self )
105
101
106
- async def get (
102
+ def list (
107
103
self ,
108
104
* ,
109
105
account_id : str ,
110
106
ipv4 : str | NotGiven = NOT_GIVEN ,
111
107
page : float | NotGiven = NOT_GIVEN ,
112
108
per_page : float | NotGiven = NOT_GIVEN ,
113
- start_end_params : dns_get_params .StartEndParams | NotGiven = NOT_GIVEN ,
109
+ start_end_params : dns_list_params .StartEndParams | NotGiven = NOT_GIVEN ,
114
110
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
115
111
# The extra values given here take precedence over values defined on the client or passed to this method.
116
112
extra_headers : Headers | None = None ,
117
113
extra_query : Query | None = None ,
118
114
extra_body : Body | None = None ,
119
115
timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
120
- ) -> dns . DNS :
116
+ ) -> AsyncPaginator [ DNSListResponse , AsyncV4PagePagination [ DNSListResponse ]] :
121
117
"""
122
118
Get Passive DNS by IP
123
119
@@ -138,59 +134,59 @@ async def get(
138
134
"""
139
135
if not account_id :
140
136
raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
141
- return await self ._get (
137
+ return self ._get_api_list (
142
138
f"/accounts/{ account_id } /intel/dns" ,
139
+ page = AsyncV4PagePagination [DNSListResponse ],
143
140
options = make_request_options (
144
141
extra_headers = extra_headers ,
145
142
extra_query = extra_query ,
146
143
extra_body = extra_body ,
147
144
timeout = timeout ,
148
- query = await async_maybe_transform (
145
+ query = maybe_transform (
149
146
{
150
147
"ipv4" : ipv4 ,
151
148
"page" : page ,
152
149
"per_page" : per_page ,
153
150
"start_end_params" : start_end_params ,
154
151
},
155
- dns_get_params . DNSGetParams ,
152
+ dns_list_params . DNSListParams ,
156
153
),
157
- post_parser = ResultWrapper ._unwrapper ,
158
154
),
159
- cast_to = cast ( Type [ dns . DNS ], ResultWrapper [ dns . DNS ]) ,
155
+ model = DNSListResponse ,
160
156
)
161
157
162
158
163
159
class DNSWithRawResponse :
164
160
def __init__ (self , dns : DNS ) -> None :
165
161
self ._dns = dns
166
162
167
- self .get = to_raw_response_wrapper (
168
- dns .get ,
163
+ self .list = to_raw_response_wrapper (
164
+ dns .list ,
169
165
)
170
166
171
167
172
168
class AsyncDNSWithRawResponse :
173
169
def __init__ (self , dns : AsyncDNS ) -> None :
174
170
self ._dns = dns
175
171
176
- self .get = async_to_raw_response_wrapper (
177
- dns .get ,
172
+ self .list = async_to_raw_response_wrapper (
173
+ dns .list ,
178
174
)
179
175
180
176
181
177
class DNSWithStreamingResponse :
182
178
def __init__ (self , dns : DNS ) -> None :
183
179
self ._dns = dns
184
180
185
- self .get = to_streamed_response_wrapper (
186
- dns .get ,
181
+ self .list = to_streamed_response_wrapper (
182
+ dns .list ,
187
183
)
188
184
189
185
190
186
class AsyncDNSWithStreamingResponse :
191
187
def __init__ (self , dns : AsyncDNS ) -> None :
192
188
self ._dns = dns
193
189
194
- self .get = async_to_streamed_response_wrapper (
195
- dns .get ,
190
+ self .list = async_to_streamed_response_wrapper (
191
+ dns .list ,
196
192
)
0 commit comments