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.
Files changed (45) hide show
  1. dremio_cli/__init__.py +5 -0
  2. dremio_cli/__main__.py +6 -0
  3. dremio_cli/cli.py +191 -0
  4. dremio_cli/client/__init__.py +1 -0
  5. dremio_cli/client/auth.py +100 -0
  6. dremio_cli/client/base.py +190 -0
  7. dremio_cli/client/cloud.py +305 -0
  8. dremio_cli/client/factory.py +122 -0
  9. dremio_cli/client/software.py +561 -0
  10. dremio_cli/commands/__init__.py +1 -0
  11. dremio_cli/commands/catalog.py +143 -0
  12. dremio_cli/commands/favorite.py +162 -0
  13. dremio_cli/commands/folder.py +290 -0
  14. dremio_cli/commands/grant.py +202 -0
  15. dremio_cli/commands/history.py +122 -0
  16. dremio_cli/commands/job.py +321 -0
  17. dremio_cli/commands/lineage.py +9 -0
  18. dremio_cli/commands/profile.py +165 -0
  19. dremio_cli/commands/role.py +319 -0
  20. dremio_cli/commands/source.py +375 -0
  21. dremio_cli/commands/space.py +226 -0
  22. dremio_cli/commands/sql.py +280 -0
  23. dremio_cli/commands/table.py +155 -0
  24. dremio_cli/commands/tag.py +145 -0
  25. dremio_cli/commands/udf.py +9 -0
  26. dremio_cli/commands/user.py +250 -0
  27. dremio_cli/commands/view.py +369 -0
  28. dremio_cli/commands/wiki.py +163 -0
  29. dremio_cli/config.py +193 -0
  30. dremio_cli/env.py +175 -0
  31. dremio_cli/formatters/__init__.py +1 -0
  32. dremio_cli/formatters/json.py +19 -0
  33. dremio_cli/formatters/table.py +45 -0
  34. dremio_cli/formatters/yaml.py +17 -0
  35. dremio_cli/history.py +198 -0
  36. dremio_cli/utils/__init__.py +1 -0
  37. dremio_cli/utils/exceptions.py +35 -0
  38. dremio_cli/utils/helpers.py +73 -0
  39. dremio_cli/utils/validators.py +147 -0
  40. dremio_cli-1.0.0.dist-info/METADATA +261 -0
  41. dremio_cli-1.0.0.dist-info/RECORD +45 -0
  42. dremio_cli-1.0.0.dist-info/WHEEL +5 -0
  43. dremio_cli-1.0.0.dist-info/entry_points.txt +2 -0
  44. dremio_cli-1.0.0.dist-info/licenses/LICENSE +21 -0
  45. dremio_cli-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,145 @@
