@@ -41,9 +41,7 @@ def main():
4141 print ("\n 1. Getting decisions data..." )
4242 try :
4343 decisions = api .pulsardecisions ().get_decisions (
44- start = start_time ,
45- end = end_time ,
46- period = "1h"
44+ start = start_time , end = end_time , period = "1h"
4745 )
4846 print (f" Total decisions: { decisions .get ('total' , 0 )} " )
4947 print (f" Number of graphs: { len (decisions .get ('graphs' , []))} " )
@@ -56,12 +54,13 @@ def main():
5654 print ("\n 2. Getting regional graph data..." )
5755 try :
5856 region_data = api .pulsardecisions ().get_decisions_graph_region (
59- start = start_time ,
60- end = end_time
57+ start = start_time , end = end_time
6158 )
6259 print (f" Regions found: { len (region_data .get ('data' , []))} " )
63- for region in region_data .get ('data' , [])[:3 ]: # Show first 3
64- print (f" - { region .get ('region' )} : { len (region .get ('counts' , []))} job counts" )
60+ for region in region_data .get ("data" , [])[:3 ]: # Show first 3
61+ print (
62+ f" - { region .get ('region' )} : { len (region .get ('counts' , []))} job counts"
63+ )
6564 except Exception as e :
6665 print (f" Error: { e } " )
6766
@@ -71,13 +70,11 @@ def main():
7170 print ("\n 3. Getting time-series graph data..." )
7271 try :
7372 time_data = api .pulsardecisions ().get_decisions_graph_time (
74- start = start_time ,
75- end = end_time ,
76- period = "5m"
73+ start = start_time , end = end_time , period = "5m"
7774 )
7875 print (f" Time points: { len (time_data .get ('data' , []))} " )
79- if time_data .get (' data' ):
80- first_point = time_data [' data' ][0 ]
76+ if time_data .get (" data" ):
77+ first_point = time_data [" data" ][0 ]
8178 print (f" First timestamp: { first_point .get ('timestamp' )} " )
8279 print (f" Job counts at first point: { len (first_point .get ('counts' , []))} " )
8380 except Exception as e :
@@ -89,12 +86,10 @@ def main():
8986 print ("\n 4. Getting area-based decisions..." )
9087 try :
9188 area_data = api .pulsardecisions ().get_decisions_area (
92- start = start_time ,
93- end = end_time ,
94- area = "US"
89+ start = start_time , end = end_time , area = "US"
9590 )
9691 print (f" Areas found: { len (area_data .get ('areas' , []))} " )
97- for area in area_data .get (' areas' , [])[:3 ]: # Show first 3
92+ for area in area_data .get (" areas" , [])[:3 ]: # Show first 3
9893 print (f" - { area .get ('area_name' )} : { area .get ('count' )} decisions" )
9994 except Exception as e :
10095 print (f" Error: { e } " )
@@ -105,13 +100,14 @@ def main():
105100 print ("\n 5. Getting ASN-based decisions..." )
106101 try :
107102 asn_data = api .pulsardecisions ().get_decisions_asn (
108- start = start_time ,
109- end = end_time
103+ start = start_time , end = end_time
110104 )
111105 print (f" ASNs found: { len (asn_data .get ('data' , []))} " )
112- for asn in asn_data .get ('data' , [])[:3 ]: # Show first 3
113- print (f" - ASN { asn .get ('asn' )} : { asn .get ('count' )} decisions "
114- f"({ asn .get ('traffic_distribution' , 0 )* 100 :.1f} % of traffic)" )
106+ for asn in asn_data .get ("data" , [])[:3 ]: # Show first 3
107+ print (
108+ f" - ASN { asn .get ('asn' )} : { asn .get ('count' )} decisions "
109+ f"({ asn .get ('traffic_distribution' , 0 )* 100 :.1f} % of traffic)"
110+ )
115111 except Exception as e :
116112 print (f" Error: { e } " )
117113
@@ -123,11 +119,11 @@ def main():
123119 results_time = api .pulsardecisions ().get_decisions_results_time (
124120 start = start_time ,
125121 end = end_time ,
126- job = "your-job-id" # Replace with actual job ID
122+ job = "your-job-id" , # Replace with actual job ID
127123 )
128124 print (f" Time points: { len (results_time .get ('data' , []))} " )
129- if results_time .get (' data' ):
130- first_point = results_time [' data' ][0 ]
125+ if results_time .get (" data" ):
126+ first_point = results_time [" data" ][0 ]
131127 print (f" Results at first point: { len (first_point .get ('results' , []))} " )
132128 except Exception as e :
133129 print (f" Error: { e } " )
@@ -138,13 +134,14 @@ def main():
138134 print ("\n 7. Getting results by area..." )
139135 try :
140136 results_area = api .pulsardecisions ().get_decisions_results_area (
141- start = start_time ,
142- end = end_time
137+ start = start_time , end = end_time
143138 )
144139 print (f" Areas found: { len (results_area .get ('area' , []))} " )
145- for area in results_area .get ('area' , [])[:3 ]: # Show first 3
146- print (f" - { area .get ('area' )} : { area .get ('decision_count' )} decisions, "
147- f"{ len (area .get ('results' , []))} unique results" )
140+ for area in results_area .get ("area" , [])[:3 ]: # Show first 3
141+ print (
142+ f" - { area .get ('area' )} : { area .get ('decision_count' )} decisions, "
143+ f"{ len (area .get ('results' , []))} unique results"
144+ )
148145 except Exception as e :
149146 print (f" Error: { e } " )
150147
@@ -154,12 +151,11 @@ def main():
154151 print ("\n 8. Getting filter data over time..." )
155152 try :
156153 filters_time = api .pulsardecisions ().get_filters_time (
157- start = start_time ,
158- end = end_time
154+ start = start_time , end = end_time
159155 )
160156 print (f" Time points: { len (filters_time .get ('filters' , []))} " )
161- if filters_time .get (' filters' ):
162- first_point = filters_time [' filters' ][0 ]
157+ if filters_time .get (" filters" ):
158+ first_point = filters_time [" filters" ][0 ]
163159 print (f" Filters at first point: { len (first_point .get ('filters' , {}))} " )
164160 except Exception as e :
165161 print (f" Error: { e } " )
@@ -171,13 +167,11 @@ def main():
171167 try :
172168 customer_id = "your-customer-id" # Replace with actual customer ID
173169 customer_data = api .pulsardecisions ().get_decision_customer (
174- customer_id ,
175- start = start_time ,
176- end = end_time
170+ customer_id , start = start_time , end = end_time
177171 )
178172 print (f" Data points: { len (customer_data .get ('data' , []))} " )
179- if customer_data .get (' data' ):
180- total = sum (point .get (' total' , 0 ) for point in customer_data [' data' ])
173+ if customer_data .get (" data" ):
174+ total = sum (point .get (" total" , 0 ) for point in customer_data [" data" ])
181175 print (f" Total decisions: { total } " )
182176 except Exception as e :
183177 print (f" Error: { e } " )
@@ -191,15 +185,11 @@ def main():
191185 domain = "example.com"
192186 rec_type = "A"
193187 record_data = api .pulsardecisions ().get_decision_record (
194- customer_id ,
195- domain ,
196- rec_type ,
197- start = start_time ,
198- end = end_time
188+ customer_id , domain , rec_type , start = start_time , end = end_time
199189 )
200190 print (f" Data points: { len (record_data .get ('data' , []))} " )
201- if record_data .get (' data' ):
202- total = sum (point .get (' total' , 0 ) for point in record_data [' data' ])
191+ if record_data .get (" data" ):
192+ total = sum (point .get (" total" , 0 ) for point in record_data [" data" ])
203193 print (f" Total decisions for { domain } /{ rec_type } : { total } " )
204194 except Exception as e :
205195 print (f" Error: { e } " )
@@ -211,9 +201,7 @@ def main():
211201 try :
212202 customer_id = "your-customer-id" # Replace with actual customer ID
213203 total_data = api .pulsardecisions ().get_decision_total (
214- customer_id ,
215- start = start_time ,
216- end = end_time
204+ customer_id , start = start_time , end = end_time
217205 )
218206 print (f" Total decisions: { total_data .get ('total' , 0 )} " )
219207 except Exception as e :
@@ -225,14 +213,17 @@ def main():
225213 print ("\n 12. Getting decisions by record..." )
226214 try :
227215 records_data = api .pulsardecisions ().get_decisions_records (
228- start = start_time ,
229- end = end_time
216+ start = start_time , end = end_time
230217 )
231218 print (f" Total decisions: { records_data .get ('total' , 0 )} " )
232219 print (f" Number of records: { len (records_data .get ('records' , {}))} " )
233- for record_key , record_info in list (records_data .get ('records' , {}).items ())[:3 ]:
234- print (f" - { record_key } : { record_info .get ('count' )} decisions "
235- f"({ record_info .get ('percentage_of_total' , 0 ):.1f} %)" )
220+ for record_key , record_info in list (records_data .get ("records" , {}).items ())[
221+ :3
222+ ]:
223+ print (
224+ f" - { record_key } : { record_info .get ('count' )} decisions "
225+ f"({ record_info .get ('percentage_of_total' , 0 ):.1f} %)"
226+ )
236227 except Exception as e :
237228 print (f" Error: { e } " )
238229
@@ -242,13 +233,16 @@ def main():
242233 print ("\n 13. Getting results by record..." )
243234 try :
244235 results_record = api .pulsardecisions ().get_decisions_results_record (
245- start = start_time ,
246- end = end_time
236+ start = start_time , end = end_time
247237 )
248238 print (f" Number of records: { len (results_record .get ('record' , {}))} " )
249- for record_key , record_info in list (results_record .get ('record' , {}).items ())[:3 ]:
250- print (f" - { record_key } : { record_info .get ('decision_count' )} decisions, "
251- f"{ len (record_info .get ('results' , {}))} unique results" )
239+ for record_key , record_info in list (results_record .get ("record" , {}).items ())[
240+ :3
241+ ]:
242+ print (
243+ f" - { record_key } : { record_info .get ('decision_count' )} decisions, "
244+ f"{ len (record_info .get ('results' , {}))} unique results"
245+ )
252246 except Exception as e :
253247 print (f" Error: { e } " )
254248
@@ -263,7 +257,7 @@ def main():
263257 period = "1h" ,
264258 area = "US" ,
265259 job = "your-job-id" , # Replace with actual job ID
266- agg = "sum"
260+ agg = "sum" ,
267261 )
268262 print (f" Total decisions (filtered): { filtered_data .get ('total' , 0 )} " )
269263 except Exception as e :
@@ -277,7 +271,7 @@ def main():
277271 multi_job_data = api .pulsardecisions ().get_decisions (
278272 start = start_time ,
279273 end = end_time ,
280- jobs = ["job1" , "job2" , "job3" ] # Replace with actual job IDs
274+ jobs = ["job1" , "job2" , "job3" ], # Replace with actual job IDs
281275 )
282276 print (f" Total decisions (multi-job): { multi_job_data .get ('total' , 0 )} " )
283277 except Exception as e :
@@ -288,5 +282,5 @@ def main():
288282 print ("=" * 60 )
289283
290284
291- if __name__ == ' __main__' :
285+ if __name__ == " __main__" :
292286 main ()
0 commit comments