sarj-platform-sdk 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. sarj_platform_sdk-0.1.0/PKG-INFO +544 -0
  2. sarj_platform_sdk-0.1.0/README.md +532 -0
  3. sarj_platform_sdk-0.1.0/pyproject.toml +53 -0
  4. sarj_platform_sdk-0.1.0/setup.cfg +4 -0
  5. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/__init__.py +17 -0
  6. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/_hooks/__init__.py +4 -0
  7. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/_hooks/sdkhooks.py +74 -0
  8. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/_hooks/types.py +112 -0
  9. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/_version.py +15 -0
  10. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/basesdk.py +392 -0
  11. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/calls.py +382 -0
  12. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/errors/__init__.py +39 -0
  13. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/errors/errorresponse.py +40 -0
  14. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/errors/no_response_error.py +17 -0
  15. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/errors/responsevalidationerror.py +27 -0
  16. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/errors/sdkdefaulterror.py +40 -0
  17. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/errors/sdkerror.py +30 -0
  18. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/httpclient.py +125 -0
  19. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/__init__.py +201 -0
  20. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/apiresponse_healthstatus_.py +40 -0
  21. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/apiresponse_publiccall_.py +38 -0
  22. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/apiresponse_publiccalldetail_.py +38 -0
  23. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/calllimitexceededpayload.py +44 -0
  24. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/callnotfoundpayload.py +36 -0
  25. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/callstatus.py +21 -0
  26. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/createcallrequest.py +49 -0
  27. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/errorresponse.py +116 -0
  28. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/fieldviolation.py +20 -0
  29. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/getcallop.py +16 -0
  30. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/healthstatus.py +37 -0
  31. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/internalerrorpayload.py +33 -0
  32. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/language.py +16 -0
  33. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/noorganizationpayload.py +34 -0
  34. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/notfoundpayload.py +31 -0
  35. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/oauthinvalidredirecturipayload.py +37 -0
  36. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/outboundcallfailedpayload.py +39 -0
  37. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/phonedirection.py +14 -0
  38. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/phonenumberblockedpayload.py +39 -0
  39. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/publiccall.py +35 -0
  40. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/publiccalldetail.py +148 -0
  41. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/publictranscriptmessage.py +31 -0
  42. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/responsemeta.py +51 -0
  43. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/scenarioforbiddenpayload.py +37 -0
  44. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/scenarionotfoundpayload.py +37 -0
  45. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/security.py +42 -0
  46. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/unauthorizedpayload.py +33 -0
  47. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/models/validationerrorpayload.py +40 -0
  48. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/py.typed +1 -0
  49. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/sdk.py +241 -0
  50. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/sdkconfiguration.py +49 -0
  51. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/system.py +158 -0
  52. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/types/__init__.py +21 -0
  53. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/types/basemodel.py +77 -0
  54. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/utils/__init__.py +178 -0
  55. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/utils/annotations.py +79 -0
  56. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/utils/datetimes.py +23 -0
  57. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/utils/dynamic_imports.py +54 -0
  58. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/utils/enums.py +134 -0
  59. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/utils/eventstreaming.py +309 -0
  60. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/utils/forms.py +234 -0
  61. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/utils/headers.py +136 -0
  62. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/utils/logger.py +22 -0
  63. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/utils/metadata.py +119 -0
  64. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/utils/queryparams.py +217 -0
  65. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/utils/requestbodies.py +66 -0
  66. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/utils/retries.py +271 -0
  67. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/utils/security.py +198 -0
  68. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/utils/serializers.py +225 -0
  69. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/utils/unions.py +32 -0
  70. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/utils/unmarshal_json_response.py +38 -0
  71. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/utils/url.py +155 -0
  72. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk/utils/values.py +137 -0
  73. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk.egg-info/PKG-INFO +544 -0
  74. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk.egg-info/SOURCES.txt +75 -0
  75. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk.egg-info/dependency_links.txt +1 -0
  76. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk.egg-info/requires.txt +3 -0
  77. sarj_platform_sdk-0.1.0/src/sarj_platform_sdk.egg-info/top_level.txt +1 -0
