uiprotect 7.14.2__tar.gz → 7.15.1__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.
Potentially problematic release.
This version of uiprotect might be problematic. Click here for more details.
- {uiprotect-7.14.2 → uiprotect-7.15.1}/PKG-INFO +1 -1
- {uiprotect-7.14.2 → uiprotect-7.15.1}/pyproject.toml +1 -1
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/api.py +28 -8
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/cli/__init__.py +4 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/cli/backup.py +1 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/cli/base.py +1 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/test_util/__init__.py +1 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/LICENSE +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/README.md +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/__init__.py +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/__main__.py +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/_compat.py +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/cli/aiports.py +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/cli/cameras.py +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/cli/chimes.py +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/cli/doorlocks.py +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/cli/events.py +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/cli/lights.py +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/cli/liveviews.py +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/cli/nvr.py +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/cli/sensors.py +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/cli/viewers.py +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/data/__init__.py +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/data/base.py +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/data/bootstrap.py +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/data/convert.py +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/data/devices.py +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/data/nvr.py +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/data/types.py +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/data/user.py +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/data/websocket.py +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/exceptions.py +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/py.typed +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/release_cache.json +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/stream.py +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/test_util/anonymize.py +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/utils.py +0 -0
- {uiprotect-7.14.2 → uiprotect-7.15.1}/src/uiprotect/websocket.py +0 -0
|
@@ -169,6 +169,7 @@ class BaseApiClient:
|
|
|
169
169
|
_last_token_cookie: Morsel[str] | None = None
|
|
170
170
|
_last_token_cookie_decode: dict[str, Any] | None = None
|
|
171
171
|
_session: aiohttp.ClientSession | None = None
|
|
172
|
+
_public_api_session: aiohttp.ClientSession | None = None
|
|
172
173
|
_loaded_session: bool = False
|
|
173
174
|
_cookiename = "TOKEN"
|
|
174
175
|
|
|
@@ -192,6 +193,7 @@ class BaseApiClient:
|
|
|
192
193
|
api_key: str | None = None,
|
|
193
194
|
verify_ssl: bool = True,
|
|
194
195
|
session: aiohttp.ClientSession | None = None,
|
|
196
|
+
public_api_session: aiohttp.ClientSession | None = None,
|
|
195
197
|
ws_timeout: int = 30,
|
|
196
198
|
cache_dir: Path | None = None,
|
|
197
199
|
config_dir: Path | None = None,
|
|
@@ -218,6 +220,9 @@ class BaseApiClient:
|
|
|
218
220
|
if session is not None:
|
|
219
221
|
self._session = session
|
|
220
222
|
|
|
223
|
+
if public_api_session is not None:
|
|
224
|
+
self._public_api_session = public_api_session
|
|
225
|
+
|
|
221
226
|
self._update_url()
|
|
222
227
|
|
|
223
228
|
def _update_cookiename(self, cookie: SimpleCookie) -> None:
|
|
@@ -261,6 +266,15 @@ class BaseApiClient:
|
|
|
261
266
|
|
|
262
267
|
return self._session
|
|
263
268
|
|
|
269
|
+
async def get_public_api_session(self) -> aiohttp.ClientSession:
|
|
270
|
+
"""Gets or creates current public API client session"""
|
|
271
|
+
if self._public_api_session is None or self._public_api_session.closed:
|
|
272
|
+
if self._public_api_session is not None and self._public_api_session.closed:
|
|
273
|
+
_LOGGER.debug("Public API session was closed, creating a new one")
|
|
274
|
+
self._public_api_session = aiohttp.ClientSession()
|
|
275
|
+
|
|
276
|
+
return self._public_api_session
|
|
277
|
+
|
|
264
278
|
async def _auth_websocket(self, force: bool) -> dict[str, str] | None:
|
|
265
279
|
"""Authenticate for Websocket."""
|
|
266
280
|
if force:
|
|
@@ -306,6 +320,12 @@ class BaseApiClient:
|
|
|
306
320
|
self._session = None
|
|
307
321
|
self._loaded_session = False
|
|
308
322
|
|
|
323
|
+
async def close_public_api_session(self) -> None:
|
|
324
|
+
"""Closing and deletes public API client session"""
|
|
325
|
+
if self._public_api_session is not None:
|
|
326
|
+
await self._public_api_session.close()
|
|
327
|
+
self._public_api_session = None
|
|
328
|
+
|
|
309
329
|
async def _cancel_update_task(self) -> None:
|
|
310
330
|
if self._update_task:
|
|
311
331
|
self._update_task.cancel()
|
|
@@ -345,7 +365,11 @@ class BaseApiClient:
|
|
|
345
365
|
_LOGGER.debug("Request url: %s", request_url)
|
|
346
366
|
if not self._verify_ssl:
|
|
347
367
|
kwargs["ssl"] = False
|
|
348
|
-
|
|
368
|
+
|
|
369
|
+
if public_api:
|
|
370
|
+
session = await self.get_public_api_session()
|
|
371
|
+
else:
|
|
372
|
+
session = await self.get_session()
|
|
349
373
|
|
|
350
374
|
for attempt in range(2):
|
|
351
375
|
try:
|
|
@@ -777,6 +801,7 @@ class ProtectApiClient(BaseApiClient):
|
|
|
777
801
|
api_key: str | None = None,
|
|
778
802
|
verify_ssl: bool = True,
|
|
779
803
|
session: aiohttp.ClientSession | None = None,
|
|
804
|
+
public_api_session: aiohttp.ClientSession | None = None,
|
|
780
805
|
ws_timeout: int = 30,
|
|
781
806
|
cache_dir: Path | None = None,
|
|
782
807
|
config_dir: Path | None = None,
|
|
@@ -797,6 +822,7 @@ class ProtectApiClient(BaseApiClient):
|
|
|
797
822
|
api_key=api_key,
|
|
798
823
|
verify_ssl=verify_ssl,
|
|
799
824
|
session=session,
|
|
825
|
+
public_api_session=public_api_session,
|
|
800
826
|
ws_timeout=ws_timeout,
|
|
801
827
|
ws_receive_timeout=ws_receive_timeout,
|
|
802
828
|
cache_dir=cache_dir,
|
|
@@ -2063,15 +2089,9 @@ class ProtectApiClient(BaseApiClient):
|
|
|
2063
2089
|
if not name:
|
|
2064
2090
|
raise BadRequest("API key name cannot be empty")
|
|
2065
2091
|
|
|
2066
|
-
user_id = None
|
|
2067
|
-
if self._last_token_cookie_decode is not None:
|
|
2068
|
-
user_id = self._last_token_cookie_decode.get("userId")
|
|
2069
|
-
if not user_id:
|
|
2070
|
-
raise BadRequest("User ID not available for API key creation")
|
|
2071
|
-
|
|
2072
2092
|
response = await self.api_request(
|
|
2073
2093
|
api_path="/proxy/users/api/v2",
|
|
2074
|
-
url=
|
|
2094
|
+
url="/user/self/keys",
|
|
2075
2095
|
method="post",
|
|
2076
2096
|
json={"name": name},
|
|
2077
2097
|
)
|
|
@@ -173,6 +173,7 @@ def main(
|
|
|
173
173
|
async def update() -> None:
|
|
174
174
|
protect._bootstrap = await protect.get_bootstrap()
|
|
175
175
|
await protect.close_session()
|
|
176
|
+
await protect.close_public_api_session()
|
|
176
177
|
|
|
177
178
|
run_async(update())
|
|
178
179
|
ctx.obj = CliContext(protect=protect, output_format=output_format)
|
|
@@ -286,6 +287,7 @@ def profile_ws(
|
|
|
286
287
|
unsub()
|
|
287
288
|
await protect.async_disconnect_ws()
|
|
288
289
|
await protect.close_session()
|
|
290
|
+
await protect.close_public_api_session()
|
|
289
291
|
|
|
290
292
|
_setup_logger()
|
|
291
293
|
|
|
@@ -325,6 +327,7 @@ def create_api_key(
|
|
|
325
327
|
async def callback() -> str:
|
|
326
328
|
api_key = await protect.create_api_key(name)
|
|
327
329
|
await protect.close_session()
|
|
330
|
+
await protect.close_public_api_session()
|
|
328
331
|
return api_key
|
|
329
332
|
|
|
330
333
|
_setup_logger()
|
|
@@ -340,6 +343,7 @@ def get_meta_info(ctx: typer.Context) -> None:
|
|
|
340
343
|
async def callback() -> MetaInfo:
|
|
341
344
|
meta = await protect.get_meta_info()
|
|
342
345
|
await protect.close_session()
|
|
346
|
+
await protect.close_public_api_session()
|
|
343
347
|
return meta
|
|
344
348
|
|
|
345
349
|
_setup_logger()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|