1
+ """Tag management commands."""
2
+
3
+ import click
4
+ from rich.console import Console
5
+
6
+ from dremio_cli.config import ProfileManager
7
+ from dremio_cli.client.factory import create_client
8
+ from dremio_cli.formatters.table import format_as_table
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 tag() -> None:
17
+ """Tag management operations."""
18
+ pass
19
+
20
+
21
+ @tag.command("set")
22
+ @click.argument("catalog_id")
23
+ @click.option("--tags", required=True, help="Comma-separated list of tags")
24
+ @click.pass_context
25
+ def set_tags(ctx, catalog_id: str, tags: str) -> None:
26
+ """Set tags on a catalog object.
27
+
28
+ Examples:
29
+ dremio tag set abc-123 --tags analytics,production
30
+ dremio tag set abc-123 --tags "sensitive data,pii,gdpr"
31
+ """
32
+ try:
33
+ # Get profile
34
+ manager = ProfileManager()
35
+ profile_name = ctx.obj.profile_name
36
+ profile = manager.get_profile(profile_name)
37
+
38
+ if not profile:
39
+ console.print(f"[red]Profile '{profile_name}' not found[/red]")
40
+ raise click.Abort()
41
+
42
+ # Create client
43
+ client = create_client(profile)
44
+
45
+ # Parse tags
46
+ tag_list = [t.strip() for t in tags.split(",")]
47
+
48
+ # Set tags
49
+ with console.status(f"[bold green]Setting tags on {catalog_id}..."):
50
+ client.set_tags(catalog_id, tag_list)
51
+
52
+ console.print(f"[green]✓[/green] Tags set successfully")
53
+ console.print(f" Tags: {', '.join(tag_list)}")
54
+
55
+ except Exception as e:
56
+ console.print(f"[red]Error: {e}[/red]")
57
+ if ctx.obj.verbose:
58
+ import traceback
59
+ traceback.print_exc()
60
+ raise click.Abort()
61
+
62
+
63
+ @tag.command("get")
64
+ @click.argument("catalog_id")
65
+ @click.pass_context
66
+ def get_tags(ctx, catalog_id: str) -> None:
67
+ """Get tags from a catalog object.
68
+
69
+ Examples:
70
+ dremio tag get abc-123
71
+ """
72
+ try:
73
+ # Get profile
74
+ manager = ProfileManager()
75
+ profile_name = ctx.obj.profile_name
76
+ profile = manager.get_profile(profile_name)
77
+
78
+ if not profile:
79
+ console.print(f"[red]Profile '{profile_name}' not found[/red]")
80
+ raise click.Abort()
81
+
82
+ # Create client
83
+ client = create_client(profile)
84
+
85
+ # Get tags
86
+ with console.status(f"[bold green]Fetching tags for {catalog_id}..."):
87
+ data = client.get_tags(catalog_id)
88
+
89
+ # Format output
90
+ output_format = ctx.obj.output_format
91
+
92
+ if output_format == "json":
93
+ console.print(format_as_json(data))
94
+ elif output_format == "yaml":
95
+ console.print(format_as_yaml(data))
96
+ else:
97
+ tags = data.get("tags", [])
98
+ if tags:
99
+ console.print(f"[bold]Tags:[/bold] {', '.join(tags)}")
100
+ else:
101
+ console.print("[yellow]No tags found[/yellow]")
102
+
103
+ except Exception as e:
104
+ console.print(f"[red]Error: {e}[/red]")
105
+ if ctx.obj.verbose:
106
+ import traceback
107
+ traceback.print_exc()
108
+ raise click.Abort()
109
+
110
+
111
+ @tag.command("delete")
112
+ @click.argument("catalog_id")
113
+ @click.confirmation_option(prompt="Are you sure you want to delete all tags?")
114
+ @click.pass_context
115
+ def delete_tags(ctx, catalog_id: str) -> None:
116
+ """Delete all tags from a catalog object.
117
+
118
+ Examples:
119
+ dremio tag delete abc-123
120
+ """
121
+ try:
122
+ # Get profile
123
+ manager = ProfileManager()
124
+ profile_name = ctx.obj.profile_name
125
+ profile = manager.get_profile(profile_name)
126
+
127
+ if not profile:
128
+ console.print(f"[red]Profile '{profile_name}' not found[/red]")
129
+ raise click.Abort()
130
+
131
+ # Create client
132
+ client = create_client(profile)
133
+
134
+ # Delete tags
135
+ with console.status(f"[bold yellow]Deleting tags from {catalog_id}..."):
136
+ client.delete_tags(catalog_id)
137
+
138
+ console.print(f"[green]✓[/green] Tags deleted successfully")
139
+
140
+ except Exception as e:
141
+ console.print(f"[red]Error: {e}[/red]")
142
+ if ctx.obj.verbose:
143
+ import traceback
144
+ traceback.print_exc()
145
+ raise click.Abort()
@@ -0,0 +1,9 @@
1
+ """udf commands."""
2
+
3
+ import click
4
+
5
+ @click.group()
6
+ def udf() -> None:
7
+ """Udf operations."""
8
+ pass
9
+
@@ -0,0 +1,250 @@
1
+ """User 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
+
14
+ console = Console()
15
+
16
+
17
+ @click.group()
18
+ def user() -> None:
19
+ """User management operations."""
20
+ pass
21
+
22
+
23
+ @user.command("list")
24
+ @click.pass_context
25
+ def list_users(ctx) -> None:
26
+ """List all users.
27
+
28
+ Examples:
29
+ dremio user list
30
+ """
31
+ try:
32
+ # Get profile
33
+ manager = ProfileManager()
34
+ profile_name = ctx.obj.profile_name
35
+ profile = manager.get_profile(profile_name)
36
+
37
+ if not profile:
38
+ console.print(f"[red]Profile '{profile_name}' not found[/red]")
39
+ raise click.Abort()
40
+
41
+ # Create client
42
+ client = create_client(profile)
43
+
44
+ # List users
45
+ with console.status(f"[bold green]Fetching users..."):
46
+ data = client.list_users()
47
+
48
+ users = data.get("users", data.get("data", []))
49
+
50
+ # Format output
51
+ output_format = ctx.obj.output_format
52
+
53
+ if output_format == "json":
54
+ console.print(format_as_json(users))
55
+ elif output_format == "yaml":
56
+ console.print(format_as_yaml(users))
57
+ else:
58
+ if users:
59
+ format_as_table(users, title=f"Users ({profile_name})")
60
+ else:
61
+ console.print("[yellow]No users found[/yellow]")
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
+ @user.command("get")
72
+ @click.argument("user_id")
73
+ @click.pass_context
74
+ def get_user(ctx, user_id: str) -> None:
75
+ """Get user by ID.
76
+
77
+ Examples:
78
+ dremio user get user-123-456
79
+ """
80
+ try:
81
+ # Get profile
82
+ manager = ProfileManager()
83
+ profile_name = ctx.obj.profile_name
84
+ profile = manager.get_profile(profile_name)
85
+
86
+ if not profile:
87
+ console.print(f"[red]Profile '{profile_name}' not found[/red]")
88
+ raise click.Abort()
89
+
90
+ # Create client
91
+ client = create_client(profile)
92
+
93
+ # Get user
94
+ with console.status(f"[bold green]Fetching user {user_id}..."):
95
+ data = client.get_user(user_id)
96
+
97
+ # Format output
98
+ output_format = ctx.obj.output_format
99
+
100
+ if output_format == "json":
101
+ console.print(format_as_json(data))
102
+ elif output_format == "yaml":
103
+ console.print(format_as_yaml(data))
104
+ else:
105
+ format_as_table(data, title=f"User: {user_id}")
106
+
107
+ except Exception as e:
108
+ console.print(f"[red]Error: {e}[/red]")
109
+ if ctx.obj.verbose:
110
+ import traceback
111
+ traceback.print_exc()
112
+ raise click.Abort()
113
+
114
+
115
+ @user.command("create")
116
+ @click.option("--name", required=True, help="User full name")
117
+ @click.option("--email", required=True, help="User email")
118
+ @click.option("--username", help="Username (defaults to email)")
119
+ @click.option("--password", help="Initial password")
120
+ @click.option("--from-file", "user_file", type=click.Path(exists=True), help="Load user from JSON file")
121
+ @click.pass_context
122
+ def create_user(ctx, name: str, email: str, username: str, password: str, user_file: str) -> None:
123
+ """Create a new user.
124
+
125
+ Examples:
126
+ dremio user create --name "John Doe" --email john@company.com
127
+ dremio user create --from-file user.json
128
+ """
129
+ try:
130
+ # Get profile
131
+ manager = ProfileManager()
132
+ profile_name = ctx.obj.profile_name
133
+ profile = manager.get_profile(profile_name)
134
+
135
+ if not profile:
136
+ console.print(f"[red]Profile '{profile_name}' not found[/red]")
137
+ raise click.Abort()
138
+
139
+ # Create client
140
+ client = create_client(profile)
141
+
142
+ # Build user data
143
+ if user_file:
144
+ with open(user_file, 'r') as f:
145
+ user_data = json.load(f)
146
+ else:
147
+ user_data = {
148
+ "name": name,
149
+ "email": email,
150
+ "userName": username or email
151
+ }
152
+ if password:
153
+ user_data["password"] = password
154
+
155
+ # Create user
156
+ with console.status(f"[bold green]Creating user..."):
157
+ result = client.create_user(user_data)
158
+
159
+ user_id = result.get("id")
160
+
161
+ console.print(f"[green]✓[/green] User created successfully")
162
+ console.print(f" ID: {user_id}")
163
+ console.print(f" Name: {result.get('name', name)}")
164
+ console.print(f" Email: {result.get('email', email)}")
165
+
166
+ except Exception as e:
167
+ console.print(f"[red]Error: {e}[/red]")
168
+ if ctx.obj.verbose:
169
+ import traceback
170
+ traceback.print_exc()
171
+ raise click.Abort()
172
+
173
+
174
+ @user.command("update")
175
+ @click.argument("user_id")
176
+ @click.option("--from-file", "user_file", type=click.Path(exists=True), required=True, help="Updated user JSON file")
177
+ @click.pass_context
178
+ def update_user(ctx, user_id: str, user_file: str) -> None:
179
+ """Update an existing user.
180
+
181
+ Examples:
182
+ dremio user update user-123 --from-file updated_user.json
183
+ """
184
+ try:
185
+ # Get profile
186
+ manager = ProfileManager()
187
+ profile_name = ctx.obj.profile_name
188
+ profile = manager.get_profile(profile_name)
189
+
190
+ if not profile:
191
+ console.print(f"[red]Profile '{profile_name}' not found[/red]")
192
+ raise click.Abort()
193
+
194
+ # Create client
195
+ client = create_client(profile)
196
+
197
+ # Load user data
198
+ with open(user_file, 'r') as f:
199
+ user_data = json.load(f)
200
+
201
+ # Update user
202
+ with console.status(f"[bold green]Updating user {user_id}..."):
203
+ result = client.update_user(user_id, user_data)
204
+
205
+ console.print(f"[green]✓[/green] User updated successfully")
206
+ console.print(f" ID: {user_id}")
207
+
208
+ except Exception as e:
209
+ console.print(f"[red]Error: {e}[/red]")
210
+ if ctx.obj.verbose:
211
+ import traceback
212
+ traceback.print_exc()
213
+ raise click.Abort()
214
+
215
+
216
+ @user.command("delete")
217
+ @click.argument("user_id")
218
+ @click.confirmation_option(prompt="Are you sure you want to delete this user?")
219
+ @click.pass_context
220
+ def delete_user(ctx, user_id: str) -> None:
221
+ """Delete a user.
222
+
223
+ Examples:
224
+ dremio user delete user-123-456
225
+ """
226
+ try:
227
+ # Get profile
228
+ manager = ProfileManager()
229
+ profile_name = ctx.obj.profile_name
230
+ profile = manager.get_profile(profile_name)
231
+
232
+ if not profile:
233
+ console.print(f"[red]Profile '{profile_name}' not found[/red]")
234
+ raise click.Abort()
235
+
236
+ # Create client
237
+ client = create_client(profile)
238
+
239
+ # Delete user
240
+ with console.status(f"[bold yellow]Deleting user {user_id}..."):
241
+ client.delete_user(user_id)
242
+
243
+ console.print(f"[green]✓[/green] User deleted successfully")
244
+
245
+ except Exception as e:
246
+ console.print(f"[red]Error: {e}[/red]")
247
+ if ctx.obj.verbose:
248
+ import traceback
249
+ traceback.print_exc()
250
+ raise click.Abort()