diff --git a/pyproject.toml b/pyproject.toml index e9f43b6..2ff53d3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "pyhuntress" -version = "0.2.10" +version = "0.2.11" authors = [ { name="Peter Annabel", email="peter.annabel@gmail.com" }, ] diff --git a/src/pyhuntress/endpoints/managedsat/AccountsIdPhishingScenariosEndpoint.py b/src/pyhuntress/endpoints/managedsat/AccountsIdPhishingScenariosEndpoint.py index d204a78..31ba9fe 100644 --- a/src/pyhuntress/endpoints/managedsat/AccountsIdPhishingScenariosEndpoint.py +++ b/src/pyhuntress/endpoints/managedsat/AccountsIdPhishingScenariosEndpoint.py @@ -10,7 +10,7 @@ from pyhuntress.types import ( HuntressSATRequestParams, ) - +# THIS ENDPOINT RETURNS ABSOLUTELY NOTHING. DO NOT USE class AccountsIdPhishingScenariosEndpoint( HuntressEndpoint, IGettable[SATPhishingScenarios, HuntressSATRequestParams], diff --git a/src/pyhuntress/endpoints/managedsat/PhishingCampaignsIdCampaignScenariosEndpoint.py b/src/pyhuntress/endpoints/managedsat/PhishingCampaignsIdCampaignScenariosEndpoint.py index 7b8f1d4..566f7fa 100644 --- a/src/pyhuntress/endpoints/managedsat/PhishingCampaignsIdCampaignScenariosEndpoint.py +++ b/src/pyhuntress/endpoints/managedsat/PhishingCampaignsIdCampaignScenariosEndpoint.py @@ -1,8 +1,10 @@ from pyhuntress.endpoints.base.huntress_endpoint import HuntressEndpoint from pyhuntress.interfaces import ( IGettable, + IPaginateable, ) -from pyhuntress.models.managedsat import SATPhishingCampaigns +from pyhuntress.models.managedsat import SATPhishingScenarios +from pyhuntress.responses.paginated_response import PaginatedResponse from pyhuntress.types import ( JSON, HuntressSATRequestParams, @@ -11,17 +13,49 @@ from pyhuntress.types import ( class PhishingCampaignsIdCampaignScenariosEndpoint( HuntressEndpoint, - IGettable[SATPhishingCampaigns, HuntressSATRequestParams], + IGettable[SATPhishingScenarios, HuntressSATRequestParams], + IPaginateable[SATPhishingScenarios, HuntressSATRequestParams], ): def __init__(self, client, parent_endpoint=None) -> None: HuntressEndpoint.__init__(self, client, "campaign-scenarios", parent_endpoint=parent_endpoint) - IGettable.__init__(self, SATPhishingCampaigns) + IGettable.__init__(self, SATPhishingScenarios) + + def paginated( + self, + page: int, + limit: int, + params: HuntressSATRequestParams | None = None, + ) -> PaginatedResponse[SATPhishingScenarios]: + """ + Performs a GET request against the /phishing-campaigns/{id}/phishing-scenarios 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[SATPhishingScenarios]: 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), + SATPhishingScenarios, + self, + "data", + page, + limit, + params, + ) def get( self, data: JSON | None = None, params: HuntressSATRequestParams | None = None, - ) -> SATPhishingCampaigns: + ) -> SATPhishingScenarios: # TODO: Make this require the learnerid as a parameter @@ -32,9 +66,9 @@ class PhishingCampaignsIdCampaignScenariosEndpoint( data (dict[str, Any]): The data to send in the request body. params (dict[str, int | str]): The parameters to send in the request query string. Returns: - SATPhishingCampaigns: The parsed response data. + SATPhishingScenarios: The parsed response data. """ return self._parse_many( - SATPhishingCampaigns, + SATPhishingScenarios, super()._make_request("GET", data=data, params=params).json().get('data', {}), )