pltr-cli 0.3.0__py3-none-any.whl → 0.5.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.
- pltr/cli.py +10 -0
- pltr/commands/dataset.py +309 -0
- pltr/commands/folder.py +338 -0
- pltr/commands/mediasets.py +422 -0
- pltr/commands/orchestration.py +642 -0
- pltr/services/dataset.py +368 -10
- pltr/services/folder.py +167 -0
- pltr/services/mediasets.py +293 -0
- pltr/services/orchestration.py +457 -0
- pltr/utils/formatting.py +638 -0
- {pltr_cli-0.3.0.dist-info → pltr_cli-0.5.0.dist-info}/METADATA +139 -5
- {pltr_cli-0.3.0.dist-info → pltr_cli-0.5.0.dist-info}/RECORD +15 -11
- pltr/services/dataset_full.py +0 -302
- pltr/services/dataset_v2.py +0 -128
- {pltr_cli-0.3.0.dist-info → pltr_cli-0.5.0.dist-info}/WHEEL +0 -0
- {pltr_cli-0.3.0.dist-info → pltr_cli-0.5.0.dist-info}/entry_points.txt +0 -0
- {pltr_cli-0.3.0.dist-info → pltr_cli-0.5.0.dist-info}/licenses/LICENSE +0 -0
pltr/utils/formatting.py
CHANGED
|
@@ -537,3 +537,641 @@ class OutputFormatter:
|
|
|
537
537
|
return self.format_output(display_data, format_type, output_file)
|
|
538
538
|
else:
|
|
539
539
|
return self.format_output(status_info, format_type, output_file)
|
|
540
|
+
|
|
541
|
+
# ============================================================================
|
|
542
|
+
# Orchestration Formatting Methods
|
|
543
|
+
# ============================================================================
|
|
544
|
+
|
|
545
|
+
def format_build_detail(
|
|
546
|
+
self,
|
|
547
|
+
build: Dict[str, Any],
|
|
548
|
+
format_type: str = "table",
|
|
549
|
+
output_file: Optional[str] = None,
|
|
550
|
+
) -> Optional[str]:
|
|
551
|
+
"""
|
|
552
|
+
Format detailed build information.
|
|
553
|
+
|
|
554
|
+
Args:
|
|
555
|
+
build: Build dictionary
|
|
556
|
+
format_type: Output format
|
|
557
|
+
output_file: Optional output file path
|
|
558
|
+
|
|
559
|
+
Returns:
|
|
560
|
+
Formatted string if no output file specified
|
|
561
|
+
"""
|
|
562
|
+
if format_type == "table":
|
|
563
|
+
# For table format, show key-value pairs
|
|
564
|
+
details = []
|
|
565
|
+
|
|
566
|
+
# Define the order of properties to display
|
|
567
|
+
property_order = [
|
|
568
|
+
"rid",
|
|
569
|
+
"status",
|
|
570
|
+
"created_by",
|
|
571
|
+
"created_time",
|
|
572
|
+
"started_time",
|
|
573
|
+
"finished_time",
|
|
574
|
+
"branch_name",
|
|
575
|
+
"commit_hash",
|
|
576
|
+
]
|
|
577
|
+
|
|
578
|
+
for prop in property_order:
|
|
579
|
+
if build.get(prop) is not None:
|
|
580
|
+
value = build[prop]
|
|
581
|
+
# Format timestamps
|
|
582
|
+
if "time" in prop:
|
|
583
|
+
value = self._format_datetime(value)
|
|
584
|
+
details.append(
|
|
585
|
+
{
|
|
586
|
+
"Property": prop.replace("_", " ").title(),
|
|
587
|
+
"Value": str(value),
|
|
588
|
+
}
|
|
589
|
+
)
|
|
590
|
+
|
|
591
|
+
# Add any remaining properties
|
|
592
|
+
for key, value in build.items():
|
|
593
|
+
if key not in property_order and value is not None:
|
|
594
|
+
details.append(
|
|
595
|
+
{"Property": key.replace("_", " ").title(), "Value": str(value)}
|
|
596
|
+
)
|
|
597
|
+
|
|
598
|
+
return self.format_output(details, format_type, output_file)
|
|
599
|
+
else:
|
|
600
|
+
return self.format_output(build, format_type, output_file)
|
|
601
|
+
|
|
602
|
+
def format_builds_list(
|
|
603
|
+
self,
|
|
604
|
+
builds: List[Dict[str, Any]],
|
|
605
|
+
format_type: str = "table",
|
|
606
|
+
output_file: Optional[str] = None,
|
|
607
|
+
) -> Optional[str]:
|
|
608
|
+
"""
|
|
609
|
+
Format list of builds.
|
|
610
|
+
|
|
611
|
+
Args:
|
|
612
|
+
builds: List of build dictionaries
|
|
613
|
+
format_type: Output format
|
|
614
|
+
output_file: Optional output file path
|
|
615
|
+
|
|
616
|
+
Returns:
|
|
617
|
+
Formatted string if no output file specified
|
|
618
|
+
"""
|
|
619
|
+
formatted_builds = []
|
|
620
|
+
for build in builds:
|
|
621
|
+
formatted_build = {
|
|
622
|
+
"RID": build.get("rid", ""),
|
|
623
|
+
"Status": build.get("status", ""),
|
|
624
|
+
"Created By": build.get("created_by", ""),
|
|
625
|
+
"Created": self._format_datetime(build.get("created_time")),
|
|
626
|
+
"Branch": build.get("branch_name", ""),
|
|
627
|
+
}
|
|
628
|
+
formatted_builds.append(formatted_build)
|
|
629
|
+
|
|
630
|
+
return self.format_output(formatted_builds, format_type, output_file)
|
|
631
|
+
|
|
632
|
+
def format_job_detail(
|
|
633
|
+
self,
|
|
634
|
+
job: Dict[str, Any],
|
|
635
|
+
format_type: str = "table",
|
|
636
|
+
output_file: Optional[str] = None,
|
|
637
|
+
) -> Optional[str]:
|
|
638
|
+
"""
|
|
639
|
+
Format detailed job information.
|
|
640
|
+
|
|
641
|
+
Args:
|
|
642
|
+
job: Job dictionary
|
|
643
|
+
format_type: Output format
|
|
644
|
+
output_file: Optional output file path
|
|
645
|
+
|
|
646
|
+
Returns:
|
|
647
|
+
Formatted string if no output file specified
|
|
648
|
+
"""
|
|
649
|
+
if format_type == "table":
|
|
650
|
+
# For table format, show key-value pairs
|
|
651
|
+
details = []
|
|
652
|
+
|
|
653
|
+
# Define the order of properties to display
|
|
654
|
+
property_order = [
|
|
655
|
+
"rid",
|
|
656
|
+
"status",
|
|
657
|
+
"job_type",
|
|
658
|
+
"build_rid",
|
|
659
|
+
"created_time",
|
|
660
|
+
"started_time",
|
|
661
|
+
"finished_time",
|
|
662
|
+
]
|
|
663
|
+
|
|
664
|
+
for prop in property_order:
|
|
665
|
+
if job.get(prop) is not None:
|
|
666
|
+
value = job[prop]
|
|
667
|
+
# Format timestamps
|
|
668
|
+
if "time" in prop:
|
|
669
|
+
value = self._format_datetime(value)
|
|
670
|
+
details.append(
|
|
671
|
+
{
|
|
672
|
+
"Property": prop.replace("_", " ").title(),
|
|
673
|
+
"Value": str(value),
|
|
674
|
+
}
|
|
675
|
+
)
|
|
676
|
+
|
|
677
|
+
# Add any remaining properties
|
|
678
|
+
for key, value in job.items():
|
|
679
|
+
if key not in property_order and value is not None:
|
|
680
|
+
details.append(
|
|
681
|
+
{"Property": key.replace("_", " ").title(), "Value": str(value)}
|
|
682
|
+
)
|
|
683
|
+
|
|
684
|
+
return self.format_output(details, format_type, output_file)
|
|
685
|
+
else:
|
|
686
|
+
return self.format_output(job, format_type, output_file)
|
|
687
|
+
|
|
688
|
+
def format_jobs_list(
|
|
689
|
+
self,
|
|
690
|
+
jobs: List[Dict[str, Any]],
|
|
691
|
+
format_type: str = "table",
|
|
692
|
+
output_file: Optional[str] = None,
|
|
693
|
+
) -> Optional[str]:
|
|
694
|
+
"""
|
|
695
|
+
Format list of jobs.
|
|
696
|
+
|
|
697
|
+
Args:
|
|
698
|
+
jobs: List of job dictionaries
|
|
699
|
+
format_type: Output format
|
|
700
|
+
output_file: Optional output file path
|
|
701
|
+
|
|
702
|
+
Returns:
|
|
703
|
+
Formatted string if no output file specified
|
|
704
|
+
"""
|
|
705
|
+
formatted_jobs = []
|
|
706
|
+
for job in jobs:
|
|
707
|
+
formatted_job = {
|
|
708
|
+
"RID": job.get("rid", ""),
|
|
709
|
+
"Status": job.get("status", ""),
|
|
710
|
+
"Type": job.get("job_type", ""),
|
|
711
|
+
"Build": job.get("build_rid", "")[:12] + "..."
|
|
712
|
+
if job.get("build_rid")
|
|
713
|
+
else "",
|
|
714
|
+
"Started": self._format_datetime(job.get("started_time")),
|
|
715
|
+
}
|
|
716
|
+
formatted_jobs.append(formatted_job)
|
|
717
|
+
|
|
718
|
+
return self.format_output(formatted_jobs, format_type, output_file)
|
|
719
|
+
|
|
720
|
+
def format_schedule_detail(
|
|
721
|
+
self,
|
|
722
|
+
schedule: Dict[str, Any],
|
|
723
|
+
format_type: str = "table",
|
|
724
|
+
output_file: Optional[str] = None,
|
|
725
|
+
) -> Optional[str]:
|
|
726
|
+
"""
|
|
727
|
+
Format detailed schedule information.
|
|
728
|
+
|
|
729
|
+
Args:
|
|
730
|
+
schedule: Schedule dictionary
|
|
731
|
+
format_type: Output format
|
|
732
|
+
output_file: Optional output file path
|
|
733
|
+
|
|
734
|
+
Returns:
|
|
735
|
+
Formatted string if no output file specified
|
|
736
|
+
"""
|
|
737
|
+
if format_type == "table":
|
|
738
|
+
# For table format, show key-value pairs
|
|
739
|
+
details = []
|
|
740
|
+
|
|
741
|
+
# Define the order of properties to display
|
|
742
|
+
property_order = [
|
|
743
|
+
"rid",
|
|
744
|
+
"display_name",
|
|
745
|
+
"description",
|
|
746
|
+
"paused",
|
|
747
|
+
"created_by",
|
|
748
|
+
"created_time",
|
|
749
|
+
"modified_by",
|
|
750
|
+
"modified_time",
|
|
751
|
+
]
|
|
752
|
+
|
|
753
|
+
for prop in property_order:
|
|
754
|
+
if schedule.get(prop) is not None:
|
|
755
|
+
value = schedule[prop]
|
|
756
|
+
# Format timestamps
|
|
757
|
+
if "time" in prop:
|
|
758
|
+
value = self._format_datetime(value)
|
|
759
|
+
# Format boolean values
|
|
760
|
+
elif prop == "paused":
|
|
761
|
+
value = "Yes" if value else "No"
|
|
762
|
+
details.append(
|
|
763
|
+
{
|
|
764
|
+
"Property": prop.replace("_", " ").title(),
|
|
765
|
+
"Value": str(value),
|
|
766
|
+
}
|
|
767
|
+
)
|
|
768
|
+
|
|
769
|
+
# Handle special nested properties
|
|
770
|
+
if schedule.get("trigger"):
|
|
771
|
+
details.append(
|
|
772
|
+
{"Property": "Trigger", "Value": str(schedule["trigger"])}
|
|
773
|
+
)
|
|
774
|
+
if schedule.get("action"):
|
|
775
|
+
details.append({"Property": "Action", "Value": str(schedule["action"])})
|
|
776
|
+
|
|
777
|
+
# Add any remaining properties
|
|
778
|
+
for key, value in schedule.items():
|
|
779
|
+
if (
|
|
780
|
+
key not in property_order + ["trigger", "action"]
|
|
781
|
+
and value is not None
|
|
782
|
+
):
|
|
783
|
+
details.append(
|
|
784
|
+
{"Property": key.replace("_", " ").title(), "Value": str(value)}
|
|
785
|
+
)
|
|
786
|
+
|
|
787
|
+
return self.format_output(details, format_type, output_file)
|
|
788
|
+
else:
|
|
789
|
+
return self.format_output(schedule, format_type, output_file)
|
|
790
|
+
|
|
791
|
+
def format_schedules_list(
|
|
792
|
+
self,
|
|
793
|
+
schedules: List[Dict[str, Any]],
|
|
794
|
+
format_type: str = "table",
|
|
795
|
+
output_file: Optional[str] = None,
|
|
796
|
+
) -> Optional[str]:
|
|
797
|
+
"""
|
|
798
|
+
Format list of schedules.
|
|
799
|
+
|
|
800
|
+
Args:
|
|
801
|
+
schedules: List of schedule dictionaries
|
|
802
|
+
format_type: Output format
|
|
803
|
+
output_file: Optional output file path
|
|
804
|
+
|
|
805
|
+
Returns:
|
|
806
|
+
Formatted string if no output file specified
|
|
807
|
+
"""
|
|
808
|
+
formatted_schedules = []
|
|
809
|
+
for schedule in schedules:
|
|
810
|
+
formatted_schedule = {
|
|
811
|
+
"RID": schedule.get("rid", ""),
|
|
812
|
+
"Name": schedule.get("display_name", ""),
|
|
813
|
+
"Description": schedule.get("description", "")[:50] + "..."
|
|
814
|
+
if schedule.get("description")
|
|
815
|
+
else "",
|
|
816
|
+
"Paused": "Yes" if schedule.get("paused") else "No",
|
|
817
|
+
"Created": self._format_datetime(schedule.get("created_time")),
|
|
818
|
+
}
|
|
819
|
+
formatted_schedules.append(formatted_schedule)
|
|
820
|
+
|
|
821
|
+
return self.format_output(formatted_schedules, format_type, output_file)
|
|
822
|
+
|
|
823
|
+
# MediaSets formatting methods
|
|
824
|
+
|
|
825
|
+
def format_media_item_info(
|
|
826
|
+
self,
|
|
827
|
+
media_item: Dict[str, Any],
|
|
828
|
+
format_type: str = "table",
|
|
829
|
+
output_file: Optional[str] = None,
|
|
830
|
+
) -> Optional[str]:
|
|
831
|
+
"""
|
|
832
|
+
Format media item information for display.
|
|
833
|
+
|
|
834
|
+
Args:
|
|
835
|
+
media_item: Media item information dictionary
|
|
836
|
+
format_type: Output format
|
|
837
|
+
output_file: Optional output file path
|
|
838
|
+
|
|
839
|
+
Returns:
|
|
840
|
+
Formatted string if no output file specified
|
|
841
|
+
"""
|
|
842
|
+
if format_type == "table":
|
|
843
|
+
details = []
|
|
844
|
+
|
|
845
|
+
property_order = [
|
|
846
|
+
("media_item_rid", "Media Item RID"),
|
|
847
|
+
("filename", "Filename"),
|
|
848
|
+
("size", "Size"),
|
|
849
|
+
("content_type", "Content Type"),
|
|
850
|
+
("created_time", "Created"),
|
|
851
|
+
("updated_time", "Updated"),
|
|
852
|
+
]
|
|
853
|
+
|
|
854
|
+
for key, label in property_order:
|
|
855
|
+
if media_item.get(key) is not None:
|
|
856
|
+
value = media_item[key]
|
|
857
|
+
if key in ["created_time", "updated_time"]:
|
|
858
|
+
value = self._format_datetime(value)
|
|
859
|
+
elif key == "size":
|
|
860
|
+
value = self._format_file_size(value)
|
|
861
|
+
details.append({"Property": label, "Value": str(value)})
|
|
862
|
+
|
|
863
|
+
# Add any remaining properties
|
|
864
|
+
for key, value in media_item.items():
|
|
865
|
+
if (
|
|
866
|
+
key not in [prop[0] for prop in property_order]
|
|
867
|
+
and value is not None
|
|
868
|
+
):
|
|
869
|
+
details.append(
|
|
870
|
+
{"Property": key.replace("_", " ").title(), "Value": str(value)}
|
|
871
|
+
)
|
|
872
|
+
|
|
873
|
+
return self.format_output(details, format_type, output_file)
|
|
874
|
+
else:
|
|
875
|
+
return self.format_output(media_item, format_type, output_file)
|
|
876
|
+
|
|
877
|
+
def format_media_path_lookup(
|
|
878
|
+
self,
|
|
879
|
+
lookup_result: Dict[str, Any],
|
|
880
|
+
format_type: str = "table",
|
|
881
|
+
output_file: Optional[str] = None,
|
|
882
|
+
) -> Optional[str]:
|
|
883
|
+
"""
|
|
884
|
+
Format media path lookup result for display.
|
|
885
|
+
|
|
886
|
+
Args:
|
|
887
|
+
lookup_result: Path lookup result dictionary
|
|
888
|
+
format_type: Output format
|
|
889
|
+
output_file: Optional output file path
|
|
890
|
+
|
|
891
|
+
Returns:
|
|
892
|
+
Formatted string if no output file specified
|
|
893
|
+
"""
|
|
894
|
+
if format_type == "table":
|
|
895
|
+
details = [
|
|
896
|
+
{"Property": "Path", "Value": lookup_result.get("path", "")},
|
|
897
|
+
{"Property": "Media Item RID", "Value": lookup_result.get("rid", "")},
|
|
898
|
+
]
|
|
899
|
+
return self.format_output(details, format_type, output_file)
|
|
900
|
+
else:
|
|
901
|
+
return self.format_output(lookup_result, format_type, output_file)
|
|
902
|
+
|
|
903
|
+
def format_media_reference(
|
|
904
|
+
self,
|
|
905
|
+
reference: Dict[str, Any],
|
|
906
|
+
format_type: str = "table",
|
|
907
|
+
output_file: Optional[str] = None,
|
|
908
|
+
) -> Optional[str]:
|
|
909
|
+
"""
|
|
910
|
+
Format media reference information for display.
|
|
911
|
+
|
|
912
|
+
Args:
|
|
913
|
+
reference: Media reference dictionary
|
|
914
|
+
format_type: Output format
|
|
915
|
+
output_file: Optional output file path
|
|
916
|
+
|
|
917
|
+
Returns:
|
|
918
|
+
Formatted string if no output file specified
|
|
919
|
+
"""
|
|
920
|
+
if format_type == "table":
|
|
921
|
+
details = []
|
|
922
|
+
|
|
923
|
+
property_order = [
|
|
924
|
+
("reference_id", "Reference ID"),
|
|
925
|
+
("url", "URL"),
|
|
926
|
+
("expires_at", "Expires At"),
|
|
927
|
+
]
|
|
928
|
+
|
|
929
|
+
for key, label in property_order:
|
|
930
|
+
if reference.get(key) is not None:
|
|
931
|
+
value = reference[key]
|
|
932
|
+
if key == "expires_at":
|
|
933
|
+
value = self._format_datetime(value)
|
|
934
|
+
details.append({"Property": label, "Value": str(value)})
|
|
935
|
+
|
|
936
|
+
# Add any remaining properties
|
|
937
|
+
for key, value in reference.items():
|
|
938
|
+
if (
|
|
939
|
+
key not in [prop[0] for prop in property_order]
|
|
940
|
+
and value is not None
|
|
941
|
+
):
|
|
942
|
+
details.append(
|
|
943
|
+
{"Property": key.replace("_", " ").title(), "Value": str(value)}
|
|
944
|
+
)
|
|
945
|
+
|
|
946
|
+
return self.format_output(details, format_type, output_file)
|
|
947
|
+
else:
|
|
948
|
+
return self.format_output(reference, format_type, output_file)
|
|
949
|
+
|
|
950
|
+
# Dataset formatting methods
|
|
951
|
+
|
|
952
|
+
def format_branches(
|
|
953
|
+
self,
|
|
954
|
+
branches: List[Dict[str, Any]],
|
|
955
|
+
format_type: str = "table",
|
|
956
|
+
output_file: Optional[str] = None,
|
|
957
|
+
) -> Optional[str]:
|
|
958
|
+
"""
|
|
959
|
+
Format dataset branches for display.
|
|
960
|
+
|
|
961
|
+
Args:
|
|
962
|
+
branches: List of branch dictionaries
|
|
963
|
+
format_type: Output format
|
|
964
|
+
output_file: Optional output file path
|
|
965
|
+
|
|
966
|
+
Returns:
|
|
967
|
+
Formatted string if no output file specified
|
|
968
|
+
"""
|
|
969
|
+
formatted_branches = []
|
|
970
|
+
for branch in branches:
|
|
971
|
+
formatted_branch = {
|
|
972
|
+
"Name": branch.get("name", ""),
|
|
973
|
+
"Transaction": branch.get("transaction_rid", "")[:12] + "..."
|
|
974
|
+
if branch.get("transaction_rid")
|
|
975
|
+
else "",
|
|
976
|
+
"Created": self._format_datetime(branch.get("created_time")),
|
|
977
|
+
"Created By": branch.get("created_by", ""),
|
|
978
|
+
}
|
|
979
|
+
formatted_branches.append(formatted_branch)
|
|
980
|
+
|
|
981
|
+
return self.format_output(formatted_branches, format_type, output_file)
|
|
982
|
+
|
|
983
|
+
def format_branch_detail(
|
|
984
|
+
self,
|
|
985
|
+
branch: Dict[str, Any],
|
|
986
|
+
format_type: str = "table",
|
|
987
|
+
output_file: Optional[str] = None,
|
|
988
|
+
) -> Optional[str]:
|
|
989
|
+
"""
|
|
990
|
+
Format detailed branch information.
|
|
991
|
+
|
|
992
|
+
Args:
|
|
993
|
+
branch: Branch dictionary
|
|
994
|
+
format_type: Output format
|
|
995
|
+
output_file: Optional output file path
|
|
996
|
+
|
|
997
|
+
Returns:
|
|
998
|
+
Formatted string if no output file specified
|
|
999
|
+
"""
|
|
1000
|
+
if format_type == "table":
|
|
1001
|
+
details = []
|
|
1002
|
+
|
|
1003
|
+
property_order = [
|
|
1004
|
+
("name", "Branch Name"),
|
|
1005
|
+
("dataset_rid", "Dataset RID"),
|
|
1006
|
+
("parent_branch", "Parent Branch"),
|
|
1007
|
+
("transaction_rid", "Transaction RID"),
|
|
1008
|
+
("created_time", "Created"),
|
|
1009
|
+
("created_by", "Created By"),
|
|
1010
|
+
]
|
|
1011
|
+
|
|
1012
|
+
for key, label in property_order:
|
|
1013
|
+
if branch.get(key) is not None:
|
|
1014
|
+
value = branch[key]
|
|
1015
|
+
if key == "created_time":
|
|
1016
|
+
value = self._format_datetime(value)
|
|
1017
|
+
details.append({"Property": label, "Value": str(value)})
|
|
1018
|
+
|
|
1019
|
+
# Add any remaining properties
|
|
1020
|
+
for key, value in branch.items():
|
|
1021
|
+
if (
|
|
1022
|
+
key not in [prop[0] for prop in property_order]
|
|
1023
|
+
and value is not None
|
|
1024
|
+
):
|
|
1025
|
+
details.append(
|
|
1026
|
+
{"Property": key.replace("_", " ").title(), "Value": str(value)}
|
|
1027
|
+
)
|
|
1028
|
+
|
|
1029
|
+
return self.format_output(details, format_type, output_file)
|
|
1030
|
+
else:
|
|
1031
|
+
return self.format_output(branch, format_type, output_file)
|
|
1032
|
+
|
|
1033
|
+
def format_files(
|
|
1034
|
+
self,
|
|
1035
|
+
files: List[Dict[str, Any]],
|
|
1036
|
+
format_type: str = "table",
|
|
1037
|
+
output_file: Optional[str] = None,
|
|
1038
|
+
) -> Optional[str]:
|
|
1039
|
+
"""
|
|
1040
|
+
Format dataset files for display.
|
|
1041
|
+
|
|
1042
|
+
Args:
|
|
1043
|
+
files: List of file dictionaries
|
|
1044
|
+
format_type: Output format
|
|
1045
|
+
output_file: Optional output file path
|
|
1046
|
+
|
|
1047
|
+
Returns:
|
|
1048
|
+
Formatted string if no output file specified
|
|
1049
|
+
"""
|
|
1050
|
+
formatted_files = []
|
|
1051
|
+
for file in files:
|
|
1052
|
+
formatted_file = {
|
|
1053
|
+
"Path": file.get("path", ""),
|
|
1054
|
+
"Size": self._format_file_size(file.get("size_bytes")),
|
|
1055
|
+
"Last Modified": self._format_datetime(file.get("last_modified")),
|
|
1056
|
+
"Transaction": file.get("transaction_rid", "")[:12] + "..."
|
|
1057
|
+
if file.get("transaction_rid")
|
|
1058
|
+
else "",
|
|
1059
|
+
}
|
|
1060
|
+
formatted_files.append(formatted_file)
|
|
1061
|
+
|
|
1062
|
+
return self.format_output(formatted_files, format_type, output_file)
|
|
1063
|
+
|
|
1064
|
+
def format_transactions(
|
|
1065
|
+
self,
|
|
1066
|
+
transactions: List[Dict[str, Any]],
|
|
1067
|
+
format_type: str = "table",
|
|
1068
|
+
output_file: Optional[str] = None,
|
|
1069
|
+
) -> Optional[str]:
|
|
1070
|
+
"""
|
|
1071
|
+
Format dataset transactions for display.
|
|
1072
|
+
|
|
1073
|
+
Args:
|
|
1074
|
+
transactions: List of transaction dictionaries
|
|
1075
|
+
format_type: Output format
|
|
1076
|
+
output_file: Optional output file path
|
|
1077
|
+
|
|
1078
|
+
Returns:
|
|
1079
|
+
Formatted string if no output file specified
|
|
1080
|
+
"""
|
|
1081
|
+
formatted_transactions = []
|
|
1082
|
+
for transaction in transactions:
|
|
1083
|
+
formatted_transaction = {
|
|
1084
|
+
"Transaction RID": transaction.get("transaction_rid", "")[:12] + "..."
|
|
1085
|
+
if transaction.get("transaction_rid")
|
|
1086
|
+
else "",
|
|
1087
|
+
"Created": self._format_datetime(transaction.get("created_time")),
|
|
1088
|
+
"Created By": transaction.get("created_by", ""),
|
|
1089
|
+
"Status": transaction.get("status", ""),
|
|
1090
|
+
}
|
|
1091
|
+
formatted_transactions.append(formatted_transaction)
|
|
1092
|
+
|
|
1093
|
+
return self.format_output(formatted_transactions, format_type, output_file)
|
|
1094
|
+
|
|
1095
|
+
def format_views(
|
|
1096
|
+
self,
|
|
1097
|
+
views: List[Dict[str, Any]],
|
|
1098
|
+
format_type: str = "table",
|
|
1099
|
+
output_file: Optional[str] = None,
|
|
1100
|
+
) -> Optional[str]:
|
|
1101
|
+
"""
|
|
1102
|
+
Format dataset views for display.
|
|
1103
|
+
|
|
1104
|
+
Args:
|
|
1105
|
+
views: List of view dictionaries
|
|
1106
|
+
format_type: Output format
|
|
1107
|
+
output_file: Optional output file path
|
|
1108
|
+
|
|
1109
|
+
Returns:
|
|
1110
|
+
Formatted string if no output file specified
|
|
1111
|
+
"""
|
|
1112
|
+
formatted_views = []
|
|
1113
|
+
for view in views:
|
|
1114
|
+
formatted_view = {
|
|
1115
|
+
"View RID": view.get("view_rid", "")[:12] + "..."
|
|
1116
|
+
if view.get("view_rid")
|
|
1117
|
+
else "",
|
|
1118
|
+
"Name": view.get("name", ""),
|
|
1119
|
+
"Description": view.get("description", "")[:50] + "..."
|
|
1120
|
+
if view.get("description", "")
|
|
1121
|
+
else "",
|
|
1122
|
+
"Created": self._format_datetime(view.get("created_time")),
|
|
1123
|
+
"Created By": view.get("created_by", ""),
|
|
1124
|
+
}
|
|
1125
|
+
formatted_views.append(formatted_view)
|
|
1126
|
+
|
|
1127
|
+
return self.format_output(formatted_views, format_type, output_file)
|
|
1128
|
+
|
|
1129
|
+
def format_view_detail(
|
|
1130
|
+
self,
|
|
1131
|
+
view: Dict[str, Any],
|
|
1132
|
+
format_type: str = "table",
|
|
1133
|
+
output_file: Optional[str] = None,
|
|
1134
|
+
) -> Optional[str]:
|
|
1135
|
+
"""
|
|
1136
|
+
Format detailed view information.
|
|
1137
|
+
|
|
1138
|
+
Args:
|
|
1139
|
+
view: View dictionary
|
|
1140
|
+
format_type: Output format
|
|
1141
|
+
output_file: Optional output file path
|
|
1142
|
+
|
|
1143
|
+
Returns:
|
|
1144
|
+
Formatted string if no output file specified
|
|
1145
|
+
"""
|
|
1146
|
+
if format_type == "table":
|
|
1147
|
+
details = []
|
|
1148
|
+
|
|
1149
|
+
property_order = [
|
|
1150
|
+
("view_rid", "View RID"),
|
|
1151
|
+
("name", "Name"),
|
|
1152
|
+
("description", "Description"),
|
|
1153
|
+
("dataset_rid", "Dataset RID"),
|
|
1154
|
+
("created_time", "Created"),
|
|
1155
|
+
("created_by", "Created By"),
|
|
1156
|
+
]
|
|
1157
|
+
|
|
1158
|
+
for key, label in property_order:
|
|
1159
|
+
if view.get(key) is not None:
|
|
1160
|
+
value = view[key]
|
|
1161
|
+
if key == "created_time":
|
|
1162
|
+
value = self._format_datetime(value)
|
|
1163
|
+
details.append({"Property": label, "Value": str(value)})
|
|
1164
|
+
|
|
1165
|
+
# Add any remaining properties
|
|
1166
|
+
for key, value in view.items():
|
|
1167
|
+
if (
|
|
1168
|
+
key not in [prop[0] for prop in property_order]
|
|
1169
|
+
and value is not None
|
|
1170
|
+
):
|
|
1171
|
+
details.append(
|
|
1172
|
+
{"Property": key.replace("_", " ").title(), "Value": str(value)}
|
|
1173
|
+
)
|
|
1174
|
+
|
|
1175
|
+
return self.format_output(details, format_type, output_file)
|
|
1176
|
+
else:
|
|
1177
|
+
return self.format_output(view, format_type, output_file)
|