cmem-cmemc 23.2__py3-none-any.whl → 23.3.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.
- cmem/cmemc/cli/__init__.py +9 -3
- cmem/cmemc/cli/_cmemc.zsh +44 -0
- cmem/cmemc/cli/commands/__init__.py +1 -0
- cmem/cmemc/cli/commands/admin.py +1 -1
- cmem/cmemc/cli/commands/client.py +2 -2
- cmem/cmemc/cli/commands/config.py +1 -1
- cmem/cmemc/cli/commands/dataset.py +104 -59
- cmem/cmemc/cli/commands/graph.py +10 -10
- cmem/cmemc/cli/commands/metrics.py +3 -3
- cmem/cmemc/cli/commands/project.py +50 -14
- cmem/cmemc/cli/commands/python.py +110 -29
- cmem/cmemc/cli/commands/query.py +6 -6
- cmem/cmemc/cli/commands/resource.py +5 -5
- cmem/cmemc/cli/commands/scheduler.py +4 -4
- cmem/cmemc/cli/commands/store.py +34 -31
- cmem/cmemc/cli/commands/user.py +6 -6
- cmem/cmemc/cli/commands/variable.py +364 -0
- cmem/cmemc/cli/commands/vocabulary.py +5 -5
- cmem/cmemc/cli/commands/workflow.py +73 -29
- cmem/cmemc/cli/commands/workspace.py +5 -5
- cmem/cmemc/cli/completion.py +269 -159
- cmem/cmemc/cli/context.py +20 -3
- cmem/cmemc/cli/manual_helper/multi_page.py +9 -6
- cmem/cmemc/cli/utils.py +80 -0
- {cmem_cmemc-23.2.dist-info → cmem_cmemc-23.3.0.dist-info}/METADATA +4 -4
- cmem_cmemc-23.3.0.dist-info/RECORD +35 -0
- {cmem_cmemc-23.2.dist-info → cmem_cmemc-23.3.0.dist-info}/WHEEL +1 -1
- cmem_cmemc-23.2.dist-info/RECORD +0 -33
- {cmem_cmemc-23.2.dist-info → cmem_cmemc-23.3.0.dist-info}/LICENSE +0 -0
- {cmem_cmemc-23.2.dist-info → cmem_cmemc-23.3.0.dist-info}/entry_points.txt +0 -0
|
@@ -5,6 +5,7 @@ import tempfile
|
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
from zipfile import ZipFile
|
|
7
7
|
import click
|
|
8
|
+
from click import UsageError
|
|
8
9
|
from jinja2 import Template
|
|
9
10
|
|
|
10
11
|
from cmem.cmemc.cli import completion
|
|
@@ -24,10 +25,11 @@ from cmem.cmempy.workspace.projects.project import (
|
|
|
24
25
|
delete_project,
|
|
25
26
|
get_failed_tasks_report,
|
|
26
27
|
get_projects,
|
|
27
|
-
make_new_project,
|
|
28
28
|
reload_project,
|
|
29
|
-
create_project_with_transformation
|
|
29
|
+
create_project_with_transformation,
|
|
30
|
+
make_new_project_with_metadata
|
|
30
31
|
)
|
|
32
|
+
from cmem.cmemc.cli.commands.variable import variable
|
|
31
33
|
|
|
32
34
|
|
|
33
35
|
def _show_type_list(app):
|
|
@@ -62,7 +64,7 @@ def _show_type_list(app):
|
|
|
62
64
|
nargs=-1,
|
|
63
65
|
required=True,
|
|
64
66
|
type=click.STRING,
|
|
65
|
-
|
|
67
|
+
shell_complete=completion.project_ids
|
|
66
68
|
)
|
|
67
69
|
@click.pass_obj
|
|
68
70
|
def open_command(app, project_ids):
|
|
@@ -136,7 +138,7 @@ def list_command(app, raw, id_only):
|
|
|
136
138
|
"project_ids",
|
|
137
139
|
nargs=-1,
|
|
138
140
|
type=click.STRING,
|
|
139
|
-
|
|
141
|
+
shell_complete=completion.project_ids
|
|
140
142
|
)
|
|
141
143
|
@click.pass_obj
|
|
142
144
|
def delete_command(app, all_, project_ids):
|
|
@@ -183,7 +185,7 @@ def delete_command(app, all_, project_ids):
|
|
|
183
185
|
@click.option(
|
|
184
186
|
"--from-transformation",
|
|
185
187
|
nargs=1,
|
|
186
|
-
|
|
188
|
+
shell_complete=completion.transformation_task_ids,
|
|
187
189
|
required=False,
|
|
188
190
|
help=(
|
|
189
191
|
"This option can be used to explicitly create the link specification, "
|
|
@@ -191,8 +193,20 @@ def delete_command(app, all_, project_ids):
|
|
|
191
193
|
"a transformation task. You need the task ID of the transformation task."
|
|
192
194
|
),
|
|
193
195
|
)
|
|
196
|
+
@click.option(
|
|
197
|
+
"--label", "labels",
|
|
198
|
+
multiple=True,
|
|
199
|
+
help="Give the label of the project. You can give more than one label if you"
|
|
200
|
+
" create more than one project."
|
|
201
|
+
)
|
|
202
|
+
@click.option(
|
|
203
|
+
"--description", "descriptions",
|
|
204
|
+
multiple=True,
|
|
205
|
+
help="Give the description of the project. You can give more than one description"
|
|
206
|
+
" if you create more than one project."
|
|
207
|
+
)
|
|
194
208
|
@click.pass_obj
|
|
195
|
-
def create_command(app, project_ids, from_transformation):
|
|
209
|
+
def create_command(app, project_ids, from_transformation, labels, descriptions):
|
|
196
210
|
"""Create projects.
|
|
197
211
|
|
|
198
212
|
This command creates one or more new projects.
|
|
@@ -232,13 +246,34 @@ def create_command(app, project_ids, from_transformation):
|
|
|
232
246
|
|
|
233
247
|
count = len(project_ids)
|
|
234
248
|
current = 1
|
|
249
|
+
if len(labels) > 0 and len(labels) != count:
|
|
250
|
+
raise UsageError(
|
|
251
|
+
"Either give labels for all projects or for no project."
|
|
252
|
+
f" Got {len(labels)} labels but {count} projects."
|
|
253
|
+
)
|
|
254
|
+
if len(descriptions) > 0 and len(descriptions) != count:
|
|
255
|
+
raise UsageError(
|
|
256
|
+
"Either give descriptions for all projects or for no project."
|
|
257
|
+
f" Got {len(descriptions)} descriptions but {count} projects."
|
|
258
|
+
)
|
|
259
|
+
|
|
235
260
|
for project_id in project_ids:
|
|
261
|
+
try:
|
|
262
|
+
label = labels[current - 1]
|
|
263
|
+
except IndexError:
|
|
264
|
+
label = project_id
|
|
265
|
+
try:
|
|
266
|
+
description = descriptions[current - 1]
|
|
267
|
+
except IndexError:
|
|
268
|
+
description = ""
|
|
236
269
|
app.echo_info(
|
|
237
270
|
f"Create new project {current}/{count}: {project_id} ... ",
|
|
238
271
|
nl=False
|
|
239
272
|
)
|
|
240
273
|
app.echo_debug(get_projects())
|
|
241
|
-
|
|
274
|
+
make_new_project_with_metadata(
|
|
275
|
+
project_id, label=label, description=description
|
|
276
|
+
)
|
|
242
277
|
app.echo_success("done")
|
|
243
278
|
current = current + 1
|
|
244
279
|
|
|
@@ -264,7 +299,7 @@ def create_command(app, project_ids, from_transformation):
|
|
|
264
299
|
writable=True,
|
|
265
300
|
file_okay=False
|
|
266
301
|
),
|
|
267
|
-
#
|
|
302
|
+
# shell_complete=directories,
|
|
268
303
|
help="The base directory, where the project files will be created. "
|
|
269
304
|
"If this directory does not exist, it will be silently created."
|
|
270
305
|
)
|
|
@@ -273,7 +308,7 @@ def create_command(app, project_ids, from_transformation):
|
|
|
273
308
|
default="xmlZip",
|
|
274
309
|
show_default=True,
|
|
275
310
|
type=click.STRING,
|
|
276
|
-
|
|
311
|
+
shell_complete=completion.marshalling_plugins,
|
|
277
312
|
help="Type of the exported project file(s). Use the --help-types option "
|
|
278
313
|
"or tab completion to see a list of possible types."
|
|
279
314
|
)
|
|
@@ -282,7 +317,7 @@ def create_command(app, project_ids, from_transformation):
|
|
|
282
317
|
default="{{date}}-{{connection}}-{{id}}.project",
|
|
283
318
|
show_default=True,
|
|
284
319
|
type=click.STRING,
|
|
285
|
-
|
|
320
|
+
shell_complete=completion.project_export_templates,
|
|
286
321
|
help="Template for the export file name(s). "
|
|
287
322
|
"Possible placeholders are (Jinja2): "
|
|
288
323
|
"{{id}} (the project ID), "
|
|
@@ -309,7 +344,7 @@ def create_command(app, project_ids, from_transformation):
|
|
|
309
344
|
"project_ids",
|
|
310
345
|
nargs=-1,
|
|
311
346
|
type=click.STRING,
|
|
312
|
-
|
|
347
|
+
shell_complete=completion.project_ids
|
|
313
348
|
)
|
|
314
349
|
@click.pass_obj
|
|
315
350
|
def export_command(
|
|
@@ -408,7 +443,7 @@ def export_command(
|
|
|
408
443
|
@click.command(cls=CmemcCommand, name="import")
|
|
409
444
|
@click.argument(
|
|
410
445
|
"path",
|
|
411
|
-
|
|
446
|
+
shell_complete=completion.project_files,
|
|
412
447
|
type=click.Path(
|
|
413
448
|
allow_dash=False,
|
|
414
449
|
dir_okay=True,
|
|
@@ -421,7 +456,7 @@ def export_command(
|
|
|
421
456
|
type=click.STRING,
|
|
422
457
|
required=False,
|
|
423
458
|
default='',
|
|
424
|
-
|
|
459
|
+
shell_complete=completion.project_ids
|
|
425
460
|
)
|
|
426
461
|
@click.option(
|
|
427
462
|
"-o", "--overwrite",
|
|
@@ -518,7 +553,7 @@ def import_command(app, path, project_id, overwrite):
|
|
|
518
553
|
"project_ids",
|
|
519
554
|
nargs=-1,
|
|
520
555
|
type=click.STRING,
|
|
521
|
-
|
|
556
|
+
shell_complete=completion.project_ids
|
|
522
557
|
)
|
|
523
558
|
@click.pass_obj
|
|
524
559
|
def reload_command(app, all_, project_ids):
|
|
@@ -583,3 +618,4 @@ project.add_command(import_command)
|
|
|
583
618
|
project.add_command(delete_command)
|
|
584
619
|
project.add_command(create_command)
|
|
585
620
|
project.add_command(reload_command)
|
|
621
|
+
project.add_command(variable)
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"""DataIntegration python management commands."""
|
|
2
2
|
import sys
|
|
3
|
+
from dataclasses import asdict
|
|
3
4
|
from re import match
|
|
4
5
|
|
|
5
6
|
import click
|
|
7
|
+
from click import UsageError
|
|
6
8
|
|
|
7
9
|
from cmem.cmemc.cli import completion
|
|
8
10
|
from cmem.cmemc.cli.commands import CmemcCommand, CmemcGroup
|
|
@@ -12,6 +14,7 @@ from cmem.cmempy.workspace.python import (
|
|
|
12
14
|
list_packages, list_plugins,
|
|
13
15
|
uninstall_package, update_plugins
|
|
14
16
|
)
|
|
17
|
+
from cmem.cmemc.cli.utils import get_published_packages
|
|
15
18
|
|
|
16
19
|
|
|
17
20
|
def _get_package_id(module_name: str) -> str:
|
|
@@ -29,7 +32,7 @@ def _looks_like_a_package(package: str) -> bool:
|
|
|
29
32
|
@click.command(cls=CmemcCommand, name="install")
|
|
30
33
|
@click.argument(
|
|
31
34
|
"PACKAGE",
|
|
32
|
-
|
|
35
|
+
shell_complete=completion.installable_packages,
|
|
33
36
|
type=click.Path(
|
|
34
37
|
readable=True,
|
|
35
38
|
allow_dash=False,
|
|
@@ -79,34 +82,58 @@ def install_command(app: ApplicationContext, package):
|
|
|
79
82
|
@click.command(cls=CmemcCommand, name="uninstall")
|
|
80
83
|
@click.argument(
|
|
81
84
|
"PACKAGE_NAME",
|
|
82
|
-
|
|
85
|
+
nargs=-1,
|
|
86
|
+
shell_complete=completion.installed_package_names
|
|
87
|
+
)
|
|
88
|
+
@click.option(
|
|
89
|
+
"-a", "--all", "all_",
|
|
90
|
+
is_flag=True,
|
|
91
|
+
help="This option removes all installed packages from the system,"
|
|
92
|
+
" leaving only the pre-installed mandatory packages in the environment."
|
|
83
93
|
)
|
|
84
94
|
@click.pass_obj
|
|
85
|
-
def uninstall_command(app: ApplicationContext, package_name):
|
|
86
|
-
"""Uninstall a python
|
|
95
|
+
def uninstall_command(app: ApplicationContext, package_name, all_):
|
|
96
|
+
"""Uninstall a python packages from the workspace.
|
|
87
97
|
|
|
88
98
|
This command is essentially a `pip uninstall` in the remote
|
|
89
99
|
python environment.
|
|
90
100
|
"""
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
101
|
+
if all_:
|
|
102
|
+
app.echo_info(
|
|
103
|
+
"Wiping Python environment ... ",
|
|
104
|
+
nl=False
|
|
105
|
+
)
|
|
106
|
+
response = uninstall_package(package_name="--all")
|
|
107
|
+
app.echo_success("done")
|
|
108
|
+
app.echo_debug("Updated Plugins: " + str(update_plugins()))
|
|
109
|
+
return
|
|
110
|
+
|
|
111
|
+
if not package_name:
|
|
112
|
+
raise UsageError(
|
|
113
|
+
"Either give at least one package name or wipe the whole python"
|
|
114
|
+
" environment with the '--all' option."
|
|
115
|
+
)
|
|
95
116
|
packages = list_packages()
|
|
96
117
|
app.echo_debug(packages)
|
|
97
|
-
|
|
98
|
-
app.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
118
|
+
for _ in package_name:
|
|
119
|
+
app.echo_info(
|
|
120
|
+
f"Uninstall package {_} ... ",
|
|
121
|
+
nl=False
|
|
122
|
+
)
|
|
123
|
+
if _ not in [package["name"] for package in packages]:
|
|
124
|
+
app.echo_error("not installed")
|
|
125
|
+
app.echo_debug("Updated Plugins: " + str(update_plugins()))
|
|
126
|
+
sys.exit(1)
|
|
127
|
+
response = uninstall_package(package_name=_)
|
|
128
|
+
for output_line in response["standardOutput"].splitlines():
|
|
129
|
+
app.echo_debug(output_line)
|
|
130
|
+
if response["success"]:
|
|
131
|
+
app.echo_success("done")
|
|
132
|
+
if len(response["errorOutput"].strip()) > 0:
|
|
133
|
+
app.echo_warning(response["errorOutput"])
|
|
134
|
+
else:
|
|
135
|
+
app.echo_error("error")
|
|
136
|
+
app.echo_debug(response.content.decode())
|
|
110
137
|
app.echo_debug("Updated Plugins: " + str(update_plugins()))
|
|
111
138
|
|
|
112
139
|
|
|
@@ -122,30 +149,65 @@ def uninstall_command(app: ApplicationContext, package_name):
|
|
|
122
149
|
help="Lists only package identifier. "
|
|
123
150
|
"This is useful for piping the IDs into other commands."
|
|
124
151
|
)
|
|
152
|
+
@click.option(
|
|
153
|
+
"--available",
|
|
154
|
+
is_flag=True,
|
|
155
|
+
help="Instead of listing installed packages, this option lists installable packages"
|
|
156
|
+
" from pypi.org, which are prefixed with 'cmem-plugin-' and so are most likely"
|
|
157
|
+
" Corporate Memory plugin packages."
|
|
158
|
+
)
|
|
125
159
|
@click.pass_obj
|
|
126
|
-
def list_command(app: ApplicationContext, raw, id_only):
|
|
160
|
+
def list_command(app: ApplicationContext, raw, id_only, available):
|
|
127
161
|
"""List installed python packages.
|
|
128
162
|
|
|
129
163
|
This command is essentially a `pip list` in the remote python environment.
|
|
130
164
|
|
|
131
165
|
It outputs a table of python package identifiers with version information.
|
|
132
166
|
"""
|
|
133
|
-
|
|
167
|
+
if available:
|
|
168
|
+
published_packages = get_published_packages()
|
|
169
|
+
|
|
170
|
+
if raw:
|
|
171
|
+
app.echo_info_json(
|
|
172
|
+
[asdict(_) for _ in published_packages]
|
|
173
|
+
)
|
|
174
|
+
return
|
|
175
|
+
|
|
176
|
+
if id_only:
|
|
177
|
+
for _ in published_packages:
|
|
178
|
+
app.echo_info(_.name)
|
|
179
|
+
return
|
|
180
|
+
|
|
181
|
+
table_published = []
|
|
182
|
+
for _ in published_packages:
|
|
183
|
+
table_published.append(
|
|
184
|
+
(_.name, _.version, str(_.published)[:10], _.description)
|
|
185
|
+
)
|
|
186
|
+
app.echo_info_table(
|
|
187
|
+
table_published,
|
|
188
|
+
headers=["Name", "Version", "Published", "Description"],
|
|
189
|
+
sort_column=0
|
|
190
|
+
)
|
|
191
|
+
return
|
|
192
|
+
|
|
193
|
+
installed_packages = list_packages()
|
|
134
194
|
if raw:
|
|
135
|
-
app.echo_info_json(
|
|
195
|
+
app.echo_info_json(installed_packages)
|
|
136
196
|
return
|
|
197
|
+
|
|
137
198
|
if id_only:
|
|
138
|
-
for package in
|
|
199
|
+
for package in installed_packages:
|
|
139
200
|
app.echo_info(package["name"])
|
|
140
201
|
return
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
202
|
+
|
|
203
|
+
table_installed = []
|
|
204
|
+
for package in installed_packages:
|
|
205
|
+
table_installed.append((
|
|
144
206
|
package["name"],
|
|
145
207
|
package["version"]
|
|
146
208
|
))
|
|
147
209
|
app.echo_info_table(
|
|
148
|
-
|
|
210
|
+
table_installed,
|
|
149
211
|
headers=["Name", "Version"],
|
|
150
212
|
sort_column=0
|
|
151
213
|
)
|
|
@@ -215,6 +277,24 @@ def list_plugins_command(
|
|
|
215
277
|
app.echo_error(raw_output["error"])
|
|
216
278
|
|
|
217
279
|
|
|
280
|
+
@click.command(cls=CmemcCommand, name="open")
|
|
281
|
+
@click.argument(
|
|
282
|
+
"PACKAGE",
|
|
283
|
+
shell_complete=completion.published_package_names,
|
|
284
|
+
)
|
|
285
|
+
@click.pass_obj
|
|
286
|
+
def open_command(app: ApplicationContext, package):
|
|
287
|
+
"""Open a package pypi.org page in the browser.
|
|
288
|
+
|
|
289
|
+
With this command, you can open the pypi.org page of a published package in your
|
|
290
|
+
browser. From there, you can follow links, review the version history as well
|
|
291
|
+
as the origin of the package, and read the provided documentation.
|
|
292
|
+
"""
|
|
293
|
+
full_url = f"https://pypi.org/project/{package}/"
|
|
294
|
+
app.echo_debug(f"Open {package}: {full_url}")
|
|
295
|
+
click.launch(full_url)
|
|
296
|
+
|
|
297
|
+
|
|
218
298
|
@click.group(cls=CmemcGroup)
|
|
219
299
|
def python():
|
|
220
300
|
"""List, install, or uninstall python packages.
|
|
@@ -232,3 +312,4 @@ python.add_command(install_command)
|
|
|
232
312
|
python.add_command(uninstall_command)
|
|
233
313
|
python.add_command(list_command)
|
|
234
314
|
python.add_command(list_plugins_command)
|
|
315
|
+
python.add_command(open_command)
|
cmem/cmemc/cli/commands/query.py
CHANGED
|
@@ -452,7 +452,7 @@ def list_command(app, id_only):
|
|
|
452
452
|
"QUERIES",
|
|
453
453
|
nargs=-1,
|
|
454
454
|
required=True,
|
|
455
|
-
|
|
455
|
+
shell_complete=completion.remote_queries_and_sparql_files
|
|
456
456
|
)
|
|
457
457
|
@click.option(
|
|
458
458
|
"--accept",
|
|
@@ -482,7 +482,7 @@ def list_command(app, id_only):
|
|
|
482
482
|
@click.option(
|
|
483
483
|
"--parameter", "-p",
|
|
484
484
|
type=(str, str),
|
|
485
|
-
|
|
485
|
+
shell_complete=completion.placeholder,
|
|
486
486
|
multiple=True,
|
|
487
487
|
help="In case of a parameterized query (placeholders with the '{{key}}' "
|
|
488
488
|
"syntax), this option fills all placeholder with a given value "
|
|
@@ -582,7 +582,7 @@ def execute_command(
|
|
|
582
582
|
"QUERIES",
|
|
583
583
|
nargs=-1,
|
|
584
584
|
required=True,
|
|
585
|
-
|
|
585
|
+
shell_complete=completion.remote_queries_and_sparql_files
|
|
586
586
|
)
|
|
587
587
|
@click.pass_obj
|
|
588
588
|
def open_command(app, queries):
|
|
@@ -623,7 +623,7 @@ def open_command(app, queries):
|
|
|
623
623
|
"--filter", "filter_",
|
|
624
624
|
type=(str, str),
|
|
625
625
|
multiple=True,
|
|
626
|
-
|
|
626
|
+
shell_complete=completion.query_status_filter,
|
|
627
627
|
help=QUERY_FILTER_HELP_TEXT,
|
|
628
628
|
)
|
|
629
629
|
@click.argument(
|
|
@@ -685,7 +685,7 @@ def status_command(app, id_only, raw, filter_, query_uuid):
|
|
|
685
685
|
@click.argument(
|
|
686
686
|
"REPLAY_FILE",
|
|
687
687
|
required=True,
|
|
688
|
-
|
|
688
|
+
shell_complete=completion.replay_files,
|
|
689
689
|
type=click.Path(
|
|
690
690
|
exists=True,
|
|
691
691
|
allow_dash=False,
|
|
@@ -717,7 +717,7 @@ def status_command(app, id_only, raw, filter_, query_uuid):
|
|
|
717
717
|
@click.option(
|
|
718
718
|
"--output-file",
|
|
719
719
|
required=False,
|
|
720
|
-
|
|
720
|
+
shell_complete=completion.replay_files,
|
|
721
721
|
help="Save the optional output to this file. Input and output of the "
|
|
722
722
|
"command can be the same file. The output is written at the end "
|
|
723
723
|
"of a successful command execution. The output can be stdout "
|
|
@@ -61,7 +61,7 @@ def _get_resources_filtered(resources, filter_name, filter_value):
|
|
|
61
61
|
"--filter", "filters_",
|
|
62
62
|
multiple=True,
|
|
63
63
|
type=(str, str),
|
|
64
|
-
|
|
64
|
+
shell_complete=completion.resource_list_filter,
|
|
65
65
|
help=RESOURCE_FILTER_TEXT
|
|
66
66
|
)
|
|
67
67
|
@click.pass_obj
|
|
@@ -101,7 +101,7 @@ def list_command(app, raw, id_only, filters_):
|
|
|
101
101
|
"resource_ids",
|
|
102
102
|
nargs=-1,
|
|
103
103
|
type=click.STRING,
|
|
104
|
-
|
|
104
|
+
shell_complete=completion.resource_ids
|
|
105
105
|
)
|
|
106
106
|
@click.option(
|
|
107
107
|
"--force",
|
|
@@ -118,7 +118,7 @@ def list_command(app, raw, id_only, filters_):
|
|
|
118
118
|
"--filter", "filters_",
|
|
119
119
|
multiple=True,
|
|
120
120
|
type=(str, str),
|
|
121
|
-
|
|
121
|
+
shell_complete=completion.resource_list_filter,
|
|
122
122
|
help=RESOURCE_FILTER_TEXT
|
|
123
123
|
)
|
|
124
124
|
@click.pass_obj
|
|
@@ -184,7 +184,7 @@ def delete_command(app, resource_ids, force, all_, filters_):
|
|
|
184
184
|
@click.argument(
|
|
185
185
|
"resource_id",
|
|
186
186
|
type=click.STRING,
|
|
187
|
-
|
|
187
|
+
shell_complete=completion.resource_ids
|
|
188
188
|
)
|
|
189
189
|
@click.option(
|
|
190
190
|
"--raw",
|
|
@@ -211,7 +211,7 @@ def inspect_command(app, resource_id, raw):
|
|
|
211
211
|
@click.argument(
|
|
212
212
|
"resource_id",
|
|
213
213
|
type=click.STRING,
|
|
214
|
-
|
|
214
|
+
shell_complete=completion.resource_ids
|
|
215
215
|
)
|
|
216
216
|
@click.option(
|
|
217
217
|
"--raw",
|
|
@@ -38,7 +38,7 @@ def _get_sorted_scheduler_ids():
|
|
|
38
38
|
nargs=-1,
|
|
39
39
|
required=True,
|
|
40
40
|
type=click.STRING,
|
|
41
|
-
|
|
41
|
+
shell_complete=completion.scheduler_ids
|
|
42
42
|
)
|
|
43
43
|
@click.option(
|
|
44
44
|
"--workflow",
|
|
@@ -121,7 +121,7 @@ def list_command(app, raw, id_only):
|
|
|
121
121
|
@click.argument(
|
|
122
122
|
"scheduler_id",
|
|
123
123
|
type=click.STRING,
|
|
124
|
-
|
|
124
|
+
shell_complete=completion.scheduler_ids
|
|
125
125
|
)
|
|
126
126
|
@click.option(
|
|
127
127
|
"--raw",
|
|
@@ -150,7 +150,7 @@ def inspect_command(app, scheduler_id, raw):
|
|
|
150
150
|
"scheduler_ids",
|
|
151
151
|
nargs=-1,
|
|
152
152
|
type=click.STRING,
|
|
153
|
-
|
|
153
|
+
shell_complete=completion.scheduler_ids
|
|
154
154
|
)
|
|
155
155
|
@click.option(
|
|
156
156
|
"-a", "--all", "all_",
|
|
@@ -198,7 +198,7 @@ def disable_command(app, scheduler_ids, all_):
|
|
|
198
198
|
"scheduler_ids",
|
|
199
199
|
nargs=-1,
|
|
200
200
|
type=click.STRING,
|
|
201
|
-
|
|
201
|
+
shell_complete=completion.scheduler_ids
|
|
202
202
|
)
|
|
203
203
|
@click.option(
|
|
204
204
|
"-a", "--all", "all_",
|
cmem/cmemc/cli/commands/store.py
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
"""DataPlatform store commands for the cmem command line interface."""
|
|
2
2
|
import os
|
|
3
|
-
import sys
|
|
4
3
|
from os.path import exists
|
|
5
4
|
|
|
6
5
|
import click
|
|
6
|
+
from click import UsageError
|
|
7
7
|
|
|
8
8
|
from cmem.cmemc.cli import completion
|
|
9
9
|
from cmem.cmemc.cli.commands import CmemcCommand, CmemcGroup
|
|
10
10
|
from cmem.cmemc.cli.context import ApplicationContext
|
|
11
|
-
from cmem.cmempy.dp.admin import
|
|
11
|
+
from cmem.cmempy.dp.admin import (
|
|
12
|
+
create_showcase_data,
|
|
13
|
+
delete_bootstrap_data,
|
|
14
|
+
import_bootstrap_data
|
|
15
|
+
)
|
|
12
16
|
from cmem.cmempy.dp.admin.backup import get_zip, post_zip
|
|
13
17
|
|
|
14
18
|
|
|
@@ -17,32 +21,37 @@ from cmem.cmempy.dp.admin.backup import get_zip, post_zip
|
|
|
17
21
|
"--import", "import_",
|
|
18
22
|
is_flag=True,
|
|
19
23
|
help="Delete existing bootstrap data if present and import bootstrap "
|
|
20
|
-
"data which was delivered "
|
|
24
|
+
"data which was delivered with Corporate Memory."
|
|
25
|
+
)
|
|
26
|
+
@click.option(
|
|
27
|
+
"--remove",
|
|
28
|
+
is_flag=True,
|
|
29
|
+
help="Delete existing bootstrap data if present."
|
|
21
30
|
)
|
|
22
31
|
@click.pass_obj
|
|
23
|
-
def bootstrap_command(app: ApplicationContext, import_):
|
|
24
|
-
"""Update/Import bootstrap data.
|
|
32
|
+
def bootstrap_command(app: ApplicationContext, import_, remove):
|
|
33
|
+
"""Update/Import or remove bootstrap data.
|
|
34
|
+
|
|
35
|
+
Use `--import` to import the bootstrap data needed for managing shapes and
|
|
36
|
+
configuration objects. This will remove the old data first.
|
|
25
37
|
|
|
26
|
-
|
|
27
|
-
configuration objects.
|
|
38
|
+
Use `--remove` to delete bootstrap data.
|
|
28
39
|
|
|
29
|
-
Note: The
|
|
30
|
-
|
|
31
|
-
to the corresponding graphs (shape catalog, vocabulary catalog, configuration
|
|
32
|
-
graph).
|
|
40
|
+
Note: The removal of existing bootstrap data will search for resources which are
|
|
41
|
+
flagged with the isSystemResource property.
|
|
33
42
|
"""
|
|
34
|
-
if
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
if import_ and remove or not import_ and not remove:
|
|
44
|
+
raise UsageError("Either use the --import or the --remove option.")
|
|
45
|
+
if import_:
|
|
46
|
+
app.echo_info("Update or import bootstrap data ... ", nl=False)
|
|
47
|
+
import_bootstrap_data()
|
|
48
|
+
app.echo_success("done")
|
|
49
|
+
return
|
|
50
|
+
if remove:
|
|
51
|
+
app.echo_info("Remove bootstrap data ... ", nl=False)
|
|
52
|
+
delete_bootstrap_data()
|
|
53
|
+
app.echo_success("done")
|
|
54
|
+
return
|
|
46
55
|
|
|
47
56
|
|
|
48
57
|
@click.command(cls=CmemcCommand, name="showcase")
|
|
@@ -77,12 +86,6 @@ def showcase_command(app, scale, create, delete):
|
|
|
77
86
|
you need to remove the showcase graphs manually (or just remove all
|
|
78
87
|
graphs).
|
|
79
88
|
"""
|
|
80
|
-
if "store" not in sys.argv:
|
|
81
|
-
app.echo_warning(
|
|
82
|
-
"The 'admin showcase' command is deprecated and will be removed "
|
|
83
|
-
"in the next major release.\n"
|
|
84
|
-
"Please use the 'admin store showcase' command instead."
|
|
85
|
-
)
|
|
86
89
|
if not delete and not create:
|
|
87
90
|
raise ValueError("Either use the --create or the --delete flag.")
|
|
88
91
|
if delete:
|
|
@@ -102,7 +105,7 @@ def showcase_command(app, scale, create, delete):
|
|
|
102
105
|
@click.command(cls=CmemcCommand, name="export")
|
|
103
106
|
@click.argument(
|
|
104
107
|
"BACKUP_FILE",
|
|
105
|
-
|
|
108
|
+
shell_complete=completion.graph_backup_files,
|
|
106
109
|
required=True,
|
|
107
110
|
type=click.Path(
|
|
108
111
|
writable=True,
|
|
@@ -161,7 +164,7 @@ def export_command(app, backup_file, overwrite):
|
|
|
161
164
|
@click.command(cls=CmemcCommand, name="import")
|
|
162
165
|
@click.argument(
|
|
163
166
|
"BACKUP_FILE",
|
|
164
|
-
|
|
167
|
+
shell_complete=completion.graph_backup_files,
|
|
165
168
|
required=True,
|
|
166
169
|
type=click.Path(
|
|
167
170
|
readable=True,
|
cmem/cmemc/cli/commands/user.py
CHANGED
|
@@ -76,7 +76,7 @@ def list_command(app: ApplicationContext, raw, id_only):
|
|
|
76
76
|
@click.command(cls=CmemcCommand, name="delete")
|
|
77
77
|
@click.argument(
|
|
78
78
|
"username",
|
|
79
|
-
|
|
79
|
+
shell_complete=completion.user_ids
|
|
80
80
|
)
|
|
81
81
|
@click.pass_obj
|
|
82
82
|
def delete_command(app: ApplicationContext, username):
|
|
@@ -130,7 +130,7 @@ def create_command(app: ApplicationContext, username):
|
|
|
130
130
|
@click.command(cls=CmemcCommand, name="update")
|
|
131
131
|
@click.argument(
|
|
132
132
|
"username",
|
|
133
|
-
|
|
133
|
+
shell_complete=completion.user_ids
|
|
134
134
|
)
|
|
135
135
|
@click.option(
|
|
136
136
|
"--first-name",
|
|
@@ -154,14 +154,14 @@ def create_command(app: ApplicationContext, username):
|
|
|
154
154
|
"--assign-group",
|
|
155
155
|
type=click.STRING,
|
|
156
156
|
multiple=True,
|
|
157
|
-
|
|
157
|
+
shell_complete=completion.user_group_ids,
|
|
158
158
|
help="Assign a group."
|
|
159
159
|
)
|
|
160
160
|
@click.option(
|
|
161
161
|
"--unassign-group",
|
|
162
162
|
type=click.STRING,
|
|
163
163
|
multiple=True,
|
|
164
|
-
|
|
164
|
+
shell_complete=completion.user_group_ids,
|
|
165
165
|
help="Unassign a group."
|
|
166
166
|
)
|
|
167
167
|
@click.pass_obj
|
|
@@ -238,7 +238,7 @@ def update_command(
|
|
|
238
238
|
@click.command(cls=CmemcCommand, name="password")
|
|
239
239
|
@click.argument(
|
|
240
240
|
"username",
|
|
241
|
-
|
|
241
|
+
shell_complete=completion.user_ids
|
|
242
242
|
)
|
|
243
243
|
@click.option(
|
|
244
244
|
"--value",
|
|
@@ -304,7 +304,7 @@ def password_command(
|
|
|
304
304
|
nargs=-1,
|
|
305
305
|
required=False,
|
|
306
306
|
type=click.STRING,
|
|
307
|
-
|
|
307
|
+
shell_complete=completion.user_ids
|
|
308
308
|
)
|
|
309
309
|
@click.pass_obj
|
|
310
310
|
def open_command(app: ApplicationContext, usernames: str):
|