yellowdog-python-examples 7.16.4__tar.gz → 7.16.5__tar.gz

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 (79) hide show
  1. {yellowdog_python_examples-7.16.4/yellowdog_python_examples.egg-info → yellowdog_python_examples-7.16.5}/PKG-INFO +1 -1
  2. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/README.md +8 -0
  3. yellowdog_python_examples-7.16.5/yellowdog_cli/__init__.py +1 -0
  4. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/list.py +110 -0
  5. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/args.py +44 -0
  6. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/items.py +10 -2
  7. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/printing.py +123 -0
  8. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5/yellowdog_python_examples.egg-info}/PKG-INFO +1 -1
  9. yellowdog_python_examples-7.16.4/yellowdog_cli/__init__.py +0 -1
  10. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/LICENSE +0 -0
  11. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/PYPI_README.md +0 -0
  12. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/pyproject.toml +0 -0
  13. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/requirements.txt +0 -0
  14. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/setup.cfg +0 -0
  15. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/tests/test_create_remove.py +0 -0
  16. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/tests/test_demos.py +0 -0
  17. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/tests/test_dryruns.py +0 -0
  18. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/tests/test_entrypoints.py +0 -0
  19. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/tests/test_gui.py +0 -0
  20. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/tests/test_list.py +0 -0
  21. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/tests/test_objects.py +0 -0
  22. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/tests/test_variable_processing.py +0 -0
  23. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/abort.py +0 -0
  24. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/admin.py +0 -0
  25. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/boost.py +0 -0
  26. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/cancel.py +0 -0
  27. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/cloudwizard.py +0 -0
  28. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/compare.py +0 -0
  29. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/create.py +0 -0
  30. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/delete.py +0 -0
  31. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/download.py +0 -0
  32. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/follow.py +0 -0
  33. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/format_json.py +0 -0
  34. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/hold.py +0 -0
  35. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/instantiate.py +0 -0
  36. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/jsonnet2json.py +0 -0
  37. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/provision.py +0 -0
  38. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/remove.py +0 -0
  39. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/resize.py +0 -0
  40. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/show.py +0 -0
  41. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/shutdown.py +0 -0
  42. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/start.py +0 -0
  43. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/submit.py +0 -0
  44. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/terminate.py +0 -0
  45. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/upload.py +0 -0
  46. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/__init__.py +0 -0
  47. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/check_imports.py +0 -0
  48. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/cloudwizard_aws.py +0 -0
  49. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/cloudwizard_aws_types.py +0 -0
  50. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/cloudwizard_azure.py +0 -0
  51. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/cloudwizard_common.py +0 -0
  52. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/cloudwizard_gcp.py +0 -0
  53. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/compact_json.py +0 -0
  54. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/config_types.py +0 -0
  55. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/csv_data.py +0 -0
  56. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/entity_utils.py +0 -0
  57. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/follow_utils.py +0 -0
  58. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/interactive.py +0 -0
  59. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/load_config.py +0 -0
  60. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/load_resources.py +0 -0
  61. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/misc_utils.py +0 -0
  62. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/property_names.py +0 -0
  63. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/provision_utils.py +0 -0
  64. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/rich_console_input_fixed.py +0 -0
  65. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/settings.py +0 -0
  66. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/start_hold_common.py +0 -0
  67. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/submit_utils.py +0 -0
  68. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/type_check.py +0 -0
  69. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/upload_utils.py +0 -0
  70. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/validate_properties.py +0 -0
  71. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/variables.py +0 -0
  72. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/wrapper.py +0 -0
  73. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/utils/ydid_utils.py +0 -0
  74. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_cli/version.py +0 -0
  75. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_python_examples.egg-info/SOURCES.txt +0 -0
  76. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_python_examples.egg-info/dependency_links.txt +0 -0
  77. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_python_examples.egg-info/entry_points.txt +0 -0
  78. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_python_examples.egg-info/requires.txt +0 -0
  79. {yellowdog_python_examples-7.16.4 → yellowdog_python_examples-7.16.5}/yellowdog_python_examples.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yellowdog-python-examples
3
- Version: 7.16.4
3
+ Version: 7.16.5
4
4
  Summary: Python CLI commands using the YellowDog Python SDK
5
5
  Author-email: YellowDog Limited <support@yellowdog.co>
