Skip to content

Commit

Permalink
fix(risks): adds paging to risk_types API (#656)
Browse files Browse the repository at this point in the history
* fix(risks): adds paging to risk_types API

* build: bump version from 2.2.15 to 2.2.16
  • Loading branch information
harningt authored Oct 21, 2024
1 parent 3f981c6 commit fb37014
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
10 changes: 9 additions & 1 deletion censys/asm/risks.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,29 @@ def patch_risk_instance(self, risk_instance_id: int, data: dict) -> dict:

def get_risk_types(
self,
limit: Optional[int] = None,
page: Optional[int] = None,
sort: Optional[List[str]] = None,
include_events: Optional[bool] = None,
accept: Optional[str] = None,
) -> dict:
"""Retrieve risk types.
Args:
limit (int, optional): Maximum number of results to return. Defaults to 1000.
page (int, optional): Page number to begin at when searching. Defaults to 1.
sort (list): Optional; Sort by field(s).
include_events (bool): Optional; Whether to include events.
accept (str): Optional; Accept header.
Returns:
dict: Risk types result.
"""
args = {"sort": sort, "includeEvents": include_events}
args: Dict[str, Any] = {"sort": sort, "includeEvents": include_events}
if page:
args["page"] = page
if limit:
args["limit"] = limit
return self._get(
self.risk_types_path,
args=args,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "censys"
version = "2.2.15"
version = "2.2.16"
description = "An easy-to-use and lightweight API wrapper for Censys APIs (censys.io)."
authors = ["Censys, Inc. <[email protected]>"]
license = "Apache-2.0"
Expand Down
2 changes: 2 additions & 0 deletions tests/asm/test_risks.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ def test_patch_risk_instance(self):
({"include_events": True}, "?includeEvents=True"),
({"include_events": False}, "?includeEvents=False"),
({"sort": ["severity", "type:asc"]}, "?sort=severity&sort=type:asc"),
({"page": 1, "limit": 10000}, "?page=1&limit=10000"),
({"page": 10}, "?page=10"),
]
)
def test_get_risk_types(self, kwargs, params):
Expand Down

0 comments on commit fb37014

Please sign in to comment.