@@ -26,7 +26,6 @@ def main():
2626 required = True ,
2727 help = "Task stage ID to list policy evaluations for" ,
2828 )
29- parser .add_argument ("--page" , type = int , default = 1 )
3029 parser .add_argument ("--page-size" , type = int , default = 20 )
3130 args = parser .parse_args ()
3231
@@ -41,62 +40,55 @@ def main():
4140 _print_header (f"Listing policy evaluations for task stage: { args .task_stage_id } " )
4241
4342 options = PolicyEvaluationListOptions (
44- page_number = args .page ,
4543 page_size = args .page_size ,
4644 )
4745
4846 try :
49- pe_list = client .policy_evaluations .list (args .task_stage_id , options )
50-
51- print (f"Total policy evaluations: { pe_list .total_count } " )
52- print (f"Page { pe_list .current_page } of { pe_list .total_pages } " )
53- print ()
54-
55- if not pe_list .items :
47+ pe_count = 0
48+ for pe in client .policy_evaluations .list (args .task_stage_id , options ):
49+ pe_count += 1
50+ print (f"- ID: { pe .id } " )
51+ print (f" Status: { pe .status } " )
52+ print (f" Policy Kind: { pe .policy_kind } " )
53+
54+ if pe .result_count :
55+ print (" Result Count:" )
56+ if pe .result_count .passed is not None :
57+ print (f" - Passed: { pe .result_count .passed } " )
58+ if pe .result_count .advisory_failed is not None :
59+ print (f" - Advisory Failed: { pe .result_count .advisory_failed } " )
60+ if pe .result_count .mandatory_failed is not None :
61+ print (f" - Mandatory Failed: { pe .result_count .mandatory_failed } " )
62+ if pe .result_count .errored is not None :
63+ print (f" - Errored: { pe .result_count .errored } " )
64+
65+ if pe .status_timestamp :
66+ print (" Status Timestamps:" )
67+ if pe .status_timestamp .passed_at :
68+ print (f" - Passed At: { pe .status_timestamp .passed_at } " )
69+ if pe .status_timestamp .failed_at :
70+ print (f" - Failed At: { pe .status_timestamp .failed_at } " )
71+ if pe .status_timestamp .running_at :
72+ print (f" - Running At: { pe .status_timestamp .running_at } " )
73+ if pe .status_timestamp .canceled_at :
74+ print (f" - Canceled At: { pe .status_timestamp .canceled_at } " )
75+ if pe .status_timestamp .errored_at :
76+ print (f" - Errored At: { pe .status_timestamp .errored_at } " )
77+
78+ if pe .policy_attachable :
79+ print (f" Task Stage: { pe .task_stage .id } ({ pe .task_stage .type } )" )
80+
81+ if pe .created_at :
82+ print (f" Created At: { pe .created_at } " )
83+ if pe .updated_at :
84+ print (f" Updated At: { pe .updated_at } " )
85+
86+ print ()
87+
88+ if pe_count == 0 :
5689 print ("No policy evaluations found for this task stage." )
5790 else :
58- for pe in pe_list .items :
59- print (f"- ID: { pe .id } " )
60- print (f" Status: { pe .status } " )
61- print (f" Policy Kind: { pe .policy_kind } " )
62-
63- if pe .result_count :
64- print (" Result Count:" )
65- if pe .result_count .passed is not None :
66- print (f" - Passed: { pe .result_count .passed } " )
67- if pe .result_count .advisory_failed is not None :
68- print (
69- f" - Advisory Failed: { pe .result_count .advisory_failed } "
70- )
71- if pe .result_count .mandatory_failed is not None :
72- print (
73- f" - Mandatory Failed: { pe .result_count .mandatory_failed } "
74- )
75- if pe .result_count .errored is not None :
76- print (f" - Errored: { pe .result_count .errored } " )
77-
78- if pe .status_timestamp :
79- print (" Status Timestamps:" )
80- if pe .status_timestamp .passed_at :
81- print (f" - Passed At: { pe .status_timestamp .passed_at } " )
82- if pe .status_timestamp .failed_at :
83- print (f" - Failed At: { pe .status_timestamp .failed_at } " )
84- if pe .status_timestamp .running_at :
85- print (f" - Running At: { pe .status_timestamp .running_at } " )
86- if pe .status_timestamp .canceled_at :
87- print (f" - Canceled At: { pe .status_timestamp .canceled_at } " )
88- if pe .status_timestamp .errored_at :
89- print (f" - Errored At: { pe .status_timestamp .errored_at } " )
90-
91- if pe .task_stage :
92- print (f" Task Stage: { pe .task_stage .id } ({ pe .task_stage .type } )" )
93-
94- if pe .created_at :
95- print (f" Created At: { pe .created_at } " )
96- if pe .updated_at :
97- print (f" Updated At: { pe .updated_at } " )
98-
99- print ()
91+ print (f"\n Total: { pe_count } policy evaluations" )
10092
10193 except Exception as e :
10294 print (f"Error listing policy evaluations: { e } " )
0 commit comments