aerostack 0.1.2__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 (61) hide show
  1. aerostack-0.1.2/PKG-INFO +604 -0
  2. aerostack-0.1.2/README.md +585 -0
  3. aerostack-0.1.2/py.typed +1 -0
  4. aerostack-0.1.2/pyproject.toml +57 -0
  5. aerostack-0.1.2/src/aerostack/__init__.py +17 -0
  6. aerostack-0.1.2/src/aerostack/_hooks/__init__.py +5 -0
  7. aerostack-0.1.2/src/aerostack/_hooks/registration.py +13 -0
  8. aerostack-0.1.2/src/aerostack/_hooks/sdkhooks.py +76 -0
  9. aerostack-0.1.2/src/aerostack/_hooks/types.py +113 -0
  10. aerostack-0.1.2/src/aerostack/_version.py +15 -0
  11. aerostack-0.1.2/src/aerostack/ai.py +178 -0
  12. aerostack-0.1.2/src/aerostack/authentication.py +368 -0
  13. aerostack-0.1.2/src/aerostack/basesdk.py +384 -0
  14. aerostack-0.1.2/src/aerostack/cache.py +344 -0
  15. aerostack-0.1.2/src/aerostack/database.py +196 -0
  16. aerostack-0.1.2/src/aerostack/errors/__init__.py +70 -0
  17. aerostack-0.1.2/src/aerostack/errors/errorresponse.py +40 -0
  18. aerostack-0.1.2/src/aerostack/errors/no_response_error.py +17 -0
  19. aerostack-0.1.2/src/aerostack/errors/responsevalidationerror.py +27 -0
  20. aerostack-0.1.2/src/aerostack/errors/sdkbaseerror.py +30 -0
  21. aerostack-0.1.2/src/aerostack/errors/sdkerror.py +40 -0
  22. aerostack-0.1.2/src/aerostack/httpclient.py +125 -0
  23. aerostack-0.1.2/src/aerostack/models/__init__.py +186 -0
  24. aerostack-0.1.2/src/aerostack/models/aichatop.py +96 -0
  25. aerostack-0.1.2/src/aerostack/models/authresponse.py +48 -0
  26. aerostack-0.1.2/src/aerostack/models/authsigninop.py +16 -0
  27. aerostack-0.1.2/src/aerostack/models/authsignupop.py +40 -0
  28. aerostack-0.1.2/src/aerostack/models/cachegetop.py +55 -0
  29. aerostack-0.1.2/src/aerostack/models/cachesetop.py +67 -0
  30. aerostack-0.1.2/src/aerostack/models/dbqueryop.py +38 -0
  31. aerostack-0.1.2/src/aerostack/models/dbqueryresult.py +34 -0
  32. aerostack-0.1.2/src/aerostack/models/queueenqueueop.py +77 -0
  33. aerostack-0.1.2/src/aerostack/models/security.py +24 -0
  34. aerostack-0.1.2/src/aerostack/models/servicesinvokeop.py +56 -0
  35. aerostack-0.1.2/src/aerostack/models/storageuploadop.py +114 -0
  36. aerostack-0.1.2/src/aerostack/models/user.py +60 -0
  37. aerostack-0.1.2/src/aerostack/py.typed +1 -0
  38. aerostack-0.1.2/src/aerostack/queue.py +182 -0
  39. aerostack-0.1.2/src/aerostack/sdk.py +209 -0
  40. aerostack-0.1.2/src/aerostack/sdkconfiguration.py +51 -0
  41. aerostack-0.1.2/src/aerostack/services.py +182 -0
  42. aerostack-0.1.2/src/aerostack/storage.py +182 -0
  43. aerostack-0.1.2/src/aerostack/types/__init__.py +21 -0
  44. aerostack-0.1.2/src/aerostack/types/basemodel.py +77 -0
  45. aerostack-0.1.2/src/aerostack/utils/__init__.py +203 -0
  46. aerostack-0.1.2/src/aerostack/utils/annotations.py +79 -0
  47. aerostack-0.1.2/src/aerostack/utils/datetimes.py +23 -0
  48. aerostack-0.1.2/src/aerostack/utils/enums.py +134 -0
  49. aerostack-0.1.2/src/aerostack/utils/eventstreaming.py +280 -0
  50. aerostack-0.1.2/src/aerostack/utils/forms.py +234 -0
  51. aerostack-0.1.2/src/aerostack/utils/headers.py +136 -0
  52. aerostack-0.1.2/src/aerostack/utils/logger.py +22 -0
  53. aerostack-0.1.2/src/aerostack/utils/metadata.py +118 -0
  54. aerostack-0.1.2/src/aerostack/utils/queryparams.py +217 -0
  55. aerostack-0.1.2/src/aerostack/utils/requestbodies.py +66 -0
  56. aerostack-0.1.2/src/aerostack/utils/retries.py +281 -0
  57. aerostack-0.1.2/src/aerostack/utils/security.py +176 -0
  58. aerostack-0.1.2/src/aerostack/utils/serializers.py +229 -0
  59. aerostack-0.1.2/src/aerostack/utils/unmarshal_json_response.py +38 -0
  60. aerostack-0.1.2/src/aerostack/utils/url.py +155 -0
  61. aerostack-0.1.2/src/aerostack/utils/values.py +137 -0