6
6
  Project-URL: Homepage, https://github.com/yellowdog/python-examples
@@ -2720,10 +2720,12 @@ The `yd-terminate` command immediately terminates Compute Requirements that matc
2720
2720
  The `yd-list` command is used to list various YellowDog items, using the `namespace` and `tag` properties (if applicable) to target the scope of what to list:
2721
2721
 
2722
2722
  - Allowances
2723
+ - Applications
2723
2724
  - Attribute Definitions
2724
2725
  - Compute Requirement Templates
2725
2726
  - Compute Requirements
2726
2727
  - Compute Source Templates
2728
+ - Groups
2727
2729
  - Image Families, Image Groups, and Images
2728
2730
  - Instances
2729
2731
  - Keyrings
@@ -2731,8 +2733,10 @@ The `yd-list` command is used to list various YellowDog items, using the `namesp
2731
2733
  - Namespace Storage Configurations
2732
2734
  - Nodes
2733
2735
  - Objects in the Object Store
2736
+ - Roles
2734
2737
  - Task Groups
2735
2738
  - Tasks
2739
+ - Users
2736
2740
  - Work Requirements
2737
2741
  - Worker Pools
2738
2742
  - Workers
@@ -2811,6 +2815,10 @@ The `yd-show` command will show the details (in JSON) of any YellowDog entity th
2811
2815
  - Image Families, Image Groups, and Images
2812
2816
  - Keyrings
2813
2817
  - Allowances
2818
+ - Users
2819
+ - Applications
2820
+ - Groups
2821
+ - Roles
2814
2822
 
2815
2823
  ## yd-compare
2816
2824
 
@@ -0,0 +1 @@
1
+ __version__ = "7.16.5"
@@ -15,11 +15,16 @@ from yellowdog_client.common import SearchClient
15
15
  from yellowdog_client.model import (
16
16
  Allowance,
17
17
  AllowanceSearch,
18
+ Application,
19
+ ApplicationSearch,
18
20
  ComputeRequirement,
19
21
  ComputeRequirementSearch,
20
22
  ComputeRequirementStatus,
21
23
  ComputeRequirementTemplateSummary,
22
24
  ComputeSourceTemplateSummary,
25
+ Group,
26
+ GroupSearch,
27
+ GroupSummary,
23
28
  Instance,
24
29
  InstanceSearch,
25
30
  Keyring,
@@ -33,8 +38,13 @@ from yellowdog_client.model import (
33
38
  NodeSearch,
34
39
  NodeStatus,
35
40
  ObjectDetail,
41
+ Role,
42
+ RoleSearch,
43
+ RoleSummary,
36
44
  Task,
37
45
  TaskGroup,
46
+ User,
47
+ UserSearch,
38
48
  Worker,
39
49
  WorkerPoolStatus,
40
50
  WorkerPoolSummary,
@@ -114,6 +124,14 @@ def main():
114
124
  list_attribute_definitions()
115
125
  elif ARGS_PARSER.namespace_policies:
116
126
  list_namespace_policies()
127
+ elif ARGS_PARSER.users:
128
+ list_users()
129
+ elif ARGS_PARSER.applications:
130
+ list_applications()
131
+ elif ARGS_PARSER.groups:
132
+ list_groups()
133
+ elif ARGS_PARSER.roles:
134
+ list_roles()
117
135
 
118
136
 
119
137
  def check_for_valid_option() -> bool:
@@ -122,9 +140,11 @@ def check_for_valid_option() -> bool:
122
140
  """
123
141
  if [
124
142
  ARGS_PARSER.allowances,
143
+ ARGS_PARSER.applications,
125
144
  ARGS_PARSER.attribute_definitions,
126
145
  ARGS_PARSER.compute_requirements,
127
146
  ARGS_PARSER.compute_templates,
147
+ ARGS_PARSER.groups,
128
148
  ARGS_PARSER.image_families,
129
149
  ARGS_PARSER.instances,
130
150
  ARGS_PARSER.keyrings,
@@ -133,8 +153,10 @@ def check_for_valid_option() -> bool:
133
153
  ARGS_PARSER.nodes,
134
154
  ARGS_PARSER.object_paths,
135
155
  ARGS_PARSER.source_templates,
156
+ ARGS_PARSER.roles,
136
157
  ARGS_PARSER.task_groups,
137
158
  ARGS_PARSER.tasks,
159
+ ARGS_PARSER.users,
138
160
  ARGS_PARSER.work_requirements,
139
161
  ARGS_PARSER.worker_pools,
140
162
  ARGS_PARSER.workers,
@@ -846,6 +868,94 @@ def list_namespace_policies():
846
868
  print_json(details)
847
869
 
848
870
 
871
+ def list_users():
872
+ """
873
+ List all users in the account.
874
+ """
875
+ user_search = UserSearch()
876
+ search_client: SearchClient = CLIENT.account_client.get_users(user_search)
877
+ users: List[User] = search_client.list_all()
878
+
879
+ if len(users) == 0:
880
+ print_log("No Users to display")
881
+ return
882
+
883
+ if not ARGS_PARSER.details:
884
+ print_numbered_object_list(CLIENT, users, object_type_name="User")
885
+ return
886
+
887
+ for selected_users in select(CLIENT, users, object_type_name="User"):
888
+ print_yd_object(selected_users)
889
+
890
+
891
+ def list_applications():
892
+ """
893
+ List all applications in the account.
894
+ """
895
+ application_search = ApplicationSearch()
896
+ search_client: SearchClient = CLIENT.account_client.get_applications(
897
+ application_search
898
+ )
899
+ applications: List[Application] = search_client.list_all()
900
+
901
+ if len(applications) == 0:
902
+ print_log("No Applications to display")
903
+ return
904
+
905
+ if not ARGS_PARSER.details:
906
+ print_numbered_object_list(CLIENT, applications, object_type_name="Application")
907
+ return
908
+
909
+ for selected_users in select(CLIENT, applications, object_type_name="Application"):
910
+ print_yd_object(selected_users)
911
+
912
+
913
+ def list_groups():
914
+ """
915
+ List all groups in the account.
916
+ """
917
+ group_search = GroupSearch()
918
+ search_client: SearchClient = CLIENT.account_client.get_groups(group_search)
919
+ group_summaries: List[GroupSummary] = search_client.list_all()
920
+
921
+ if len(group_summaries) == 0:
922
+ print_log("No Groups to display")
923
+ return
924
+
925
+ groups: List[Group] = [
926
+ CLIENT.account_client.get_group(x.id) for x in group_summaries
927
+ ]
928
+
929
+ if not ARGS_PARSER.details:
930
+ print_numbered_object_list(CLIENT, groups, object_type_name="Group")
931
+ return
932
+
933
+ for selected_users in select(CLIENT, groups, object_type_name="Group"):
934
+ print_yd_object(selected_users)
935
+
936
+
937
+ def list_roles():
938
+ """
939
+ List all roles in the account.
940
+ """
941
+ role_search = RoleSearch()
942
+ search_client: SearchClient = CLIENT.account_client.get_roles(role_search)
943
+ role_summaries: List[RoleSummary] = search_client.list_all()
944
+
945
+ if len(role_summaries) == 0:
946
+ print_log("No Roles to display")
947
+ return
948
+
949
+ groups: List[Role] = [CLIENT.account_client.get_role(x.id) for x in role_summaries]
950
+
951
+ if not ARGS_PARSER.details:
952
+ print_numbered_object_list(CLIENT, groups, object_type_name="Role")
953
+ return
954
+
955
+ for selected_users in select(CLIENT, groups, object_type_name="Role"):
956
+ print_yd_object(selected_users)
957
+
958
+
849
959
  def get_autoscaling_capacity(namespace: str) -> Dict:
850
960
  """
851
961
  Get the current autoscaling values for a namespace.
@@ -627,6 +627,30 @@ class CLIParser:
627
627
  required=False,
628
628
  help="list namespace policies",
629
629
  )
630
+ parser.add_argument(
631
+ "--users",
632
+ action="store_true",
633
+ required=False,
634
+ help="list users",
635
+ )
636
+ parser.add_argument(
637
+ "--applications",
638
+ action="store_true",
639
+ required=False,
640
+ help="list applications",
641
+ )
642
+ parser.add_argument(
643
+ "--groups",
644
+ action="store_true",
645
+ required=False,
646
+ help="list groups",
647
+ )
648
+ parser.add_argument(
649
+ "--roles",
650
+ action="store_true",
651
+ required=False,
652
+ help="list roles",
653
+ )
630
654
  parser.add_argument(
631
655
  "--output-file",
632
656
  type=str,
@@ -1501,6 +1525,26 @@ class CLIParser:
1501
1525
  def namespace_policies(self) -> Optional[bool]:
1502
1526
  return self.args.namespace_policies
1503
1527
 
1528
+ @property
1529
+ @allow_missing_attribute
1530
+ def users(self) -> Optional[bool]:
1531
+ return self.args.users
1532
+
1533
+ @property
1534
+ @allow_missing_attribute
1535
+ def applications(self) -> Optional[bool]:
1536
+ return self.args.applications
1537
+
1538
+ @property
1539
+ @allow_missing_attribute
1540
+ def groups(self) -> Optional[bool]:
1541
+ return self.args.groups
1542
+
1543
+ @property
1544
+ @allow_missing_attribute
1545
+ def roles(self) -> Optional[bool]:
1546
+ return self.args.roles
1547
+
1504
1548
  @property
1505
1549
  @allow_missing_attribute
1506
1550
  def show_keyring_passwords(self) -> Optional[bool]:
@@ -6,11 +6,13 @@ from typing import TypeVar
6
6
 
7
7
  from yellowdog_client.model import (
8
8
  Allowance,
9
+ Application,
9
10
  ComputeRequirement,
10
11
  ComputeRequirementTemplateSummary,
11
12
  ComputeSourceTemplate,
12
13
  ComputeSourceTemplateSummary,
13
14
  ConfiguredWorkerPool,
15
+ Group,
14
16
  Instance,
15
17
  KeyringSummary,
16
18
  MachineImageFamilySummary,
@@ -19,8 +21,10 @@ from yellowdog_client.model import (
19
21
  Node,
20
22
  ObjectPath,
21
23
  ProvisionedWorkerPool,
24
+ Role,
22
25
  Task,
23
26
  TaskGroup,
27
+ User,
24
28
  Worker,
25
29
  WorkerPoolSummary,
26
30
  WorkRequirementSummary,
@@ -32,22 +36,26 @@ Item = TypeVar(
32
36
  "Item",
33
37
  AWSAvailabilityZone,
34
38
  Allowance,
39
+ Application,
35
40
  ComputeRequirement,
36
41
  ComputeRequirementTemplateSummary,
37
42
  ComputeSourceTemplate,
38
43
  ComputeSourceTemplateSummary,
39
44
  ConfiguredWorkerPool,
45
+ Group,
40
46
  Instance,
41
47
  KeyringSummary,
42
48
  MachineImageFamilySummary,
43
49
  NamespacePolicy,
44
50
  NamespaceStorageConfiguration,
51
+ Node,
45
52
  ObjectPath,
46
53
  ProvisionedWorkerPool,
54
+ Role,
47
55
  Task,
48
56
  TaskGroup,
49
- Worker,
57
+ User,
50
58
  WorkRequirementSummary,
59
+ Worker,
51
60
  WorkerPoolSummary,
52
- Node,
53
61
  )
@@ -21,6 +21,7 @@ from yellowdog_client import PlatformClient
21
21
  from yellowdog_client.common.json import Json
22
22
  from yellowdog_client.model import (
23
23
  Allowance,
24
+ Application,
24
25
  BestComputeSourceReport,
25
26
  BestComputeSourceReportSource,
26
27
  ComputeRequirement,
@@ -30,7 +31,10 @@ from yellowdog_client.model import (
30
31
  ComputeRequirementTemplateUsage,
31
32
  ComputeSourceTemplateSummary,
32
33
  ConfiguredWorkerPool,
34
+ ExternalUser,
35
+ Group,
33
36
  Instance,
37
+ InternalUser,
34
38
  KeyringSummary,
35
39
  MachineImageFamilySummary,
36
40
  NamespacePolicy,
@@ -39,8 +43,10 @@ from yellowdog_client.model import (
39
43
  ObjectPath,
40
44
  ProvisionedWorkerPool,
41
45
  ProvisionedWorkerPoolProperties,
46
+ Role,
42
47
  Task,
43
48
  TaskGroup,
49
+ User,
44
50
  Worker,
45
51
  WorkerPoolSummary,
46
52
  WorkRequirement,
@@ -709,6 +715,115 @@ def namespace_policies_table(
709
715
  return headers, table
710
716
 
711
717
 
718
+ def users_table(
719
+ users: List[User],
720
+ ) -> (List[str], List[List]):
721
+ headers = [
722
+ "#",
723
+ "Name",
724
+ "User Type",
725
+ "Username",
726
+ "Email",
727
+ "ID",
728
+ ]
729
+ table = []
730
+ for index, user in enumerate(users):
731
+ if isinstance(user, InternalUser):
732
+ table.append(
733
+ [
734
+ index + 1,
735
+ user.name,
736
+ "Internal",
737
+ user.username,
738
+ user.email,
739
+ user.id,
740
+ ]
741
+ )
742
+ elif isinstance(user, ExternalUser): # External user
743
+ table.append(
744
+ [
745
+ index + 1,
746
+ user.name,
747
+ "External",
748
+ "",
749
+ user.email,
750
+ user.id,
751
+ ]
752
+ )
753
+ return headers, table
754
+
755
+
756
+ def applications_table(
757
+ applications: List[Application],
758
+ ) -> (List[str], List[List]):
759
+ headers = [
760
+ "#",
761
+ "Name",
762
+ "Description",
763
+ "ID",
764
+ ]
765
+ table = []
766
+ for index, application in enumerate(applications):
767
+ table.append(
768
+ [
769
+ index + 1,
770
+ application.name,
771
+ application.description,
772
+ application.id,
773
+ ]
774
+ )
775
+ return headers, table
776
+
777
+
778
+ def groups_table(
779
+ groups: List[Group],
780
+ ) -> (List[str], List[List]):
781
+ headers = [
782
+ "#",
783
+ "Name",
784
+ "Admin Group?",
785
+ "Description",
786
+ "Roles",
787
+ "ID",
788
+ ]
789
+ table = []
790
+ for index, group in enumerate(groups):
791
+ table.append(
792
+ [
793
+ index + 1,
794
+ group.name,
795
+ group.adminGroup,
796
+ f"{group.description[:40] + '...' if len(group.description) > 40 else group.description}",
797
+ ", ".join([x.role.name for x in group.roles]),
798
+ group.id,
799
+ ]
800
+ )
801
+ return headers, table
802
+
803
+
804
+ def roles_table(
805
+ roles: List[Role],
806
+ ) -> (List[str], List[List]):
807
+ headers = [
808
+ "#",
809
+ "Name",
810
+ "Permissions",
811
+ "ID",
812
+ ]
813
+ table = []
814
+ for index, role in enumerate(roles):
815
+ permissions = ", ".join(sorted([x.value for x in role.permissions]))
816
+ table.append(
817
+ [
818
+ index + 1,
819
+ role.name,
820
+ f"{permissions[:40] + '...' if len(permissions) > 40 else permissions}",
821
+ role.id,
822
+ ]
823
+ )
824
+ return headers, table
825
+
826
+
712
827
  def print_numbered_object_list(
713
828
  client: PlatformClient,
714
829
  objects: List[Union[Item, str, Dict]],
@@ -769,6 +884,14 @@ def print_numbered_object_list(
769
884
  headers, table = nodes_table(objects)
770
885
  elif isinstance(objects[0], Worker):
771
886
  headers, table = workers_table(objects)
887
+ elif isinstance(objects[0], User):
888
+ headers, table = users_table(objects)
889
+ elif isinstance(objects[0], Application):
890
+ headers, table = applications_table(objects)
891
+ elif isinstance(objects[0], Group):
892
+ headers, table = groups_table(objects)
893
+ elif isinstance(objects[0], Role):
894
+ headers, table = roles_table(objects)
772
895
  else:
773
896
  table = []
774
897
  for index, obj in enumerate(objects):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yellowdog-python-examples
3
- Version: 7.16.4
3
+ Version: 7.16.5
4
4
  Summary: Python CLI commands using the YellowDog Python SDK
5
5
  Author-email: YellowDog Limited <support@yellowdog.co>
6
6
  Project-URL: Homepage, https://github.com/yellowdog/python-examples
@@ -1 +0,0 @@
1
- __version__ = "7.16.4"