forked from slashml/gatewayz-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
667 lines (528 loc) · 22.3 KB
/
Copy pathclient.py
File metadata and controls
667 lines (528 loc) · 22.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
# This file was auto-generated by docsalot from our API Definition.
from __future__ import annotations
import typing
import httpx
from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from .core.request_options import RequestOptions
from .raw_client import AsyncRawGatewayzApi, RawGatewayzApi
if typing.TYPE_CHECKING:
from .activity.client import ActivityClient, AsyncActivityClient
from .admin.client import AdminClient, AsyncAdminClient
from .authentication.client import AsyncAuthenticationClient, AuthenticationClient
from .chat.client import AsyncChatClient, ChatClient
from .chat_history.client import AsyncChatHistoryClient, ChatHistoryClient
from .coupons.client import AsyncCouponsClient, CouponsClient
from .debug.client import AsyncDebugClient, DebugClient
from .models.client import AsyncModelsClient, ModelsClient
from .notifications.client import AsyncNotificationsClient, NotificationsClient
from .plans.client import AsyncPlansClient, PlansClient
from .providers.client import AsyncProvidersClient, ProvidersClient
from .ranking.client import AsyncRankingClient, RankingClient
from .stripe_payments.client import AsyncStripePaymentsClient, StripePaymentsClient
from .subscription.client import AsyncSubscriptionClient, SubscriptionClient
from .trial.client import AsyncTrialClient, TrialClient
class GatewayzApi:
"""
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
Parameters
----------
base_url : str
The base url to use for requests from the client.
token : typing.Optional[typing.Union[str, typing.Callable[[], str]]]
headers : typing.Optional[typing.Dict[str, str]]
Additional headers to send with every request.
timeout : typing.Optional[float]
The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
follow_redirects : typing.Optional[bool]
Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
httpx_client : typing.Optional[httpx.Client]
The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
Examples
--------
from gatewayz import GatewayzApi
client = GatewayzApi(
token="YOUR_TOKEN",
base_url="https://yourhost.com/path/to/api",
)
"""
def __init__(
self,
*,
base_url: str,
token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
headers: typing.Optional[typing.Dict[str, str]] = None,
timeout: typing.Optional[float] = None,
follow_redirects: typing.Optional[bool] = True,
httpx_client: typing.Optional[httpx.Client] = None,
):
_defaulted_timeout = (
timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
)
self._client_wrapper = SyncClientWrapper(
base_url=base_url,
token=token,
headers=headers,
httpx_client=httpx_client
if httpx_client is not None
else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
if follow_redirects is not None
else httpx.Client(timeout=_defaulted_timeout),
timeout=_defaulted_timeout,
)
self._raw_client = RawGatewayzApi(client_wrapper=self._client_wrapper)
self._chat: typing.Optional[ChatClient] = None
self._providers: typing.Optional[ProvidersClient] = None
self._models: typing.Optional[ModelsClient] = None
self._authentication: typing.Optional[AuthenticationClient] = None
self._admin: typing.Optional[AdminClient] = None
self._debug: typing.Optional[DebugClient] = None
self._notifications: typing.Optional[NotificationsClient] = None
self._plans: typing.Optional[PlansClient] = None
self._trial: typing.Optional[TrialClient] = None
self._subscription: typing.Optional[SubscriptionClient] = None
self._stripe_payments: typing.Optional[StripePaymentsClient] = None
self._chat_history: typing.Optional[ChatHistoryClient] = None
self._ranking: typing.Optional[RankingClient] = None
self._activity: typing.Optional[ActivityClient] = None
self._coupons: typing.Optional[CouponsClient] = None
@property
def with_raw_response(self) -> RawGatewayzApi:
"""
Retrieves a raw implementation of this client that returns raw responses.
Returns
-------
RawGatewayzApi
"""
return self._raw_client
def health_check_health_get(
self, *, request_options: typing.Optional[RequestOptions] = None
) -> typing.Optional[typing.Any]:
"""
Parameters
----------
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
typing.Optional[typing.Any]
Successful Response
Examples
--------
from gatewayz import GatewayzApi
client = GatewayzApi(
token="YOUR_TOKEN",
base_url="https://yourhost.com/path/to/api",
)
client.health_check_health_get()
"""
_response = self._raw_client.health_check_health_get(request_options=request_options)
return _response.data
def ping_ping_get(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Optional[typing.Any]:
"""
Ping endpoint that returns 'pong' and the number of times it has been called.
Returns:
dict: Response with message 'pong' and the total count of pings
Example response:
{
"message": "pong",
"count": 42,
"timestamp": "2025-10-02T10:30:00.000000"
}
Parameters
----------
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
typing.Optional[typing.Any]
Successful Response
Examples
--------
from gatewayz import GatewayzApi
client = GatewayzApi(
token="YOUR_TOKEN",
base_url="https://yourhost.com/path/to/api",
)
client.ping_ping_get()
"""
_response = self._raw_client.ping_ping_get(request_options=request_options)
return _response.data
def ping_stats_ping_stats_get(
self, *, request_options: typing.Optional[RequestOptions] = None
) -> typing.Optional[typing.Any]:
"""
Get ping statistics.
Returns:
dict: Statistics about ping usage
Example response:
{
"total_pings": 42,
"timestamp": "2025-10-02T10:30:00.000000"
}
Parameters
----------
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
typing.Optional[typing.Any]
Successful Response
Examples
--------
from gatewayz import GatewayzApi
client = GatewayzApi(
token="YOUR_TOKEN",
base_url="https://yourhost.com/path/to/api",
)
client.ping_stats_ping_stats_get()
"""
_response = self._raw_client.ping_stats_ping_stats_get(request_options=request_options)
return _response.data
@property
def chat(self):
if self._chat is None:
from .chat.client import ChatClient # noqa: E402
self._chat = ChatClient(client_wrapper=self._client_wrapper)
return self._chat
@property
def providers(self):
if self._providers is None:
from .providers.client import ProvidersClient # noqa: E402
self._providers = ProvidersClient(client_wrapper=self._client_wrapper)
return self._providers
@property
def models(self):
if self._models is None:
from .models.client import ModelsClient # noqa: E402
self._models = ModelsClient(client_wrapper=self._client_wrapper)
return self._models
@property
def authentication(self):
if self._authentication is None:
from .authentication.client import AuthenticationClient # noqa: E402
self._authentication = AuthenticationClient(client_wrapper=self._client_wrapper)
return self._authentication
@property
def admin(self):
if self._admin is None:
from .admin.client import AdminClient # noqa: E402
self._admin = AdminClient(client_wrapper=self._client_wrapper)
return self._admin
@property
def debug(self):
if self._debug is None:
from .debug.client import DebugClient # noqa: E402
self._debug = DebugClient(client_wrapper=self._client_wrapper)
return self._debug
@property
def notifications(self):
if self._notifications is None:
from .notifications.client import NotificationsClient # noqa: E402
self._notifications = NotificationsClient(client_wrapper=self._client_wrapper)
return self._notifications
@property
def plans(self):
if self._plans is None:
from .plans.client import PlansClient # noqa: E402
self._plans = PlansClient(client_wrapper=self._client_wrapper)
return self._plans
@property
def trial(self):
if self._trial is None:
from .trial.client import TrialClient # noqa: E402
self._trial = TrialClient(client_wrapper=self._client_wrapper)
return self._trial
@property
def subscription(self):
if self._subscription is None:
from .subscription.client import SubscriptionClient # noqa: E402
self._subscription = SubscriptionClient(client_wrapper=self._client_wrapper)
return self._subscription
@property
def stripe_payments(self):
if self._stripe_payments is None:
from .stripe_payments.client import StripePaymentsClient # noqa: E402
self._stripe_payments = StripePaymentsClient(client_wrapper=self._client_wrapper)
return self._stripe_payments
@property
def chat_history(self):
if self._chat_history is None:
from .chat_history.client import ChatHistoryClient # noqa: E402
self._chat_history = ChatHistoryClient(client_wrapper=self._client_wrapper)
return self._chat_history
@property
def ranking(self):
if self._ranking is None:
from .ranking.client import RankingClient # noqa: E402
self._ranking = RankingClient(client_wrapper=self._client_wrapper)
return self._ranking
@property
def activity(self):
if self._activity is None:
from .activity.client import ActivityClient # noqa: E402
self._activity = ActivityClient(client_wrapper=self._client_wrapper)
return self._activity
@property
def coupons(self):
if self._coupons is None:
from .coupons.client import CouponsClient # noqa: E402
self._coupons = CouponsClient(client_wrapper=self._client_wrapper)
return self._coupons
class AsyncGatewayzApi:
"""
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
Parameters
----------
base_url : str
The base url to use for requests from the client.
token : typing.Optional[typing.Union[str, typing.Callable[[], str]]]
headers : typing.Optional[typing.Dict[str, str]]
Additional headers to send with every request.
timeout : typing.Optional[float]
The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
follow_redirects : typing.Optional[bool]
Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
httpx_client : typing.Optional[httpx.AsyncClient]
The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
Examples
--------
from gatewayz import AsyncGatewayzApi
client = AsyncGatewayzApi(
token="YOUR_TOKEN",
base_url="https://yourhost.com/path/to/api",
)
"""
def __init__(
self,
*,
base_url: str,
token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
headers: typing.Optional[typing.Dict[str, str]] = None,
timeout: typing.Optional[float] = None,
follow_redirects: typing.Optional[bool] = True,
httpx_client: typing.Optional[httpx.AsyncClient] = None,
):
_defaulted_timeout = (
timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
)
self._client_wrapper = AsyncClientWrapper(
base_url=base_url,
token=token,
headers=headers,
httpx_client=httpx_client
if httpx_client is not None
else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
if follow_redirects is not None
else httpx.AsyncClient(timeout=_defaulted_timeout),
timeout=_defaulted_timeout,
)
self._raw_client = AsyncRawGatewayzApi(client_wrapper=self._client_wrapper)
self._chat: typing.Optional[AsyncChatClient] = None
self._providers: typing.Optional[AsyncProvidersClient] = None
self._models: typing.Optional[AsyncModelsClient] = None
self._authentication: typing.Optional[AsyncAuthenticationClient] = None
self._admin: typing.Optional[AsyncAdminClient] = None
self._debug: typing.Optional[AsyncDebugClient] = None
self._notifications: typing.Optional[AsyncNotificationsClient] = None
self._plans: typing.Optional[AsyncPlansClient] = None
self._trial: typing.Optional[AsyncTrialClient] = None
self._subscription: typing.Optional[AsyncSubscriptionClient] = None
self._stripe_payments: typing.Optional[AsyncStripePaymentsClient] = None
self._chat_history: typing.Optional[AsyncChatHistoryClient] = None
self._ranking: typing.Optional[AsyncRankingClient] = None
self._activity: typing.Optional[AsyncActivityClient] = None
self._coupons: typing.Optional[AsyncCouponsClient] = None
@property
def with_raw_response(self) -> AsyncRawGatewayzApi:
"""
Retrieves a raw implementation of this client that returns raw responses.
Returns
-------
AsyncRawGatewayzApi
"""
return self._raw_client
async def health_check_health_get(
self, *, request_options: typing.Optional[RequestOptions] = None
) -> typing.Optional[typing.Any]:
"""
Parameters
----------
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
typing.Optional[typing.Any]
Successful Response
Examples
--------
import asyncio
from gatewayz import AsyncGatewayzApi
client = AsyncGatewayzApi(
token="YOUR_TOKEN",
base_url="https://yourhost.com/path/to/api",
)
async def main() -> None:
await client.health_check_health_get()
asyncio.run(main())
"""
_response = await self._raw_client.health_check_health_get(request_options=request_options)
return _response.data
async def ping_ping_get(
self, *, request_options: typing.Optional[RequestOptions] = None
) -> typing.Optional[typing.Any]:
"""
Ping endpoint that returns 'pong' and the number of times it has been called.
Returns:
dict: Response with message 'pong' and the total count of pings
Example response:
{
"message": "pong",
"count": 42,
"timestamp": "2025-10-02T10:30:00.000000"
}
Parameters
----------
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
typing.Optional[typing.Any]
Successful Response
Examples
--------
import asyncio
from gatewayz import AsyncGatewayzApi
client = AsyncGatewayzApi(
token="YOUR_TOKEN",
base_url="https://yourhost.com/path/to/api",
)
async def main() -> None:
await client.ping_ping_get()
asyncio.run(main())
"""
_response = await self._raw_client.ping_ping_get(request_options=request_options)
return _response.data
async def ping_stats_ping_stats_get(
self, *, request_options: typing.Optional[RequestOptions] = None
) -> typing.Optional[typing.Any]:
"""
Get ping statistics.
Returns:
dict: Statistics about ping usage
Example response:
{
"total_pings": 42,
"timestamp": "2025-10-02T10:30:00.000000"
}
Parameters
----------
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
typing.Optional[typing.Any]
Successful Response
Examples
--------
import asyncio
from gatewayz import AsyncGatewayzApi
client = AsyncGatewayzApi(
token="YOUR_TOKEN",
base_url="https://yourhost.com/path/to/api",
)
async def main() -> None:
await client.ping_stats_ping_stats_get()
asyncio.run(main())
"""
_response = await self._raw_client.ping_stats_ping_stats_get(request_options=request_options)
return _response.data
@property
def chat(self):
if self._chat is None:
from .chat.client import AsyncChatClient # noqa: E402
self._chat = AsyncChatClient(client_wrapper=self._client_wrapper)
return self._chat
@property
def providers(self):
if self._providers is None:
from .providers.client import AsyncProvidersClient # noqa: E402
self._providers = AsyncProvidersClient(client_wrapper=self._client_wrapper)
return self._providers
@property
def models(self):
if self._models is None:
from .models.client import AsyncModelsClient # noqa: E402
self._models = AsyncModelsClient(client_wrapper=self._client_wrapper)
return self._models
@property
def authentication(self):
if self._authentication is None:
from .authentication.client import AsyncAuthenticationClient # noqa: E402
self._authentication = AsyncAuthenticationClient(client_wrapper=self._client_wrapper)
return self._authentication
@property
def admin(self):
if self._admin is None:
from .admin.client import AsyncAdminClient # noqa: E402
self._admin = AsyncAdminClient(client_wrapper=self._client_wrapper)
return self._admin
@property
def debug(self):
if self._debug is None:
from .debug.client import AsyncDebugClient # noqa: E402
self._debug = AsyncDebugClient(client_wrapper=self._client_wrapper)
return self._debug
@property
def notifications(self):
if self._notifications is None:
from .notifications.client import AsyncNotificationsClient # noqa: E402
self._notifications = AsyncNotificationsClient(client_wrapper=self._client_wrapper)
return self._notifications
@property
def plans(self):
if self._plans is None:
from .plans.client import AsyncPlansClient # noqa: E402
self._plans = AsyncPlansClient(client_wrapper=self._client_wrapper)
return self._plans
@property
def trial(self):
if self._trial is None:
from .trial.client import AsyncTrialClient # noqa: E402
self._trial = AsyncTrialClient(client_wrapper=self._client_wrapper)
return self._trial
@property
def subscription(self):
if self._subscription is None:
from .subscription.client import AsyncSubscriptionClient # noqa: E402
self._subscription = AsyncSubscriptionClient(client_wrapper=self._client_wrapper)
return self._subscription
@property
def stripe_payments(self):
if self._stripe_payments is None:
from .stripe_payments.client import AsyncStripePaymentsClient # noqa: E402
self._stripe_payments = AsyncStripePaymentsClient(client_wrapper=self._client_wrapper)
return self._stripe_payments
@property
def chat_history(self):
if self._chat_history is None:
from .chat_history.client import AsyncChatHistoryClient # noqa: E402
self._chat_history = AsyncChatHistoryClient(client_wrapper=self._client_wrapper)
return self._chat_history
@property
def ranking(self):
if self._ranking is None:
from .ranking.client import AsyncRankingClient # noqa: E402
self._ranking = AsyncRankingClient(client_wrapper=self._client_wrapper)
return self._ranking
@property
def activity(self):
if self._activity is None:
from .activity.client import AsyncActivityClient # noqa: E402
self._activity = AsyncActivityClient(client_wrapper=self._client_wrapper)
return self._activity
@property
def coupons(self):
if self._coupons is None:
from .coupons.client import AsyncCouponsClient # noqa: E402
self._coupons = AsyncCouponsClient(client_wrapper=self._client_wrapper)
return self._coupons