uiprotect 7.8.0__py3-none-any.whl → 7.9.0__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.
Potentially problematic release.
This version of uiprotect might be problematic. Click here for more details.
- uiprotect/api.py +35 -2
- uiprotect/cli/__init__.py +18 -0
- uiprotect/cli/base.py +0 -1
- {uiprotect-7.8.0.dist-info → uiprotect-7.9.0.dist-info}/METADATA +1 -1
- {uiprotect-7.8.0.dist-info → uiprotect-7.9.0.dist-info}/RECORD +8 -8
- {uiprotect-7.8.0.dist-info → uiprotect-7.9.0.dist-info}/LICENSE +0 -0
- {uiprotect-7.8.0.dist-info → uiprotect-7.9.0.dist-info}/WHEEL +0 -0
- {uiprotect-7.8.0.dist-info → uiprotect-7.9.0.dist-info}/entry_points.txt +0 -0
uiprotect/api.py
CHANGED
|
@@ -390,12 +390,15 @@ class BaseApiClient:
|
|
|
390
390
|
method: str = "get",
|
|
391
391
|
require_auth: bool = True,
|
|
392
392
|
raise_exception: bool = True,
|
|
393
|
+
api_path: str | None = None,
|
|
393
394
|
**kwargs: Any,
|
|
394
395
|
) -> bytes | None:
|
|
395
|
-
"""Make a request
|
|
396
|
+
"""Make a API request"""
|
|
397
|
+
path = api_path if api_path is not None else self.api_path
|
|
398
|
+
|
|
396
399
|
response = await self.request(
|
|
397
400
|
method,
|
|
398
|
-
f"{
|
|
401
|
+
f"{path}{url}",
|
|
399
402
|
require_auth=require_auth,
|
|
400
403
|
auto_close=False,
|
|
401
404
|
**kwargs,
|
|
@@ -449,6 +452,7 @@ class BaseApiClient:
|
|
|
449
452
|
method: str = "get",
|
|
450
453
|
require_auth: bool = True,
|
|
451
454
|
raise_exception: bool = True,
|
|
455
|
+
api_path: str | None = None,
|
|
452
456
|
**kwargs: Any,
|
|
453
457
|
) -> list[Any] | dict[str, Any] | None:
|
|
454
458
|
data = await self.api_request_raw(
|
|
@@ -456,6 +460,7 @@ class BaseApiClient:
|
|
|
456
460
|
method=method,
|
|
457
461
|
require_auth=require_auth,
|
|
458
462
|
raise_exception=raise_exception,
|
|
463
|
+
api_path=api_path,
|
|
459
464
|
**kwargs,
|
|
460
465
|
)
|
|
461
466
|
|
|
@@ -2038,3 +2043,31 @@ class ProtectApiClient(BaseApiClient):
|
|
|
2038
2043
|
method="post",
|
|
2039
2044
|
)
|
|
2040
2045
|
return PTZPreset(**preset)
|
|
2046
|
+
|
|
2047
|
+
async def create_api_key(self, name: str) -> str:
|
|
2048
|
+
"""Create an API key with the given name and return the full API key."""
|
|
2049
|
+
if not name:
|
|
2050
|
+
raise BadRequest("API key name cannot be empty")
|
|
2051
|
+
|
|
2052
|
+
user_id = None
|
|
2053
|
+
if self._last_token_cookie_decode is not None:
|
|
2054
|
+
user_id = self._last_token_cookie_decode.get("userId")
|
|
2055
|
+
if not user_id:
|
|
2056
|
+
raise BadRequest("User ID not available for API key creation")
|
|
2057
|
+
|
|
2058
|
+
response = await self.api_request(
|
|
2059
|
+
api_path="/proxy/users/api/v2",
|
|
2060
|
+
url=f"/user/{user_id}/keys",
|
|
2061
|
+
method="post",
|
|
2062
|
+
json={"name": name},
|
|
2063
|
+
)
|
|
2064
|
+
|
|
2065
|
+
if (
|
|
2066
|
+
not isinstance(response, dict)
|
|
2067
|
+
or "data" not in response
|
|
2068
|
+
or not isinstance(response["data"], dict)
|
|
2069
|
+
or "full_api_key" not in response["data"]
|
|
2070
|
+
):
|
|
2071
|
+
raise BadRequest("Failed to create API key")
|
|
2072
|
+
|
|
2073
|
+
return response["data"]["full_api_key"]
|
uiprotect/cli/__init__.py
CHANGED
|
@@ -320,3 +320,21 @@ def release_versions(ctx: typer.Context) -> None:
|
|
|
320
320
|
|
|
321
321
|
Path(RELEASE_CACHE).write_bytes(output)
|
|
322
322
|
typer.echo(output.decode("utf-8"))
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
@app.command()
|
|
326
|
+
def create_api_key(
|
|
327
|
+
ctx: typer.Context,
|
|
328
|
+
name: str = typer.Argument(..., help="Name for the API key"),
|
|
329
|
+
) -> None:
|
|
330
|
+
"""Create a new API key for the current user."""
|
|
331
|
+
protect = cast(ProtectApiClient, ctx.obj.protect)
|
|
332
|
+
|
|
333
|
+
async def callback() -> str:
|
|
334
|
+
api_key = await protect.create_api_key(name)
|
|
335
|
+
await protect.close_session()
|
|
336
|
+
return api_key
|
|
337
|
+
|
|
338
|
+
_setup_logger()
|
|
339
|
+
result = run_async(callback())
|
|
340
|
+
typer.echo(result)
|
uiprotect/cli/base.py
CHANGED
|
@@ -223,7 +223,6 @@ def init_common_commands(
|
|
|
223
223
|
device_commands: dict[str, Callable[..., Any]] = {}
|
|
224
224
|
|
|
225
225
|
deviceless_commands["list-ids"] = app.command()(list_ids)
|
|
226
|
-
device_commands["protect-url"] = app.command()(protect_url)
|
|
227
226
|
device_commands["is-wired"] = app.command()(is_wired)
|
|
228
227
|
device_commands["is-wifi"] = app.command()(is_wifi)
|
|
229
228
|
device_commands["is-bluetooth"] = app.command()(is_bluetooth)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
uiprotect/__init__.py,sha256=Oz6i1tonIz4QWVnEPkbielJDJ3WQdwZVgYtjY4IwGAQ,636
|
|
2
2
|
uiprotect/__main__.py,sha256=C_bHCOkv5qj6WMy-6ELoY3Y6HDhLxOa1a30CzmbZhsg,462
|
|
3
3
|
uiprotect/_compat.py,sha256=HThmb1zQZCEssCxYYbQzFhJq8zYYlVaSnIEZabKc-6U,302
|
|
4
|
-
uiprotect/api.py,sha256=
|
|
5
|
-
uiprotect/cli/__init__.py,sha256=
|
|
4
|
+
uiprotect/api.py,sha256=1rNElQNITuhXeRAOxLXBS0vIcASvYTxuQOY0FuGwGU8,71606
|
|
5
|
+
uiprotect/cli/__init__.py,sha256=B70Zdwq4cdw3wyu39uY0lMkjk5EoWLRIfVncuTOZ4AE,9423
|
|
6
6
|
uiprotect/cli/aiports.py,sha256=wpEr2w_hY18CGpFiQM2Yc0FiVwG_1l2CzZhZLGNigvI,1576
|
|
7
7
|
uiprotect/cli/backup.py,sha256=ZiS7RZnJGKI8TJKLW2cOUzkRM8nyTvE5Ov_jZZGtvSM,36708
|
|
8
|
-
uiprotect/cli/base.py,sha256=
|
|
8
|
+
uiprotect/cli/base.py,sha256=5-z-IS8g9iQqhR_YbjxaJAFiMMAY_7cCtNAtvLdRCoM,7524
|
|
9
9
|
uiprotect/cli/cameras.py,sha256=YvvMccQEYG3Wih0Ix8tan1R1vfaJ6cogg6YKWLzMUV8,16973
|
|
10
10
|
uiprotect/cli/chimes.py,sha256=XANn21bQVkestkKOm9HjxSM8ZGrRrqvUXLouaQ3LTqs,5326
|
|
11
11
|
uiprotect/cli/doorlocks.py,sha256=Go_Tn68bAcmrRAnUIi4kBiR7ciKQsu_R150ubPTjUAs,3523
|
|
@@ -32,8 +32,8 @@ uiprotect/test_util/__init__.py,sha256=HlQBgIgdtrvT-gQ5OWP92LbgVr_YzsD5NFImLRonU
|
|
|
32
32
|
uiprotect/test_util/anonymize.py,sha256=f-8ijU-_y9r-uAbhIPn0f0I6hzJpAkvJzc8UpWihObI,8478
|
|
33
33
|
uiprotect/utils.py,sha256=5Z30chqnQhQdtD1vabRtZXjBpeiJagL5KDuALQlWxk8,20559
|
|
34
34
|
uiprotect/websocket.py,sha256=tEyenqblNXHcjWYuf4oRP1E7buNwx6zoECMwpBr-jig,8191
|
|
35
|
-
uiprotect-7.
|
|
36
|
-
uiprotect-7.
|
|
37
|
-
uiprotect-7.
|
|
38
|
-
uiprotect-7.
|
|
39
|
-
uiprotect-7.
|
|
35
|
+
uiprotect-7.9.0.dist-info/LICENSE,sha256=INx18jhdbVXMEiiBANeKEbrbz57ckgzxk5uutmmcxGk,1111
|
|
36
|
+
uiprotect-7.9.0.dist-info/METADATA,sha256=ne29AflkRuWI3sEicYeWB7xt9IUGLE4MYCoT97g3C4c,11108
|
|
37
|
+
uiprotect-7.9.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
38
|
+
uiprotect-7.9.0.dist-info/entry_points.txt,sha256=J78AUTPrTTxgI3s7SVgrmGqDP7piX2wuuEORzhDdVRA,47
|
|
39
|
+
uiprotect-7.9.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|