mirror of
https://github.com/brygphilomena/pyhuntress.git
synced 2025-11-04 16:27:30 +00:00
fix more pagination
This commit is contained in:
parent
b9068b8185
commit
8f0d836447
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "pyhuntress"
|
||||
version = "0.2.11"
|
||||
version = "0.2.12"
|
||||
authors = [
|
||||
{ name="Peter Annabel", email="peter.annabel@gmail.com" },
|
||||
]
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
from pyhuntress.endpoints.base.huntress_endpoint import HuntressEndpoint
|
||||
from pyhuntress.interfaces import (
|
||||
IGettable,
|
||||
IPaginateable,
|
||||
)
|
||||
from pyhuntress.models.managedsat import SATPhishingScenarios
|
||||
from pyhuntress.responses.paginated_response import PaginatedResponse
|
||||
from pyhuntress.types import (
|
||||
JSON,
|
||||
HuntressSATRequestParams,
|
||||
@ -12,10 +14,43 @@ from pyhuntress.types import (
|
||||
class PhishingCampaignScenariosIdScenarioEndpoint(
|
||||
HuntressEndpoint,
|
||||
IGettable[SATPhishingScenarios, HuntressSATRequestParams],
|
||||
IPaginateable[SATPhishingScenarios, HuntressSATRequestParams],
|
||||
):
|
||||
def __init__(self, client, parent_endpoint=None) -> None:
|
||||
HuntressEndpoint.__init__(self, client, "scenario", parent_endpoint=parent_endpoint)
|
||||
IGettable.__init__(self, SATPhishingScenarios)
|
||||
IPaginateable.__init__(self, SATPhishingScenarios)
|
||||
|
||||
def paginated(
|
||||
self,
|
||||
page: int,
|
||||
limit: int,
|
||||
params: HuntressSATRequestParams | None = None,
|
||||
) -> PaginatedResponse[SATPhishingScenarios]:
|
||||
"""
|
||||
Performs a GET request against the /phishing-campaign-scenarios/{id}/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,
|
||||
|
||||
@ -19,6 +19,7 @@ class PhishingCampaignsIdCampaignScenariosEndpoint(
|
||||
def __init__(self, client, parent_endpoint=None) -> None:
|
||||
HuntressEndpoint.__init__(self, client, "campaign-scenarios", parent_endpoint=parent_endpoint)
|
||||
IGettable.__init__(self, SATPhishingScenarios)
|
||||
IPaginateable.__init__(self, SATPhishingScenarios)
|
||||
|
||||
def paginated(
|
||||
self,
|
||||
@ -27,7 +28,7 @@ class PhishingCampaignsIdCampaignScenariosEndpoint(
|
||||
params: HuntressSATRequestParams | None = None,
|
||||
) -> PaginatedResponse[SATPhishingScenarios]:
|
||||
"""
|
||||
Performs a GET request against the /phishing-campaigns/{id}/phishing-scenarios endpoint and returns an initialized PaginatedResponse object.
|
||||
Performs a GET request against the /phishing-campaigns/{id}/campaign-scenarios endpoint and returns an initialized PaginatedResponse object.
|
||||
|
||||
Parameters:
|
||||
page (int): The page number to request.
|
||||
@ -56,9 +57,7 @@ class PhishingCampaignsIdCampaignScenariosEndpoint(
|
||||
data: JSON | None = None,
|
||||
params: HuntressSATRequestParams | None = None,
|
||||
) -> SATPhishingScenarios:
|
||||
|
||||
# TODO: Make this require the learnerid as a parameter
|
||||
|
||||
|
||||
"""
|
||||
Performs a GET request against the /phishing-campaigns/{id}/campaign-scenarios endpoint.
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user