tango-python 0.0.1a1__tar.gz → 0.1.0a1__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.
- tango_python-0.1.0a1/.release-please-manifest.json +3 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/CHANGELOG.md +8 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/PKG-INFO +12 -21
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/README.md +11 -20
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/pyproject.toml +1 -1
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/_client.py +32 -48
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/_version.py +1 -1
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/conftest.py +3 -8
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/test_client.py +78 -161
- tango_python-0.0.1a1/.release-please-manifest.json +0 -3
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/.gitignore +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/CONTRIBUTING.md +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/LICENSE +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/SECURITY.md +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/api.md +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/bin/check-release-environment +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/bin/publish-pypi +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/examples/.keep +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/mypy.ini +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/noxfile.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/release-please-config.json +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/requirements-dev.lock +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/requirements.lock +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/__init__.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/_base_client.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/_compat.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/_constants.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/_exceptions.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/_files.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/_models.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/_qs.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/_resource.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/_response.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/_streaming.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/_types.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/_utils/__init__.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/_utils/_logs.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/_utils/_proxy.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/_utils/_reflection.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/_utils/_streams.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/_utils/_sync.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/_utils/_transform.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/_utils/_typing.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/_utils/_utils.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/lib/.keep +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/py.typed +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/resources/__init__.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/resources/agencies.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/resources/assistance_listings.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/resources/bulk/__init__.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/resources/bulk/bulk.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/resources/bulk/entities.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/resources/business_types.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/resources/contracts.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/resources/departments.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/resources/entities.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/resources/idvs/__init__.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/resources/idvs/awards.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/resources/idvs/idvs.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/resources/naics.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/resources/notices.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/resources/offices.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/resources/opportunities.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/resources/pscs.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/resources/schemas.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/resources/subawards.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/resources/versions.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/__init__.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/agency.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/agency_list_params.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/agency_list_response.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/assistance_listing.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/assistance_listing_list_response.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/assistance_listing_retrieve_response.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/bulk/__init__.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/business_type.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/business_type_list_response.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/contract_list_params.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/contract_list_response.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/contract_retrieve_response.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/department.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/department_list_response.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/entity_list_params.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/entity_list_response.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/entity_retrieve_response.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/idv.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/idv_list_params.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/idv_list_response.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/idvs/__init__.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/idvs/award_list_params.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/idvs/award_list_response.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/naic_list_params.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/naic_list_response.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/naic_retrieve_response.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/naics_code.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/notice_list_params.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/notice_list_response.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/notice_retrieve_response.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/office.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/office_list_params.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/office_list_response.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/opportunity_list_params.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/opportunity_list_response.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/opportunity_retrieve_response.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/product_service_code.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/psc_list_response.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/schema_retrieve_params.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/schema_retrieve_response.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/subaward.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/subaward_list_params.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/src/tango/types/subaward_list_response.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/__init__.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/api_resources/__init__.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/api_resources/bulk/__init__.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/api_resources/bulk/test_entities.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/api_resources/idvs/__init__.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/api_resources/idvs/test_awards.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/api_resources/test_agencies.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/api_resources/test_assistance_listings.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/api_resources/test_business_types.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/api_resources/test_contracts.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/api_resources/test_departments.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/api_resources/test_entities.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/api_resources/test_idvs.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/api_resources/test_naics.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/api_resources/test_notices.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/api_resources/test_offices.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/api_resources/test_opportunities.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/api_resources/test_pscs.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/api_resources/test_schemas.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/api_resources/test_subawards.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/api_resources/test_versions.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/sample_file.txt +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/test_deepcopy.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/test_extract_files.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/test_files.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/test_models.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/test_qs.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/test_required_args.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/test_response.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/test_streaming.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/test_transform.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/test_utils/test_proxy.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/test_utils/test_typing.py +0 -0
- {tango_python-0.0.1a1 → tango_python-0.1.0a1}/tests/utils.py +0 -0
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.0-alpha.1 (2024-11-29)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v0.0.1-alpha.1...v0.1.0-alpha.1](https://github.com/makegov/tango-python/compare/v0.0.1-alpha.1...v0.1.0-alpha.1)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **api:** update via SDK Studio ([#4](https://github.com/makegov/tango-python/issues/4)) ([53ec9bd](https://github.com/makegov/tango-python/commit/53ec9bd1e1938224f9fd6ff0036fd61f3bbbcc67))
|
|
10
|
+
|
|
3
11
|
## 0.0.1-alpha.1 (2024-11-29)
|
|
4
12
|
|
|
5
13
|
Full Changelog: [v0.0.1-alpha.0...v0.0.1-alpha.1](https://github.com/makegov/tango-python/compare/v0.0.1-alpha.0...v0.0.1-alpha.1)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: tango-python
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.1.0a1
|
|
4
4
|
Summary: The official Python library for the tango API
|
|
5
5
|
Project-URL: Homepage, https://github.com/makegov/tango-python
|
|
6
6
|
Project-URL: Repository, https://github.com/makegov/tango-python
|
|
@@ -55,27 +55,32 @@ pip install --pre tango-python
|
|
|
55
55
|
The full API of this library can be found in [api.md](https://github.com/makegov/tango-python/tree/main/api.md).
|
|
56
56
|
|
|
57
57
|
```python
|
|
58
|
+
import os
|
|
58
59
|
from tango import Tango
|
|
59
60
|
|
|
60
61
|
client = Tango(
|
|
61
|
-
|
|
62
|
-
client_secret="My Client Secret",
|
|
62
|
+
access_token=os.environ.get("TANGO_API_ACCESS_TOKEN"), # This is the default and can be omitted
|
|
63
63
|
)
|
|
64
64
|
|
|
65
65
|
schema = client.schemas.retrieve()
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
+
While you can provide a `access_token` keyword argument,
|
|
69
|
+
we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
|
|
70
|
+
to add `TANGO_API_ACCESS_TOKEN="My Access Token"` to your `.env` file
|
|
71
|
+
so that your Access Token is not stored in source control.
|
|
72
|
+
|
|
68
73
|
## Async usage
|
|
69
74
|
|
|
70
75
|
Simply import `AsyncTango` instead of `Tango` and use `await` with each API call:
|
|
71
76
|
|
|
72
77
|
```python
|
|
78
|
+
import os
|
|
73
79
|
import asyncio
|
|
74
80
|
from tango import AsyncTango
|
|
75
81
|
|
|
76
82
|
client = AsyncTango(
|
|
77
|
-
|
|
78
|
-
client_secret="My Client Secret",
|
|
83
|
+
access_token=os.environ.get("TANGO_API_ACCESS_TOKEN"), # This is the default and can be omitted
|
|
79
84
|
)
|
|
80
85
|
|
|
81
86
|
|
|
@@ -110,10 +115,7 @@ All errors inherit from `tango.APIError`.
|
|
|
110
115
|
import tango
|
|
111
116
|
from tango import Tango
|
|
112
117
|
|
|
113
|
-
client = Tango(
|
|
114
|
-
client_id="My Client ID",
|
|
115
|
-
client_secret="My Client Secret",
|
|
116
|
-
)
|
|
118
|
+
client = Tango()
|
|
117
119
|
|
|
118
120
|
try:
|
|
119
121
|
client.schemas.retrieve()
|
|
@@ -156,8 +158,6 @@ from tango import Tango
|
|
|
156
158
|
client = Tango(
|
|
157
159
|
# default is 2
|
|
158
160
|
max_retries=0,
|
|
159
|
-
client_id="My Client ID",
|
|
160
|
-
client_secret="My Client Secret",
|
|
161
161
|
)
|
|
162
162
|
|
|
163
163
|
# Or, configure per-request:
|
|
@@ -176,15 +176,11 @@ from tango import Tango
|
|
|
176
176
|
client = Tango(
|
|
177
177
|
# 20 seconds (default is 1 minute)
|
|
178
178
|
timeout=20.0,
|
|
179
|
-
client_id="My Client ID",
|
|
180
|
-
client_secret="My Client Secret",
|
|
181
179
|
)
|
|
182
180
|
|
|
183
181
|
# More granular control:
|
|
184
182
|
client = Tango(
|
|
185
183
|
timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),
|
|
186
|
-
client_id="My Client ID",
|
|
187
|
-
client_secret="My Client Secret",
|
|
188
184
|
)
|
|
189
185
|
|
|
190
186
|
# Override per-request:
|
|
@@ -228,10 +224,7 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
|
|
|
228
224
|
```py
|
|
229
225
|
from tango import Tango
|
|
230
226
|
|
|
231
|
-
client = Tango(
|
|
232
|
-
client_id="My Client ID",
|
|
233
|
-
client_secret="My Client Secret",
|
|
234
|
-
)
|
|
227
|
+
client = Tango()
|
|
235
228
|
response = client.schemas.with_raw_response.retrieve()
|
|
236
229
|
print(response.headers.get('X-My-Header'))
|
|
237
230
|
|
|
@@ -312,8 +305,6 @@ client = Tango(
|
|
|
312
305
|
proxies="http://my.test.proxy.example.com",
|
|
313
306
|
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
|
|
314
307
|
),
|
|
315
|
-
client_id="My Client ID",
|
|
316
|
-
client_secret="My Client Secret",
|
|
317
308
|
)
|
|
318
309
|
```
|
|
319
310
|
|
|
@@ -24,27 +24,32 @@ pip install --pre tango-python
|
|
|
24
24
|
The full API of this library can be found in [api.md](api.md).
|
|
25
25
|
|
|
26
26
|
```python
|
|
27
|
+
import os
|
|
27
28
|
from tango import Tango
|
|
28
29
|
|
|
29
30
|
client = Tango(
|
|
30
|
-
|
|
31
|
-
client_secret="My Client Secret",
|
|
31
|
+
access_token=os.environ.get("TANGO_API_ACCESS_TOKEN"), # This is the default and can be omitted
|
|
32
32
|
)
|
|
33
33
|
|
|
34
34
|
schema = client.schemas.retrieve()
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
+
While you can provide a `access_token` keyword argument,
|
|
38
|
+
we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
|
|
39
|
+
to add `TANGO_API_ACCESS_TOKEN="My Access Token"` to your `.env` file
|
|
40
|
+
so that your Access Token is not stored in source control.
|
|
41
|
+
|
|
37
42
|
## Async usage
|
|
38
43
|
|
|
39
44
|
Simply import `AsyncTango` instead of `Tango` and use `await` with each API call:
|
|
40
45
|
|
|
41
46
|
```python
|
|
47
|
+
import os
|
|
42
48
|
import asyncio
|
|
43
49
|
from tango import AsyncTango
|
|
44
50
|
|
|
45
51
|
client = AsyncTango(
|
|
46
|
-
|
|
47
|
-
client_secret="My Client Secret",
|
|
52
|
+
access_token=os.environ.get("TANGO_API_ACCESS_TOKEN"), # This is the default and can be omitted
|
|
48
53
|
)
|
|
49
54
|
|
|
50
55
|
|
|
@@ -79,10 +84,7 @@ All errors inherit from `tango.APIError`.
|
|
|
79
84
|
import tango
|
|
80
85
|
from tango import Tango
|
|
81
86
|
|
|
82
|
-
client = Tango(
|
|
83
|
-
client_id="My Client ID",
|
|
84
|
-
client_secret="My Client Secret",
|
|
85
|
-
)
|
|
87
|
+
client = Tango()
|
|
86
88
|
|
|
87
89
|
try:
|
|
88
90
|
client.schemas.retrieve()
|
|
@@ -125,8 +127,6 @@ from tango import Tango
|
|
|
125
127
|
client = Tango(
|
|
126
128
|
# default is 2
|
|
127
129
|
max_retries=0,
|
|
128
|
-
client_id="My Client ID",
|
|
129
|
-
client_secret="My Client Secret",
|
|
130
130
|
)
|
|
131
131
|
|
|
132
132
|
# Or, configure per-request:
|
|
@@ -145,15 +145,11 @@ from tango import Tango
|
|
|
145
145
|
client = Tango(
|
|
146
146
|
# 20 seconds (default is 1 minute)
|
|
147
147
|
timeout=20.0,
|
|
148
|
-
client_id="My Client ID",
|
|
149
|
-
client_secret="My Client Secret",
|
|
150
148
|
)
|
|
151
149
|
|
|
152
150
|
# More granular control:
|
|
153
151
|
client = Tango(
|
|
154
152
|
timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),
|
|
155
|
-
client_id="My Client ID",
|
|
156
|
-
client_secret="My Client Secret",
|
|
157
153
|
)
|
|
158
154
|
|
|
159
155
|
# Override per-request:
|
|
@@ -197,10 +193,7 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
|
|
|
197
193
|
```py
|
|
198
194
|
from tango import Tango
|
|
199
195
|
|
|
200
|
-
client = Tango(
|
|
201
|
-
client_id="My Client ID",
|
|
202
|
-
client_secret="My Client Secret",
|
|
203
|
-
)
|
|
196
|
+
client = Tango()
|
|
204
197
|
response = client.schemas.with_raw_response.retrieve()
|
|
205
198
|
print(response.headers.get('X-My-Header'))
|
|
206
199
|
|
|
@@ -281,8 +274,6 @@ client = Tango(
|
|
|
281
274
|
proxies="http://my.test.proxy.example.com",
|
|
282
275
|
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
|
|
283
276
|
),
|
|
284
|
-
client_id="My Client ID",
|
|
285
|
-
client_secret="My Client Secret",
|
|
286
277
|
)
|
|
287
278
|
```
|
|
288
279
|
|
|
@@ -66,14 +66,12 @@ class Tango(SyncAPIClient):
|
|
|
66
66
|
with_streaming_response: TangoWithStreamedResponse
|
|
67
67
|
|
|
68
68
|
# client options
|
|
69
|
-
|
|
70
|
-
client_secret: str
|
|
69
|
+
access_token: str
|
|
71
70
|
|
|
72
71
|
def __init__(
|
|
73
72
|
self,
|
|
74
73
|
*,
|
|
75
|
-
|
|
76
|
-
client_secret: str | None = None,
|
|
74
|
+
access_token: str | None = None,
|
|
77
75
|
base_url: str | httpx.URL | None = None,
|
|
78
76
|
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
|
|
79
77
|
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
@@ -95,25 +93,15 @@ class Tango(SyncAPIClient):
|
|
|
95
93
|
) -> None:
|
|
96
94
|
"""Construct a new synchronous tango client instance.
|
|
97
95
|
|
|
98
|
-
This automatically infers the
|
|
99
|
-
- `client_id` from `CLIENT_ID`
|
|
100
|
-
- `client_secret` from `CLIENT_SECRET`
|
|
96
|
+
This automatically infers the `access_token` argument from the `TANGO_API_ACCESS_TOKEN` environment variable if it is not provided.
|
|
101
97
|
"""
|
|
102
|
-
if
|
|
103
|
-
|
|
104
|
-
if
|
|
98
|
+
if access_token is None:
|
|
99
|
+
access_token = os.environ.get("TANGO_API_ACCESS_TOKEN")
|
|
100
|
+
if access_token is None:
|
|
105
101
|
raise TangoError(
|
|
106
|
-
"The
|
|
102
|
+
"The access_token client option must be set either by passing access_token to the client or by setting the TANGO_API_ACCESS_TOKEN environment variable"
|
|
107
103
|
)
|
|
108
|
-
self.
|
|
109
|
-
|
|
110
|
-
if client_secret is None:
|
|
111
|
-
client_secret = os.environ.get("CLIENT_SECRET")
|
|
112
|
-
if client_secret is None:
|
|
113
|
-
raise TangoError(
|
|
114
|
-
"The client_secret client option must be set either by passing client_secret to the client or by setting the CLIENT_SECRET environment variable"
|
|
115
|
-
)
|
|
116
|
-
self.client_secret = client_secret
|
|
104
|
+
self.access_token = access_token
|
|
117
105
|
|
|
118
106
|
if base_url is None:
|
|
119
107
|
base_url = os.environ.get("TANGO_BASE_URL")
|
|
@@ -155,6 +143,12 @@ class Tango(SyncAPIClient):
|
|
|
155
143
|
def qs(self) -> Querystring:
|
|
156
144
|
return Querystring(array_format="comma")
|
|
157
145
|
|
|
146
|
+
@property
|
|
147
|
+
@override
|
|
148
|
+
def auth_headers(self) -> dict[str, str]:
|
|
149
|
+
access_token = self.access_token
|
|
150
|
+
return {"Authorization": f"Bearer {access_token}"}
|
|
151
|
+
|
|
158
152
|
@property
|
|
159
153
|
@override
|
|
160
154
|
def default_headers(self) -> dict[str, str | Omit]:
|
|
@@ -167,8 +161,7 @@ class Tango(SyncAPIClient):
|
|
|
167
161
|
def copy(
|
|
168
162
|
self,
|
|
169
163
|
*,
|
|
170
|
-
|
|
171
|
-
client_secret: str | None = None,
|
|
164
|
+
access_token: str | None = None,
|
|
172
165
|
base_url: str | httpx.URL | None = None,
|
|
173
166
|
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
|
|
174
167
|
http_client: httpx.Client | None = None,
|
|
@@ -202,8 +195,7 @@ class Tango(SyncAPIClient):
|
|
|
202
195
|
|
|
203
196
|
http_client = http_client or self._client
|
|
204
197
|
return self.__class__(
|
|
205
|
-
|
|
206
|
-
client_secret=client_secret or self.client_secret,
|
|
198
|
+
access_token=access_token or self.access_token,
|
|
207
199
|
base_url=base_url or self.base_url,
|
|
208
200
|
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
|
|
209
201
|
http_client=http_client,
|
|
@@ -272,14 +264,12 @@ class AsyncTango(AsyncAPIClient):
|
|
|
272
264
|
with_streaming_response: AsyncTangoWithStreamedResponse
|
|
273
265
|
|
|
274
266
|
# client options
|
|
275
|
-
|
|
276
|
-
client_secret: str
|
|
267
|
+
access_token: str
|
|
277
268
|
|
|
278
269
|
def __init__(
|
|
279
270
|
self,
|
|
280
271
|
*,
|
|
281
|
-
|
|
282
|
-
client_secret: str | None = None,
|
|
272
|
+
access_token: str | None = None,
|
|
283
273
|
base_url: str | httpx.URL | None = None,
|
|
284
274
|
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
|
|
285
275
|
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
@@ -301,25 +291,15 @@ class AsyncTango(AsyncAPIClient):
|
|
|
301
291
|
) -> None:
|
|
302
292
|
"""Construct a new async tango client instance.
|
|
303
293
|
|
|
304
|
-
This automatically infers the
|
|
305
|
-
- `client_id` from `CLIENT_ID`
|
|
306
|
-
- `client_secret` from `CLIENT_SECRET`
|
|
294
|
+
This automatically infers the `access_token` argument from the `TANGO_API_ACCESS_TOKEN` environment variable if it is not provided.
|
|
307
295
|
"""
|
|
308
|
-
if
|
|
309
|
-
|
|
310
|
-
if
|
|
296
|
+
if access_token is None:
|
|
297
|
+
access_token = os.environ.get("TANGO_API_ACCESS_TOKEN")
|
|
298
|
+
if access_token is None:
|
|
311
299
|
raise TangoError(
|
|
312
|
-
"The
|
|
300
|
+
"The access_token client option must be set either by passing access_token to the client or by setting the TANGO_API_ACCESS_TOKEN environment variable"
|
|
313
301
|
)
|
|
314
|
-
self.
|
|
315
|
-
|
|
316
|
-
if client_secret is None:
|
|
317
|
-
client_secret = os.environ.get("CLIENT_SECRET")
|
|
318
|
-
if client_secret is None:
|
|
319
|
-
raise TangoError(
|
|
320
|
-
"The client_secret client option must be set either by passing client_secret to the client or by setting the CLIENT_SECRET environment variable"
|
|
321
|
-
)
|
|
322
|
-
self.client_secret = client_secret
|
|
302
|
+
self.access_token = access_token
|
|
323
303
|
|
|
324
304
|
if base_url is None:
|
|
325
305
|
base_url = os.environ.get("TANGO_BASE_URL")
|
|
@@ -361,6 +341,12 @@ class AsyncTango(AsyncAPIClient):
|
|
|
361
341
|
def qs(self) -> Querystring:
|
|
362
342
|
return Querystring(array_format="comma")
|
|
363
343
|
|
|
344
|
+
@property
|
|
345
|
+
@override
|
|
346
|
+
def auth_headers(self) -> dict[str, str]:
|
|
347
|
+
access_token = self.access_token
|
|
348
|
+
return {"Authorization": f"Bearer {access_token}"}
|
|
349
|
+
|
|
364
350
|
@property
|
|
365
351
|
@override
|
|
366
352
|
def default_headers(self) -> dict[str, str | Omit]:
|
|
@@ -373,8 +359,7 @@ class AsyncTango(AsyncAPIClient):
|
|
|
373
359
|
def copy(
|
|
374
360
|
self,
|
|
375
361
|
*,
|
|
376
|
-
|
|
377
|
-
client_secret: str | None = None,
|
|
362
|
+
access_token: str | None = None,
|
|
378
363
|
base_url: str | httpx.URL | None = None,
|
|
379
364
|
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
|
|
380
365
|
http_client: httpx.AsyncClient | None = None,
|
|
@@ -408,8 +393,7 @@ class AsyncTango(AsyncAPIClient):
|
|
|
408
393
|
|
|
409
394
|
http_client = http_client or self._client
|
|
410
395
|
return self.__class__(
|
|
411
|
-
|
|
412
|
-
client_secret=client_secret or self.client_secret,
|
|
396
|
+
access_token=access_token or self.access_token,
|
|
413
397
|
base_url=base_url or self.base_url,
|
|
414
398
|
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
|
|
415
399
|
http_client=http_client,
|
|
@@ -28,8 +28,7 @@ def pytest_collection_modifyitems(items: list[pytest.Function]) -> None:
|
|
|
28
28
|
|
|
29
29
|
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
client_secret = "My Client Secret"
|
|
31
|
+
access_token = "My Access Token"
|
|
33
32
|
|
|
34
33
|
|
|
35
34
|
@pytest.fixture(scope="session")
|
|
@@ -38,9 +37,7 @@ def client(request: FixtureRequest) -> Iterator[Tango]:
|
|
|
38
37
|
if not isinstance(strict, bool):
|
|
39
38
|
raise TypeError(f"Unexpected fixture parameter type {type(strict)}, expected {bool}")
|
|
40
39
|
|
|
41
|
-
with Tango(
|
|
42
|
-
base_url=base_url, client_id=client_id, client_secret=client_secret, _strict_response_validation=strict
|
|
43
|
-
) as client:
|
|
40
|
+
with Tango(base_url=base_url, access_token=access_token, _strict_response_validation=strict) as client:
|
|
44
41
|
yield client
|
|
45
42
|
|
|
46
43
|
|
|
@@ -50,7 +47,5 @@ async def async_client(request: FixtureRequest) -> AsyncIterator[AsyncTango]:
|
|
|
50
47
|
if not isinstance(strict, bool):
|
|
51
48
|
raise TypeError(f"Unexpected fixture parameter type {type(strict)}, expected {bool}")
|
|
52
49
|
|
|
53
|
-
async with AsyncTango(
|
|
54
|
-
base_url=base_url, client_id=client_id, client_secret=client_secret, _strict_response_validation=strict
|
|
55
|
-
) as client:
|
|
50
|
+
async with AsyncTango(base_url=base_url, access_token=access_token, _strict_response_validation=strict) as client:
|
|
56
51
|
yield client
|