diff --git a/src/posit/connect/endpoints.py b/src/posit/connect/endpoints.py deleted file mode 100644 index 33dcbc96..00000000 --- a/src/posit/connect/endpoints.py +++ /dev/null @@ -1,36 +0,0 @@ -import os -import requests - -_MAX_PAGE_SIZE = 500 - - -def get_users( - endpoint: str, - session: requests.Session, - /, - page_number: int, - *, - page_size: int = 500, -): - """ - Fetches the current page of users. - - Returns: - List[User]: A list of User objects representing the fetched users. - """ - # Construct the endpoint URL. - endpoint = os.path.join(endpoint, "v1/users") - # Redefine the page number using 1-based indexing. - page_number = page_number + 1 - # Define query parameters for pagination. - params = {"page_number": page_number, "page_size": page_size} - # Send a GET request to the endpoint with the specified parameters. - response = session.get(endpoint, params=params) - # Convert response to dict - json = response.json() - # Parse the JSON response and extract the results. - results = json["results"] - # Mark exhausted if the result size is less than the maximum page size. - exhausted = len(results) < page_size - # Create User objects from the results and return them as a list. - return (results, exhausted) diff --git a/src/posit/connect/endpoints_test.py b/src/posit/connect/endpoints_test.py deleted file mode 100644 index bf043e0f..00000000 --- a/src/posit/connect/endpoints_test.py +++ /dev/null @@ -1,16 +0,0 @@ -from unittest.mock import MagicMock, Mock, patch - -from .endpoints import get_users - - -class TestGetUsers: - @patch("posit.connect.users.Session") - def test(self, Session: MagicMock): - session = Session.return_value - get = session.get = Mock() - response = get.return_value = Mock() - json = response.json = Mock() - json.return_value = {"results": ["foo"]} - users, exhausted = get_users("http://foo.bar", session, page_number=0) - assert users == ["foo"] - assert exhausted