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]
|
[project]
|
||||||
name = "pyhuntress"
|
name = "pyhuntress"
|
||||||
version = "0.2.11"
|
version = "0.2.12"
|
||||||
authors = [
|
authors = [
|
||||||
{ name="Peter Annabel", email="peter.annabel@gmail.com" },
|
{ name="Peter Annabel", email="peter.annabel@gmail.com" },
|
||||||
]
|
]
|
||||||
|
|||||||
@ -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 SATPhishingScenarios
|
from pyhuntress.models.managedsat import SATPhishingScenarios
|
||||||
|
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 PhishingCampaignScenariosIdScenarioEndpoint(
|
class PhishingCampaignScenariosIdScenarioEndpoint(
|
||||||
HuntressEndpoint,
|
HuntressEndpoint,
|
||||||
IGettable[SATPhishingScenarios, HuntressSATRequestParams],
|
IGettable[SATPhishingScenarios, HuntressSATRequestParams],
|
||||||
|
IPaginateable[SATPhishingScenarios, HuntressSATRequestParams],
|
||||||
):
|
):
|
||||||
def __init__(self, client, parent_endpoint=None) -> None:
|
def __init__(self, client, parent_endpoint=None) -> None:
|
||||||
HuntressEndpoint.__init__(self, client, "scenario", parent_endpoint=parent_endpoint)
|
HuntressEndpoint.__init__(self, client, "scenario", parent_endpoint=parent_endpoint)
|
||||||
IGettable.__init__(self, SATPhishingScenarios)
|
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(
|
def get(
|
||||||
self,
|
self,
|
||||||
|
|||||||
@ -19,6 +19,7 @@ class PhishingCampaignsIdCampaignScenariosEndpoint(
|
|||||||
def __init__(self, client, parent_endpoint=None) -> None:
|
def __init__(self, client, parent_endpoint=None) -> None:
|
||||||
HuntressEndpoint.__init__(self, client, "campaign-scenarios", parent_endpoint=parent_endpoint)
|
HuntressEndpoint.__init__(self, client, "campaign-scenarios", parent_endpoint=parent_endpoint)
|
||||||
IGettable.__init__(self, SATPhishingScenarios)
|
IGettable.__init__(self, SATPhishingScenarios)
|
||||||
|
IPaginateable.__init__(self, SATPhishingScenarios)
|
||||||
|
|
||||||
def paginated(
|
def paginated(
|
||||||
self,
|
self,
|
||||||
@ -27,7 +28,7 @@ class PhishingCampaignsIdCampaignScenariosEndpoint(
|
|||||||
params: HuntressSATRequestParams | None = None,
|
params: HuntressSATRequestParams | None = None,
|
||||||
) -> PaginatedResponse[SATPhishingScenarios]:
|
) -> 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:
|
Parameters:
|
||||||
page (int): The page number to request.
|
page (int): The page number to request.
|
||||||
@ -56,9 +57,7 @@ class PhishingCampaignsIdCampaignScenariosEndpoint(
|
|||||||
data: JSON | None = None,
|
data: JSON | None = None,
|
||||||
params: HuntressSATRequestParams | None = None,
|
params: HuntressSATRequestParams | None = None,
|
||||||
) -> SATPhishingScenarios:
|
) -> SATPhishingScenarios:
|
||||||
|
|
||||||
# TODO: Make this require the learnerid as a parameter
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Performs a GET request against the /phishing-campaigns/{id}/campaign-scenarios endpoint.
|
Performs a GET request against the /phishing-campaigns/{id}/campaign-scenarios endpoint.
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user