tango-python 0.4.3__py3-none-any.whl → 0.4.4__py3-none-any.whl
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/client.py +15 -0
- {tango_python-0.4.3.dist-info → tango_python-0.4.4.dist-info}/METADATA +1 -1
- {tango_python-0.4.3.dist-info → tango_python-0.4.4.dist-info}/RECORD +5 -5
- {tango_python-0.4.3.dist-info → tango_python-0.4.4.dist-info}/WHEEL +0 -0
- {tango_python-0.4.3.dist-info → tango_python-0.4.4.dist-info}/licenses/LICENSE +0 -0
tango/client.py
CHANGED
|
@@ -59,6 +59,8 @@ class TangoClient:
|
|
|
59
59
|
self,
|
|
60
60
|
api_key: str | None = None,
|
|
61
61
|
base_url: str = "https://tango.makegov.com",
|
|
62
|
+
user_agent: str | None = None,
|
|
63
|
+
extra_headers: dict[str, str] | None = None,
|
|
62
64
|
):
|
|
63
65
|
"""
|
|
64
66
|
Initialize the Tango API client
|
|
@@ -67,6 +69,8 @@ class TangoClient:
|
|
|
67
69
|
api_key: API key for authentication. If not provided, will attempt to load from
|
|
68
70
|
TANGO_API_KEY environment variable.
|
|
69
71
|
base_url: Base URL for the API
|
|
72
|
+
user_agent: Custom User-Agent header value.
|
|
73
|
+
extra_headers: Additional headers to include in every request.
|
|
70
74
|
"""
|
|
71
75
|
# Load API key from environment if not provided
|
|
72
76
|
self.api_key = api_key or os.getenv("TANGO_API_KEY")
|
|
@@ -76,9 +80,14 @@ class TangoClient:
|
|
|
76
80
|
headers = {}
|
|
77
81
|
if self.api_key:
|
|
78
82
|
headers["X-API-KEY"] = self.api_key
|
|
83
|
+
if user_agent:
|
|
84
|
+
headers["User-Agent"] = user_agent
|
|
85
|
+
if extra_headers:
|
|
86
|
+
headers.update(extra_headers)
|
|
79
87
|
|
|
80
88
|
self.client = httpx.Client(headers=headers, timeout=30.0)
|
|
81
89
|
self._last_rate_limit_info: RateLimitInfo | None = None
|
|
90
|
+
self._last_response_headers: httpx.Headers | None = None
|
|
82
91
|
|
|
83
92
|
# Use hardcoded sensible defaults
|
|
84
93
|
cache_size = 100
|
|
@@ -105,6 +114,11 @@ class TangoClient:
|
|
|
105
114
|
"""Rate limit info from the most recent API response."""
|
|
106
115
|
return self._last_rate_limit_info
|
|
107
116
|
|
|
117
|
+
@property
|
|
118
|
+
def last_response_headers(self) -> httpx.Headers | None:
|
|
119
|
+
"""Full HTTP headers from the most recent API response."""
|
|
120
|
+
return self._last_response_headers
|
|
121
|
+
|
|
108
122
|
@staticmethod
|
|
109
123
|
def _parse_rate_limit_headers(headers: httpx.Headers) -> RateLimitInfo:
|
|
110
124
|
"""Extract rate limit info from response headers."""
|
|
@@ -140,6 +154,7 @@ class TangoClient:
|
|
|
140
154
|
|
|
141
155
|
try:
|
|
142
156
|
response = self.client.request(method=method, url=url, params=params, json=json_data)
|
|
157
|
+
self._last_response_headers = response.headers
|
|
143
158
|
self._last_rate_limit_info = self._parse_rate_limit_headers(response.headers)
|
|
144
159
|
|
|
145
160
|
if response.status_code == 401:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
tango/__init__.py,sha256=MkZ4VcgIB5WFfCaxK6XXrK25icagQ2o9ZNta64xsqgw,1142
|
|
2
|
-
tango/client.py,sha256=
|
|
2
|
+
tango/client.py,sha256=Dm8v3xMO3uX-GGM1ioLySzjLavPmlxhkrqZw4q6wTWw,88396
|
|
3
3
|
tango/exceptions.py,sha256=aRvDm0dUCEtNDfRVYCX7SEDdd1WlIVVY6sN78Tzo-a0,3114
|
|
4
4
|
tango/models.py,sha256=EDKsZ4fsxkAbDhX5roOfiKYyPjZaTV-5QKrPaQCsb0Y,20959
|
|
5
5
|
tango/shapes/__init__.py,sha256=7ea1WU74jp4znhNw-gXruag6m6eyPZtbVgbDFmFUWro,1072
|
|
@@ -10,7 +10,7 @@ tango/shapes/models.py,sha256=h3pIhOqrrdlN953Y6r0oney5HFbKPOD-frRndRWimJ0,3018
|
|
|
10
10
|
tango/shapes/parser.py,sha256=k6OsI2w3GH6-IBbc-XTLgL1mWH7bMf7A_dA6pr1xKfw,24619
|
|
11
11
|
tango/shapes/schema.py,sha256=VRPOB1sBdjFyimNchrZKIpTHn83CyX4RfU9077aQtIU,14136
|
|
12
12
|
tango/shapes/types.py,sha256=27jrAE0VIdrKaLjR_FK71hfIIGX2Tg3ex7REEBV1TFE,1301
|
|
13
|
-
tango_python-0.4.
|
|
14
|
-
tango_python-0.4.
|
|
15
|
-
tango_python-0.4.
|
|
16
|
-
tango_python-0.4.
|
|
13
|
+
tango_python-0.4.4.dist-info/METADATA,sha256=QGTVP5M9kTipieVrII_ocUU061ukbG61bgDfscHIpgg,17595
|
|
14
|
+
tango_python-0.4.4.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
15
|
+
tango_python-0.4.4.dist-info/licenses/LICENSE,sha256=j2kYVHMwTkoGn3ZNScnrdIueG0k2XzB_LCPFoyBc2wk,1064
|
|
16
|
+
tango_python-0.4.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|