@@ -0,0 +1,544 @@
1
+ Metadata-Version: 2.4
2
+ Name: sarj-platform-sdk
3
+ Version: 0.1.0
4
+ Summary: Python SDK for the Sarj.ai Developer API
5
+ Author: Sarj.ai
6
+ License: Apache-2.0
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: httpcore>=1.0.9
10
+ Requires-Dist: httpx>=0.28.1
11
+ Requires-Dist: pydantic>=2.11.2
12
+
13
+ # openapi
14
+
15
+ Developer-friendly & type-safe Python SDK specifically catered to leverage *openapi* API.
16
+
17
+ [![Built by Speakeasy](https://img.shields.io/badge/Built_by-SPEAKEASY-374151?style=for-the-badge&labelColor=f3f4f6)](https://www.speakeasy.com/?utm_source=openapi&utm_campaign=python)
18
+ [![License: MIT](https://img.shields.io/badge/LICENSE_//_MIT-3b5bdb?style=for-the-badge&labelColor=eff6ff)](https://opensource.org/licenses/MIT)
19
+
20
+
21
+ <br /><br />
22
+ > [!IMPORTANT]
23
+ > This SDK is not yet ready for production use. To complete setup please follow the steps outlined in your [workspace](https://app.speakeasy.com/org/sarjai-9hl/sarjai). Delete this section before > publishing to a package manager.
24
+
25
+ <!-- Start Summary [summary] -->
26
+ ## Summary
27
+
28
+ Sarj.ai Developer API: Public API for programmatic access to the **Sarj.ai voice platform**.
29
+
30
+ > [!TIP]
31
+ > **New here?** Start with the [Getting Started guide](/api/v1/docs/getting-started)
32
+ > to go from API key to first call in under 5 minutes.
33
+ >
34
+ > **Building with AI agents?** See the [MCP Server guide](/api/v1/docs/mcp)
35
+ > to connect Claude Code, Cursor, or any MCP-compatible agent.
36
+
37
+ ---
38
+
39
+ ## Authentication
40
+
41
+ All authenticated endpoints require a **Bearer token** in the `Authorization`
42
+ header:
43
+
44
+ ```
45
+ Authorization: Bearer <your-api-key>
46
+ ```
47
+
48
+ Generate an API key from [platform.sarj.ai/api-keys](https://platform.sarj.ai/api-keys).
49
+
50
+ > [!WARNING]
51
+ > If you receive a `401 Unauthorized` response, your key may be invalid,
52
+ > expired, or missing. Check the `error.type` field in the response body.
53
+
54
+ ---
55
+
56
+ ## Response Format
57
+
58
+ **Success**
59
+
60
+ ```json
61
+ {
62
+ "data": { ... },
63
+ "meta": { "request_id": "550e8400-e29b-41d4-a716-446655440000" }
64
+ }
65
+ ```
66
+
67
+ **Error**
68
+
69
+ ```json
70
+ {
71
+ "error": {
72
+ "type": "unauthorized",
73
+ "message": "Authentication required."
74
+ },
75
+ "meta": { "request_id": "550e8400-e29b-41d4-a716-446655440000" }
76
+ }
77
+ ```
78
+
79
+ Always branch on `error.type` — the `message` field is for humans only.
80
+
81
+ ---
82
+
83
+ ## Support
84
+
85
+ Include `meta.request_id` in all support tickets for faster resolution.
86
+
87
+
88
+ For more information about the API: [Sarj.ai Documentation](https://platform-docs.sarj.ai)
89
+ <!-- End Summary [summary] -->
90
+
91
+ <!-- Start Table of Contents [toc] -->
92
+ ## Table of Contents
93
+ <!-- $toc-max-depth=2 -->
94
+ * [openapi](#openapi)
95
+ * [Authentication](#authentication)
96
+ * [Response Format](#response-format)
97
+ * [Support](#support)
98
+ * [SDK Installation](#sdk-installation)
99
+ * [IDE Support](#ide-support)
100
+ * [SDK Example Usage](#sdk-example-usage)
101
+ * [Authentication](#authentication-1)
102
+ * [Available Resources and Operations](#available-resources-and-operations)
103
+ * [Retries](#retries)
104
+ * [Error Handling](#error-handling)
105
+ * [Server Selection](#server-selection)
106
+ * [Custom HTTP Client](#custom-http-client)
107
+ * [Resource Management](#resource-management)
108
+ * [Debugging](#debugging)
109
+ * [Development](#development)
110
+ * [Maturity](#maturity)
111
+ * [Contributions](#contributions)
112
+
113
+ <!-- End Table of Contents [toc] -->
114
+
115
+ <!-- Start SDK Installation [installation] -->
116
+ ## SDK Installation
117
+
118
+ > [!TIP]
119
+ > To finish publishing your SDK to PyPI you must [run your first generation action](https://www.speakeasy.com/docs/github-setup#step-by-step-guide).
120
+
121
+
122
+ > [!NOTE]
123
+ > **Python version upgrade policy**
124
+ >
125
+ > Once a Python version reaches its [official end of life date](https://devguide.python.org/versions/), a 3-month grace period is provided for users to upgrade. Following this grace period, the minimum python version supported in the SDK will be updated.
126
+
127
+ The SDK can be installed with *uv*, *pip*, or *poetry* package managers.
128
+
129
+ ### uv
130
+
131
+ *uv* is a fast Python package installer and resolver, designed as a drop-in replacement for pip and pip-tools. It's recommended for its speed and modern Python tooling capabilities.
132
+
133
+ ```bash
134
+ uv add git+<UNSET>.git
135
+ ```
136
+
137
+ ### PIP
138
+
139
+ *PIP* is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line.
140
+
141
+ ```bash
142
+ pip install git+<UNSET>.git
143
+ ```
144
+
145
+ ### Poetry
146
+
147
+ *Poetry* is a modern tool that simplifies dependency management and package publishing by using a single `pyproject.toml` file to handle project metadata and dependencies.
148
+
149
+ ```bash
150
+ poetry add git+<UNSET>.git
151
+ ```
152
+
153
+ ### Shell and script usage with `uv`
154
+
155
+ You can use this SDK in a Python shell with [uv](https://docs.astral.sh/uv/) and the `uvx` command that comes with it like so:
156
+
157
+ ```shell
158
+ uvx --from sarj-platform-sdk python
159
+ ```
160
+
161
+ It's also possible to write a standalone Python script without needing to set up a whole project like so:
162
+
163
+ ```python
164
+ #!/usr/bin/env -S uv run --script
165
+ # /// script
166
+ # requires-python = ">=3.10"
167
+ # dependencies = [
168
+ # "sarj-platform-sdk",
169
+ # ]
170
+ # ///
171
+
172
+ from sarj_platform_sdk import SDK
173
+
174
+ sdk = SDK(
175
+ # SDK arguments
176
+ )
177
+
178
+ # Rest of script here...
179
+ ```
180
+
181
+ Once that is saved to a file, you can run it with `uv run script.py` where
182
+ `script.py` can be replaced with the actual file name.
183
+ <!-- End SDK Installation [installation] -->
184
+
185
+ <!-- Start IDE Support [idesupport] -->
186
+ ## IDE Support
187
+
188
+ ### PyCharm
189
+
190
+ Generally, the SDK will work well with most IDEs out of the box. However, when using PyCharm, you can enjoy much better integration with Pydantic by installing an additional plugin.
191
+
192
+ - [PyCharm Pydantic Plugin](https://docs.pydantic.dev/latest/integrations/pycharm/)
193
+ <!-- End IDE Support [idesupport] -->
194
+
195
+ <!-- Start SDK Example Usage [usage] -->
196
+ ## SDK Example Usage
197
+
198
+ ### Example
199
+
200
+ ```python
201
+ # Synchronous Example
202
+ from sarj_platform_sdk import SDK
203
+
204
+
205
+ with SDK() as sdk:
206
+
207
+ res = sdk.system.health_health_get()
208
+
209
+ # Handle response
210
+ print(res)
211
+ ```
212
+
213
+ </br>
214
+
215
+ The same SDK client can also be used to make asynchronous requests by importing asyncio.
216
+
217
+ ```python
218
+ # Asynchronous Example
219
+ import asyncio
220
+ from sarj_platform_sdk import SDK
221
+
222
+ async def main():
223
+
224
+ async with SDK() as sdk:
225
+
226
+ res = await sdk.system.health_health_get_async()
227
+
228
+ # Handle response
229
+ print(res)
230
+
231
+ asyncio.run(main())
232
+ ```
233
+ <!-- End SDK Example Usage [usage] -->
234
+
235
+ <!-- Start Authentication [security] -->
236
+ ## Authentication
237
+
238
+ ### Per-Client Security Schemes
239
+
240
+ This SDK supports the following security scheme globally:
241
+
242
+ | Name | Type | Scheme |
243
+ | -------------- | ---- | ----------- |
244
+ | `api_key_auth` | http | HTTP Bearer |
245
+
246
+ To authenticate with the API the `api_key_auth` parameter must be set when initializing the SDK client instance. For example:
247
+ ```python
248
+ from sarj_platform_sdk import SDK
249
+
250
+
251
+ with SDK(
252
+ api_key_auth="<YOUR_BEARER_TOKEN_HERE>",
253
+ ) as sdk:
254
+
255
+ res = sdk.system.health_health_get()
256
+
257
+ # Handle response
258
+ print(res)
259
+
260
+ ```
261
+ <!-- End Authentication [security] -->
262
+
263
+ <!-- Start Available Resources and Operations [operations] -->
264
+ ## Available Resources and Operations
265
+
266
+ <details open>
267
+ <summary>Available methods</summary>
268
+
269
+ ### [Calls](docs/sdks/calls/README.md)
270
+
271
+ * [create_call](docs/sdks/calls/README.md#create_call) - Place an outbound Sarj.ai voice call
272
+ * [get_call](docs/sdks/calls/README.md#get_call) - Fetch Sarj.ai voice call details by call_id
273
+
274
+ ### [System](docs/sdks/system/README.md)
275
+
276
+ * [health_health_get](docs/sdks/system/README.md#health_health_get) - Health Check
277
+
278
+ </details>
279
+ <!-- End Available Resources and Operations [operations] -->
280
+
281
+ <!-- Start Retries [retries] -->
282
+ ## Retries
283
+
284
+ Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
285
+
286
+ To change the default retry strategy for a single API call, simply provide a `RetryConfig` object to the call:
287
+ ```python
288
+ from sarj_platform_sdk import SDK
289
+ from sarj_platform_sdk.utils import BackoffStrategy, RetryConfig
290
+
291
+
292
+ with SDK() as sdk:
293
+
294
+ res = sdk.system.health_health_get(,
295
+ RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False))
296
+
297
+ # Handle response
298
+ print(res)
299
+
300
+ ```
301
+
302
+ If you'd like to override the default retry strategy for all operations that support retries, you can use the `retry_config` optional parameter when initializing the SDK:
303
+ ```python
304
+ from sarj_platform_sdk import SDK
305
+ from sarj_platform_sdk.utils import BackoffStrategy, RetryConfig
306
+
307
+
308
+ with SDK(
309
+ retry_config=RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False),
310
+ ) as sdk:
311
+
312
+ res = sdk.system.health_health_get()
313
+
314
+ # Handle response
315
+ print(res)
316
+
317
+ ```
318
+ <!-- End Retries [retries] -->
319
+
320
+ <!-- Start Error Handling [errors] -->
321
+ ## Error Handling
322
+
323
+ [`SDKError`](./src/sarj_platform_sdk/errors/sdkerror.py) is the base class for all HTTP error responses. It has the following properties:
324
+
325
+ | Property | Type | Description |
326
+ | ------------------ | ---------------- | --------------------------------------------------------------------------------------- |
327
+ | `err.message` | `str` | Error message |
328
+ | `err.status_code` | `int` | HTTP response status code eg `404` |
329
+ | `err.headers` | `httpx.Headers` | HTTP response headers |
330
+ | `err.body` | `str` | HTTP body. Can be empty string if no body is returned. |
331
+ | `err.raw_response` | `httpx.Response` | Raw HTTP response |
332
+ | `err.data` | | Optional. Some errors may contain structured data. [See Error Classes](#error-classes). |
333
+
334
+ ### Example
335
+ ```python
336
+ from sarj_platform_sdk import SDK, errors
337
+
338
+
339
+ with SDK(
340
+ api_key_auth="<YOUR_BEARER_TOKEN_HERE>",
341
+ ) as sdk:
342
+ res = None
343
+ try:
344
+
345
+ res = sdk.calls.create_call(phone_number="+966512345678", scenario_id="<id>")
346
+
347
+ # Handle response
348
+ print(res)
349
+
350
+
351
+ except errors.SDKError as e:
352
+ # The base class for HTTP error responses
353
+ print(e.message)
354
+ print(e.status_code)
355
+ print(e.body)
356
+ print(e.headers)
357
+ print(e.raw_response)
358
+
359
+ # Depending on the method different errors may be thrown
360
+ if isinstance(e, errors.ErrorResponse):
361
+ print(e.data.error) # models.Error
362
+ print(e.data.meta) # Optional[models.ResponseMeta]
363
+ ```
364
+
365
+ ### Error Classes
366
+ **Primary error:**
367
+ * [`SDKError`](./src/sarj_platform_sdk/errors/sdkerror.py): The base class for HTTP error responses.
368
+
369
+ <details><summary>Less common errors (6)</summary>
370
+
371
+ <br />
372
+
373
+ **Network errors:**
374
+ * [`httpx.RequestError`](https://www.python-httpx.org/exceptions/#httpx.RequestError): Base class for request errors.
375
+ * [`httpx.ConnectError`](https://www.python-httpx.org/exceptions/#httpx.ConnectError): HTTP client was unable to make a request to a server.
376
+ * [`httpx.TimeoutException`](https://www.python-httpx.org/exceptions/#httpx.TimeoutException): HTTP request timed out.
377
+
378
+
379
+ **Inherit from [`SDKError`](./src/sarj_platform_sdk/errors/sdkerror.py)**:
380
+ * [`ErrorResponse`](./src/sarj_platform_sdk/errors/errorresponse.py): Standard envelope for all public API error responses. `error` is a discriminated union — branch on `error.type` to access variant-specific fields. Clients MUST treat unknown `type` values as retryable internal errors to preserve forward compatibility. Applicable to 2 of 3 methods.*
381
+ * [`ResponseValidationError`](./src/sarj_platform_sdk/errors/responsevalidationerror.py): Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via the `cause` attribute.
382
+
383
+ </details>
384
+
385
+ \* Check [the method documentation](#available-resources-and-operations) to see if the error is applicable.
386
+ <!-- End Error Handling [errors] -->
387
+
388
+ <!-- Start Server Selection [server] -->
389
+ ## Server Selection
390
+
391
+ ### Override Server URL Per-Client
392
+
393
+ The default server can be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example:
394
+ ```python
395
+ from sarj_platform_sdk import SDK
396
+
397
+
398
+ with SDK(
399
+ server_url="https://platform-api.sarj.ai/api/v1",
400
+ ) as sdk:
401
+
402
+ res = sdk.system.health_health_get()
403
+
404
+ # Handle response
405
+ print(res)
406
+
407
+ ```
408
+ <!-- End Server Selection [server] -->
409
+
410
+ <!-- Start Custom HTTP Client [http-client] -->
411
+ ## Custom HTTP Client
412
+
413
+ The Python SDK makes API calls using the [httpx](https://www.python-httpx.org/) HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with your own HTTP client instance.
414
+ Depending on whether you are using the sync or async version of the SDK, you can pass an instance of `HttpClient` or `AsyncHttpClient` respectively, which are Protocol's ensuring that the client has the necessary methods to make API calls.
415
+ This allows you to wrap the client with your own custom logic, such as adding custom headers, logging, or error handling, or you can just pass an instance of `httpx.Client` or `httpx.AsyncClient` directly.
416
+
417
+ For example, you could specify a header for every request that this sdk makes as follows:
418
+ ```python
419
+ from sarj_platform_sdk import SDK
420
+ import httpx
421
+
422
+ http_client = httpx.Client(headers={"x-custom-header": "someValue"})
423
+ s = SDK(client=http_client)
424
+ ```
425
+
426
+ or you could wrap the client with your own custom logic:
427
+ ```python
428
+ from sarj_platform_sdk import SDK
429
+ from sarj_platform_sdk.httpclient import AsyncHttpClient
430
+ import httpx
431
+
432
+ class CustomClient(AsyncHttpClient):
433
+ client: AsyncHttpClient
434
+
435
+ def __init__(self, client: AsyncHttpClient):
436
+ self.client = client
437
+
438
+ async def send(
439
+ self,
440
+ request: httpx.Request,
441
+ *,
442
+ stream: bool = False,
443
+ auth: Union[
444
+ httpx._types.AuthTypes, httpx._client.UseClientDefault, None
445
+ ] = httpx.USE_CLIENT_DEFAULT,
446
+ follow_redirects: Union[
447
+ bool, httpx._client.UseClientDefault
448
+ ] = httpx.USE_CLIENT_DEFAULT,
449
+ ) -> httpx.Response:
450
+ request.headers["Client-Level-Header"] = "added by client"
451
+
452
+ return await self.client.send(
453
+ request, stream=stream, auth=auth, follow_redirects=follow_redirects
454
+ )
455
+
456
+ def build_request(
457
+ self,
458
+ method: str,
459
+ url: httpx._types.URLTypes,
460
+ *,
461
+ content: Optional[httpx._types.RequestContent] = None,
462
+ data: Optional[httpx._types.RequestData] = None,
463
+ files: Optional[httpx._types.RequestFiles] = None,
464
+ json: Optional[Any] = None,
465
+ params: Optional[httpx._types.QueryParamTypes] = None,
466
+ headers: Optional[httpx._types.HeaderTypes] = None,
467
+ cookies: Optional[httpx._types.CookieTypes] = None,
468
+ timeout: Union[
469
+ httpx._types.TimeoutTypes, httpx._client.UseClientDefault
470
+ ] = httpx.USE_CLIENT_DEFAULT,
471
+ extensions: Optional[httpx._types.RequestExtensions] = None,
472
+ ) -> httpx.Request:
473
+ return self.client.build_request(
474
+ method,
475
+ url,
476
+ content=content,
477
+ data=data,
478
+ files=files,
479
+ json=json,
480
+ params=params,
481
+ headers=headers,
482
+ cookies=cookies,
483
+ timeout=timeout,
484
+ extensions=extensions,
485
+ )
486
+
487
+ s = SDK(async_client=CustomClient(httpx.AsyncClient()))
488
+ ```
489
+ <!-- End Custom HTTP Client [http-client] -->
490
+
491
+ <!-- Start Resource Management [resource-management] -->
492
+ ## Resource Management
493
+
494
+ The `SDK` class implements the context manager protocol and registers a finalizer function to close the underlying sync and async HTTPX clients it uses under the hood. This will close HTTP connections, release memory and free up other resources held by the SDK. In short-lived Python programs and notebooks that make a few SDK method calls, resource management may not be a concern. However, in longer-lived programs, it is beneficial to create a single SDK instance via a [context manager][context-manager] and reuse it across the application.
495
+
496
+ [context-manager]: https://docs.python.org/3/reference/datamodel.html#context-managers
497
+
498
+ ```python
499
+ from sarj_platform_sdk import SDK
500
+ def main():
501
+
502
+ with SDK() as sdk:
503
+ # Rest of application here...
504
+
505
+
506
+ # Or when using async:
507
+ async def amain():
508
+
509
+ async with SDK() as sdk:
510
+ # Rest of application here...
511
+ ```
512
+ <!-- End Resource Management [resource-management] -->
513
+
514
+ <!-- Start Debugging [debug] -->
515
+ ## Debugging
516
+
517
+ You can setup your SDK to emit debug logs for SDK requests and responses.
518
+
519
+ You can pass your own logger class directly into your SDK.
520
+ ```python
521
+ from sarj_platform_sdk import SDK
522
+ import logging
523
+
524
+ logging.basicConfig(level=logging.DEBUG)
525
+ s = SDK(debug_logger=logging.getLogger("sarj_platform_sdk"))
526
+ ```
527
+ <!-- End Debugging [debug] -->
528
+
529
+ <!-- Placeholder for Future Speakeasy SDK Sections -->
530
+
531
+ # Development
532
+
533
+ ## Maturity
534
+
535
+ This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage
536
+ to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally
537
+ looking for the latest version.
538
+
539
+ ## Contributions
540
+
541
+ While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation.
542
+ We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.
543
+
544
+ ### SDK Created by [Speakeasy](https://www.speakeasy.com/?utm_source=openapi&utm_campaign=python)