Skip to content

Commit fb37014

Browse files
authored
fix(risks): adds paging to risk_types API (#656)
* fix(risks): adds paging to risk_types API * build: bump version from 2.2.15 to 2.2.16
1 parent 3f981c6 commit fb37014

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

censys/asm/risks.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -126,21 +126,29 @@ def patch_risk_instance(self, risk_instance_id: int, data: dict) -> dict:
126126

127127
def get_risk_types(
128128
self,
129+
limit: Optional[int] = None,
130+
page: Optional[int] = None,
129131
sort: Optional[List[str]] = None,
130132
include_events: Optional[bool] = None,
131133
accept: Optional[str] = None,
132134
) -> dict:
133135
"""Retrieve risk types.
134136
135137
Args:
138+
limit (int, optional): Maximum number of results to return. Defaults to 1000.
139+
page (int, optional): Page number to begin at when searching. Defaults to 1.
136140
sort (list): Optional; Sort by field(s).
137141
include_events (bool): Optional; Whether to include events.
138142
accept (str): Optional; Accept header.
139143
140144
Returns:
141145
dict: Risk types result.
142146
"""
143-
args = {"sort": sort, "includeEvents": include_events}
147+
args: Dict[str, Any] = {"sort": sort, "includeEvents": include_events}
148+
if page:
149+
args["page"] = page
150+
if limit:
151+
args["limit"] = limit
144152
return self._get(
145153
self.risk_types_path,
146154
args=args,

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "censys"
3-
version = "2.2.15"
3+
version = "2.2.16"
44
description = "An easy-to-use and lightweight API wrapper for Censys APIs (censys.io)."
55
authors = ["Censys, Inc. <support@censys.io>"]
66
license = "Apache-2.0"

tests/asm/test_risks.py

+2
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ def test_patch_risk_instance(self):
217217
({"include_events": True}, "?includeEvents=True"),
218218
({"include_events": False}, "?includeEvents=False"),
219219
({"sort": ["severity", "type:asc"]}, "?sort=severity&sort=type:asc"),
220+
({"page": 1, "limit": 10000}, "?page=1&limit=10000"),
221+
({"page": 10}, "?page=10"),
220222
]
221223
)
222224
def test_get_risk_types(self, kwargs, params):

0 commit comments

Comments
 (0)