add pagination to accounts/{id}

This commit is contained in:
Peter Annabel 2025-07-29 10:03:47 -05:00
parent b3eae5456b
commit 01d6783d3e
2 changed files with 32 additions and 1 deletions

View File

@ -22,7 +22,7 @@ class AccountsEndpoint(
IGettable.__init__(self, SATAccounts) IGettable.__init__(self, SATAccounts)
IPaginateable.__init__(self, SATAccounts) IPaginateable.__init__(self, SATAccounts)
def id(self, id: int) -> AccountsIdEndpoint: def id(self, id: str) -> AccountsIdEndpoint:
""" """
Sets the ID for this endpoint and returns an initialized AccountsIdEndpoint object to move down the chain. Sets the ID for this endpoint and returns an initialized AccountsIdEndpoint object to move down the chain.

View File

@ -36,6 +36,37 @@ class AccountsIdEndpoint(
self.phishing_campaigns = self._register_child_endpoint(AccountsIdPhishingCampaignsEndpoint(client, parent_endpoint=self)) self.phishing_campaigns = self._register_child_endpoint(AccountsIdPhishingCampaignsEndpoint(client, parent_endpoint=self))
self.phishing_scenarios = self._register_child_endpoint(AccountsIdPhishingScenariosEndpoint(client, parent_endpoint=self)) self.phishing_scenarios = self._register_child_endpoint(AccountsIdPhishingScenariosEndpoint(client, parent_endpoint=self))
def paginated(
self,
page: int,
limit: int,
params: HuntressSATRequestParams | None = None,
) -> PaginatedResponse[SATAccounts]:
"""
Performs a GET request against the /accounts/{id} endpoint and returns an initialized PaginatedResponse object.
Parameters:
page (int): The page number to request.
limit (int): The number of results to return per page.
params (dict[str, int | str]): The parameters to send in the request query string.
Returns:
PaginatedResponse[SATAccounts]: The initialized PaginatedResponse object.
"""
if params:
params["page[number]"] = page
params["page[size]"] = limit
else:
params = {"page[number]": page, "page[size]": limit}
return PaginatedResponse(
super()._make_request("GET", params=params),
SATAccounts,
self,
"data",
page,
limit,
params,
)
def get( def get(
self, self,
data: JSON | None = None, data: JSON | None = None,