2
2
3
3
from __future__ import annotations
4
4
5
- from typing import Union
5
+ from typing import Type , Union , cast
6
6
from datetime import datetime
7
7
from typing_extensions import Literal
8
8
9
9
import httpx
10
10
11
+ from .request import (
12
+ RequestResource ,
13
+ AsyncRequestResource ,
14
+ RequestResourceWithRawResponse ,
15
+ AsyncRequestResourceWithRawResponse ,
16
+ RequestResourceWithStreamingResponse ,
17
+ AsyncRequestResourceWithStreamingResponse ,
18
+ )
19
+ from .response import (
20
+ ResponseResource ,
21
+ AsyncResponseResource ,
22
+ ResponseResourceWithRawResponse ,
23
+ AsyncResponseResourceWithRawResponse ,
24
+ ResponseResourceWithStreamingResponse ,
25
+ AsyncResponseResourceWithStreamingResponse ,
26
+ )
11
27
from ...._types import NOT_GIVEN , Body , Query , Headers , NotGiven
12
28
from ...._utils import maybe_transform
13
29
from ...._compat import cached_property
18
34
async_to_raw_response_wrapper ,
19
35
async_to_streamed_response_wrapper ,
20
36
)
37
+ from ...._wrappers import ResultWrapper
21
38
from ....pagination import SyncV4PagePaginationArray , AsyncV4PagePaginationArray
22
39
from ...._base_client import (
23
40
AsyncPaginator ,
24
41
make_request_options ,
25
42
)
26
43
from ....types .ai_gateway import log_list_params
44
+ from ....types .ai_gateway .log_get_response import LogGetResponse
27
45
from ....types .ai_gateway .log_list_response import LogListResponse
28
46
29
47
__all__ = ["LogsResource" , "AsyncLogsResource" ]
30
48
31
49
32
50
class LogsResource (SyncAPIResource ):
51
+ @cached_property
52
+ def request (self ) -> RequestResource :
53
+ return RequestResource (self ._client )
54
+
55
+ @cached_property
56
+ def response (self ) -> ResponseResource :
57
+ return ResponseResource (self ._client )
58
+
33
59
@cached_property
34
60
def with_raw_response (self ) -> LogsResourceWithRawResponse :
35
61
return LogsResourceWithRawResponse (self )
@@ -103,8 +129,61 @@ def list(
103
129
model = LogListResponse ,
104
130
)
105
131
132
+ def get (
133
+ self ,
134
+ log_id : str ,
135
+ * ,
136
+ account_id : str ,
137
+ id : str ,
138
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
139
+ # The extra values given here take precedence over values defined on the client or passed to this method.
140
+ extra_headers : Headers | None = None ,
141
+ extra_query : Query | None = None ,
142
+ extra_body : Body | None = None ,
143
+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
144
+ ) -> LogGetResponse :
145
+ """
146
+ Get Gateway Log Detail
147
+
148
+ Args:
149
+ id: gateway id
150
+
151
+ extra_headers: Send extra headers
152
+
153
+ extra_query: Add additional query parameters to the request
154
+
155
+ extra_body: Add additional JSON properties to the request
156
+
157
+ timeout: Override the client-level default timeout for this request, in seconds
158
+ """
159
+ if not account_id :
160
+ raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
161
+ if not id :
162
+ raise ValueError (f"Expected a non-empty value for `id` but received { id !r} " )
163
+ if not log_id :
164
+ raise ValueError (f"Expected a non-empty value for `log_id` but received { log_id !r} " )
165
+ return self ._get (
166
+ f"/accounts/{ account_id } /ai-gateway/gateways/{ id } /logs/{ log_id } " ,
167
+ options = make_request_options (
168
+ extra_headers = extra_headers ,
169
+ extra_query = extra_query ,
170
+ extra_body = extra_body ,
171
+ timeout = timeout ,
172
+ post_parser = ResultWrapper [LogGetResponse ]._unwrapper ,
173
+ ),
174
+ cast_to = cast (Type [LogGetResponse ], ResultWrapper [LogGetResponse ]),
175
+ )
176
+
106
177
107
178
class AsyncLogsResource (AsyncAPIResource ):
179
+ @cached_property
180
+ def request (self ) -> AsyncRequestResource :
181
+ return AsyncRequestResource (self ._client )
182
+
183
+ @cached_property
184
+ def response (self ) -> AsyncResponseResource :
185
+ return AsyncResponseResource (self ._client )
186
+
108
187
@cached_property
109
188
def with_raw_response (self ) -> AsyncLogsResourceWithRawResponse :
110
189
return AsyncLogsResourceWithRawResponse (self )
@@ -178,6 +257,51 @@ def list(
178
257
model = LogListResponse ,
179
258
)
180
259
260
+ async def get (
261
+ self ,
262
+ log_id : str ,
263
+ * ,
264
+ account_id : str ,
265
+ id : str ,
266
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
267
+ # The extra values given here take precedence over values defined on the client or passed to this method.
268
+ extra_headers : Headers | None = None ,
269
+ extra_query : Query | None = None ,
270
+ extra_body : Body | None = None ,
271
+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
272
+ ) -> LogGetResponse :
273
+ """
274
+ Get Gateway Log Detail
275
+
276
+ Args:
277
+ id: gateway id
278
+
279
+ extra_headers: Send extra headers
280
+
281
+ extra_query: Add additional query parameters to the request
282
+
283
+ extra_body: Add additional JSON properties to the request
284
+
285
+ timeout: Override the client-level default timeout for this request, in seconds
286
+ """
287
+ if not account_id :
288
+ raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
289
+ if not id :
290
+ raise ValueError (f"Expected a non-empty value for `id` but received { id !r} " )
291
+ if not log_id :
292
+ raise ValueError (f"Expected a non-empty value for `log_id` but received { log_id !r} " )
293
+ return await self ._get (
294
+ f"/accounts/{ account_id } /ai-gateway/gateways/{ id } /logs/{ log_id } " ,
295
+ options = make_request_options (
296
+ extra_headers = extra_headers ,
297
+ extra_query = extra_query ,
298
+ extra_body = extra_body ,
299
+ timeout = timeout ,
300
+ post_parser = ResultWrapper [LogGetResponse ]._unwrapper ,
301
+ ),
302
+ cast_to = cast (Type [LogGetResponse ], ResultWrapper [LogGetResponse ]),
303
+ )
304
+
181
305
182
306
class LogsResourceWithRawResponse :
183
307
def __init__ (self , logs : LogsResource ) -> None :
@@ -186,6 +310,17 @@ def __init__(self, logs: LogsResource) -> None:
186
310
self .list = to_raw_response_wrapper (
187
311
logs .list ,
188
312
)
313
+ self .get = to_raw_response_wrapper (
314
+ logs .get ,
315
+ )
316
+
317
+ @cached_property
318
+ def request (self ) -> RequestResourceWithRawResponse :
319
+ return RequestResourceWithRawResponse (self ._logs .request )
320
+
321
+ @cached_property
322
+ def response (self ) -> ResponseResourceWithRawResponse :
323
+ return ResponseResourceWithRawResponse (self ._logs .response )
189
324
190
325
191
326
class AsyncLogsResourceWithRawResponse :
@@ -195,6 +330,17 @@ def __init__(self, logs: AsyncLogsResource) -> None:
195
330
self .list = async_to_raw_response_wrapper (
196
331
logs .list ,
197
332
)
333
+ self .get = async_to_raw_response_wrapper (
334
+ logs .get ,
335
+ )
336
+
337
+ @cached_property
338
+ def request (self ) -> AsyncRequestResourceWithRawResponse :
339
+ return AsyncRequestResourceWithRawResponse (self ._logs .request )
340
+
341
+ @cached_property
342
+ def response (self ) -> AsyncResponseResourceWithRawResponse :
343
+ return AsyncResponseResourceWithRawResponse (self ._logs .response )
198
344
199
345
200
346
class LogsResourceWithStreamingResponse :
@@ -204,6 +350,17 @@ def __init__(self, logs: LogsResource) -> None:
204
350
self .list = to_streamed_response_wrapper (
205
351
logs .list ,
206
352
)
353
+ self .get = to_streamed_response_wrapper (
354
+ logs .get ,
355
+ )
356
+
357
+ @cached_property
358
+ def request (self ) -> RequestResourceWithStreamingResponse :
359
+ return RequestResourceWithStreamingResponse (self ._logs .request )
360
+
361
+ @cached_property
362
+ def response (self ) -> ResponseResourceWithStreamingResponse :
363
+ return ResponseResourceWithStreamingResponse (self ._logs .response )
207
364
208
365
209
366
class AsyncLogsResourceWithStreamingResponse :
@@ -213,3 +370,14 @@ def __init__(self, logs: AsyncLogsResource) -> None:
213
370
self .list = async_to_streamed_response_wrapper (
214
371
logs .list ,
215
372
)
373
+ self .get = async_to_streamed_response_wrapper (
374
+ logs .get ,
375
+ )
376
+
377
+ @cached_property
378
+ def request (self ) -> AsyncRequestResourceWithStreamingResponse :
379
+ return AsyncRequestResourceWithStreamingResponse (self ._logs .request )
380
+
381
+ @cached_property
382
+ def response (self ) -> AsyncResponseResourceWithStreamingResponse :
383
+ return AsyncResponseResourceWithStreamingResponse (self ._logs .response )
0 commit comments