add pagination to attempts

This commit is contained in:
Peter Annabel 2025-07-29 12:46:09 -05:00
parent 8f0d836447
commit b4839e4cf1
2 changed files with 36 additions and 1 deletions

View File

@ -1,6 +1,6 @@
[project] [project]
name = "pyhuntress" name = "pyhuntress"
version = "0.2.12" version = "0.2.13"
authors = [ authors = [
{ name="Peter Annabel", email="peter.annabel@gmail.com" }, { name="Peter Annabel", email="peter.annabel@gmail.com" },
] ]

View File

@ -1,8 +1,10 @@
from pyhuntress.endpoints.base.huntress_endpoint import HuntressEndpoint from pyhuntress.endpoints.base.huntress_endpoint import HuntressEndpoint
from pyhuntress.interfaces import ( from pyhuntress.interfaces import (
IGettable, IGettable,
IPaginateable,
) )
from pyhuntress.models.managedsat import SATPhishingCampaignAttempts from pyhuntress.models.managedsat import SATPhishingCampaignAttempts
from pyhuntress.responses.paginated_response import PaginatedResponse
from pyhuntress.types import ( from pyhuntress.types import (
JSON, JSON,
HuntressSATRequestParams, HuntressSATRequestParams,
@ -12,10 +14,43 @@ from pyhuntress.types import (
class PhishingCampaignScenariosIdAttemptsEndpoint( class PhishingCampaignScenariosIdAttemptsEndpoint(
HuntressEndpoint, HuntressEndpoint,
IGettable[SATPhishingCampaignAttempts, HuntressSATRequestParams], IGettable[SATPhishingCampaignAttempts, HuntressSATRequestParams],
IPaginateable[SATPhishingCampaignAttempts, HuntressSATRequestParams],
): ):
def __init__(self, client, parent_endpoint=None) -> None: def __init__(self, client, parent_endpoint=None) -> None:
HuntressEndpoint.__init__(self, client, "attempts", parent_endpoint=parent_endpoint) HuntressEndpoint.__init__(self, client, "attempts", parent_endpoint=parent_endpoint)
IGettable.__init__(self, SATPhishingCampaignAttempts) IGettable.__init__(self, SATPhishingCampaignAttempts)
IPaginateable.__init__(self, SATPhishingCampaignAttempts)
def paginated(
self,
page: int,
limit: int,
params: HuntressSATRequestParams | None = None,
) -> PaginatedResponse[SATPhishingCampaignAttempts]:
"""
Performs a GET request against the /phishing-campaign-scenarios/{id}/attempts 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[SATPhishingCampaignAttempts]: 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),
SATPhishingCampaignAttempts,
self,
"data",
page,
limit,
params,
)
def get( def get(
self, self,