@@ -0,0 +1,604 @@
1
+ Metadata-Version: 2.4
2
+ Name: aerostack
3
+ Version: 0.1.2
4
+ Summary: Aerostack API Client SDK for Python
5
+ Author: Speakeasy
6
+ Requires-Python: >=3.9
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.9
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Requires-Dist: httpcore (>=1.0.9)
15
+ Requires-Dist: httpx (>=0.28.1)
16
+ Requires-Dist: pydantic (>=2.11.2)
17
+ Description-Content-Type: text/markdown
18
+
19
+ # aerostack
20
+
21
+ Developer-friendly & type-safe Python SDK specifically catered to leverage *aerostack* API.
22
+
23
+ [![License: MIT](https://img.shields.io/badge/LICENSE_//_MIT-3b5bdb?style=for-the-badge&labelColor=eff6ff)](https://opensource.org/licenses/MIT)
24
+
25
+ <br /><br />
26
+ > [!IMPORTANT]
27
+
28
+ <!-- Start Summary [summary] -->
29
+ ## Summary
30
+
31
+ Aerostack API: Aerostack Platform API - Unified access to database, authentication,
32
+ caching, queues, storage, and AI services.
33
+ <!-- End Summary [summary] -->
34
+
35
+ <!-- Start Table of Contents [toc] -->
36
+ ## Table of Contents
37
+ <!-- $toc-max-depth=2 -->
38
+ * [aerostack](#aerostack)
39
+ * [SDK Installation](#sdk-installation)
40
+ * [IDE Support](#ide-support)
41
+ * [SDK Example Usage](#sdk-example-usage)
42
+ * [Authentication](#authentication)
43
+ * [Available Resources and Operations](#available-resources-and-operations)
44
+ * [File uploads](#file-uploads)
45
+ * [Retries](#retries)
46
+ * [Error Handling](#error-handling)
47
+ * [Server Selection](#server-selection)
48
+ * [Custom HTTP Client](#custom-http-client)
49
+ * [Resource Management](#resource-management)
50
+ * [Debugging](#debugging)
51
+ * [Development](#development)
52
+ * [Maturity](#maturity)
53
+ * [Contributions](#contributions)
54
+
55
+ <!-- End Table of Contents [toc] -->
56
+
57
+ <!-- Start SDK Installation [installation] -->
58
+ ## SDK Installation
59
+
60
+ > [!TIP]
61
+ > 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).
62
+
63
+ > [!NOTE]
64
+ > **Python version upgrade policy**
65
+ >
66
+ > 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.
67
+
68
+ The SDK can be installed with *uv*, *pip*, or *poetry* package managers.
69
+
70
+ ### uv
71
+
72
+ *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.
73
+
74
+ ```bash
75
+ uv add git+<UNSET>.git
76
+ ```
77
+
78
+ ### PIP
79
+
80
+ *PIP* is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line.
81
+
82
+ ```bash
83
+ pip install git+<UNSET>.git
84
+ ```
85
+
86
+ ### Poetry
87
+
88
+ *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.
89
+
90
+ ```bash
91
+ poetry add git+<UNSET>.git
92
+ ```
93
+
94
+ ### Shell and script usage with `uv`
95
+
96
+ 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:
97
+
98
+ ```shell
99
+ uvx --from aerostack python
100
+ ```
101
+
102
+ It's also possible to write a standalone Python script without needing to set up a whole project like so:
103
+
104
+ ```python
105
+ #!/usr/bin/env -S uv run --script
106
+ # /// script
107
+ # requires-python = ">=3.10"
108
+ # dependencies = [
109
+ # "aerostack",
110
+ # ]
111
+ # ///
112
+
113
+ from aerostack import SDK
114
+
115
+ sdk = SDK(
116
+ # SDK arguments
117
+ )
118
+
119
+ # Rest of script here...
120
+ ```
121
+
122
+ Once that is saved to a file, you can run it with `uv run script.py` where
123
+ `script.py` can be replaced with the actual file name.
124
+ <!-- End SDK Installation [installation] -->
125
+
126
+ <!-- Start IDE Support [idesupport] -->
127
+ ## IDE Support
128
+
129
+ ### PyCharm
130
+
131
+ 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.
132
+
133
+ - [PyCharm Pydantic Plugin](https://docs.pydantic.dev/latest/integrations/pycharm/)
134
+ <!-- End IDE Support [idesupport] -->
135
+
136
+ <!-- Start SDK Example Usage [usage] -->
137
+ ## SDK Example Usage
138
+
139
+ ### Example
140
+
141
+ ```python
142
+ # Synchronous Example
143
+ from aerostack import SDK
144
+
145
+ with SDK(
146
+ api_key_auth="<YOUR_API_KEY_HERE>",
147
+ ) as sdk:
148
+
149
+ res = sdk.ai.ai_chat(request={
150
+ "messages": [
151
+ {},
152
+ ],
153
+ "model": "@cf/meta/llama-3-8b-instruct",
154
+ })
155
+
156
+ # Handle response
157
+ print(res)
158
+ ```
159
+
160
+ </br>
161
+
162
+ The same SDK client can also be used to make asynchronous requests by importing asyncio.
163
+
164
+ ```python
165
+ # Asynchronous Example
166
+ from aerostack import SDK
167
+ import asyncio
168
+
169
+ async def main():
170
+
171
+ async with SDK(
172
+ api_key_auth="<YOUR_API_KEY_HERE>",
173
+ ) as sdk:
174
+
175
+ res = await sdk.ai.ai_chat_async(request={
176
+ "messages": [
177
+ {},
178
+ ],
179
+ "model": "@cf/meta/llama-3-8b-instruct",
180
+ })
181
+
182
+ # Handle response
183
+ print(res)
184
+
185
+ asyncio.run(main())
186
+ ```
187
+ <!-- End SDK Example Usage [usage] -->
188
+
189
+ <!-- Start Authentication [security] -->
190
+ ## Authentication
191
+
192
+ ### Per-Client Security Schemes
193
+
194
+ This SDK supports the following security scheme globally:
195
+
196
+ | Name | Type | Scheme |
197
+ | -------------- | ------ | ------- |
198
+ | `api_key_auth` | apiKey | API key |
199
+
200
+ To authenticate with the API the `api_key_auth` parameter must be set when initializing the SDK client instance. For example:
201
+ ```python
202
+ from aerostack import SDK
203
+
204
+ with SDK(
205
+ api_key_auth="<YOUR_API_KEY_HERE>",
206
+ ) as sdk:
207
+
208
+ res = sdk.ai.ai_chat(request={
209
+ "messages": [
210
+ {},
211
+ ],
212
+ "model": "@cf/meta/llama-3-8b-instruct",
213
+ })
214
+
215
+ # Handle response
216
+ print(res)
217
+
218
+ ```
219
+ <!-- End Authentication [security] -->
220
+
221
+ <!-- Start Available Resources and Operations [operations] -->
222
+ ## Available Resources and Operations
223
+
224
+ <details open>
225
+ <summary>Available methods</summary>
226
+
227
+ ### [Ai](docs/sdks/ai/README.md)
228
+
229
+ * [ai_chat](docs/sdks/ai/README.md#ai_chat) - Generate AI chat completion
230
+
231
+ ### [Authentication](docs/sdks/authentication/README.md)
232
+
233
+ * [auth_signin](docs/sdks/authentication/README.md#auth_signin) - Sign in user
234
+ * [auth_signup](docs/sdks/authentication/README.md#auth_signup) - Sign up new user
235
+
236
+ ### [Cache](docs/sdks/cache/README.md)
237
+
238
+ * [cache_get](docs/sdks/cache/README.md#cache_get) - Get cached value
239
+ * [cache_set](docs/sdks/cache/README.md#cache_set) - Set cached value
240
+
241
+ ### [Database](docs/sdks/database/README.md)
242
+
243
+ * [db_query](docs/sdks/database/README.md#db_query) - Execute SQL query
244
+
245
+ ### [Queue](docs/sdks/queue/README.md)
246
+
247
+ * [queue_enqueue](docs/sdks/queue/README.md#queue_enqueue) - Add job to queue
248
+
249
+ ### [Services](docs/sdks/services/README.md)
250
+
251
+ * [services_invoke](docs/sdks/services/README.md#services_invoke) - Invoke another service
252
+
253
+ ### [Storage](docs/sdks/storage/README.md)
254
+
255
+ * [storage_upload](docs/sdks/storage/README.md#storage_upload) - Upload file to storage
256
+
257
+ </details>
258
+ <!-- End Available Resources and Operations [operations] -->
259
+
260
+ <!-- Start File uploads [file-upload] -->
261
+ ## File uploads
262
+
263
+ Certain SDK methods accept file objects as part of a request body or multi-part request. It is possible and typically recommended to upload files as a stream rather than reading the entire contents into memory. This avoids excessive memory consumption and potentially crashing with out-of-memory errors when working with very large files. The following example demonstrates how to attach a file stream to a request.
264
+
265
+ > [!TIP]
266
+ >
267
+ > For endpoints that handle file uploads bytes arrays can also be used. However, using streams is recommended for large files.
268
+ >
269
+
270
+ ```python
271
+ from aerostack import SDK
272
+
273
+ with SDK(
274
+ api_key_auth="<YOUR_API_KEY_HERE>",
275
+ ) as sdk:
276
+
277
+ res = sdk.storage.storage_upload(request={
278
+ "content_type": "image/jpeg",
279
+ "file": {
280
+ "content": open("example.file", "rb"),
281
+ "file_name": "example.file",
282
+ },
283
+ "key": "avatars/user-123.jpg",
284
+ })
285
+
286
+ # Handle response
287
+ print(res)
288
+
289
+ ```
290
+ <!-- End File uploads [file-upload] -->
291
+
292
+ <!-- Start Retries [retries] -->
293
+ ## Retries
294
+
295
+ 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.
296
+
297
+ To change the default retry strategy for a single API call, simply provide a `RetryConfig` object to the call:
298
+ ```python
299
+ from aerostack import SDK
300
+ from aerostack.utils import BackoffStrategy, RetryConfig
301
+
302
+ with SDK(
303
+ api_key_auth="<YOUR_API_KEY_HERE>",
304
+ ) as sdk:
305
+
306
+ res = sdk.ai.ai_chat(request={
307
+ "messages": [
308
+ {},
309
+ ],
310
+ "model": "@cf/meta/llama-3-8b-instruct",
311
+ },
312
+ RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False))
313
+
314
+ # Handle response
315
+ print(res)
316
+
317
+ ```
318
+
319
+ 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:
320
+ ```python
321
+ from aerostack import SDK
322
+ from aerostack.utils import BackoffStrategy, RetryConfig
323
+
324
+ with SDK(
325
+ retry_config=RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False),
326
+ api_key_auth="<YOUR_API_KEY_HERE>",
327
+ ) as sdk:
328
+
329
+ res = sdk.ai.ai_chat(request={
330
+ "messages": [
331
+ {},
332
+ ],
333
+ "model": "@cf/meta/llama-3-8b-instruct",
334
+ })
335
+
336
+ # Handle response
337
+ print(res)
338
+
339
+ ```
340
+ <!-- End Retries [retries] -->
341
+
342
+ <!-- Start Error Handling [errors] -->
343
+ ## Error Handling
344
+
345
+ [`SDKBaseError`](./src/aerostack/errors/sdkbaseerror.py) is the base class for all HTTP error responses. It has the following properties:
346
+
347
+ | Property | Type | Description |
348
+ | ------------------ | ---------------- | --------------------------------------------------------------------------------------- |
349
+ | `err.message` | `str` | Error message |
350
+ | `err.status_code` | `int` | HTTP response status code eg `404` |
351
+ | `err.headers` | `httpx.Headers` | HTTP response headers |
352
+ | `err.body` | `str` | HTTP body. Can be empty string if no body is returned. |
353
+ | `err.raw_response` | `httpx.Response` | Raw HTTP response |
354
+ | `err.data` | | Optional. Some errors may contain structured data. [See Error Classes](#error-classes). |
355
+
356
+ ### Example
357
+ ```python
358
+ from aerostack import SDK, errors
359
+
360
+ with SDK(
361
+ api_key_auth="<YOUR_API_KEY_HERE>",
362
+ ) as sdk:
363
+ res = None
364
+ try:
365
+
366
+ res = sdk.authentication.auth_signin(request={
367
+ "email": "Tina.Buckridge@yahoo.com",
368
+ "password": "nIQ75VVtUTq8bO4",
369
+ })
370
+
371
+ # Handle response
372
+ print(res)
373
+
374
+ except errors.SDKBaseError as e:
375
+ # The base class for HTTP error responses
376
+ print(e.message)
377
+ print(e.status_code)
378
+ print(e.body)
379
+ print(e.headers)
380
+ print(e.raw_response)
381
+
382
+ # Depending on the method different errors may be thrown
383
+ if isinstance(e, errors.ErrorResponse):
384
+ print(e.data.code) # errors.Code
385
+ print(e.data.details) # Optional[Dict[str, Any]]
386
+ print(e.data.message) # str
387
+ ```
388
+
389
+ ### Error Classes
390
+ **Primary error:**
391
+ * [`SDKBaseError`](./src/aerostack/errors/sdkbaseerror.py): The base class for HTTP error responses.
392
+
393
+ <details><summary>Less common errors (6)</summary>
394
+
395
+ <br />
396
+
397
+ **Network errors:**
398
+ * [`httpx.RequestError`](https://www.python-httpx.org/exceptions/#httpx.RequestError): Base class for request errors.
399
+ * [`httpx.ConnectError`](https://www.python-httpx.org/exceptions/#httpx.ConnectError): HTTP client was unable to make a request to a server.
400
+ * [`httpx.TimeoutException`](https://www.python-httpx.org/exceptions/#httpx.TimeoutException): HTTP request timed out.
401
+
402
+ **Inherit from [`SDKBaseError`](./src/aerostack/errors/sdkbaseerror.py)**:
403
+ * [`ErrorResponse`](./src/aerostack/errors/errorresponse.py): Applicable to 3 of 9 methods.*
404
+ * [`ResponseValidationError`](./src/aerostack/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.
405
+
406
+ </details>
407
+
408
+ \* Check [the method documentation](#available-resources-and-operations) to see if the error is applicable.
409
+ <!-- End Error Handling [errors] -->
410
+
411
+ <!-- Start Server Selection [server] -->
412
+ ## Server Selection
413
+
414
+ ### Select Server by Index
415
+
416
+ You can override the default server globally by passing a server index to the `server_idx: int` optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:
417
+
418
+ | # | Server | Description |
419
+ | --- | ----------------------------- | ----------------- |
420
+ | 0 | `https://api.aerostack.ai/v1` | Production |
421
+ | 1 | `http://localhost:8787/v1` | Local Development |
422
+
423
+ #### Example
424
+
425
+ ```python
426
+ from aerostack import SDK
427
+
428
+ with SDK(
429
+ server_idx=0,
430
+ api_key_auth="<YOUR_API_KEY_HERE>",
431
+ ) as sdk:
432
+
433
+ res = sdk.ai.ai_chat(request={
434
+ "messages": [
435
+ {},
436
+ ],
437
+ "model": "@cf/meta/llama-3-8b-instruct",
438
+ })
439
+
440
+ # Handle response
441
+ print(res)
442
+
443
+ ```
444
+
445
+ ### Override Server URL Per-Client
446
+
447
+ The default server can also be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example:
448
+ ```python
449
+ from aerostack import SDK
450
+
451
+ with SDK(
452
+ server_url="http://localhost:8787/v1",
453
+ api_key_auth="<YOUR_API_KEY_HERE>",
454
+ ) as sdk:
455
+
456
+ res = sdk.ai.ai_chat(request={
457
+ "messages": [
458
+ {},
459
+ ],
460
+ "model": "@cf/meta/llama-3-8b-instruct",
461
+ })
462
+
463
+ # Handle response
464
+ print(res)
465
+
466
+ ```
467
+ <!-- End Server Selection [server] -->
468
+
469
+ <!-- Start Custom HTTP Client [http-client] -->
470
+ ## Custom HTTP Client
471
+
472
+ 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.
473
+ 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.
474
+ 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.
475
+
476
+ For example, you could specify a header for every request that this sdk makes as follows:
477
+ ```python
478
+ from aerostack import SDK
479
+ import httpx
480
+
481
+ http_client = httpx.Client(headers={"x-custom-header": "someValue"})
482
+ s = SDK(client=http_client)
483
+ ```
484
+
485
+ or you could wrap the client with your own custom logic:
486
+ ```python
487
+ from aerostack import SDK
488
+ from aerostack.httpclient import AsyncHttpClient
489
+ import httpx
490
+
491
+ class CustomClient(AsyncHttpClient):
492
+ client: AsyncHttpClient
493
+
494
+ def __init__(self, client: AsyncHttpClient):
495
+ self.client = client
496
+
497
+ async def send(
498
+ self,
499
+ request: httpx.Request,
500
+ *,
501
+ stream: bool = False,
502
+ auth: Union[
503
+ httpx._types.AuthTypes, httpx._client.UseClientDefault, None
504
+ ] = httpx.USE_CLIENT_DEFAULT,
505
+ follow_redirects: Union[
506
+ bool, httpx._client.UseClientDefault
507
+ ] = httpx.USE_CLIENT_DEFAULT,
508
+ ) -> httpx.Response:
509
+ request.headers["Client-Level-Header"] = "added by client"
510
+
511
+ return await self.client.send(
512
+ request, stream=stream, auth=auth, follow_redirects=follow_redirects
513
+ )
514
+
515
+ def build_request(
516
+ self,
517
+ method: str,
518
+ url: httpx._types.URLTypes,
519
+ *,
520
+ content: Optional[httpx._types.RequestContent] = None,
521
+ data: Optional[httpx._types.RequestData] = None,
522
+ files: Optional[httpx._types.RequestFiles] = None,
523
+ json: Optional[Any] = None,
524
+ params: Optional[httpx._types.QueryParamTypes] = None,
525
+ headers: Optional[httpx._types.HeaderTypes] = None,
526
+ cookies: Optional[httpx._types.CookieTypes] = None,
527
+ timeout: Union[
528
+ httpx._types.TimeoutTypes, httpx._client.UseClientDefault
529
+ ] = httpx.USE_CLIENT_DEFAULT,
530
+ extensions: Optional[httpx._types.RequestExtensions] = None,
531
+ ) -> httpx.Request:
532
+ return self.client.build_request(
533
+ method,
534
+ url,
535
+ content=content,
536
+ data=data,
537
+ files=files,
538
+ json=json,
539
+ params=params,
540
+ headers=headers,
541
+ cookies=cookies,
542
+ timeout=timeout,
543
+ extensions=extensions,
544
+ )
545
+
546
+ s = SDK(async_client=CustomClient(httpx.AsyncClient()))
547
+ ```
548
+ <!-- End Custom HTTP Client [http-client] -->
549
+
550
+ <!-- Start Resource Management [resource-management] -->
551
+ ## Resource Management
552
+
553
+ 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.
554
+
555
+ [context-manager]: https://docs.python.org/3/reference/datamodel.html#context-managers
556
+
557
+ ```python
558
+ from aerostack import SDK
559
+ def main():
560
+
561
+ with SDK(
562
+ api_key_auth="<YOUR_API_KEY_HERE>",
563
+ ) as sdk:
564
+ # Rest of application here...
565
+
566
+ # Or when using async:
567
+ async def amain():
568
+
569
+ async with SDK(
570
+ api_key_auth="<YOUR_API_KEY_HERE>",
571
+ ) as sdk:
572
+ # Rest of application here...
573
+ ```
574
+ <!-- End Resource Management [resource-management] -->
575
+
576
+ <!-- Start Debugging [debug] -->
577
+ ## Debugging
578
+
579
+ You can setup your SDK to emit debug logs for SDK requests and responses.
580
+
581
+ You can pass your own logger class directly into your SDK.
582
+ ```python
583
+ from aerostack import SDK
584
+ import logging
585
+
586
+ logging.basicConfig(level=logging.DEBUG)
587
+ s = SDK(debug_logger=logging.getLogger("aerostack"))
588
+ ```
589
+ <!-- End Debugging [debug] -->
590
+
591
+ # Development
592
+
593
+ ## Maturity
594
+
595
+ This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage
596
+ to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally
597
+ looking for the latest version.
598
+
599
+ ## Contributions
600
+
601
+ 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.
602
+ 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.
603
+
604
+