Skip to content

Commit b373049

Browse files
authored
fix: Increase limit to retrieve policy events without pagination (#179)
* fix: Increase limit to retrieve policy events without pagination * fix: Solve linting problems
1 parent 1e35812 commit b373049

File tree

3 files changed

+5
-33
lines changed

3 files changed

+5
-33
lines changed

examples/get_secure_policy_events.py

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
#
1313

1414
import getopt
15-
import json
16-
import operator
17-
import re
1815
import sys
1916

2017
from sdcclient import SdSecureClient
@@ -73,32 +70,8 @@ def usage():
7370

7471
all_outputs = dict()
7572

76-
while True:
77-
78-
#
79-
# Return the result
80-
#
81-
if not ok:
82-
print(res)
83-
sys.exit(1)
84-
85-
if not res["ctx"]["cursor"] or len(res['data']) == 0:
86-
break
87-
88-
for event in res['data']:
89-
if summarize:
90-
sanitize_output = re.sub(r'\S+\s\(id=\S+\)', '', event['output'])
91-
all_outputs[sanitize_output] = all_outputs.get(sanitize_output, 0) + 1
92-
else:
93-
sys.stdout.write(json.dumps(event) + "\n")
94-
95-
ok, res = sdclient.get_more_policy_events(res['ctx'])
73+
if not ok:
74+
print(res)
75+
sys.exit(1)
9676

97-
if summarize:
98-
sorted = sorted(list(all_outputs.items()), key=operator.itemgetter(1), reverse=True)
99-
count = 0
100-
for val in sorted:
101-
count += 1
102-
sys.stdout.write("{} {}\n".format(val[1], val[0]))
103-
if limit != 0 and count > limit:
104-
break
77+
print(res["data"])

sdcclient/_monitor.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import json
2-
import re
32
from typing import Any, Tuple, Union
43

54
from sdcclient._common import _SdcCommon

sdcclient/secure/_policy_events_v1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def get_policy_events_range(self, from_sec, to_sec, filter=None):
5050
'''
5151
options = {"from": int(from_sec) * 1_000_000_000,
5252
"to": int(to_sec) * 1_000_000_000,
53-
"limit": 50,
53+
"limit": 999,
5454
"filter": filter}
5555
ctx = {k: v for k, v in options.items() if v is not None}
5656
return self._get_policy_events_int(ctx)

0 commit comments

Comments
 (0)