mirror of
https://github.com/brygphilomena/pyhuntress.git
synced 2025-11-06 17:17:29 +00:00
73 lines
2.4 KiB
Python
73 lines
2.4 KiB
Python
from pyhuntress.endpoints.base.huntress_endpoint import HuntressEndpoint
|
|
from pyhuntress.interfaces import (
|
|
IGettable,
|
|
IPaginateable,
|
|
)
|
|
from pyhuntress.models.managedsat import SATUsers
|
|
from pyhuntress.responses.paginated_response import PaginatedResponse
|
|
from pyhuntress.types import (
|
|
JSON,
|
|
HuntressSATRequestParams,
|
|
)
|
|
|
|
|
|
class AccountsIdUsersEndpoint(
|
|
HuntressEndpoint,
|
|
IGettable[SATUsers, HuntressSATRequestParams],
|
|
IPaginateable[SATUsers, HuntressSATRequestParams],
|
|
):
|
|
def __init__(self, client, parent_endpoint=None) -> None:
|
|
HuntressEndpoint.__init__(self, client, "users", parent_endpoint=parent_endpoint)
|
|
IGettable.__init__(self, SATUsers)
|
|
IPaginateable.__init__(self, SATUsers)
|
|
|
|
def paginated(
|
|
self,
|
|
page: int,
|
|
limit: int,
|
|
params: HuntressSATRequestParams | None = None,
|
|
) -> PaginatedResponse[SATUsers]:
|
|
"""
|
|
Performs a GET request against the /accounts/{id}/users 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[SATUsers]: 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),
|
|
SATUsers,
|
|
self,
|
|
"data",
|
|
page,
|
|
limit,
|
|
params,
|
|
)
|
|
|
|
def get(
|
|
self,
|
|
data: JSON | None = None,
|
|
params: HuntressSATRequestParams | None = None,
|
|
) -> SATUsers:
|
|
"""
|
|
Performs a GET request against the /accounts/{id}/users endpoint.
|
|
|
|
Parameters:
|
|
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:
|
|
SATUsersInformation: The parsed response data.
|
|
"""
|
|
return self._parse_many(
|
|
SATUsers,
|
|
super()._make_request("GET", data=data, params=params).json().get('data', {}),
|
|
)
|