mirror of
				https://github.com/brygphilomena/pyhuntress.git
				synced 2025-11-04 00:07:29 +00:00 
			
		
		
		
	add pagination to accounts/{id}/learners
This commit is contained in:
		
							parent
							
								
									edd624ba8e
								
							
						
					
					
						commit
						b3eae5456b
					
				@ -1,6 +1,6 @@
 | 
				
			|||||||
[project]
 | 
					[project]
 | 
				
			||||||
name = "pyhuntress"
 | 
					name = "pyhuntress"
 | 
				
			||||||
version = "0.2.6"
 | 
					version = "0.2.7"
 | 
				
			||||||
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 SATLearners
 | 
					from pyhuntress.models.managedsat import SATLearners
 | 
				
			||||||
 | 
					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 AccountsIdLearnersEndpoint(
 | 
					class AccountsIdLearnersEndpoint(
 | 
				
			||||||
    HuntressEndpoint,
 | 
					    HuntressEndpoint,
 | 
				
			||||||
    IGettable[SATLearners, HuntressSATRequestParams],
 | 
					    IGettable[SATLearners, HuntressSATRequestParams],
 | 
				
			||||||
 | 
					    IPaginateable[SATLearners, HuntressSATRequestParams],
 | 
				
			||||||
):
 | 
					):
 | 
				
			||||||
    def __init__(self, client, parent_endpoint=None) -> None:
 | 
					    def __init__(self, client, parent_endpoint=None) -> None:
 | 
				
			||||||
        HuntressEndpoint.__init__(self, client, "learners", parent_endpoint=parent_endpoint)
 | 
					        HuntressEndpoint.__init__(self, client, "learners", parent_endpoint=parent_endpoint)
 | 
				
			||||||
        IGettable.__init__(self, SATLearners)
 | 
					        IGettable.__init__(self, SATLearners)
 | 
				
			||||||
 | 
					        IPaginateable.__init__(self, SATLearners)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def paginated(
 | 
				
			||||||
 | 
					        self,
 | 
				
			||||||
 | 
					        page: int,
 | 
				
			||||||
 | 
					        limit: int,
 | 
				
			||||||
 | 
					        params: HuntressSATRequestParams | None = None,
 | 
				
			||||||
 | 
					    ) -> PaginatedResponse[SATLearners]:
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					        Performs a GET request against the /accounts/{id}/learners 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[SATLearners]: 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),
 | 
				
			||||||
 | 
					            SATLearners,
 | 
				
			||||||
 | 
					            self,
 | 
				
			||||||
 | 
					            "data",
 | 
				
			||||||
 | 
					            page,
 | 
				
			||||||
 | 
					            limit,
 | 
				
			||||||
 | 
					            params,
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def get(
 | 
					    def get(
 | 
				
			||||||
        self,
 | 
					        self,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user