flypix 1.1.5__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.
- flypix-1.1.5/LICENSE +21 -0
- flypix-1.1.5/PKG-INFO +587 -0
- flypix-1.1.5/README-PYPI.md +572 -0
- flypix-1.1.5/README.md +572 -0
- flypix-1.1.5/pyproject.toml +54 -0
- flypix-1.1.5/setup.cfg +4 -0
- flypix-1.1.5/src/flypix/__init__.py +17 -0
- flypix-1.1.5/src/flypix/_hooks/__init__.py +4 -0
- flypix-1.1.5/src/flypix/_hooks/sdkhooks.py +74 -0
- flypix-1.1.5/src/flypix/_hooks/types.py +124 -0
- flypix-1.1.5/src/flypix/_version.py +15 -0
- flypix-1.1.5/src/flypix/auth.py +382 -0
- flypix-1.1.5/src/flypix/basesdk.py +392 -0
- flypix-1.1.5/src/flypix/errors/__init__.py +34 -0
- flypix-1.1.5/src/flypix/errors/flypixdefaulterror.py +40 -0
- flypix-1.1.5/src/flypix/errors/flypixerror.py +30 -0
- flypix-1.1.5/src/flypix/errors/no_response_error.py +17 -0
- flypix-1.1.5/src/flypix/errors/responsevalidationerror.py +27 -0
- flypix-1.1.5/src/flypix/files.py +2140 -0
- flypix-1.1.5/src/flypix/folders.py +752 -0
- flypix-1.1.5/src/flypix/geosense.py +790 -0
- flypix-1.1.5/src/flypix/httpclient.py +125 -0
- flypix-1.1.5/src/flypix/inferences.py +540 -0
- flypix-1.1.5/src/flypix/models/__init__.py +677 -0
- flypix-1.1.5/src/flypix/models/annotationgeometrypayload.py +18 -0
- flypix-1.1.5/src/flypix/models/anymessagecontext.py +28 -0
- flypix-1.1.5/src/flypix/models/applymodelrequest.py +15 -0
- flypix-1.1.5/src/flypix/models/applymodelresponse.py +49 -0
- flypix-1.1.5/src/flypix/models/artifactresponse.py +42 -0
- flypix-1.1.5/src/flypix/models/artifacttype.py +7 -0
- flypix-1.1.5/src/flypix/models/balanceresponse.py +18 -0
- flypix-1.1.5/src/flypix/models/body_upload_geojson_vectors_vector_id_upload_geojson_post.py +14 -0
- flypix-1.1.5/src/flypix/models/body_upload_geopkg.py +14 -0
- flypix-1.1.5/src/flypix/models/body_upload_shapefile.py +14 -0
- flypix-1.1.5/src/flypix/models/chatmessageresponse.py +53 -0
- flypix-1.1.5/src/flypix/models/classresponse.py +21 -0
- flypix-1.1.5/src/flypix/models/cogsource.py +49 -0
- flypix-1.1.5/src/flypix/models/createannotationsrequest.py +23 -0
- flypix-1.1.5/src/flypix/models/createartifactrequest.py +18 -0
- flypix-1.1.5/src/flypix/models/createclassrequest.py +38 -0
- flypix-1.1.5/src/flypix/models/createmanyregionsrequest.py +15 -0
- flypix-1.1.5/src/flypix/models/createregionpayload.py +27 -0
- flypix-1.1.5/src/flypix/models/createvectorforvisiblefile.py +38 -0
- flypix-1.1.5/src/flypix/models/datacontext.py +31 -0
- flypix-1.1.5/src/flypix/models/entitydeletionresponse.py +19 -0
- flypix-1.1.5/src/flypix/models/estimatemodelresponse.py +16 -0
- flypix-1.1.5/src/flypix/models/filelinkresponse.py +13 -0
- flypix-1.1.5/src/flypix/models/fileresponse.py +79 -0
- flypix-1.1.5/src/flypix/models/files_deleteop.py +16 -0
- flypix-1.1.5/src/flypix/models/files_get_download_linkop.py +16 -0
- flypix-1.1.5/src/flypix/models/files_get_storage_usageop.py +16 -0
- flypix-1.1.5/src/flypix/models/files_get_visible_rasterop.py +16 -0
- flypix-1.1.5/src/flypix/models/files_getop.py +16 -0
- flypix-1.1.5/src/flypix/models/files_list_for_folderop.py +16 -0
- flypix-1.1.5/src/flypix/models/files_list_for_projectop.py +16 -0
- flypix-1.1.5/src/flypix/models/files_upload_from_urlop.py +63 -0
- flypix-1.1.5/src/flypix/models/files_upload_v2op.py +63 -0
- flypix-1.1.5/src/flypix/models/files_uploadop.py +63 -0
- flypix-1.1.5/src/flypix/models/filestatus.py +16 -0
- flypix-1.1.5/src/flypix/models/filetype.py +17 -0
- flypix-1.1.5/src/flypix/models/foldercreationrequest.py +41 -0
- flypix-1.1.5/src/flypix/models/folderresponse.py +36 -0
- flypix-1.1.5/src/flypix/models/folders_deleteop.py +16 -0
- flypix-1.1.5/src/flypix/models/folders_list_for_folderop.py +16 -0
- flypix-1.1.5/src/flypix/models/folders_list_for_projectop.py +16 -0
- flypix-1.1.5/src/flypix/models/geosense_create_artifactop.py +23 -0
- flypix-1.1.5/src/flypix/models/geosense_create_sessionop.py +16 -0
- flypix-1.1.5/src/flypix/models/geosense_get_artifactop.py +21 -0
- flypix-1.1.5/src/flypix/models/geosense_send_messageop.py +23 -0
- flypix-1.1.5/src/flypix/models/inferenceresponse.py +51 -0
- flypix-1.1.5/src/flypix/models/inferences_list_for_fileop.py +16 -0
- flypix-1.1.5/src/flypix/models/inferences_list_for_projectop.py +16 -0
- flypix-1.1.5/src/flypix/models/inferences_list_for_tenantop.py +16 -0
- flypix-1.1.5/src/flypix/models/inferencestatus.py +17 -0
- flypix-1.1.5/src/flypix/models/loginrequest.py +16 -0
- flypix-1.1.5/src/flypix/models/loginresponse.py +48 -0
- flypix-1.1.5/src/flypix/models/models_applyop.py +23 -0
- flypix-1.1.5/src/flypix/models/models_deleteop.py +16 -0
- flypix-1.1.5/src/flypix/models/models_estimate_applicationop.py +23 -0
- flypix-1.1.5/src/flypix/models/models_get_inference_statusop.py +16 -0
- flypix-1.1.5/src/flypix/models/models_list_for_projectop.py +16 -0
- flypix-1.1.5/src/flypix/models/models_list_for_tenantop.py +16 -0
- flypix-1.1.5/src/flypix/models/modelstatus.py +15 -0
- flypix-1.1.5/src/flypix/models/officialmodelresponse.py +45 -0
- flypix-1.1.5/src/flypix/models/payments_get_balanceop.py +16 -0
- flypix-1.1.5/src/flypix/models/privatemodelresponse.py +58 -0
- flypix-1.1.5/src/flypix/models/projectcreationrequest.py +18 -0
- flypix-1.1.5/src/flypix/models/projectresponse.py +27 -0
- flypix-1.1.5/src/flypix/models/projects_deleteop.py +16 -0
- flypix-1.1.5/src/flypix/models/projects_list_for_tenantop.py +16 -0
- flypix-1.1.5/src/flypix/models/rasterresponse.py +69 -0
- flypix-1.1.5/src/flypix/models/rasters_list_for_fileop.py +16 -0
- flypix-1.1.5/src/flypix/models/rasters_list_for_projectop.py +16 -0
- flypix-1.1.5/src/flypix/models/rasters_list_for_tenantop.py +16 -0
- flypix-1.1.5/src/flypix/models/rastersource.py +17 -0
- flypix-1.1.5/src/flypix/models/rasterstatus.py +16 -0
- flypix-1.1.5/src/flypix/models/reason.py +21 -0
- flypix-1.1.5/src/flypix/models/refreshrequest.py +13 -0
- flypix-1.1.5/src/flypix/models/regioninferencebehavior.py +14 -0
- flypix-1.1.5/src/flypix/models/regionmetadata.py +47 -0
- flypix-1.1.5/src/flypix/models/regionresponse.py +47 -0
- flypix-1.1.5/src/flypix/models/regions_createop.py +26 -0
- flypix-1.1.5/src/flypix/models/regions_list_for_fileop.py +16 -0
- flypix-1.1.5/src/flypix/models/regiontrainingbehavior.py +16 -0
- flypix-1.1.5/src/flypix/models/responsestatus.py +16 -0
- flypix-1.1.5/src/flypix/models/security.py +42 -0
- flypix-1.1.5/src/flypix/models/sendmessagerequest.py +49 -0
- flypix-1.1.5/src/flypix/models/tenantresponse.py +18 -0
- flypix-1.1.5/src/flypix/models/transaction.py +56 -0
- flypix-1.1.5/src/flypix/models/transactiontype.py +15 -0
- flypix-1.1.5/src/flypix/models/uploadannotationsresponse.py +23 -0
- flypix-1.1.5/src/flypix/models/uploadfileresponsestatus.py +19 -0
- flypix-1.1.5/src/flypix/models/uploadsource.py +60 -0
- flypix-1.1.5/src/flypix/models/usageresponse.py +28 -0
- flypix-1.1.5/src/flypix/models/vectorcreationsource.py +14 -0
- flypix-1.1.5/src/flypix/models/vectorfeatures.py +36 -0
- flypix-1.1.5/src/flypix/models/vectorfeaturesdict.py +26 -0
- flypix-1.1.5/src/flypix/models/vectormetadata.py +14 -0
- flypix-1.1.5/src/flypix/models/vectorresponse.py +32 -0
- flypix-1.1.5/src/flypix/models/vectors_create_annotationsop.py +26 -0
- flypix-1.1.5/src/flypix/models/vectors_create_classop.py +23 -0
- flypix-1.1.5/src/flypix/models/vectors_deleteop.py +16 -0
- flypix-1.1.5/src/flypix/models/vectors_get_featuresop.py +16 -0
- flypix-1.1.5/src/flypix/models/vectors_list_classes_for_projectop.py +16 -0
- flypix-1.1.5/src/flypix/models/vectors_list_for_fileop.py +16 -0
- flypix-1.1.5/src/flypix/models/vectors_upload_geojsonop.py +26 -0
- flypix-1.1.5/src/flypix/models/vectors_upload_gpkgop.py +23 -0
- flypix-1.1.5/src/flypix/models/vectors_upload_shapefileop.py +23 -0
- flypix-1.1.5/src/flypix/models/wmtssource.py +49 -0
- flypix-1.1.5/src/flypix/models_.py +1266 -0
- flypix-1.1.5/src/flypix/payments.py +188 -0
- flypix-1.1.5/src/flypix/projects.py +556 -0
- flypix-1.1.5/src/flypix/py.typed +1 -0
- flypix-1.1.5/src/flypix/rasters.py +540 -0
- flypix-1.1.5/src/flypix/regions.py +598 -0
- flypix-1.1.5/src/flypix/sdk.py +246 -0
- flypix-1.1.5/src/flypix/sdkconfiguration.py +49 -0
- flypix-1.1.5/src/flypix/types/__init__.py +24 -0
- flypix-1.1.5/src/flypix/types/base64fileinput.py +43 -0
- flypix-1.1.5/src/flypix/types/basemodel.py +77 -0
- flypix-1.1.5/src/flypix/users.py +174 -0
- flypix-1.1.5/src/flypix/utils/__init__.py +180 -0
- flypix-1.1.5/src/flypix/utils/annotations.py +79 -0
- flypix-1.1.5/src/flypix/utils/datetimes.py +37 -0
- flypix-1.1.5/src/flypix/utils/dynamic_imports.py +54 -0
- flypix-1.1.5/src/flypix/utils/enums.py +134 -0
- flypix-1.1.5/src/flypix/utils/eventstreaming.py +326 -0
- flypix-1.1.5/src/flypix/utils/forms.py +239 -0
- flypix-1.1.5/src/flypix/utils/headers.py +136 -0
- flypix-1.1.5/src/flypix/utils/logger.py +22 -0
- flypix-1.1.5/src/flypix/utils/metadata.py +119 -0
- flypix-1.1.5/src/flypix/utils/queryparams.py +217 -0
- flypix-1.1.5/src/flypix/utils/requestbodies.py +67 -0
- flypix-1.1.5/src/flypix/utils/retries.py +356 -0
- flypix-1.1.5/src/flypix/utils/security.py +198 -0
- flypix-1.1.5/src/flypix/utils/serializers.py +306 -0
- flypix-1.1.5/src/flypix/utils/unions.py +41 -0
- flypix-1.1.5/src/flypix/utils/unmarshal_json_response.py +38 -0
- flypix-1.1.5/src/flypix/utils/url.py +155 -0
- flypix-1.1.5/src/flypix/utils/values.py +137 -0
- flypix-1.1.5/src/flypix/vectors.py +1912 -0
- flypix-1.1.5/src/flypix.egg-info/PKG-INFO +587 -0
- flypix-1.1.5/src/flypix.egg-info/SOURCES.txt +164 -0
- flypix-1.1.5/src/flypix.egg-info/dependency_links.txt +1 -0
- flypix-1.1.5/src/flypix.egg-info/requires.txt +3 -0
- flypix-1.1.5/src/flypix.egg-info/top_level.txt +1 -0
flypix-1.1.5/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 FlyPix AI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
flypix-1.1.5/PKG-INFO
ADDED
|
@@ -0,0 +1,587 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: flypix
|
|
3
|
+
Version: 1.1.5
|
|
4
|
+
Summary: Python Client SDK Generated by Speakeasy.
|
|
5
|
+
Author: FlyPix AI
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: repository, https://github.com/flypix-ai/flypix-sdk.git
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: httpcore>=1.0.9
|
|
12
|
+
Requires-Dist: httpx>=0.28.1
|
|
13
|
+
Requires-Dist: pydantic<2.13,>=2.11.2
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
# flypix
|
|
17
|
+
|
|
18
|
+
The official Python SDK for the [FlyPix](https://flypix.ai) API — programmatic
|
|
19
|
+
access to projects, files, models, inferences, vectors, and more.
|
|
20
|
+
|
|
21
|
+
> **Status:** pre-release. The SDK is generated from the FlyPix OpenAPI spec with
|
|
22
|
+
> [Speakeasy](https://www.speakeasy.com). See [`SETUP.md`](https://github.com/flypix-ai/flypix-sdk/blob/master/./SETUP.md) for how it
|
|
23
|
+
> is generated and maintained. Installation and usage are documented in the
|
|
24
|
+
> generated sections below.
|
|
25
|
+
|
|
26
|
+
## Contributing
|
|
27
|
+
|
|
28
|
+
This SDK is generated — the code under `src/flypix/` is **not** hand-edited.
|
|
29
|
+
Improvements to naming and ergonomics happen in `openapi/overlay.yaml`; see
|
|
30
|
+
[`SETUP.md`](https://github.com/flypix-ai/flypix-sdk/blob/master/./SETUP.md).
|
|
31
|
+
|
|
32
|
+
## License
|
|
33
|
+
|
|
34
|
+
See [LICENSE](https://github.com/flypix-ai/flypix-sdk/blob/master/./LICENSE).
|
|
35
|
+
|
|
36
|
+
<!-- Start Summary [summary] -->
|
|
37
|
+
## Summary
|
|
38
|
+
|
|
39
|
+
Public API:
|
|
40
|
+
Public OpenAPI Schema
|
|
41
|
+
|
|
42
|
+
This API lets you interact directly with the application with HTTP requests.
|
|
43
|
+
|
|
44
|
+
You will need to set a valid authorization header for every request:
|
|
45
|
+
|
|
46
|
+
`Authorization: Bearer <token>`
|
|
47
|
+
|
|
48
|
+
Example use case: Find an existing file and its vector features:
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
POST /auth/login/password -> Fetch token and use it in subsequent requests
|
|
52
|
+
GET /users/tenant/for-user/ -> Get your tenant id for subsequent requests
|
|
53
|
+
GET /projects/for-tenant/{tenant_id} -> Find your project
|
|
54
|
+
GET /files/for-project/{project_id} -> Find your file
|
|
55
|
+
GET /files/{file_id}/visible -> Get a download link for the visible raster
|
|
56
|
+
GET /vectors/for-file/{file_id} -> Get the vector ids for the file
|
|
57
|
+
GET /vectors/{vector_id}/features -> Get the annotations
|
|
58
|
+
```
|
|
59
|
+
<!-- End Summary [summary] -->
|
|
60
|
+
|
|
61
|
+
<!-- Start Table of Contents [toc] -->
|
|
62
|
+
## Table of Contents
|
|
63
|
+
<!-- $toc-max-depth=2 -->
|
|
64
|
+
* [flypix](https://github.com/flypix-ai/flypix-sdk/blob/master/#flypix)
|
|
65
|
+
* [Contributing](https://github.com/flypix-ai/flypix-sdk/blob/master/#contributing)
|
|
66
|
+
* [License](https://github.com/flypix-ai/flypix-sdk/blob/master/#license)
|
|
67
|
+
* [SDK Installation](https://github.com/flypix-ai/flypix-sdk/blob/master/#sdk-installation)
|
|
68
|
+
* [IDE Support](https://github.com/flypix-ai/flypix-sdk/blob/master/#ide-support)
|
|
69
|
+
* [SDK Example Usage](https://github.com/flypix-ai/flypix-sdk/blob/master/#sdk-example-usage)
|
|
70
|
+
* [Authentication](https://github.com/flypix-ai/flypix-sdk/blob/master/#authentication)
|
|
71
|
+
* [Available Resources and Operations](https://github.com/flypix-ai/flypix-sdk/blob/master/#available-resources-and-operations)
|
|
72
|
+
* [File uploads](https://github.com/flypix-ai/flypix-sdk/blob/master/#file-uploads)
|
|
73
|
+
* [Retries](https://github.com/flypix-ai/flypix-sdk/blob/master/#retries)
|
|
74
|
+
* [Error Handling](https://github.com/flypix-ai/flypix-sdk/blob/master/#error-handling)
|
|
75
|
+
* [Server Selection](https://github.com/flypix-ai/flypix-sdk/blob/master/#server-selection)
|
|
76
|
+
* [Custom HTTP Client](https://github.com/flypix-ai/flypix-sdk/blob/master/#custom-http-client)
|
|
77
|
+
* [Resource Management](https://github.com/flypix-ai/flypix-sdk/blob/master/#resource-management)
|
|
78
|
+
* [Debugging](https://github.com/flypix-ai/flypix-sdk/blob/master/#debugging)
|
|
79
|
+
|
|
80
|
+
<!-- End Table of Contents [toc] -->
|
|
81
|
+
|
|
82
|
+
<!-- Start SDK Installation [installation] -->
|
|
83
|
+
## SDK Installation
|
|
84
|
+
|
|
85
|
+
> [!NOTE]
|
|
86
|
+
> **Python version upgrade policy**
|
|
87
|
+
>
|
|
88
|
+
> 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.
|
|
89
|
+
|
|
90
|
+
The SDK can be installed with *uv*, *pip*, or *poetry* package managers.
|
|
91
|
+
|
|
92
|
+
### uv
|
|
93
|
+
|
|
94
|
+
*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.
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
uv add flypix
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### PIP
|
|
101
|
+
|
|
102
|
+
*PIP* is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line.
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
pip install flypix
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Poetry
|
|
109
|
+
|
|
110
|
+
*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.
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
poetry add flypix
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Shell and script usage with `uv`
|
|
117
|
+
|
|
118
|
+
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:
|
|
119
|
+
|
|
120
|
+
```shell
|
|
121
|
+
uvx --from flypix python
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
It's also possible to write a standalone Python script without needing to set up a whole project like so:
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
#!/usr/bin/env -S uv run --script
|
|
128
|
+
# /// script
|
|
129
|
+
# requires-python = ">=3.10"
|
|
130
|
+
# dependencies = [
|
|
131
|
+
# "flypix",
|
|
132
|
+
# ]
|
|
133
|
+
# ///
|
|
134
|
+
|
|
135
|
+
from flypix import FlyPix
|
|
136
|
+
|
|
137
|
+
sdk = FlyPix(
|
|
138
|
+
# SDK arguments
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
# Rest of script here...
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Once that is saved to a file, you can run it with `uv run script.py` where
|
|
145
|
+
`script.py` can be replaced with the actual file name.
|
|
146
|
+
<!-- End SDK Installation [installation] -->
|
|
147
|
+
|
|
148
|
+
<!-- Start IDE Support [idesupport] -->
|
|
149
|
+
## IDE Support
|
|
150
|
+
|
|
151
|
+
### PyCharm
|
|
152
|
+
|
|
153
|
+
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.
|
|
154
|
+
|
|
155
|
+
- [PyCharm Pydantic Plugin](https://docs.pydantic.dev/latest/integrations/pycharm/)
|
|
156
|
+
<!-- End IDE Support [idesupport] -->
|
|
157
|
+
|
|
158
|
+
<!-- Start SDK Example Usage [usage] -->
|
|
159
|
+
## SDK Example Usage
|
|
160
|
+
|
|
161
|
+
### Example
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
# Synchronous Example
|
|
165
|
+
from flypix import FlyPix
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
with FlyPix() as fly_pix:
|
|
169
|
+
|
|
170
|
+
res = fly_pix.auth.login_with_password(username="Allie.Hartmann", password="9ne8TpFJLsebftr")
|
|
171
|
+
|
|
172
|
+
# Handle response
|
|
173
|
+
print(res)
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
</br>
|
|
177
|
+
|
|
178
|
+
The same SDK client can also be used to make asynchronous requests by importing asyncio.
|
|
179
|
+
|
|
180
|
+
```python
|
|
181
|
+
# Asynchronous Example
|
|
182
|
+
import asyncio
|
|
183
|
+
from flypix import FlyPix
|
|
184
|
+
|
|
185
|
+
async def main():
|
|
186
|
+
|
|
187
|
+
async with FlyPix() as fly_pix:
|
|
188
|
+
|
|
189
|
+
res = await fly_pix.auth.login_with_password_async(username="Allie.Hartmann", password="9ne8TpFJLsebftr")
|
|
190
|
+
|
|
191
|
+
# Handle response
|
|
192
|
+
print(res)
|
|
193
|
+
|
|
194
|
+
asyncio.run(main())
|
|
195
|
+
```
|
|
196
|
+
<!-- End SDK Example Usage [usage] -->
|
|
197
|
+
|
|
198
|
+
<!-- Start Authentication [security] -->
|
|
199
|
+
## Authentication
|
|
200
|
+
|
|
201
|
+
### Per-Client Security Schemes
|
|
202
|
+
|
|
203
|
+
This SDK supports the following security scheme globally:
|
|
204
|
+
|
|
205
|
+
| Name | Type | Scheme |
|
|
206
|
+
| ------------- | ---- | ----------- |
|
|
207
|
+
| `bearer_auth` | http | HTTP Bearer |
|
|
208
|
+
|
|
209
|
+
To authenticate with the API the `bearer_auth` parameter must be set when initializing the SDK client instance. For example:
|
|
210
|
+
```python
|
|
211
|
+
from flypix import FlyPix
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
with FlyPix(
|
|
215
|
+
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
|
|
216
|
+
) as fly_pix:
|
|
217
|
+
|
|
218
|
+
res = fly_pix.auth.login_with_password(username="Allie.Hartmann", password="9ne8TpFJLsebftr")
|
|
219
|
+
|
|
220
|
+
# Handle response
|
|
221
|
+
print(res)
|
|
222
|
+
|
|
223
|
+
```
|
|
224
|
+
<!-- End Authentication [security] -->
|
|
225
|
+
|
|
226
|
+
<!-- Start Available Resources and Operations [operations] -->
|
|
227
|
+
## Available Resources and Operations
|
|
228
|
+
|
|
229
|
+
<details open>
|
|
230
|
+
<summary>Available methods</summary>
|
|
231
|
+
|
|
232
|
+
### [Auth](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/auth/README.md)
|
|
233
|
+
|
|
234
|
+
* [login_with_password](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/auth/README.md#login_with_password) - Login With Password
|
|
235
|
+
* [refresh_token](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/auth/README.md#refresh_token) - Refresh Token
|
|
236
|
+
|
|
237
|
+
### [Files](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/files/README.md)
|
|
238
|
+
|
|
239
|
+
* [list_for_project](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/files/README.md#list_for_project) - Get Files For Project Root
|
|
240
|
+
* [list_for_folder](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/files/README.md#list_for_folder) - Get For Folder
|
|
241
|
+
* [get](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/files/README.md#get) - Get File
|
|
242
|
+
* [delete](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/files/README.md#delete) - Delete File
|
|
243
|
+
* [get_visible_raster](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/files/README.md#get_visible_raster) - Get Visible Raster Of File
|
|
244
|
+
* [get_download_link](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/files/README.md#get_download_link) - Get File Download Link
|
|
245
|
+
* [get_by_ids](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/files/README.md#get_by_ids) - Get Files By Ids
|
|
246
|
+
* [get_storage_usage](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/files/README.md#get_storage_usage) - Get Storage Usage
|
|
247
|
+
* [~~upload~~](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/files/README.md#upload) - Upload File :warning: **Deprecated**
|
|
248
|
+
* [upload_v2](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/files/README.md#upload_v2) - Upload File
|
|
249
|
+
* [upload_from_url](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/files/README.md#upload_from_url) - Upload File From Url
|
|
250
|
+
|
|
251
|
+
### [Folders](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/folders/README.md)
|
|
252
|
+
|
|
253
|
+
* [list_for_folder](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/folders/README.md#list_for_folder) - Get Folders For Folder
|
|
254
|
+
* [list_for_project](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/folders/README.md#list_for_project) - Get Folders In Project Root
|
|
255
|
+
* [delete](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/folders/README.md#delete) - Delete Folder
|
|
256
|
+
* [create](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/folders/README.md#create) - Create Folder
|
|
257
|
+
|
|
258
|
+
### [Geosense](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/geosense/README.md)
|
|
259
|
+
|
|
260
|
+
* [create_session](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/geosense/README.md#create_session) - Create Session In Project
|
|
261
|
+
* [create_artifact](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/geosense/README.md#create_artifact) - Create Session Artifact
|
|
262
|
+
* [get_artifact](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/geosense/README.md#get_artifact) - Get Session Artifact
|
|
263
|
+
* [send_message](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/geosense/README.md#send_message) - Send Message
|
|
264
|
+
|
|
265
|
+
### [Inferences](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/inferences/README.md)
|
|
266
|
+
|
|
267
|
+
* [list_for_tenant](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/inferences/README.md#list_for_tenant) - Get Inferences For Tenant
|
|
268
|
+
* [list_for_project](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/inferences/README.md#list_for_project) - Get Inferences For Project
|
|
269
|
+
* [list_for_file](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/inferences/README.md#list_for_file) - Get Inferences For File
|
|
270
|
+
|
|
271
|
+
### [Models](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/models/README.md)
|
|
272
|
+
|
|
273
|
+
* [list_for_tenant](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/models/README.md#list_for_tenant) - Get Models For Tenant
|
|
274
|
+
* [list_for_project](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/models/README.md#list_for_project) - Get Models For Project
|
|
275
|
+
* [list_official](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/models/README.md#list_official) - Get Official Models
|
|
276
|
+
* [apply](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/models/README.md#apply) - Apply Model On File
|
|
277
|
+
* [estimate_application](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/models/README.md#estimate_application) - Estimate Model Application On File
|
|
278
|
+
* [get_inference_status](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/models/README.md#get_inference_status) - Get Inference Status
|
|
279
|
+
* [delete](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/models/README.md#delete) - Delete Model
|
|
280
|
+
|
|
281
|
+
### [Payments](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/payments/README.md)
|
|
282
|
+
|
|
283
|
+
* [get_balance](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/payments/README.md#get_balance) - Get Tenant Balance
|
|
284
|
+
|
|
285
|
+
### [Projects](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/projects/README.md)
|
|
286
|
+
|
|
287
|
+
* [list_for_tenant](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/projects/README.md#list_for_tenant) - Get Projects For Tenant
|
|
288
|
+
* [delete](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/projects/README.md#delete) - Delete Project
|
|
289
|
+
* [create](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/projects/README.md#create) - Create Project
|
|
290
|
+
|
|
291
|
+
### [Rasters](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/rasters/README.md)
|
|
292
|
+
|
|
293
|
+
* [list_for_tenant](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/rasters/README.md#list_for_tenant) - Get Rasters For Tenant
|
|
294
|
+
* [list_for_project](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/rasters/README.md#list_for_project) - Get Rasters For Project
|
|
295
|
+
* [list_for_file](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/rasters/README.md#list_for_file) - Get Rasters For File
|
|
296
|
+
|
|
297
|
+
### [Regions](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/regions/README.md)
|
|
298
|
+
|
|
299
|
+
* [list_for_file](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/regions/README.md#list_for_file) - Get Regions For File
|
|
300
|
+
* [create](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/regions/README.md#create) - Create Regions In File
|
|
301
|
+
* [delete](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/regions/README.md#delete) - Delete Regions
|
|
302
|
+
|
|
303
|
+
### [Users](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/users/README.md)
|
|
304
|
+
|
|
305
|
+
* [list_tenants](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/users/README.md#list_tenants) - Get Tenants For User
|
|
306
|
+
|
|
307
|
+
### [Vectors](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/vectors/README.md)
|
|
308
|
+
|
|
309
|
+
* [list_for_file](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/vectors/README.md#list_for_file) - Get Vectors For File
|
|
310
|
+
* [list_classes_for_project](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/vectors/README.md#list_classes_for_project) - Get Project Classes
|
|
311
|
+
* [create_class](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/vectors/README.md#create_class) - Create Class In Project
|
|
312
|
+
* [get_features](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/vectors/README.md#get_features) - Get Vector Features
|
|
313
|
+
* [create](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/vectors/README.md#create) - Create Empty Vector
|
|
314
|
+
* [delete](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/vectors/README.md#delete) - Delete Vector
|
|
315
|
+
* [create_annotations](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/vectors/README.md#create_annotations) - Create Annotations In Vector
|
|
316
|
+
* [upload_geojson](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/vectors/README.md#upload_geojson) - Upload Geojson
|
|
317
|
+
* [upload_gpkg](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/vectors/README.md#upload_gpkg) - Upload Gpkg
|
|
318
|
+
* [upload_shapefile](https://github.com/flypix-ai/flypix-sdk/blob/master/docs/sdks/vectors/README.md#upload_shapefile) - Upload Shp
|
|
319
|
+
|
|
320
|
+
</details>
|
|
321
|
+
<!-- End Available Resources and Operations [operations] -->
|
|
322
|
+
|
|
323
|
+
<!-- Start File uploads [file-upload] -->
|
|
324
|
+
## File uploads
|
|
325
|
+
|
|
326
|
+
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.
|
|
327
|
+
|
|
328
|
+
> [!TIP]
|
|
329
|
+
>
|
|
330
|
+
> For endpoints that handle file uploads bytes arrays can also be used. However, using streams is recommended for large files.
|
|
331
|
+
>
|
|
332
|
+
|
|
333
|
+
```python
|
|
334
|
+
from flypix import FlyPix
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
with FlyPix(
|
|
338
|
+
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
|
|
339
|
+
) as fly_pix:
|
|
340
|
+
|
|
341
|
+
res = fly_pix.files.upload_v2(tenant_id="170b602d-192c-4e40-a031-f5892fa57f45", project_id="55299aef-34b1-4aaa-a1aa-cbeca6dd058b", filename="example.file", body=open("example.file", "rb"))
|
|
342
|
+
|
|
343
|
+
# Handle response
|
|
344
|
+
print(res)
|
|
345
|
+
|
|
346
|
+
```
|
|
347
|
+
<!-- End File uploads [file-upload] -->
|
|
348
|
+
|
|
349
|
+
<!-- Start Retries [retries] -->
|
|
350
|
+
## Retries
|
|
351
|
+
|
|
352
|
+
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.
|
|
353
|
+
|
|
354
|
+
To change the default retry strategy for a single API call, simply provide a `RetryConfig` object to the call:
|
|
355
|
+
```python
|
|
356
|
+
from flypix import FlyPix
|
|
357
|
+
from flypix.utils import BackoffStrategy, RetryConfig
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
with FlyPix() as fly_pix:
|
|
361
|
+
|
|
362
|
+
res = fly_pix.auth.login_with_password(username="Allie.Hartmann", password="9ne8TpFJLsebftr",
|
|
363
|
+
RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False))
|
|
364
|
+
|
|
365
|
+
# Handle response
|
|
366
|
+
print(res)
|
|
367
|
+
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
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:
|
|
371
|
+
```python
|
|
372
|
+
from flypix import FlyPix
|
|
373
|
+
from flypix.utils import BackoffStrategy, RetryConfig
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
with FlyPix(
|
|
377
|
+
retry_config=RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False),
|
|
378
|
+
) as fly_pix:
|
|
379
|
+
|
|
380
|
+
res = fly_pix.auth.login_with_password(username="Allie.Hartmann", password="9ne8TpFJLsebftr")
|
|
381
|
+
|
|
382
|
+
# Handle response
|
|
383
|
+
print(res)
|
|
384
|
+
|
|
385
|
+
```
|
|
386
|
+
<!-- End Retries [retries] -->
|
|
387
|
+
|
|
388
|
+
<!-- Start Error Handling [errors] -->
|
|
389
|
+
## Error Handling
|
|
390
|
+
|
|
391
|
+
[`FlyPixError`](https://github.com/flypix-ai/flypix-sdk/blob/master/./src/flypix/errors/flypixerror.py) is the base class for all HTTP error responses. It has the following properties:
|
|
392
|
+
|
|
393
|
+
| Property | Type | Description |
|
|
394
|
+
| ------------------ | ---------------- | ------------------------------------------------------ |
|
|
395
|
+
| `err.message` | `str` | Error message |
|
|
396
|
+
| `err.status_code` | `int` | HTTP response status code eg `404` |
|
|
397
|
+
| `err.headers` | `httpx.Headers` | HTTP response headers |
|
|
398
|
+
| `err.body` | `str` | HTTP body. Can be empty string if no body is returned. |
|
|
399
|
+
| `err.raw_response` | `httpx.Response` | Raw HTTP response |
|
|
400
|
+
|
|
401
|
+
### Example
|
|
402
|
+
```python
|
|
403
|
+
from flypix import FlyPix, errors
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
with FlyPix() as fly_pix:
|
|
407
|
+
res = None
|
|
408
|
+
try:
|
|
409
|
+
|
|
410
|
+
res = fly_pix.auth.login_with_password(username="Allie.Hartmann", password="9ne8TpFJLsebftr")
|
|
411
|
+
|
|
412
|
+
# Handle response
|
|
413
|
+
print(res)
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
except errors.FlyPixError as e:
|
|
417
|
+
# The base class for HTTP error responses
|
|
418
|
+
print(e.message)
|
|
419
|
+
print(e.status_code)
|
|
420
|
+
print(e.body)
|
|
421
|
+
print(e.headers)
|
|
422
|
+
print(e.raw_response)
|
|
423
|
+
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
### Error Classes
|
|
427
|
+
**Primary error:**
|
|
428
|
+
* [`FlyPixError`](https://github.com/flypix-ai/flypix-sdk/blob/master/./src/flypix/errors/flypixerror.py): The base class for HTTP error responses.
|
|
429
|
+
|
|
430
|
+
<details><summary>Less common errors (5)</summary>
|
|
431
|
+
|
|
432
|
+
<br />
|
|
433
|
+
|
|
434
|
+
**Network errors:**
|
|
435
|
+
* [`httpx.RequestError`](https://www.python-httpx.org/exceptions/#httpx.RequestError): Base class for request errors.
|
|
436
|
+
* [`httpx.ConnectError`](https://www.python-httpx.org/exceptions/#httpx.ConnectError): HTTP client was unable to make a request to a server.
|
|
437
|
+
* [`httpx.TimeoutException`](https://www.python-httpx.org/exceptions/#httpx.TimeoutException): HTTP request timed out.
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
**Inherit from [`FlyPixError`](https://github.com/flypix-ai/flypix-sdk/blob/master/./src/flypix/errors/flypixerror.py)**:
|
|
441
|
+
* [`ResponseValidationError`](https://github.com/flypix-ai/flypix-sdk/blob/master/./src/flypix/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.
|
|
442
|
+
|
|
443
|
+
</details>
|
|
444
|
+
<!-- End Error Handling [errors] -->
|
|
445
|
+
|
|
446
|
+
<!-- Start Server Selection [server] -->
|
|
447
|
+
## Server Selection
|
|
448
|
+
|
|
449
|
+
### Override Server URL Per-Client
|
|
450
|
+
|
|
451
|
+
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:
|
|
452
|
+
```python
|
|
453
|
+
from flypix import FlyPix
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
with FlyPix(
|
|
457
|
+
server_url="https://api.flypix.ai",
|
|
458
|
+
) as fly_pix:
|
|
459
|
+
|
|
460
|
+
res = fly_pix.auth.login_with_password(username="Allie.Hartmann", password="9ne8TpFJLsebftr")
|
|
461
|
+
|
|
462
|
+
# Handle response
|
|
463
|
+
print(res)
|
|
464
|
+
|
|
465
|
+
```
|
|
466
|
+
<!-- End Server Selection [server] -->
|
|
467
|
+
|
|
468
|
+
<!-- Start Custom HTTP Client [http-client] -->
|
|
469
|
+
## Custom HTTP Client
|
|
470
|
+
|
|
471
|
+
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.
|
|
472
|
+
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.
|
|
473
|
+
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.
|
|
474
|
+
|
|
475
|
+
For example, you could specify a header for every request that this sdk makes as follows:
|
|
476
|
+
```python
|
|
477
|
+
from flypix import FlyPix
|
|
478
|
+
import httpx
|
|
479
|
+
|
|
480
|
+
http_client = httpx.Client(headers={"x-custom-header": "someValue"})
|
|
481
|
+
s = FlyPix(client=http_client)
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
or you could wrap the client with your own custom logic:
|
|
485
|
+
```python
|
|
486
|
+
from flypix import FlyPix
|
|
487
|
+
from flypix.httpclient import AsyncHttpClient
|
|
488
|
+
import httpx
|
|
489
|
+
|
|
490
|
+
class CustomClient(AsyncHttpClient):
|
|
491
|
+
client: AsyncHttpClient
|
|
492
|
+
|
|
493
|
+
def __init__(self, client: AsyncHttpClient):
|
|
494
|
+
self.client = client
|
|
495
|
+
|
|
496
|
+
async def send(
|
|
497
|
+
self,
|
|
498
|
+
request: httpx.Request,
|
|
499
|
+
*,
|
|
500
|
+
stream: bool = False,
|
|
501
|
+
auth: Union[
|
|
502
|
+
httpx._types.AuthTypes, httpx._client.UseClientDefault, None
|
|
503
|
+
] = httpx.USE_CLIENT_DEFAULT,
|
|
504
|
+
follow_redirects: Union[
|
|
505
|
+
bool, httpx._client.UseClientDefault
|
|
506
|
+
] = httpx.USE_CLIENT_DEFAULT,
|
|
507
|
+
) -> httpx.Response:
|
|
508
|
+
request.headers["Client-Level-Header"] = "added by client"
|
|
509
|
+
|
|
510
|
+
return await self.client.send(
|
|
511
|
+
request, stream=stream, auth=auth, follow_redirects=follow_redirects
|
|
512
|
+
)
|
|
513
|
+
|
|
514
|
+
def build_request(
|
|
515
|
+
self,
|
|
516
|
+
method: str,
|
|
517
|
+
url: httpx._types.URLTypes,
|
|
518
|
+
*,
|
|
519
|
+
content: Optional[httpx._types.RequestContent] = None,
|
|
520
|
+
data: Optional[httpx._types.RequestData] = None,
|
|
521
|
+
files: Optional[httpx._types.RequestFiles] = None,
|
|
522
|
+
json: Optional[Any] = None,
|
|
523
|
+
params: Optional[httpx._types.QueryParamTypes] = None,
|
|
524
|
+
headers: Optional[httpx._types.HeaderTypes] = None,
|
|
525
|
+
cookies: Optional[httpx._types.CookieTypes] = None,
|
|
526
|
+
timeout: Union[
|
|
527
|
+
httpx._types.TimeoutTypes, httpx._client.UseClientDefault
|
|
528
|
+
] = httpx.USE_CLIENT_DEFAULT,
|
|
529
|
+
extensions: Optional[httpx._types.RequestExtensions] = None,
|
|
530
|
+
) -> httpx.Request:
|
|
531
|
+
return self.client.build_request(
|
|
532
|
+
method,
|
|
533
|
+
url,
|
|
534
|
+
content=content,
|
|
535
|
+
data=data,
|
|
536
|
+
files=files,
|
|
537
|
+
json=json,
|
|
538
|
+
params=params,
|
|
539
|
+
headers=headers,
|
|
540
|
+
cookies=cookies,
|
|
541
|
+
timeout=timeout,
|
|
542
|
+
extensions=extensions,
|
|
543
|
+
)
|
|
544
|
+
|
|
545
|
+
s = FlyPix(async_client=CustomClient(httpx.AsyncClient()))
|
|
546
|
+
```
|
|
547
|
+
<!-- End Custom HTTP Client [http-client] -->
|
|
548
|
+
|
|
549
|
+
<!-- Start Resource Management [resource-management] -->
|
|
550
|
+
## Resource Management
|
|
551
|
+
|
|
552
|
+
The `FlyPix` 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.
|
|
553
|
+
|
|
554
|
+
[context-manager]: https://docs.python.org/3/reference/datamodel.html#context-managers
|
|
555
|
+
|
|
556
|
+
```python
|
|
557
|
+
from flypix import FlyPix
|
|
558
|
+
def main():
|
|
559
|
+
|
|
560
|
+
with FlyPix() as fly_pix:
|
|
561
|
+
# Rest of application here...
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
# Or when using async:
|
|
565
|
+
async def amain():
|
|
566
|
+
|
|
567
|
+
async with FlyPix() as fly_pix:
|
|
568
|
+
# Rest of application here...
|
|
569
|
+
```
|
|
570
|
+
<!-- End Resource Management [resource-management] -->
|
|
571
|
+
|
|
572
|
+
<!-- Start Debugging [debug] -->
|
|
573
|
+
## Debugging
|
|
574
|
+
|
|
575
|
+
You can setup your SDK to emit debug logs for SDK requests and responses.
|
|
576
|
+
|
|
577
|
+
You can pass your own logger class directly into your SDK.
|
|
578
|
+
```python
|
|
579
|
+
from flypix import FlyPix
|
|
580
|
+
import logging
|
|
581
|
+
|
|
582
|
+
logging.basicConfig(level=logging.DEBUG)
|
|
583
|
+
s = FlyPix(debug_logger=logging.getLogger("flypix"))
|
|
584
|
+
```
|
|
585
|
+
<!-- End Debugging [debug] -->
|
|
586
|
+
|
|
587
|
+
<!-- Placeholder for Future Speakeasy SDK Sections -->
|