apitally 0.9.0__py3-none-any.whl → 0.10.1__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.
- apitally/__init__.py +1 -1
- apitally/client/asyncio.py +9 -6
- apitally/client/threading.py +9 -6
- apitally/django.py +6 -4
- apitally/flask.py +5 -1
- apitally/litestar.py +6 -4
- apitally/starlette.py +6 -4
- {apitally-0.9.0.dist-info → apitally-0.10.1.dist-info}/METADATA +7 -7
- apitally-0.10.1.dist-info/RECORD +19 -0
- apitally-0.9.0.dist-info/RECORD +0 -19
- {apitally-0.9.0.dist-info → apitally-0.10.1.dist-info}/LICENSE +0 -0
- {apitally-0.9.0.dist-info → apitally-0.10.1.dist-info}/WHEEL +0 -0
apitally/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.
|
1
|
+
__version__ = "0.10.1"
|
apitally/client/asyncio.py
CHANGED
@@ -98,11 +98,7 @@ class ApitallyClient(ApitallyClientBase):
|
|
98
98
|
async def _send_app_info(self, client: httpx.AsyncClient, payload: Dict[str, Any]) -> None:
|
99
99
|
logger.debug("Sending app info")
|
100
100
|
response = await client.post(url="/info", json=payload, timeout=REQUEST_TIMEOUT)
|
101
|
-
|
102
|
-
self.stop_sync_loop()
|
103
|
-
logger.error(f"Invalid Apitally client ID {self.client_id}")
|
104
|
-
else:
|
105
|
-
response.raise_for_status()
|
101
|
+
self._handle_hub_response(response)
|
106
102
|
self._app_info_sent = True
|
107
103
|
self._app_info_payload = None
|
108
104
|
|
@@ -110,4 +106,11 @@ class ApitallyClient(ApitallyClientBase):
|
|
110
106
|
async def _send_requests_data(self, client: httpx.AsyncClient, payload: Dict[str, Any]) -> None:
|
111
107
|
logger.debug("Sending requests data")
|
112
108
|
response = await client.post(url="/requests", json=payload)
|
113
|
-
|
109
|
+
self._handle_hub_response(response)
|
110
|
+
|
111
|
+
def _handle_hub_response(self, response: httpx.Response) -> None:
|
112
|
+
if response.status_code == 404:
|
113
|
+
self.stop_sync_loop()
|
114
|
+
logger.error(f"Invalid Apitally client ID {self.client_id}")
|
115
|
+
else:
|
116
|
+
response.raise_for_status()
|
apitally/client/threading.py
CHANGED
@@ -112,11 +112,7 @@ class ApitallyClient(ApitallyClientBase):
|
|
112
112
|
def _send_app_info(self, session: requests.Session, payload: Dict[str, Any]) -> None:
|
113
113
|
logger.debug("Sending app info")
|
114
114
|
response = session.post(url=f"{self.hub_url}/info", json=payload, timeout=REQUEST_TIMEOUT)
|
115
|
-
|
116
|
-
self.stop_sync_loop()
|
117
|
-
logger.error(f"Invalid Apitally client ID {self.client_id}")
|
118
|
-
else:
|
119
|
-
response.raise_for_status()
|
115
|
+
self._handle_hub_response(response)
|
120
116
|
self._app_info_sent = True
|
121
117
|
self._app_info_payload = None
|
122
118
|
|
@@ -124,4 +120,11 @@ class ApitallyClient(ApitallyClientBase):
|
|
124
120
|
def _send_requests_data(self, session: requests.Session, payload: Dict[str, Any]) -> None:
|
125
121
|
logger.debug("Sending requests data")
|
126
122
|
response = session.post(url=f"{self.hub_url}/requests", json=payload, timeout=REQUEST_TIMEOUT)
|
127
|
-
|
123
|
+
self._handle_hub_response(response)
|
124
|
+
|
125
|
+
def _handle_hub_response(self, response: requests.Response) -> None:
|
126
|
+
if response.status_code == 404:
|
127
|
+
self.stop_sync_loop()
|
128
|
+
logger.error(f"Invalid Apitally client ID {self.client_id}")
|
129
|
+
else:
|
130
|
+
response.raise_for_status()
|
apitally/django.py
CHANGED
@@ -164,12 +164,14 @@ class ApitallyMiddleware:
|
|
164
164
|
|
165
165
|
def get_consumer(self, request: HttpRequest) -> Optional[str]:
|
166
166
|
try:
|
167
|
-
if hasattr(request, "
|
167
|
+
if hasattr(request, "apitally_consumer"):
|
168
|
+
return str(request.apitally_consumer)
|
169
|
+
if hasattr(request, "consumer_identifier"): # Keeping this for legacy support
|
168
170
|
return str(request.consumer_identifier)
|
169
171
|
if self.config is not None and self.config.identify_consumer_callback is not None:
|
170
|
-
|
171
|
-
if
|
172
|
-
return str(
|
172
|
+
consumer = self.config.identify_consumer_callback(request)
|
173
|
+
if consumer is not None:
|
174
|
+
return str(consumer)
|
173
175
|
except Exception: # pragma: no cover
|
174
176
|
logger.exception("Failed to get consumer identifier for request")
|
175
177
|
return None
|
apitally/flask.py
CHANGED
@@ -115,7 +115,11 @@ class ApitallyMiddleware:
|
|
115
115
|
return environ["PATH_INFO"], False
|
116
116
|
|
117
117
|
def get_consumer(self) -> Optional[str]:
|
118
|
-
|
118
|
+
if "apitally_consumer" in g:
|
119
|
+
return str(g.apitally_consumer)
|
120
|
+
if "consumer_identifier" in g: # Keeping this for legacy support
|
121
|
+
return str(g.consumer_identifier)
|
122
|
+
return None
|
119
123
|
|
120
124
|
|
121
125
|
def _get_app_info(app: Flask, app_version: Optional[str] = None, openapi_url: Optional[str] = None) -> Dict[str, Any]:
|
apitally/litestar.py
CHANGED
@@ -168,12 +168,14 @@ class ApitallyPlugin(InitPluginProtocol):
|
|
168
168
|
return False # pragma: no cover
|
169
169
|
|
170
170
|
def get_consumer(self, request: Request) -> Optional[str]:
|
171
|
-
if hasattr(request.state, "
|
171
|
+
if hasattr(request.state, "apitally_consumer"):
|
172
|
+
return str(request.state.apitally_consumer)
|
173
|
+
if hasattr(request.state, "consumer_identifier"): # Keeping this for legacy support
|
172
174
|
return str(request.state.consumer_identifier)
|
173
175
|
if self.identify_consumer_callback is not None:
|
174
|
-
|
175
|
-
if
|
176
|
-
return str(
|
176
|
+
consumer = self.identify_consumer_callback(request)
|
177
|
+
if consumer is not None:
|
178
|
+
return str(consumer)
|
177
179
|
return None
|
178
180
|
|
179
181
|
|
apitally/starlette.py
CHANGED
@@ -142,12 +142,14 @@ class ApitallyMiddleware(BaseHTTPMiddleware):
|
|
142
142
|
return request.url.path, False
|
143
143
|
|
144
144
|
def get_consumer(self, request: Request) -> Optional[str]:
|
145
|
-
if hasattr(request.state, "
|
145
|
+
if hasattr(request.state, "apitally_consumer"):
|
146
|
+
return str(request.state.apitally_consumer)
|
147
|
+
if hasattr(request.state, "consumer_identifier"): # Keeping this for legacy support
|
146
148
|
return str(request.state.consumer_identifier)
|
147
149
|
if self.identify_consumer_callback is not None:
|
148
|
-
|
149
|
-
if
|
150
|
-
return str(
|
150
|
+
consumer = self.identify_consumer_callback(request)
|
151
|
+
if consumer is not None:
|
152
|
+
return str(consumer)
|
151
153
|
return None
|
152
154
|
|
153
155
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: apitally
|
3
|
-
Version: 0.
|
4
|
-
Summary: API monitoring for REST APIs built with FastAPI, Flask, Django, Starlette and Litestar.
|
3
|
+
Version: 0.10.1
|
4
|
+
Summary: Simple API monitoring & analytics for REST APIs built with FastAPI, Flask, Django, Starlette and Litestar.
|
5
5
|
Home-page: https://apitally.io
|
6
6
|
License: MIT
|
7
7
|
Author: Apitally
|
@@ -42,20 +42,20 @@ Requires-Dist: sentry-sdk (>=2.2.0) ; extra == "sentry"
|
|
42
42
|
Requires-Dist: starlette (>=0.21.0,<1.0.0) ; extra == "fastapi" or extra == "starlette"
|
43
43
|
Requires-Dist: uritemplate (>=3.0.0) ; extra == "django-rest-framework"
|
44
44
|
Project-URL: Documentation, https://docs.apitally.io
|
45
|
-
Project-URL: Repository, https://github.com/apitally/
|
45
|
+
Project-URL: Repository, https://github.com/apitally/apitally-py
|
46
46
|
Description-Content-Type: text/markdown
|
47
47
|
|
48
48
|
<p align="center">
|
49
49
|
<picture>
|
50
50
|
<source media="(prefers-color-scheme: dark)" srcset="https://assets.apitally.io/logos/logo-vertical-dark.png">
|
51
51
|
<source media="(prefers-color-scheme: light)" srcset="https://assets.apitally.io/logos/logo-vertical-light.png">
|
52
|
-
<img alt="Apitally logo" src="https://assets.apitally.io/logos/logo-vertical-light.png">
|
52
|
+
<img alt="Apitally logo" src="https://assets.apitally.io/logos/logo-vertical-light.png" width="150">
|
53
53
|
</picture>
|
54
54
|
</p>
|
55
55
|
|
56
56
|
<p align="center"><b>API monitoring made easy.</b></p>
|
57
57
|
|
58
|
-
<p align="center"><i>Apitally is a simple
|
58
|
+
<p align="center"><i>Apitally is a simple API monitoring & analytics tool with a focus on data privacy.<br>It is super easy to use for API projects in Python or Node.js and never collects sensitive data.</i></p>
|
59
59
|
|
60
60
|
<p align="center">🔗 <b><a href="https://apitally.io" target="_blank">apitally.io</a></b></p>
|
61
61
|
|
@@ -65,8 +65,8 @@ Description-Content-Type: text/markdown
|
|
65
65
|
|
66
66
|
# Apitally client library for Python
|
67
67
|
|
68
|
-
[](https://github.com/apitally/apitally-py/actions)
|
69
|
+
[](https://codecov.io/gh/apitally/apitally-py)
|
70
70
|
[](https://pypi.org/project/apitally/)
|
71
71
|
|
72
72
|
This client library for Apitally currently supports the following Python web
|
@@ -0,0 +1,19 @@
|
|
1
|
+
apitally/__init__.py,sha256=v7Gyp89umFzDtY45tTjCdXqZnQ2RN01AibdYNxEvxYo,23
|
2
|
+
apitally/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
+
apitally/client/asyncio.py,sha256=nvW3LcwIJsfE4h-nHiHJLSdnluxdZGu9AyH6l6MJH24,4556
|
4
|
+
apitally/client/base.py,sha256=VWtHTkA6UT5aV37i_CXUvcfmYrabjHGBhzbDU6EeH1A,12785
|
5
|
+
apitally/client/logging.py,sha256=QMsKIIAFo92PNBUleeTgsrsQa7SEal-oJa1oOHUr1wI,507
|
6
|
+
apitally/client/threading.py,sha256=aEFDXDr5SI2g0Zv1GNcP9PhToeZ5Tp2VhPtPwbPGAIs,4957
|
7
|
+
apitally/common.py,sha256=GbVmnXxhRvV30d7CfCQ9r0AeXj14Mv9Jm_Yd1bRWP28,1088
|
8
|
+
apitally/django.py,sha256=ZsCKTUq4V3nCwIcrO8_3mPQFuPRiriqRSxQ8IPMRoOQ,12922
|
9
|
+
apitally/django_ninja.py,sha256=iMvZd7j04nbOLpJgYxs7tpbsyXlZuhmHjcswXMvyUlU,82
|
10
|
+
apitally/django_rest_framework.py,sha256=iMvZd7j04nbOLpJgYxs7tpbsyXlZuhmHjcswXMvyUlU,82
|
11
|
+
apitally/fastapi.py,sha256=Q3n2bVREKQ_V_2yCQ48ngPtr-NJxDskpT_l20xhSbpM,85
|
12
|
+
apitally/flask.py,sha256=iD2mbFqrWoEFFmDNXUtR32OYwlHob4I3tJT90-kwcnw,5691
|
13
|
+
apitally/litestar.py,sha256=fgpdIlOpXS7TYFM02GUXk78H8WuJgDWMePPsQf-Pw1I,8092
|
14
|
+
apitally/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
15
|
+
apitally/starlette.py,sha256=e0PoLTrihHioLGDF1TThjlsiyYtusa6Or6GKCX7Y9NQ,7881
|
16
|
+
apitally-0.10.1.dist-info/LICENSE,sha256=vbLzC-4TddtXX-_AFEBKMYWRlxC_MN0g66QhPxo8PgY,1065
|
17
|
+
apitally-0.10.1.dist-info/METADATA,sha256=m6jKQm1yML6RCaURdrSzJsn76em3JYScavaPDyCvxQs,6834
|
18
|
+
apitally-0.10.1.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
|
19
|
+
apitally-0.10.1.dist-info/RECORD,,
|
apitally-0.9.0.dist-info/RECORD
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
apitally/__init__.py,sha256=H9NWRZb7NbeRRPLP_V1fARmLNXranorVM-OOY-8_2ug,22
|
2
|
-
apitally/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
-
apitally/client/asyncio.py,sha256=uR5JlH37G6gZvAJ7A1gYOGkjn3zjC-4I6avA1fncXHs,4433
|
4
|
-
apitally/client/base.py,sha256=VWtHTkA6UT5aV37i_CXUvcfmYrabjHGBhzbDU6EeH1A,12785
|
5
|
-
apitally/client/logging.py,sha256=QMsKIIAFo92PNBUleeTgsrsQa7SEal-oJa1oOHUr1wI,507
|
6
|
-
apitally/client/threading.py,sha256=ihQzUStrSQFynpqXgFpseAXrHuc5Et1QvG-YHlzqDr8,4831
|
7
|
-
apitally/common.py,sha256=GbVmnXxhRvV30d7CfCQ9r0AeXj14Mv9Jm_Yd1bRWP28,1088
|
8
|
-
apitally/django.py,sha256=Ym590Tiz1Qnk-IgFcna8r-XkSgcln2riziSPZCwD9nw,12812
|
9
|
-
apitally/django_ninja.py,sha256=iMvZd7j04nbOLpJgYxs7tpbsyXlZuhmHjcswXMvyUlU,82
|
10
|
-
apitally/django_rest_framework.py,sha256=iMvZd7j04nbOLpJgYxs7tpbsyXlZuhmHjcswXMvyUlU,82
|
11
|
-
apitally/fastapi.py,sha256=Q3n2bVREKQ_V_2yCQ48ngPtr-NJxDskpT_l20xhSbpM,85
|
12
|
-
apitally/flask.py,sha256=Utn92aXXl_1f4bKvuf4iZDB4v1vVLpeW5p1tF57Kf-8,5552
|
13
|
-
apitally/litestar.py,sha256=1-skfFDKjYa7y6mOdNvjR4YGtsQbNA0iGQP1jyre41Q,7978
|
14
|
-
apitally/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
15
|
-
apitally/starlette.py,sha256=kyXgzw0L90GUOZCgjuwM3q0uOpPX-hD0TQb2Wgqbqb8,7767
|
16
|
-
apitally-0.9.0.dist-info/LICENSE,sha256=vbLzC-4TddtXX-_AFEBKMYWRlxC_MN0g66QhPxo8PgY,1065
|
17
|
-
apitally-0.9.0.dist-info/METADATA,sha256=SsnJeg47jd8Q8MP9RXC9mbmweeE8ywLCxOLtQks3VKQ,6815
|
18
|
-
apitally-0.9.0.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
|
19
|
-
apitally-0.9.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|