pltr-cli 0.5.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 +1 -1
- pltr/cli.py +14 -0
- pltr/commands/connectivity.py +432 -0
- pltr/commands/dataset.py +268 -0
- pltr/commands/project.py +440 -0
- pltr/commands/resource.py +499 -0
- pltr/commands/resource_role.py +454 -0
- pltr/commands/space.py +662 -0
- pltr/services/connectivity.py +305 -0
- pltr/services/dataset.py +243 -8
- pltr/services/project.py +232 -0
- pltr/services/resource.py +289 -0
- pltr/services/resource_role.py +321 -0
- pltr/services/space.py +354 -0
- pltr/utils/formatting.py +108 -1
- {pltr_cli-0.5.0.dist-info → pltr_cli-0.5.1.dist-info}/METADATA +101 -2
- {pltr_cli-0.5.0.dist-info → pltr_cli-0.5.1.dist-info}/RECORD +20 -10
- {pltr_cli-0.5.0.dist-info → pltr_cli-0.5.1.dist-info}/WHEEL +0 -0
- {pltr_cli-0.5.0.dist-info → pltr_cli-0.5.1.dist-info}/entry_points.txt +0 -0
- {pltr_cli-0.5.0.dist-info → pltr_cli-0.5.1.dist-info}/licenses/LICENSE +0 -0
pltr/commands/dataset.py
CHANGED
|
@@ -233,6 +233,60 @@ def list_files(
|
|
|
233
233
|
raise typer.Exit(1)
|
|
234
234
|
|
|
235
235
|
|
|
236
|
+
@files_app.command("upload")
|
|
237
|
+
def upload_file(
|
|
238
|
+
file_path: str = typer.Argument(..., help="Local path to file to upload"),
|
|
239
|
+
dataset_rid: str = typer.Argument(
|
|
240
|
+
..., help="Dataset Resource Identifier", autocompletion=complete_rid
|
|
241
|
+
),
|
|
242
|
+
branch: str = typer.Option("master", "--branch", help="Dataset branch"),
|
|
243
|
+
transaction_rid: Optional[str] = typer.Option(
|
|
244
|
+
None, "--transaction-rid", help="Transaction RID for the upload"
|
|
245
|
+
),
|
|
246
|
+
profile: Optional[str] = typer.Option(
|
|
247
|
+
None, "--profile", "-p", help="Profile name", autocompletion=complete_profile
|
|
248
|
+
),
|
|
249
|
+
):
|
|
250
|
+
"""Upload a file to a dataset."""
|
|
251
|
+
try:
|
|
252
|
+
cache_rid(dataset_rid)
|
|
253
|
+
service = DatasetService(profile=profile)
|
|
254
|
+
|
|
255
|
+
# Check if file exists
|
|
256
|
+
from pathlib import Path
|
|
257
|
+
|
|
258
|
+
file_path_obj = Path(file_path)
|
|
259
|
+
if not file_path_obj.exists():
|
|
260
|
+
formatter.print_error(f"File not found: {file_path}")
|
|
261
|
+
raise typer.Exit(1)
|
|
262
|
+
|
|
263
|
+
with SpinnerProgressTracker().track_spinner(
|
|
264
|
+
f"Uploading {file_path_obj.name} to {dataset_rid}..."
|
|
265
|
+
):
|
|
266
|
+
result = service.upload_file(
|
|
267
|
+
dataset_rid, file_path, branch, transaction_rid
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
formatter.print_success("File uploaded successfully")
|
|
271
|
+
formatter.print_info(f"File: {result.get('file_path', file_path)}")
|
|
272
|
+
formatter.print_info(f"Dataset: {dataset_rid}")
|
|
273
|
+
formatter.print_info(f"Branch: {branch}")
|
|
274
|
+
formatter.print_info(f"Size: {result.get('size_bytes', 'unknown')} bytes")
|
|
275
|
+
|
|
276
|
+
if result.get("transaction_rid"):
|
|
277
|
+
formatter.print_info(f"Transaction: {result['transaction_rid']}")
|
|
278
|
+
formatter.print_warning(
|
|
279
|
+
"Remember to commit the transaction to make changes permanent"
|
|
280
|
+
)
|
|
281
|
+
|
|
282
|
+
except (ProfileNotFoundError, MissingCredentialsError) as e:
|
|
283
|
+
formatter.print_error(f"Authentication error: {e}")
|
|
284
|
+
raise typer.Exit(1)
|
|
285
|
+
except Exception as e:
|
|
286
|
+
formatter.print_error(f"Failed to upload file: {e}")
|
|
287
|
+
raise typer.Exit(1)
|
|
288
|
+
|
|
289
|
+
|
|
236
290
|
@files_app.command("get")
|
|
237
291
|
def get_file(
|
|
238
292
|
dataset_rid: str = typer.Argument(
|
|
@@ -267,6 +321,220 @@ def get_file(
|
|
|
267
321
|
|
|
268
322
|
|
|
269
323
|
# Transaction commands
|
|
324
|
+
@transactions_app.command("start")
|
|
325
|
+
def start_transaction(
|
|
326
|
+
dataset_rid: str = typer.Argument(
|
|
327
|
+
..., help="Dataset Resource Identifier", autocompletion=complete_rid
|
|
328
|
+
),
|
|
329
|
+
branch: str = typer.Option("master", "--branch", help="Dataset branch"),
|
|
330
|
+
transaction_type: str = typer.Option(
|
|
331
|
+
"APPEND", "--type", help="Transaction type (APPEND, UPDATE, SNAPSHOT, DELETE)"
|
|
332
|
+
),
|
|
333
|
+
profile: Optional[str] = typer.Option(
|
|
334
|
+
None, "--profile", "-p", help="Profile name", autocompletion=complete_profile
|
|
335
|
+
),
|
|
336
|
+
format: str = typer.Option(
|
|
337
|
+
"table",
|
|
338
|
+
"--format",
|
|
339
|
+
"-f",
|
|
340
|
+
help="Output format (table, json, csv)",
|
|
341
|
+
autocompletion=complete_output_format,
|
|
342
|
+
),
|
|
343
|
+
):
|
|
344
|
+
"""Start a new transaction for a dataset."""
|
|
345
|
+
try:
|
|
346
|
+
cache_rid(dataset_rid)
|
|
347
|
+
service = DatasetService(profile=profile)
|
|
348
|
+
|
|
349
|
+
# Validate transaction type
|
|
350
|
+
valid_types = ["APPEND", "UPDATE", "SNAPSHOT", "DELETE"]
|
|
351
|
+
if transaction_type not in valid_types:
|
|
352
|
+
formatter.print_error(
|
|
353
|
+
f"Invalid transaction type. Must be one of: {', '.join(valid_types)}"
|
|
354
|
+
)
|
|
355
|
+
raise typer.Exit(1)
|
|
356
|
+
|
|
357
|
+
with SpinnerProgressTracker().track_spinner(
|
|
358
|
+
f"Starting {transaction_type} transaction for {dataset_rid} (branch: {branch})..."
|
|
359
|
+
):
|
|
360
|
+
transaction = service.create_transaction(
|
|
361
|
+
dataset_rid, branch, transaction_type
|
|
362
|
+
)
|
|
363
|
+
|
|
364
|
+
formatter.print_success("Transaction started successfully")
|
|
365
|
+
formatter.print_info(
|
|
366
|
+
f"Transaction RID: {transaction.get('transaction_rid', 'unknown')}"
|
|
367
|
+
)
|
|
368
|
+
formatter.print_info(f"Status: {transaction.get('status', 'OPEN')}")
|
|
369
|
+
formatter.print_info(
|
|
370
|
+
f"Type: {transaction.get('transaction_type', transaction_type)}"
|
|
371
|
+
)
|
|
372
|
+
|
|
373
|
+
# Show transaction details
|
|
374
|
+
formatter.format_transaction_detail(transaction, format)
|
|
375
|
+
|
|
376
|
+
# Show usage hint
|
|
377
|
+
transaction_rid = transaction.get("transaction_rid", "unknown")
|
|
378
|
+
if transaction_rid != "unknown":
|
|
379
|
+
formatter.print_info("\nNext steps:")
|
|
380
|
+
formatter.print_info(
|
|
381
|
+
f" Upload files: pltr dataset files upload <file-path> {dataset_rid} --transaction-rid {transaction_rid}"
|
|
382
|
+
)
|
|
383
|
+
formatter.print_info(
|
|
384
|
+
f" Commit: pltr dataset transactions commit {dataset_rid} {transaction_rid}"
|
|
385
|
+
)
|
|
386
|
+
formatter.print_info(
|
|
387
|
+
f" Abort: pltr dataset transactions abort {dataset_rid} {transaction_rid}"
|
|
388
|
+
)
|
|
389
|
+
|
|
390
|
+
except (ProfileNotFoundError, MissingCredentialsError) as e:
|
|
391
|
+
formatter.print_error(f"Authentication error: {e}")
|
|
392
|
+
raise typer.Exit(1)
|
|
393
|
+
except Exception as e:
|
|
394
|
+
formatter.print_error(f"Failed to start transaction: {e}")
|
|
395
|
+
raise typer.Exit(1)
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
@transactions_app.command("commit")
|
|
399
|
+
def commit_transaction(
|
|
400
|
+
dataset_rid: str = typer.Argument(
|
|
401
|
+
..., help="Dataset Resource Identifier", autocompletion=complete_rid
|
|
402
|
+
),
|
|
403
|
+
transaction_rid: str = typer.Argument(..., help="Transaction Resource Identifier"),
|
|
404
|
+
profile: Optional[str] = typer.Option(
|
|
405
|
+
None, "--profile", "-p", help="Profile name", autocompletion=complete_profile
|
|
406
|
+
),
|
|
407
|
+
format: str = typer.Option(
|
|
408
|
+
"table",
|
|
409
|
+
"--format",
|
|
410
|
+
"-f",
|
|
411
|
+
help="Output format (table, json, csv)",
|
|
412
|
+
autocompletion=complete_output_format,
|
|
413
|
+
),
|
|
414
|
+
):
|
|
415
|
+
"""Commit an open transaction."""
|
|
416
|
+
try:
|
|
417
|
+
cache_rid(dataset_rid)
|
|
418
|
+
service = DatasetService(profile=profile)
|
|
419
|
+
|
|
420
|
+
with SpinnerProgressTracker().track_spinner(
|
|
421
|
+
f"Committing transaction {transaction_rid}..."
|
|
422
|
+
):
|
|
423
|
+
result = service.commit_transaction(dataset_rid, transaction_rid)
|
|
424
|
+
|
|
425
|
+
formatter.print_success("Transaction committed successfully")
|
|
426
|
+
formatter.print_info(f"Transaction RID: {transaction_rid}")
|
|
427
|
+
formatter.print_info(f"Dataset RID: {dataset_rid}")
|
|
428
|
+
formatter.print_info(f"Status: {result.get('status', 'COMMITTED')}")
|
|
429
|
+
|
|
430
|
+
# Show result details
|
|
431
|
+
formatter.format_transaction_result(result, format)
|
|
432
|
+
|
|
433
|
+
except (ProfileNotFoundError, MissingCredentialsError) as e:
|
|
434
|
+
formatter.print_error(f"Authentication error: {e}")
|
|
435
|
+
raise typer.Exit(1)
|
|
436
|
+
except Exception as e:
|
|
437
|
+
formatter.print_error(f"Failed to commit transaction: {e}")
|
|
438
|
+
raise typer.Exit(1)
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
@transactions_app.command("abort")
|
|
442
|
+
def abort_transaction(
|
|
443
|
+
dataset_rid: str = typer.Argument(
|
|
444
|
+
..., help="Dataset Resource Identifier", autocompletion=complete_rid
|
|
445
|
+
),
|
|
446
|
+
transaction_rid: str = typer.Argument(..., help="Transaction Resource Identifier"),
|
|
447
|
+
confirm: bool = typer.Option(False, "--yes", "-y", help="Skip confirmation prompt"),
|
|
448
|
+
profile: Optional[str] = typer.Option(
|
|
449
|
+
None, "--profile", "-p", help="Profile name", autocompletion=complete_profile
|
|
450
|
+
),
|
|
451
|
+
format: str = typer.Option(
|
|
452
|
+
"table",
|
|
453
|
+
"--format",
|
|
454
|
+
"-f",
|
|
455
|
+
help="Output format (table, json, csv)",
|
|
456
|
+
autocompletion=complete_output_format,
|
|
457
|
+
),
|
|
458
|
+
):
|
|
459
|
+
"""Abort an open transaction."""
|
|
460
|
+
try:
|
|
461
|
+
cache_rid(dataset_rid)
|
|
462
|
+
service = DatasetService(profile=profile)
|
|
463
|
+
|
|
464
|
+
# Confirmation prompt
|
|
465
|
+
if not confirm:
|
|
466
|
+
confirmed = typer.confirm(
|
|
467
|
+
f"Are you sure you want to abort transaction {transaction_rid}? "
|
|
468
|
+
f"This will discard all changes made in this transaction."
|
|
469
|
+
)
|
|
470
|
+
if not confirmed:
|
|
471
|
+
formatter.print_info("Transaction abort cancelled")
|
|
472
|
+
raise typer.Exit(0)
|
|
473
|
+
|
|
474
|
+
with SpinnerProgressTracker().track_spinner(
|
|
475
|
+
f"Aborting transaction {transaction_rid}..."
|
|
476
|
+
):
|
|
477
|
+
result = service.abort_transaction(dataset_rid, transaction_rid)
|
|
478
|
+
|
|
479
|
+
formatter.print_success("Transaction aborted successfully")
|
|
480
|
+
formatter.print_info(f"Transaction RID: {transaction_rid}")
|
|
481
|
+
formatter.print_info(f"Dataset RID: {dataset_rid}")
|
|
482
|
+
formatter.print_info(f"Status: {result.get('status', 'ABORTED')}")
|
|
483
|
+
formatter.print_warning(
|
|
484
|
+
"All changes made in this transaction have been discarded"
|
|
485
|
+
)
|
|
486
|
+
|
|
487
|
+
# Show result details
|
|
488
|
+
formatter.format_transaction_result(result, format)
|
|
489
|
+
|
|
490
|
+
except (ProfileNotFoundError, MissingCredentialsError) as e:
|
|
491
|
+
formatter.print_error(f"Authentication error: {e}")
|
|
492
|
+
raise typer.Exit(1)
|
|
493
|
+
except Exception as e:
|
|
494
|
+
formatter.print_error(f"Failed to abort transaction: {e}")
|
|
495
|
+
raise typer.Exit(1)
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
@transactions_app.command("status")
|
|
499
|
+
def get_transaction_status(
|
|
500
|
+
dataset_rid: str = typer.Argument(
|
|
501
|
+
..., help="Dataset Resource Identifier", autocompletion=complete_rid
|
|
502
|
+
),
|
|
503
|
+
transaction_rid: str = typer.Argument(..., help="Transaction Resource Identifier"),
|
|
504
|
+
profile: Optional[str] = typer.Option(
|
|
505
|
+
None, "--profile", "-p", help="Profile name", autocompletion=complete_profile
|
|
506
|
+
),
|
|
507
|
+
format: str = typer.Option(
|
|
508
|
+
"table",
|
|
509
|
+
"--format",
|
|
510
|
+
"-f",
|
|
511
|
+
help="Output format (table, json, csv)",
|
|
512
|
+
autocompletion=complete_output_format,
|
|
513
|
+
),
|
|
514
|
+
):
|
|
515
|
+
"""Get the status of a specific transaction."""
|
|
516
|
+
try:
|
|
517
|
+
cache_rid(dataset_rid)
|
|
518
|
+
service = DatasetService(profile=profile)
|
|
519
|
+
|
|
520
|
+
with SpinnerProgressTracker().track_spinner(
|
|
521
|
+
f"Fetching transaction status for {transaction_rid}..."
|
|
522
|
+
):
|
|
523
|
+
transaction = service.get_transaction_status(dataset_rid, transaction_rid)
|
|
524
|
+
|
|
525
|
+
formatter.print_success("Transaction status retrieved")
|
|
526
|
+
|
|
527
|
+
# Show transaction details
|
|
528
|
+
formatter.format_transaction_detail(transaction, format)
|
|
529
|
+
|
|
530
|
+
except (ProfileNotFoundError, MissingCredentialsError) as e:
|
|
531
|
+
formatter.print_error(f"Authentication error: {e}")
|
|
532
|
+
raise typer.Exit(1)
|
|
533
|
+
except Exception as e:
|
|
534
|
+
formatter.print_error(f"Failed to get transaction status: {e}")
|
|
535
|
+
raise typer.Exit(1)
|
|
536
|
+
|
|
537
|
+
|
|
270
538
|
@transactions_app.command("list")
|
|
271
539
|
def list_transactions(
|
|
272
540
|
dataset_rid: str = typer.Argument(
|