videosdkagent-cli 0.0.1__py2.py3-none-any.whl → 0.0.4__py2.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.
- videosdk_cli/auth.py +95 -30
- videosdk_cli/build.py +1387 -287
- videosdk_cli/main.py +69 -36
- videosdk_cli/projects.py +36 -19
- videosdk_cli/templates.py +87 -32
- videosdk_cli/utils/analytics.py +4 -3
- videosdk_cli/utils/api_client.py +26 -24
- videosdk_cli/utils/apis/deployment_client.py +247 -86
- videosdk_cli/utils/apis/videosdk_auth_api_client.py +5 -6
- videosdk_cli/utils/auth_api_client.py +2 -2
- videosdk_cli/utils/manager/agent_manager.py +275 -107
- videosdk_cli/utils/template_helper.py +102 -28
- videosdk_cli/utils/ui/progress_runner.py +15 -7
- videosdk_cli/utils/ui/theme.py +144 -0
- videosdk_cli/utils/videosdk_yaml_helper.py +173 -23
- {videosdkagent_cli-0.0.1.dist-info → videosdkagent_cli-0.0.4.dist-info}/METADATA +2 -2
- videosdkagent_cli-0.0.4.dist-info/RECORD +28 -0
- videosdk_cli/secret_set.py +0 -82
- videosdkagent_cli-0.0.1.dist-info/RECORD +0 -28
- {videosdkagent_cli-0.0.1.dist-info → videosdkagent_cli-0.0.4.dist-info}/WHEEL +0 -0
- {videosdkagent_cli-0.0.1.dist-info → videosdkagent_cli-0.0.4.dist-info}/entry_points.txt +0 -0
videosdk_cli/auth.py
CHANGED
|
@@ -1,57 +1,122 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import click
|
|
3
|
-
from videosdk_cli.utils.config_manager import
|
|
4
|
-
from videosdk_cli.utils.api_client import VideoSDKClient
|
|
3
|
+
from videosdk_cli.utils.config_manager import set_config_value
|
|
5
4
|
from videosdk_cli.utils.auth_api_client import AuthAPIClient
|
|
5
|
+
from videosdk_cli.utils.ui.theme import (
|
|
6
|
+
console,
|
|
7
|
+
print_header,
|
|
8
|
+
print_success,
|
|
9
|
+
print_info,
|
|
10
|
+
PRIMARY,
|
|
11
|
+
MUTED,
|
|
12
|
+
)
|
|
6
13
|
import os
|
|
7
14
|
import webbrowser
|
|
8
15
|
|
|
16
|
+
|
|
17
|
+
@click.group()
|
|
18
|
+
def auth_cli():
|
|
19
|
+
"""
|
|
20
|
+
Authenticate with VideoSDK.
|
|
21
|
+
|
|
22
|
+
Login or logout from your VideoSDK account. Authentication is required
|
|
23
|
+
for deploying and managing agents.
|
|
24
|
+
|
|
25
|
+
\b
|
|
26
|
+
Commands:
|
|
27
|
+
login Authenticate with your VideoSDK account
|
|
28
|
+
logout Remove stored authentication token
|
|
29
|
+
"""
|
|
30
|
+
pass
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@auth_cli.command(name="login")
|
|
34
|
+
def login():
|
|
35
|
+
"""
|
|
36
|
+
Login to your VideoSDK account.
|
|
37
|
+
|
|
38
|
+
Opens a browser window for authentication. After successful login,
|
|
39
|
+
your credentials are stored locally for future CLI commands.
|
|
40
|
+
|
|
41
|
+
\b
|
|
42
|
+
Example:
|
|
43
|
+
$ videosdk auth login
|
|
44
|
+
"""
|
|
45
|
+
try:
|
|
46
|
+
asyncio.run(handle_auth())
|
|
47
|
+
except KeyboardInterrupt:
|
|
48
|
+
console.print(f"\n[{PRIMARY}]Authentication cancelled by user[/{PRIMARY}]")
|
|
49
|
+
except Exception as e:
|
|
50
|
+
raise click.ClickException(f"Authentication failed: Please try again")
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@auth_cli.command(name="logout")
|
|
54
|
+
def logout():
|
|
55
|
+
"""
|
|
56
|
+
Logout from your VideoSDK account.
|
|
57
|
+
|
|
58
|
+
Removes the stored authentication token. You will need to login
|
|
59
|
+
again to use authenticated commands.
|
|
60
|
+
|
|
61
|
+
\b
|
|
62
|
+
Example:
|
|
63
|
+
$ videosdk auth logout
|
|
64
|
+
"""
|
|
65
|
+
try:
|
|
66
|
+
asyncio.run(handle_logout())
|
|
67
|
+
except KeyboardInterrupt:
|
|
68
|
+
console.print(f"\n[{PRIMARY}]Logout cancelled by user[/{PRIMARY}]")
|
|
69
|
+
except Exception as e:
|
|
70
|
+
raise click.ClickException(f"Logout failed: Please try again")
|
|
71
|
+
|
|
72
|
+
|
|
9
73
|
async def handle_auth():
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
74
|
+
from videosdk_cli.utils.template_helper import API_BASE_URL, DASHBOARD_URL
|
|
75
|
+
|
|
76
|
+
client = AuthAPIClient(api_base_url=API_BASE_URL)
|
|
77
|
+
|
|
78
|
+
print_header("Authentication")
|
|
79
|
+
print_info("Initiating browser authentication...")
|
|
13
80
|
|
|
14
81
|
data = await client.start_auth()
|
|
15
82
|
|
|
16
|
-
generated_url=
|
|
83
|
+
generated_url = DASHBOARD_URL + "/cli/confirm-auth?requestId=" + data["requestId"]
|
|
17
84
|
webbrowser.open(generated_url)
|
|
18
85
|
|
|
19
|
-
|
|
86
|
+
print_success(f"Opened authentication URL in browser")
|
|
87
|
+
console.print(f" [{MUTED}]{generated_url}[/{MUTED}]")
|
|
88
|
+
console.print()
|
|
20
89
|
|
|
21
90
|
requestId = data["requestId"]
|
|
22
91
|
expires_in = data["expiresIn"]
|
|
23
92
|
|
|
24
|
-
spinner = ["|", "/", "-", "\\"]
|
|
25
93
|
poll_interval = 3
|
|
26
94
|
attempts = expires_in // poll_interval
|
|
27
95
|
|
|
28
|
-
|
|
96
|
+
with console.status(
|
|
97
|
+
f"[{PRIMARY}]Waiting for authentication...[/{PRIMARY}]", spinner="dots"
|
|
98
|
+
) as status:
|
|
99
|
+
for i in range(attempts):
|
|
100
|
+
await asyncio.sleep(poll_interval)
|
|
29
101
|
|
|
30
|
-
|
|
31
|
-
click.echo(spinner[i % len(spinner)], nl=False)
|
|
32
|
-
click.echo("\b", nl=False)
|
|
33
|
-
await asyncio.sleep(poll_interval)
|
|
102
|
+
auth_status = await client.check_status(requestId)
|
|
34
103
|
|
|
35
|
-
|
|
104
|
+
if auth_status["status"] == "approved":
|
|
105
|
+
set_config_value("VIDEOSDK_AUTH_TOKEN", auth_status["token"])
|
|
106
|
+
status.stop()
|
|
107
|
+
print_success("Successfully authenticated!")
|
|
108
|
+
return
|
|
36
109
|
|
|
37
|
-
|
|
38
|
-
|
|
110
|
+
if auth_status["status"] == "expired":
|
|
111
|
+
status.stop()
|
|
112
|
+
raise click.ClickException(
|
|
113
|
+
"Authentication link expired. Please run `videosdk auth login` again."
|
|
114
|
+
)
|
|
39
115
|
|
|
40
|
-
|
|
41
|
-
f"\n✔ Successfully authenticated)"
|
|
42
|
-
)
|
|
43
|
-
return
|
|
116
|
+
raise click.ClickException("Authentication timed out. Please try again.")
|
|
44
117
|
|
|
45
|
-
if status["status"] == "expired":
|
|
46
|
-
raise click.ClickException(
|
|
47
|
-
"Authentication link expired. Please run `videosdk auth` again."
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
raise click.ClickException(
|
|
51
|
-
"Authentication timed out. Please try again."
|
|
52
|
-
)
|
|
53
118
|
|
|
54
119
|
async def handle_logout():
|
|
120
|
+
print_header("Logout")
|
|
55
121
|
set_config_value("VIDEOSDK_AUTH_TOKEN", None)
|
|
56
|
-
|
|
57
|
-
|
|
122
|
+
print_success("Successfully logged out")
|