dremio-cli 1.0.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.
- dremio_cli/__init__.py +5 -0
- dremio_cli/__main__.py +6 -0
- dremio_cli/cli.py +191 -0
- dremio_cli/client/__init__.py +1 -0
- dremio_cli/client/auth.py +100 -0
- dremio_cli/client/base.py +190 -0
- dremio_cli/client/cloud.py +305 -0
- dremio_cli/client/factory.py +122 -0
- dremio_cli/client/software.py +561 -0
- dremio_cli/commands/__init__.py +1 -0
- dremio_cli/commands/catalog.py +143 -0
- dremio_cli/commands/favorite.py +162 -0
- dremio_cli/commands/folder.py +290 -0
- dremio_cli/commands/grant.py +202 -0
- dremio_cli/commands/history.py +122 -0
- dremio_cli/commands/job.py +321 -0
- dremio_cli/commands/lineage.py +9 -0
- dremio_cli/commands/profile.py +165 -0
- dremio_cli/commands/role.py +319 -0
- dremio_cli/commands/source.py +375 -0
- dremio_cli/commands/space.py +226 -0
- dremio_cli/commands/sql.py +280 -0
- dremio_cli/commands/table.py +155 -0
- dremio_cli/commands/tag.py +145 -0
- dremio_cli/commands/udf.py +9 -0
- dremio_cli/commands/user.py +250 -0
- dremio_cli/commands/view.py +369 -0
- dremio_cli/commands/wiki.py +163 -0
- dremio_cli/config.py +193 -0
- dremio_cli/env.py +175 -0
- dremio_cli/formatters/__init__.py +1 -0
- dremio_cli/formatters/json.py +19 -0
- dremio_cli/formatters/table.py +45 -0
- dremio_cli/formatters/yaml.py +17 -0
- dremio_cli/history.py +198 -0
- dremio_cli/utils/__init__.py +1 -0
- dremio_cli/utils/exceptions.py +35 -0
- dremio_cli/utils/helpers.py +73 -0
- dremio_cli/utils/validators.py +147 -0
- dremio_cli-1.0.0.dist-info/METADATA +261 -0
- dremio_cli-1.0.0.dist-info/RECORD +45 -0
- dremio_cli-1.0.0.dist-info/WHEEL +5 -0
- dremio_cli-1.0.0.dist-info/entry_points.txt +2 -0
- dremio_cli-1.0.0.dist-info/licenses/LICENSE +21 -0
- dremio_cli-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
"""View management commands."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import click
|
|
5
|
+
from rich.console import Console
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from dremio_cli.config import ProfileManager
|
|
9
|
+
from dremio_cli.client.factory import create_client
|
|
10
|
+
from dremio_cli.formatters.table import format_as_table
|
|
11
|
+
from dremio_cli.formatters.json import format_as_json
|
|
12
|
+
from dremio_cli.formatters.yaml import format_as_yaml
|
|
13
|
+
from dremio_cli.utils.validators import validate_path
|
|
14
|
+
|
|
15
|
+
console = Console()
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@click.group()
|
|
19
|
+
def view() -> None:
|
|
20
|
+
"""View management operations."""
|
|
21
|
+
pass
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@view.command("create")
|
|
25
|
+
@click.option("--path", required=True, help="View path as JSON array or dot-separated (e.g., '[\"space\", \"view\"]' or 'space.view')")
|
|
26
|
+
@click.option("--sql", help="SQL query for the view")
|
|
27
|
+
@click.option("--from-file", type=click.Path(exists=True), help="Load view definition from JSON file")
|
|
28
|
+
@click.pass_context
|
|
29
|
+
def create_view(ctx, path: str, sql: str, from_file: str) -> None:
|
|
30
|
+
"""Create a new view.
|
|
31
|
+
|
|
32
|
+
Examples:
|
|
33
|
+
dremio view create --path '["MySpace", "MyView"]' --sql "SELECT * FROM table"
|
|
34
|
+
dremio view create --path "MySpace.MyView" --sql "SELECT 1 as col"
|
|
35
|
+
dremio view create --from-file view-definition.json
|
|
36
|
+
"""
|
|
37
|
+
try:
|
|
38
|
+
# Get profile
|
|
39
|
+
manager = ProfileManager()
|
|
40
|
+
profile_name = ctx.obj.profile_name
|
|
41
|
+
profile = manager.get_profile(profile_name)
|
|
42
|
+
|
|
43
|
+
if not profile:
|
|
44
|
+
console.print(f"[red]Profile '{profile_name}' not found[/red]")
|
|
45
|
+
raise click.Abort()
|
|
46
|
+
|
|
47
|
+
# Create client
|
|
48
|
+
client = create_client(profile)
|
|
49
|
+
|
|
50
|
+
# Load view definition
|
|
51
|
+
if from_file:
|
|
52
|
+
with open(from_file, 'r') as f:
|
|
53
|
+
view_data = json.load(f)
|
|
54
|
+
else:
|
|
55
|
+
if not sql:
|
|
56
|
+
console.print("[red]Error: Either --sql or --from-file is required[/red]")
|
|
57
|
+
raise click.Abort()
|
|
58
|
+
|
|
59
|
+
# Parse path
|
|
60
|
+
view_path = validate_path(path)
|
|
61
|
+
|
|
62
|
+
# Create view definition
|
|
63
|
+
view_data = {
|
|
64
|
+
"entityType": "dataset",
|
|
65
|
+
"type": "VIRTUAL_DATASET",
|
|
66
|
+
"path": view_path,
|
|
67
|
+
"sql": sql,
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
# Create view
|
|
71
|
+
with console.status(f"[bold green]Creating view..."):
|
|
72
|
+
result = client.create_view(view_data)
|
|
73
|
+
|
|
74
|
+
view_id = result.get("id")
|
|
75
|
+
view_path = result.get("path", [])
|
|
76
|
+
|
|
77
|
+
console.print(f"[green]✓[/green] View created successfully")
|
|
78
|
+
console.print(f" ID: {view_id}")
|
|
79
|
+
console.print(f" Path: {'.'.join(view_path)}")
|
|
80
|
+
|
|
81
|
+
# Display full result if verbose
|
|
82
|
+
if ctx.obj.verbose:
|
|
83
|
+
output_format = ctx.obj.output_format
|
|
84
|
+
if output_format == "json":
|
|
85
|
+
console.print(format_as_json(result))
|
|
86
|
+
elif output_format == "yaml":
|
|
87
|
+
console.print(format_as_yaml(result))
|
|
88
|
+
|
|
89
|
+
except Exception as e:
|
|
90
|
+
console.print(f"[red]Error: {e}[/red]")
|
|
91
|
+
if ctx.obj.verbose:
|
|
92
|
+
import traceback
|
|
93
|
+
traceback.print_exc()
|
|
94
|
+
raise click.Abort()
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
@view.command("get")
|
|
98
|
+
@click.argument("view_id")
|
|
99
|
+
@click.option("--include", help="Include additional fields")
|
|
100
|
+
@click.pass_context
|
|
101
|
+
def get_view(ctx, view_id: str, include: str) -> None:
|
|
102
|
+
"""Get view by ID.
|
|
103
|
+
|
|
104
|
+
Examples:
|
|
105
|
+
dremio view get abc-123-def-456
|
|
106
|
+
dremio view get abc-123-def-456 --include sql
|
|
107
|
+
"""
|
|
108
|
+
try:
|
|
109
|
+
# Get profile
|
|
110
|
+
manager = ProfileManager()
|
|
111
|
+
profile_name = ctx.obj.profile_name
|
|
112
|
+
profile = manager.get_profile(profile_name)
|
|
113
|
+
|
|
114
|
+
if not profile:
|
|
115
|
+
console.print(f"[red]Profile '{profile_name}' not found[/red]")
|
|
116
|
+
raise click.Abort()
|
|
117
|
+
|
|
118
|
+
# Create client
|
|
119
|
+
client = create_client(profile)
|
|
120
|
+
|
|
121
|
+
# Get view
|
|
122
|
+
with console.status(f"[bold green]Fetching view {view_id}..."):
|
|
123
|
+
data = client.get_catalog_item(view_id, include=include)
|
|
124
|
+
|
|
125
|
+
# Format output
|
|
126
|
+
output_format = ctx.obj.output_format
|
|
127
|
+
|
|
128
|
+
if output_format == "json":
|
|
129
|
+
console.print(format_as_json(data))
|
|
130
|
+
elif output_format == "yaml":
|
|
131
|
+
console.print(format_as_yaml(data))
|
|
132
|
+
else:
|
|
133
|
+
format_as_table(data, title=f"View: {view_id}")
|
|
134
|
+
|
|
135
|
+
except Exception as e:
|
|
136
|
+
console.print(f"[red]Error: {e}[/red]")
|
|
137
|
+
if ctx.obj.verbose:
|
|
138
|
+
import traceback
|
|
139
|
+
traceback.print_exc()
|
|
140
|
+
raise click.Abort()
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
@view.command("get-by-path")
|
|
144
|
+
@click.argument("path")
|
|
145
|
+
@click.option("--include", help="Include additional fields")
|
|
146
|
+
@click.pass_context
|
|
147
|
+
def get_view_by_path(ctx, path: str, include: str) -> None:
|
|
148
|
+
"""Get view by path.
|
|
149
|
+
|
|
150
|
+
Examples:
|
|
151
|
+
dremio view get-by-path "MySpace.MyView"
|
|
152
|
+
dremio view get-by-path '["MySpace", "MyView"]'
|
|
153
|
+
"""
|
|
154
|
+
try:
|
|
155
|
+
# Get profile
|
|
156
|
+
manager = ProfileManager()
|
|
157
|
+
profile_name = ctx.obj.profile_name
|
|
158
|
+
profile = manager.get_profile(profile_name)
|
|
159
|
+
|
|
160
|
+
if not profile:
|
|
161
|
+
console.print(f"[red]Profile '{profile_name}' not found[/red]")
|
|
162
|
+
raise click.Abort()
|
|
163
|
+
|
|
164
|
+
# Create client
|
|
165
|
+
client = create_client(profile)
|
|
166
|
+
|
|
167
|
+
# Get view by path
|
|
168
|
+
with console.status(f"[bold green]Fetching view {path}..."):
|
|
169
|
+
data = client.get_catalog_item_by_path(path, include=include)
|
|
170
|
+
|
|
171
|
+
# Format output
|
|
172
|
+
output_format = ctx.obj.output_format
|
|
173
|
+
|
|
174
|
+
if output_format == "json":
|
|
175
|
+
console.print(format_as_json(data))
|
|
176
|
+
elif output_format == "yaml":
|
|
177
|
+
console.print(format_as_yaml(data))
|
|
178
|
+
else:
|
|
179
|
+
format_as_table(data, title=f"View: {path}")
|
|
180
|
+
|
|
181
|
+
except Exception as e:
|
|
182
|
+
console.print(f"[red]Error: {e}[/red]")
|
|
183
|
+
if ctx.obj.verbose:
|
|
184
|
+
import traceback
|
|
185
|
+
traceback.print_exc()
|
|
186
|
+
raise click.Abort()
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
@view.command("update")
|
|
190
|
+
@click.argument("view_id")
|
|
191
|
+
@click.option("--sql", help="New SQL query for the view")
|
|
192
|
+
@click.option("--from-file", type=click.Path(exists=True), help="Load view definition from JSON file")
|
|
193
|
+
@click.pass_context
|
|
194
|
+
def update_view(ctx, view_id: str, sql: str, from_file: str) -> None:
|
|
195
|
+
"""Update an existing view.
|
|
196
|
+
|
|
197
|
+
Examples:
|
|
198
|
+
dremio view update abc-123 --sql "SELECT * FROM table WHERE id > 100"
|
|
199
|
+
dremio view update abc-123 --from-file updated-view.json
|
|
200
|
+
"""
|
|
201
|
+
try:
|
|
202
|
+
# Get profile
|
|
203
|
+
manager = ProfileManager()
|
|
204
|
+
profile_name = ctx.obj.profile_name
|
|
205
|
+
profile = manager.get_profile(profile_name)
|
|
206
|
+
|
|
207
|
+
if not profile:
|
|
208
|
+
console.print(f"[red]Profile '{profile_name}' not found[/red]")
|
|
209
|
+
raise click.Abort()
|
|
210
|
+
|
|
211
|
+
# Create client
|
|
212
|
+
client = create_client(profile)
|
|
213
|
+
|
|
214
|
+
# Get current view to get tag
|
|
215
|
+
current_view = client.get_catalog_item(view_id)
|
|
216
|
+
|
|
217
|
+
# Load update data
|
|
218
|
+
if from_file:
|
|
219
|
+
with open(from_file, 'r') as f:
|
|
220
|
+
update_data = json.load(f)
|
|
221
|
+
else:
|
|
222
|
+
if not sql:
|
|
223
|
+
console.print("[red]Error: Either --sql or --from-file is required[/red]")
|
|
224
|
+
raise click.Abort()
|
|
225
|
+
|
|
226
|
+
# Create update with new SQL
|
|
227
|
+
update_data = {
|
|
228
|
+
"entityType": "dataset",
|
|
229
|
+
"type": "VIRTUAL_DATASET",
|
|
230
|
+
"id": view_id,
|
|
231
|
+
"path": current_view.get("path"),
|
|
232
|
+
"tag": current_view.get("tag"),
|
|
233
|
+
"sql": sql,
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
# Ensure tag is present for optimistic concurrency
|
|
237
|
+
if "tag" not in update_data:
|
|
238
|
+
update_data["tag"] = current_view.get("tag")
|
|
239
|
+
|
|
240
|
+
# Update view
|
|
241
|
+
with console.status(f"[bold green]Updating view {view_id}..."):
|
|
242
|
+
result = client.update_view(view_id, update_data)
|
|
243
|
+
|
|
244
|
+
console.print(f"[green]✓[/green] View updated successfully")
|
|
245
|
+
console.print(f" ID: {result.get('id')}")
|
|
246
|
+
console.print(f" Path: {'.'.join(result.get('path', []))}")
|
|
247
|
+
|
|
248
|
+
# Display full result if verbose
|
|
249
|
+
if ctx.obj.verbose:
|
|
250
|
+
output_format = ctx.obj.output_format
|
|
251
|
+
if output_format == "json":
|
|
252
|
+
console.print(format_as_json(result))
|
|
253
|
+
elif output_format == "yaml":
|
|
254
|
+
console.print(format_as_yaml(result))
|
|
255
|
+
|
|
256
|
+
except Exception as e:
|
|
257
|
+
console.print(f"[red]Error: {e}[/red]")
|
|
258
|
+
if ctx.obj.verbose:
|
|
259
|
+
import traceback
|
|
260
|
+
traceback.print_exc()
|
|
261
|
+
raise click.Abort()
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
@view.command("delete")
|
|
265
|
+
@click.argument("view_id")
|
|
266
|
+
@click.option("--tag", help="Version tag for optimistic concurrency control")
|
|
267
|
+
@click.confirmation_option(prompt="Are you sure you want to delete this view?")
|
|
268
|
+
@click.pass_context
|
|
269
|
+
def delete_view(ctx, view_id: str, tag: str) -> None:
|
|
270
|
+
"""Delete a view.
|
|
271
|
+
|
|
272
|
+
Examples:
|
|
273
|
+
dremio view delete abc-123-def-456
|
|
274
|
+
dremio view delete abc-123-def-456 --tag "version-tag"
|
|
275
|
+
"""
|
|
276
|
+
try:
|
|
277
|
+
# Get profile
|
|
278
|
+
manager = ProfileManager()
|
|
279
|
+
profile_name = ctx.obj.profile_name
|
|
280
|
+
profile = manager.get_profile(profile_name)
|
|
281
|
+
|
|
282
|
+
if not profile:
|
|
283
|
+
console.print(f"[red]Profile '{profile_name}' not found[/red]")
|
|
284
|
+
raise click.Abort()
|
|
285
|
+
|
|
286
|
+
# Create client
|
|
287
|
+
client = create_client(profile)
|
|
288
|
+
|
|
289
|
+
# Get tag if not provided
|
|
290
|
+
if not tag:
|
|
291
|
+
view = client.get_catalog_item(view_id)
|
|
292
|
+
tag = view.get("tag")
|
|
293
|
+
|
|
294
|
+
# Delete view
|
|
295
|
+
with console.status(f"[bold yellow]Deleting view {view_id}..."):
|
|
296
|
+
client.delete_view(view_id, tag)
|
|
297
|
+
|
|
298
|
+
console.print(f"[green]✓[/green] View deleted successfully")
|
|
299
|
+
|
|
300
|
+
except Exception as e:
|
|
301
|
+
console.print(f"[red]Error: {e}[/red]")
|
|
302
|
+
if ctx.obj.verbose:
|
|
303
|
+
import traceback
|
|
304
|
+
traceback.print_exc()
|
|
305
|
+
raise click.Abort()
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
@view.command("list")
|
|
309
|
+
@click.option("--space", help="Filter views by space name")
|
|
310
|
+
@click.pass_context
|
|
311
|
+
def list_views(ctx, space: str) -> None:
|
|
312
|
+
"""List all views.
|
|
313
|
+
|
|
314
|
+
Examples:
|
|
315
|
+
dremio view list
|
|
316
|
+
dremio view list --space MySpace
|
|
317
|
+
"""
|
|
318
|
+
try:
|
|
319
|
+
# Get profile
|
|
320
|
+
manager = ProfileManager()
|
|
321
|
+
profile_name = ctx.obj.profile_name
|
|
322
|
+
profile = manager.get_profile(profile_name)
|
|
323
|
+
|
|
324
|
+
if not profile:
|
|
325
|
+
console.print(f"[red]Profile '{profile_name}' not found[/red]")
|
|
326
|
+
raise click.Abort()
|
|
327
|
+
|
|
328
|
+
# Create client
|
|
329
|
+
client = create_client(profile)
|
|
330
|
+
|
|
331
|
+
# Get catalog
|
|
332
|
+
with console.status(f"[bold green]Fetching views..."):
|
|
333
|
+
data = client.get_catalog()
|
|
334
|
+
|
|
335
|
+
items = data.get("data", [])
|
|
336
|
+
|
|
337
|
+
# Filter for views
|
|
338
|
+
views = [
|
|
339
|
+
item for item in items
|
|
340
|
+
if item.get("type") == "VIRTUAL_DATASET" or item.get("datasetType") == "VIRTUAL_DATASET"
|
|
341
|
+
]
|
|
342
|
+
|
|
343
|
+
# Filter by space if specified
|
|
344
|
+
if space:
|
|
345
|
+
views = [
|
|
346
|
+
view for view in views
|
|
347
|
+
if view.get("path", [])[0] == space
|
|
348
|
+
]
|
|
349
|
+
|
|
350
|
+
# Format output
|
|
351
|
+
output_format = ctx.obj.output_format
|
|
352
|
+
|
|
353
|
+
if output_format == "json":
|
|
354
|
+
console.print(format_as_json(views))
|
|
355
|
+
elif output_format == "yaml":
|
|
356
|
+
console.print(format_as_yaml(views))
|
|
357
|
+
else:
|
|
358
|
+
if views:
|
|
359
|
+
title = f"Views in {space}" if space else "All Views"
|
|
360
|
+
format_as_table(views, title=title)
|
|
361
|
+
else:
|
|
362
|
+
console.print("[yellow]No views found[/yellow]")
|
|
363
|
+
|
|
364
|
+
except Exception as e:
|
|
365
|
+
console.print(f"[red]Error: {e}[/red]")
|
|
366
|
+
if ctx.obj.verbose:
|
|
367
|
+
import traceback
|
|
368
|
+
traceback.print_exc()
|
|
369
|
+
raise click.Abort()
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"""Wiki management commands."""
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
from rich.console import Console
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from dremio_cli.config import ProfileManager
|
|
8
|
+
from dremio_cli.client.factory import create_client
|
|
9
|
+
from dremio_cli.formatters.json import format_as_json
|
|
10
|
+
from dremio_cli.formatters.yaml import format_as_yaml
|
|
11
|
+
|
|
12
|
+
console = Console()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@click.group()
|
|
16
|
+
def wiki() -> None:
|
|
17
|
+
"""Wiki management operations."""
|
|
18
|
+
pass
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@wiki.command("set")
|
|
22
|
+
@click.argument("catalog_id")
|
|
23
|
+
@click.option("--text", help="Wiki text content")
|
|
24
|
+
@click.option("--file", "wiki_file", type=click.Path(exists=True), help="Load wiki from file")
|
|
25
|
+
@click.pass_context
|
|
26
|
+
def set_wiki(ctx, catalog_id: str, text: str, wiki_file: str) -> None:
|
|
27
|
+
"""Set wiki documentation on a catalog object.
|
|
28
|
+
|
|
29
|
+
Examples:
|
|
30
|
+
dremio wiki set abc-123 --text "# My Dataset\\n\\nThis is documentation"
|
|
31
|
+
dremio wiki set abc-123 --file README.md
|
|
32
|
+
"""
|
|
33
|
+
try:
|
|
34
|
+
# Get profile
|
|
35
|
+
manager = ProfileManager()
|
|
36
|
+
profile_name = ctx.obj.profile_name
|
|
37
|
+
profile = manager.get_profile(profile_name)
|
|
38
|
+
|
|
39
|
+
if not profile:
|
|
40
|
+
console.print(f"[red]Profile '{profile_name}' not found[/red]")
|
|
41
|
+
raise click.Abort()
|
|
42
|
+
|
|
43
|
+
# Get wiki content
|
|
44
|
+
if wiki_file:
|
|
45
|
+
with open(wiki_file, 'r') as f:
|
|
46
|
+
wiki_content = f.read()
|
|
47
|
+
elif text:
|
|
48
|
+
wiki_content = text
|
|
49
|
+
else:
|
|
50
|
+
console.print("[red]Error: Either --text or --file is required[/red]")
|
|
51
|
+
raise click.Abort()
|
|
52
|
+
|
|
53
|
+
# Create client
|
|
54
|
+
client = create_client(profile)
|
|
55
|
+
|
|
56
|
+
# Set wiki
|
|
57
|
+
with console.status(f"[bold green]Setting wiki on {catalog_id}..."):
|
|
58
|
+
client.set_wiki(catalog_id, wiki_content)
|
|
59
|
+
|
|
60
|
+
console.print(f"[green]✓[/green] Wiki set successfully")
|
|
61
|
+
console.print(f" Length: {len(wiki_content)} characters")
|
|
62
|
+
|
|
63
|
+
except Exception as e:
|
|
64
|
+
console.print(f"[red]Error: {e}[/red]")
|
|
65
|
+
if ctx.obj.verbose:
|
|
66
|
+
import traceback
|
|
67
|
+
traceback.print_exc()
|
|
68
|
+
raise click.Abort()
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@wiki.command("get")
|
|
72
|
+
@click.argument("catalog_id")
|
|
73
|
+
@click.option("--output-file", type=click.Path(), help="Save wiki to file")
|
|
74
|
+
@click.pass_context
|
|
75
|
+
def get_wiki(ctx, catalog_id: str, output_file: str) -> None:
|
|
76
|
+
"""Get wiki documentation from a catalog object.
|
|
77
|
+
|
|
78
|
+
Examples:
|
|
79
|
+
dremio wiki get abc-123
|
|
80
|
+
dremio wiki get abc-123 --output-file README.md
|
|
81
|
+
"""
|
|
82
|
+
try:
|
|
83
|
+
# Get profile
|
|
84
|
+
manager = ProfileManager()
|
|
85
|
+
profile_name = ctx.obj.profile_name
|
|
86
|
+
profile = manager.get_profile(profile_name)
|
|
87
|
+
|
|
88
|
+
if not profile:
|
|
89
|
+
console.print(f"[red]Profile '{profile_name}' not found[/red]")
|
|
90
|
+
raise click.Abort()
|
|
91
|
+
|
|
92
|
+
# Create client
|
|
93
|
+
client = create_client(profile)
|
|
94
|
+
|
|
95
|
+
# Get wiki
|
|
96
|
+
with console.status(f"[bold green]Fetching wiki for {catalog_id}..."):
|
|
97
|
+
data = client.get_wiki(catalog_id)
|
|
98
|
+
|
|
99
|
+
wiki_text = data.get("text", "")
|
|
100
|
+
|
|
101
|
+
if output_file:
|
|
102
|
+
# Save to file
|
|
103
|
+
Path(output_file).write_text(wiki_text)
|
|
104
|
+
console.print(f"[green]✓[/green] Wiki saved to {output_file}")
|
|
105
|
+
console.print(f" Length: {len(wiki_text)} characters")
|
|
106
|
+
else:
|
|
107
|
+
# Display wiki
|
|
108
|
+
output_format = ctx.obj.output_format
|
|
109
|
+
|
|
110
|
+
if output_format == "json":
|
|
111
|
+
console.print(format_as_json(data))
|
|
112
|
+
elif output_format == "yaml":
|
|
113
|
+
console.print(format_as_yaml(data))
|
|
114
|
+
else:
|
|
115
|
+
if wiki_text:
|
|
116
|
+
console.print("\n[bold]Wiki Content:[/bold]\n")
|
|
117
|
+
console.print(wiki_text)
|
|
118
|
+
else:
|
|
119
|
+
console.print("[yellow]No wiki content found[/yellow]")
|
|
120
|
+
|
|
121
|
+
except Exception as e:
|
|
122
|
+
console.print(f"[red]Error: {e}[/red]")
|
|
123
|
+
if ctx.obj.verbose:
|
|
124
|
+
import traceback
|
|
125
|
+
traceback.print_exc()
|
|
126
|
+
raise click.Abort()
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
@wiki.command("delete")
|
|
130
|
+
@click.argument("catalog_id")
|
|
131
|
+
@click.confirmation_option(prompt="Are you sure you want to delete the wiki?")
|
|
132
|
+
@click.pass_context
|
|
133
|
+
def delete_wiki(ctx, catalog_id: str) -> None:
|
|
134
|
+
"""Delete wiki documentation from a catalog object.
|
|
135
|
+
|
|
136
|
+
Examples:
|
|
137
|
+
dremio wiki delete abc-123
|
|
138
|
+
"""
|
|
139
|
+
try:
|
|
140
|
+
# Get profile
|
|
141
|
+
manager = ProfileManager()
|
|
142
|
+
profile_name = ctx.obj.profile_name
|
|
143
|
+
profile = manager.get_profile(profile_name)
|
|
144
|
+
|
|
145
|
+
if not profile:
|
|
146
|
+
console.print(f"[red]Profile '{profile_name}' not found[/red]")
|
|
147
|
+
raise click.Abort()
|
|
148
|
+
|
|
149
|
+
# Create client
|
|
150
|
+
client = create_client(profile)
|
|
151
|
+
|
|
152
|
+
# Delete wiki
|
|
153
|
+
with console.status(f"[bold yellow]Deleting wiki from {catalog_id}..."):
|
|
154
|
+
client.delete_wiki(catalog_id)
|
|
155
|
+
|
|
156
|
+
console.print(f"[green]✓[/green] Wiki deleted successfully")
|
|
157
|
+
|
|
158
|
+
except Exception as e:
|
|
159
|
+
console.print(f"[red]Error: {e}[/red]")
|
|
160
|
+
if ctx.obj.verbose:
|
|
161
|
+
import traceback
|
|
162
|
+
traceback.print_exc()
|
|
163
|
+
raise click.Abort()
|