remotivelabs-cli 0.0.1a13__py3-none-any.whl → 0.0.1a15__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.
- cli/cloud/auth_tokens.py +2 -3
- cli/cloud/recordings.py +99 -1
- cli/cloud/rest_helper.py +6 -4
- cli/cloud/service_account_tokens.py +2 -2
- {remotivelabs_cli-0.0.1a13.dist-info → remotivelabs_cli-0.0.1a15.dist-info}/METADATA +1 -1
- {remotivelabs_cli-0.0.1a13.dist-info → remotivelabs_cli-0.0.1a15.dist-info}/RECORD +9 -9
- {remotivelabs_cli-0.0.1a13.dist-info → remotivelabs_cli-0.0.1a15.dist-info}/LICENSE +0 -0
- {remotivelabs_cli-0.0.1a13.dist-info → remotivelabs_cli-0.0.1a15.dist-info}/WHEEL +0 -0
- {remotivelabs_cli-0.0.1a13.dist-info → remotivelabs_cli-0.0.1a15.dist-info}/entry_points.txt +0 -0
cli/cloud/auth_tokens.py
CHANGED
@@ -35,11 +35,10 @@ def list_personal_access_tokens():
|
|
35
35
|
|
36
36
|
@app.command(name="revoke", help="Revoke the specified access token")
|
37
37
|
def revoke(
|
38
|
-
|
38
|
+
name: str = typer.Option(..., help="Name of the access token to revoke")
|
39
39
|
):
|
40
40
|
rest.ensure_auth_token()
|
41
|
-
rest.handle_delete(f'/api/me/keys/{
|
42
|
-
|
41
|
+
rest.handle_delete(f'/api/me/keys/{name}', success_msg="Successfully revoked")
|
43
42
|
|
44
43
|
@app.command()
|
45
44
|
def describe(
|
cli/cloud/recordings.py
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
import sys
|
2
2
|
import signal
|
3
3
|
import re
|
4
|
+
import pathlib
|
4
5
|
from multiprocessing import Process
|
5
6
|
import typer
|
6
7
|
import requests
|
7
8
|
import os
|
9
|
+
|
10
|
+
import glob
|
8
11
|
import json
|
9
12
|
import shutil
|
10
|
-
from rich.progress import Progress, SpinnerColumn, TextColumn
|
13
|
+
from rich.progress import Progress, SpinnerColumn, TextColumn,TaskProgressColumn
|
11
14
|
from . import rest_helper as rest
|
12
15
|
|
13
16
|
app = typer.Typer()
|
@@ -192,6 +195,101 @@ def upload(path: str = typer.Argument(..., help="Path to valid recording to upl
|
|
192
195
|
else:
|
193
196
|
print(r.text)
|
194
197
|
|
198
|
+
@app.command()
|
199
|
+
def upload_broker_configuration(
|
200
|
+
directory:str = typer.Argument(..., help="Configuration directory"),
|
201
|
+
recording_session: str = typer.Option(..., help="Recording session id", envvar='REMOTIVE_CLOUD_RECORDING_SESSION'),
|
202
|
+
project: str = typer.Option(..., help="Project ID", envvar='REMOTIVE_CLOUD_PROJECT'),
|
203
|
+
overwrite: bool = typer.Option(False, help="Overwrite existing configuration if it exists")
|
204
|
+
):
|
205
|
+
with Progress(
|
206
|
+
SpinnerColumn(),
|
207
|
+
TextColumn("[progress.description]{task.description}"),
|
208
|
+
transient=True,
|
209
|
+
) as progress:
|
210
|
+
|
211
|
+
#
|
212
|
+
# List files in specified directory. Look for interfaces.json and use that directory where this is located
|
213
|
+
# as configuration home directory
|
214
|
+
#
|
215
|
+
files = list(filter(lambda item : "interfaces.json" in item, glob.iglob(directory + '**/**', recursive=True)))
|
216
|
+
if len(files) == 0:
|
217
|
+
sys.stderr.write("No interfaces.json found in directory, this file is required")
|
218
|
+
raise typer.Exit(1)
|
219
|
+
if len(files) > 1:
|
220
|
+
sys.stderr.write(f"{len(files)} interfaces.json found in directoryw which is not supported")
|
221
|
+
raise typer.Exit(1)
|
222
|
+
broker_config_dir_name = os.path.dirname(files[0]).rsplit('/', 1)[-1]
|
223
|
+
|
224
|
+
#
|
225
|
+
# Get the current details about broker configurations to see if a config with this
|
226
|
+
# name already exists
|
227
|
+
#
|
228
|
+
task=progress.add_task(description=f"Preparing upload of {broker_config_dir_name}", total=1)
|
229
|
+
details_resp=rest.handle_get(f"/api/project/{project}/files/recording/{recording_session}", return_response=True)
|
230
|
+
details=details_resp.json()
|
231
|
+
existing_configs = details['brokerConfigurations']
|
232
|
+
if (len(existing_configs) > 0):
|
233
|
+
data=list(filter(lambda x : x['name'] == broker_config_dir_name, existing_configs))
|
234
|
+
if len(data) > 0:
|
235
|
+
if (overwrite):
|
236
|
+
rest.handle_delete(f'/api/project/{project}/files/recording/{recording_session}/configuration/{broker_config_dir_name}', quiet=True)
|
237
|
+
else:
|
238
|
+
sys.stderr.write("Broker configuration already exists, use --overwrite to replace\n")
|
239
|
+
raise typer.Exit(1)
|
240
|
+
|
241
|
+
#
|
242
|
+
# From the list of files, create a tuple of local_path to the actual file
|
243
|
+
# and a remote path as it should be stored in cloud
|
244
|
+
#
|
245
|
+
file_infos = list(map(lambda item :
|
246
|
+
{ 'local_path' : item,
|
247
|
+
'remote_path' : f"/{broker_config_dir_name}{item.rsplit(broker_config_dir_name,1)[-1]}"} ,glob.iglob(directory + '**/*.*', recursive=True)))
|
248
|
+
|
249
|
+
#
|
250
|
+
# convert this remote paths and ask cloud to prepare upload urls for those
|
251
|
+
#
|
252
|
+
json_request_upload_urls_req = {
|
253
|
+
'name' : 'not_used',
|
254
|
+
'paths' : list(map(lambda x: x['remote_path'], file_infos))
|
255
|
+
}
|
256
|
+
|
257
|
+
response = rest.handle_put(url = f'/api/project/{project}/files/recording/{recording_session}/configuration', return_response=True, body=json.dumps(json_request_upload_urls_req))
|
258
|
+
if (response.status_code != 200):
|
259
|
+
print(f'Failed to prepare configuration upload')
|
260
|
+
print(f'{response.text} - {response.status_code}')
|
261
|
+
raise typer.Exit(1)
|
262
|
+
progress.update(task, advance=1)
|
263
|
+
|
264
|
+
|
265
|
+
|
266
|
+
task=progress.add_task(description=f"Uploading {broker_config_dir_name}", total=len(file_infos))
|
267
|
+
|
268
|
+
#
|
269
|
+
# Upload urls is a remote_path : upload_url dict
|
270
|
+
# '/my_config/interfaces.json' : "<upload_url>"
|
271
|
+
#
|
272
|
+
upload_urls = json.loads(response.text)
|
273
|
+
|
274
|
+
# For each file - upload
|
275
|
+
for file in file_infos:
|
276
|
+
key=file['remote_path']
|
277
|
+
path=file['local_path']
|
278
|
+
url=upload_urls[key]
|
279
|
+
headers={
|
280
|
+
'Content-Type' : "application/x-www-form-urlencoded"
|
281
|
+
}
|
282
|
+
r = requests.put(url, open(path, 'rb'), headers=headers)
|
283
|
+
progress.update(task, advance=1)
|
284
|
+
if r.status_code != 200:
|
285
|
+
print("Failed to upload broker configuration")
|
286
|
+
print(r.status_code)
|
287
|
+
print(r.text)
|
288
|
+
typer.Exit(1)
|
289
|
+
|
290
|
+
print(f"Successfully uploaded broker configuration {broker_config_dir_name}")
|
291
|
+
|
292
|
+
|
195
293
|
|
196
294
|
@app.command(help="Downloads the specified broker configuration directory as zip file")
|
197
295
|
def download_configuration(
|
cli/cloud/rest_helper.py
CHANGED
@@ -77,17 +77,19 @@ def has_access(url, params={}):
|
|
77
77
|
return True
|
78
78
|
|
79
79
|
|
80
|
-
def handle_delete(url, params={}):
|
80
|
+
def handle_delete(url, params={}, quiet=False, success_msg="Successfully deleted"):
|
81
81
|
ensure_auth_token()
|
82
82
|
r = requests.delete(f'{base_url}{url}', headers=headers, params=params)
|
83
83
|
if r.status_code == 200:
|
84
|
-
|
84
|
+
if quiet == False:
|
85
|
+
print(json.dumps(r.json()))
|
85
86
|
if r.status_code == 204:
|
86
|
-
|
87
|
+
if quiet == False:
|
88
|
+
sys.stderr.write(f'{success_msg}\n')
|
87
89
|
else:
|
88
90
|
print(f'Got status code: {r.status_code}')
|
89
91
|
print(r.text)
|
90
|
-
|
92
|
+
typer.Exit(1)
|
91
93
|
|
92
94
|
def handle_post(url, body=None, params={}, return_response: bool = False):
|
93
95
|
ensure_auth_token()
|
@@ -47,10 +47,10 @@ def list_files():
|
|
47
47
|
|
48
48
|
@app.command(name="revoke", help="Revoke service account access token")
|
49
49
|
def revoke(
|
50
|
+
name: str = typer.Argument(..., help="Access token name"),
|
50
51
|
service_account: str = typer.Option(..., help="Service account name"),
|
51
|
-
token_name: str = typer.Option(..., help="Access token name"),
|
52
52
|
project: str = typer.Option(..., help="Project ID", envvar='REMOTIVE_CLOUD_PROJECT')):
|
53
|
-
rest.handle_delete(f"/api/project/{project}/admin/accounts/{service_account}/keys/{
|
53
|
+
rest.handle_delete(f"/api/project/{project}/admin/accounts/{service_account}/keys/{name}")
|
54
54
|
|
55
55
|
|
56
56
|
def write_token(file, token):
|
@@ -3,22 +3,22 @@ cli/__init__.py,sha256=Mjnyow0Ngm-b-SdPz4HAkREzch7wKZ2Wy_hxLez49Lc,26
|
|
3
3
|
cli/brokers.py,sha256=aBPML6W0nbCaAu5LLHGzRSiPV_TQhB17fi6oPWLb22U,5365
|
4
4
|
cli/cloud/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
5
5
|
cli/cloud/auth.py,sha256=h7xnxGQmZ-8AxbjXstXFy6BD6bsGbkIRlRaRAKZnlw0,3547
|
6
|
-
cli/cloud/auth_tokens.py,sha256=
|
6
|
+
cli/cloud/auth_tokens.py,sha256=WWfnUlwc703JQrv9HyN2aRlhqYV-nvSE_gmrwXWvumE,3141
|
7
7
|
cli/cloud/brokers.py,sha256=-R1F4gpiIUfr8__QbP_CxVvH7ZdVBgKApP7cregn5Uo,3685
|
8
8
|
cli/cloud/cloud_cli.py,sha256=un7h49FbIf-IrW_51cTx2CyBK7pUg4A2zs768p9sxN8,1348
|
9
9
|
cli/cloud/configs.py,sha256=2qPP4XxVO4deVT0srdP4FN6IRj4Ig4i9229thtfO710,3507
|
10
10
|
cli/cloud/projects.py,sha256=w5Oqie80e59XrMNiIxIUIrlt3frYOyOpCbalkqZR7RQ,1366
|
11
|
-
cli/cloud/recordings.py,sha256=
|
12
|
-
cli/cloud/rest_helper.py,sha256=
|
13
|
-
cli/cloud/service_account_tokens.py,sha256=
|
11
|
+
cli/cloud/recordings.py,sha256=k2bfRLD482HOwtjn4CYqGhdIuAzP0R0mzmlI1VrARlc,14592
|
12
|
+
cli/cloud/rest_helper.py,sha256=8mHu-IEku-fs9mLYpJT0uPl7gwgx97dEEXN2u31Y7LA,3688
|
13
|
+
cli/cloud/service_account_tokens.py,sha256=24GebX1JE3ATHfUGSDTZzcH3qmeJ9x34VSpJYGNX_hM,2322
|
14
14
|
cli/cloud/service_accounts.py,sha256=jpiSuteew_9hz0-dtLbLfavM9Bg6Zs2wTbS2a-4FVwM,1630
|
15
15
|
cli/lib/__about__.py,sha256=GLOW8iEx5xn9rbJvxUH3elZiLi47SAWamMjdJTd52k0,141
|
16
16
|
cli/lib/broker.py,sha256=6LUSC4-KhixXHkeclXZblIQ8xLMzmkoJp1ldcnp3el8,5123
|
17
17
|
cli/remotive.py,sha256=3tqaStMU1HZy2BQoNjXOHXw4Sb0-yP80yP3R8SVGK_0,432
|
18
18
|
cli/requirements.txt,sha256=k2SdtUayWWypl_24paMPHrMu7oH0E3_S_9w9zdAng-Y,77
|
19
19
|
cli/test/test_simple.py,sha256=c60_dg5EmhNVmBC6rDcDP-tvKJCBqjIA2Z5Ym9ums4M,63
|
20
|
-
remotivelabs_cli-0.0.
|
21
|
-
remotivelabs_cli-0.0.
|
22
|
-
remotivelabs_cli-0.0.
|
23
|
-
remotivelabs_cli-0.0.
|
24
|
-
remotivelabs_cli-0.0.
|
20
|
+
remotivelabs_cli-0.0.1a15.dist-info/LICENSE,sha256=qDPP_yfuv1fF-u7EfexN-cN3M8aFgGVndGhGLovLKz0,608
|
21
|
+
remotivelabs_cli-0.0.1a15.dist-info/METADATA,sha256=6HskOGehbXCRNcid28l5CfYZy_RsfiBXHKQUBS6HvB0,2790
|
22
|
+
remotivelabs_cli-0.0.1a15.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
23
|
+
remotivelabs_cli-0.0.1a15.dist-info/entry_points.txt,sha256=lvDhPgagLqW_KTnLPCwKSqfYlEp-1uYVosRiPjsVj10,45
|
24
|
+
remotivelabs_cli-0.0.1a15.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{remotivelabs_cli-0.0.1a13.dist-info → remotivelabs_cli-0.0.1a15.dist-info}/entry_points.txt
RENAMED
File without changes
|