pltr-cli 0.4.0__py3-none-any.whl → 0.5.1__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.
pltr/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.1.0"
1
+ __version__ = "0.5.0"
pltr/cli.py CHANGED
@@ -11,12 +11,19 @@ from pltr.commands import (
11
11
  verify,
12
12
  dataset,
13
13
  folder,
14
+ project,
15
+ resource,
16
+ resource_role,
17
+ space,
14
18
  ontology,
19
+ orchestration,
15
20
  sql,
16
21
  admin,
17
22
  shell,
18
23
  completion,
19
24
  alias,
25
+ mediasets,
26
+ connectivity,
20
27
  )
21
28
 
22
29
  app = typer.Typer(
@@ -30,8 +37,23 @@ app.add_typer(configure.app, name="configure", help="Manage authentication profi
30
37
  app.add_typer(verify.app, name="verify", help="Verify authentication")
31
38
  app.add_typer(dataset.app, name="dataset", help="Manage datasets")
32
39
  app.add_typer(folder.app, name="folder", help="Manage folders")
40
+ app.add_typer(project.app, name="project", help="Manage projects")
41
+ app.add_typer(resource.app, name="resource", help="Manage resources")
42
+ app.add_typer(
43
+ resource_role.app, name="resource-role", help="Manage resource permissions"
44
+ )
45
+ app.add_typer(space.app, name="space", help="Manage spaces")
33
46
  app.add_typer(ontology.app, name="ontology", help="Ontology operations")
47
+ app.add_typer(
48
+ orchestration.app, name="orchestration", help="Manage builds, jobs, and schedules"
49
+ )
34
50
  app.add_typer(sql.app, name="sql", help="Execute SQL queries")
51
+ app.add_typer(
52
+ mediasets.app, name="media-sets", help="Manage media sets and media content"
53
+ )
54
+ app.add_typer(
55
+ connectivity.app, name="connectivity", help="Manage connections and data imports"
56
+ )
35
57
  app.add_typer(
36
58
  admin.app,
37
59
  name="admin",
@@ -0,0 +1,432 @@
1
+ """
2
+ Connectivity management commands for Foundry connections and imports.
3
+ """
4
+
5
+ import typer
6
+ import json
7
+ from typing import Optional
8
+ from rich.console import Console
9
+
10
+ from ..services.connectivity import ConnectivityService
11
+ from ..utils.formatting import OutputFormatter
12
+ from ..utils.progress import SpinnerProgressTracker
13
+ from ..auth.base import ProfileNotFoundError, MissingCredentialsError
14
+ from ..utils.completion import (
15
+ complete_rid,
16
+ complete_profile,
17
+ complete_output_format,
18
+ cache_rid,
19
+ )
20
+
21
+ app = typer.Typer()
22
+ connection_app = typer.Typer()
23
+ import_app = typer.Typer()
24
+ console = Console()
25
+ formatter = OutputFormatter(console)
26
+
27
+ # Add sub-apps
28
+ app.add_typer(connection_app, name="connection", help="Manage connections")
29
+ app.add_typer(import_app, name="import", help="Manage data imports")
30
+
31
+
32
+ @connection_app.command("list")
33
+ def list_connections(
34
+ profile: Optional[str] = typer.Option(
35
+ None, "--profile", "-p", help="Profile name", autocompletion=complete_profile
36
+ ),
37
+ format: str = typer.Option(
38
+ "table",
39
+ "--format",
40
+ "-f",
41
+ help="Output format (table, json, csv)",
42
+ autocompletion=complete_output_format,
43
+ ),
44
+ output: Optional[str] = typer.Option(
45
+ None, "--output", "-o", help="Output file path"
46
+ ),
47
+ ):
48
+ """List available connections."""
49
+ try:
50
+ with SpinnerProgressTracker().track_spinner("Fetching connections..."):
51
+ service = ConnectivityService(profile=profile)
52
+ connections = service.list_connections()
53
+
54
+ if not connections:
55
+ console.print("[yellow]No connections found[/yellow]")
56
+ return
57
+
58
+ formatter.format_output(connections, format, output)
59
+
60
+ except (ProfileNotFoundError, MissingCredentialsError) as e:
61
+ console.print(f"[red]Authentication error: {e}[/red]")
62
+ raise typer.Exit(1)
63
+ except Exception as e:
64
+ console.print(f"[red]Error listing connections: {e}[/red]")
65
+ raise typer.Exit(1)
66
+
67
+
68
+ @connection_app.command("get")
69
+ def get_connection(
70
+ connection_rid: str = typer.Argument(
71
+ ..., help="Connection Resource Identifier", autocompletion=complete_rid
72
+ ),
73
+ profile: Optional[str] = typer.Option(
74
+ None, "--profile", "-p", help="Profile name", autocompletion=complete_profile
75
+ ),
76
+ format: str = typer.Option(
77
+ "table",
78
+ "--format",
79
+ "-f",
80
+ help="Output format (table, json, csv)",
81
+ autocompletion=complete_output_format,
82
+ ),
83
+ output: Optional[str] = typer.Option(
84
+ None, "--output", "-o", help="Output file path"
85
+ ),
86
+ ):
87
+ """Get detailed information about a specific connection."""
88
+ try:
89
+ cache_rid(connection_rid)
90
+
91
+ with SpinnerProgressTracker().track_spinner(
92
+ f"Fetching connection {connection_rid}..."
93
+ ):
94
+ service = ConnectivityService(profile=profile)
95
+ connection = service.get_connection(connection_rid)
96
+
97
+ formatter.format_output([connection], format, output)
98
+
99
+ except (ProfileNotFoundError, MissingCredentialsError) as e:
100
+ console.print(f"[red]Authentication error: {e}[/red]")
101
+ raise typer.Exit(1)
102
+ except Exception as e:
103
+ console.print(f"[red]Error getting connection: {e}[/red]")
104
+ raise typer.Exit(1)
105
+
106
+
107
+ @import_app.command("file")
108
+ def import_file(
109
+ connection_rid: str = typer.Argument(
110
+ ..., help="Connection Resource Identifier", autocompletion=complete_rid
111
+ ),
112
+ source_path: str = typer.Argument(..., help="Source file path in the connection"),
113
+ target_dataset_rid: str = typer.Argument(
114
+ ..., help="Target dataset RID", autocompletion=complete_rid
115
+ ),
116
+ profile: Optional[str] = typer.Option(
117
+ None, "--profile", "-p", help="Profile name", autocompletion=complete_profile
118
+ ),
119
+ config: Optional[str] = typer.Option(
120
+ None, "--config", "-c", help="Import configuration in JSON format"
121
+ ),
122
+ execute: bool = typer.Option(
123
+ False, "--execute", help="Execute the import immediately after creation"
124
+ ),
125
+ format: str = typer.Option(
126
+ "table",
127
+ "--format",
128
+ "-f",
129
+ help="Output format (table, json, csv)",
130
+ autocompletion=complete_output_format,
131
+ ),
132
+ output: Optional[str] = typer.Option(
133
+ None, "--output", "-o", help="Output file path"
134
+ ),
135
+ ):
136
+ """Create and optionally execute a file import via connection."""
137
+ try:
138
+ cache_rid(connection_rid)
139
+ cache_rid(target_dataset_rid)
140
+
141
+ # Parse import configuration if provided
142
+ import_config = None
143
+ if config:
144
+ try:
145
+ import_config = json.loads(config)
146
+ except json.JSONDecodeError as e:
147
+ console.print(f"[red]Invalid JSON configuration: {e}[/red]")
148
+ raise typer.Exit(1)
149
+
150
+ service = ConnectivityService(profile=profile)
151
+
152
+ with SpinnerProgressTracker().track_spinner("Creating file import..."):
153
+ file_import = service.create_file_import(
154
+ connection_rid=connection_rid,
155
+ source_path=source_path,
156
+ target_dataset_rid=target_dataset_rid,
157
+ import_config=import_config,
158
+ )
159
+
160
+ result_data = [file_import]
161
+
162
+ # Execute import if requested
163
+ if execute:
164
+ import_rid = file_import.get("rid")
165
+ if import_rid:
166
+ with SpinnerProgressTracker().track_spinner("Executing file import..."):
167
+ execution_result = service.execute_file_import(import_rid)
168
+ result_data.append({"execution": execution_result})
169
+ console.print(f"[green]File import executed: {import_rid}[/green]")
170
+ else:
171
+ console.print(
172
+ "[yellow]Warning: Could not execute - missing import RID[/yellow]"
173
+ )
174
+
175
+ formatter.format_output(result_data, format, output)
176
+
177
+ except (ProfileNotFoundError, MissingCredentialsError) as e:
178
+ console.print(f"[red]Authentication error: {e}[/red]")
179
+ raise typer.Exit(1)
180
+ except Exception as e:
181
+ console.print(f"[red]Error creating file import: {e}[/red]")
182
+ raise typer.Exit(1)
183
+
184
+
185
+ @import_app.command("table")
186
+ def import_table(
187
+ connection_rid: str = typer.Argument(
188
+ ..., help="Connection Resource Identifier", autocompletion=complete_rid
189
+ ),
190
+ source_table: str = typer.Argument(..., help="Source table name in the connection"),
191
+ target_dataset_rid: str = typer.Argument(
192
+ ..., help="Target dataset RID", autocompletion=complete_rid
193
+ ),
194
+ profile: Optional[str] = typer.Option(
195
+ None, "--profile", "-p", help="Profile name", autocompletion=complete_profile
196
+ ),
197
+ config: Optional[str] = typer.Option(
198
+ None, "--config", "-c", help="Import configuration in JSON format"
199
+ ),
200
+ execute: bool = typer.Option(
201
+ False, "--execute", help="Execute the import immediately after creation"
202
+ ),
203
+ format: str = typer.Option(
204
+ "table",
205
+ "--format",
206
+ "-f",
207
+ help="Output format (table, json, csv)",
208
+ autocompletion=complete_output_format,
209
+ ),
210
+ output: Optional[str] = typer.Option(
211
+ None, "--output", "-o", help="Output file path"
212
+ ),
213
+ ):
214
+ """Create and optionally execute a table import via connection."""
215
+ try:
216
+ cache_rid(connection_rid)
217
+ cache_rid(target_dataset_rid)
218
+
219
+ # Parse import configuration if provided
220
+ import_config = None
221
+ if config:
222
+ try:
223
+ import_config = json.loads(config)
224
+ except json.JSONDecodeError as e:
225
+ console.print(f"[red]Invalid JSON configuration: {e}[/red]")
226
+ raise typer.Exit(1)
227
+
228
+ service = ConnectivityService(profile=profile)
229
+
230
+ with SpinnerProgressTracker().track_spinner("Creating table import..."):
231
+ table_import = service.create_table_import(
232
+ connection_rid=connection_rid,
233
+ source_table=source_table,
234
+ target_dataset_rid=target_dataset_rid,
235
+ import_config=import_config,
236
+ )
237
+
238
+ result_data = [table_import]
239
+
240
+ # Execute import if requested
241
+ if execute:
242
+ import_rid = table_import.get("rid")
243
+ if import_rid:
244
+ with SpinnerProgressTracker().track_spinner(
245
+ "Executing table import..."
246
+ ):
247
+ execution_result = service.execute_table_import(import_rid)
248
+ result_data.append({"execution": execution_result})
249
+ console.print(f"[green]Table import executed: {import_rid}[/green]")
250
+ else:
251
+ console.print(
252
+ "[yellow]Warning: Could not execute - missing import RID[/yellow]"
253
+ )
254
+
255
+ formatter.format_output(result_data, format, output)
256
+
257
+ except (ProfileNotFoundError, MissingCredentialsError) as e:
258
+ console.print(f"[red]Authentication error: {e}[/red]")
259
+ raise typer.Exit(1)
260
+ except Exception as e:
261
+ console.print(f"[red]Error creating table import: {e}[/red]")
262
+ raise typer.Exit(1)
263
+
264
+
265
+ @import_app.command("list-file")
266
+ def list_file_imports(
267
+ connection_rid: Optional[str] = typer.Option(
268
+ None,
269
+ "--connection",
270
+ "-c",
271
+ help="Filter by connection RID",
272
+ autocompletion=complete_rid,
273
+ ),
274
+ profile: Optional[str] = typer.Option(
275
+ None, "--profile", "-p", help="Profile name", autocompletion=complete_profile
276
+ ),
277
+ format: str = typer.Option(
278
+ "table",
279
+ "--format",
280
+ "-f",
281
+ help="Output format (table, json, csv)",
282
+ autocompletion=complete_output_format,
283
+ ),
284
+ output: Optional[str] = typer.Option(
285
+ None, "--output", "-o", help="Output file path"
286
+ ),
287
+ ):
288
+ """List file imports, optionally filtered by connection."""
289
+ try:
290
+ if connection_rid:
291
+ cache_rid(connection_rid)
292
+
293
+ with SpinnerProgressTracker().track_spinner("Fetching file imports..."):
294
+ service = ConnectivityService(profile=profile)
295
+ imports = service.list_file_imports(connection_rid=connection_rid)
296
+
297
+ if not imports:
298
+ console.print("[yellow]No file imports found[/yellow]")
299
+ return
300
+
301
+ formatter.format_output(imports, format, output)
302
+
303
+ except (ProfileNotFoundError, MissingCredentialsError) as e:
304
+ console.print(f"[red]Authentication error: {e}[/red]")
305
+ raise typer.Exit(1)
306
+ except Exception as e:
307
+ console.print(f"[red]Error listing file imports: {e}[/red]")
308
+ raise typer.Exit(1)
309
+
310
+
311
+ @import_app.command("list-table")
312
+ def list_table_imports(
313
+ connection_rid: Optional[str] = typer.Option(
314
+ None,
315
+ "--connection",
316
+ "-c",
317
+ help="Filter by connection RID",
318
+ autocompletion=complete_rid,
319
+ ),
320
+ profile: Optional[str] = typer.Option(
321
+ None, "--profile", "-p", help="Profile name", autocompletion=complete_profile
322
+ ),
323
+ format: str = typer.Option(
324
+ "table",
325
+ "--format",
326
+ "-f",
327
+ help="Output format (table, json, csv)",
328
+ autocompletion=complete_output_format,
329
+ ),
330
+ output: Optional[str] = typer.Option(
331
+ None, "--output", "-o", help="Output file path"
332
+ ),
333
+ ):
334
+ """List table imports, optionally filtered by connection."""
335
+ try:
336
+ if connection_rid:
337
+ cache_rid(connection_rid)
338
+
339
+ with SpinnerProgressTracker().track_spinner("Fetching table imports..."):
340
+ service = ConnectivityService(profile=profile)
341
+ imports = service.list_table_imports(connection_rid=connection_rid)
342
+
343
+ if not imports:
344
+ console.print("[yellow]No table imports found[/yellow]")
345
+ return
346
+
347
+ formatter.format_output(imports, format, output)
348
+
349
+ except (ProfileNotFoundError, MissingCredentialsError) as e:
350
+ console.print(f"[red]Authentication error: {e}[/red]")
351
+ raise typer.Exit(1)
352
+ except Exception as e:
353
+ console.print(f"[red]Error listing table imports: {e}[/red]")
354
+ raise typer.Exit(1)
355
+
356
+
357
+ @import_app.command("get-file")
358
+ def get_file_import(
359
+ import_rid: str = typer.Argument(
360
+ ..., help="File import Resource Identifier", autocompletion=complete_rid
361
+ ),
362
+ profile: Optional[str] = typer.Option(
363
+ None, "--profile", "-p", help="Profile name", autocompletion=complete_profile
364
+ ),
365
+ format: str = typer.Option(
366
+ "table",
367
+ "--format",
368
+ "-f",
369
+ help="Output format (table, json, csv)",
370
+ autocompletion=complete_output_format,
371
+ ),
372
+ output: Optional[str] = typer.Option(
373
+ None, "--output", "-o", help="Output file path"
374
+ ),
375
+ ):
376
+ """Get detailed information about a specific file import."""
377
+ try:
378
+ cache_rid(import_rid)
379
+
380
+ with SpinnerProgressTracker().track_spinner(
381
+ f"Fetching file import {import_rid}..."
382
+ ):
383
+ service = ConnectivityService(profile=profile)
384
+ file_import = service.get_file_import(import_rid)
385
+
386
+ formatter.format_output([file_import], format, output)
387
+
388
+ except (ProfileNotFoundError, MissingCredentialsError) as e:
389
+ console.print(f"[red]Authentication error: {e}[/red]")
390
+ raise typer.Exit(1)
391
+ except Exception as e:
392
+ console.print(f"[red]Error getting file import: {e}[/red]")
393
+ raise typer.Exit(1)
394
+
395
+
396
+ @import_app.command("get-table")
397
+ def get_table_import(
398
+ import_rid: str = typer.Argument(
399
+ ..., help="Table import Resource Identifier", autocompletion=complete_rid
400
+ ),
401
+ profile: Optional[str] = typer.Option(
402
+ None, "--profile", "-p", help="Profile name", autocompletion=complete_profile
403
+ ),
404
+ format: str = typer.Option(
405
+ "table",
406
+ "--format",
407
+ "-f",
408
+ help="Output format (table, json, csv)",
409
+ autocompletion=complete_output_format,
410
+ ),
411
+ output: Optional[str] = typer.Option(
412
+ None, "--output", "-o", help="Output file path"
413
+ ),
414
+ ):
415
+ """Get detailed information about a specific table import."""
416
+ try:
417
+ cache_rid(import_rid)
418
+
419
+ with SpinnerProgressTracker().track_spinner(
420
+ f"Fetching table import {import_rid}..."
421
+ ):
422
+ service = ConnectivityService(profile=profile)
423
+ table_import = service.get_table_import(import_rid)
424
+
425
+ formatter.format_output([table_import], format, output)
426
+
427
+ except (ProfileNotFoundError, MissingCredentialsError) as e:
428
+ console.print(f"[red]Authentication error: {e}[/red]")
429
+ raise typer.Exit(1)
430
+ except Exception as e:
431
+ console.print(f"[red]Error getting table import: {e}[/red]")
432
+ raise typer.Exit(1)