mirror of
https://github.com/brygphilomena/pyhuntress.git
synced 2025-11-04 16:27:30 +00:00
Added pagination to phsihing-campaigns/{id}/campaign-scenarios
This commit is contained in:
parent
6de7fb2ce2
commit
b9068b8185
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "pyhuntress"
|
||||
version = "0.2.10"
|
||||
version = "0.2.11"
|
||||
authors = [
|
||||
{ name="Peter Annabel", email="peter.annabel@gmail.com" },
|
||||
]
|
||||
|
||||
@ -10,7 +10,7 @@ from pyhuntress.types import (
|
||||
HuntressSATRequestParams,
|
||||
)
|
||||
|
||||
|
||||
# THIS ENDPOINT RETURNS ABSOLUTELY NOTHING. DO NOT USE
|
||||
class AccountsIdPhishingScenariosEndpoint(
|
||||
HuntressEndpoint,
|
||||
IGettable[SATPhishingScenarios, HuntressSATRequestParams],
|
||||
|
||||
@ -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', {}),
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user