예제 #1
0
    def list_server_databases(self, server_id):
        """List the database servers assigned to the specified server ID.

        Args:
            server_id(int): Pterodactyl Server ID.
        """
        endpoint = 'application/servers/%s/databases' % server_id
        response = self._api_request(endpoint=endpoint)
        return PaginatedResponse(self, endpoint, response)
예제 #2
0
파일: nests.py 프로젝트: iamkubi/pydactyl
    def list_nests(self, *include):
        """List all nests.

        Args:
            include(*string): Zero or more include options (eggs, servers)
        """
        params = None if not include else {'include': ','.join(include)}
        endpoint = 'application/nests'
        response = self._api_request(endpoint=endpoint, params=params)
        return PaginatedResponse(self, endpoint, response)
예제 #3
0
파일: nodes.py 프로젝트: iamkubi/pydactyl
    def list_nodes(self, include=None):
        """List all nodes.

        Args:
            include(str): Comma separated list of includes
        """
        endpoint = 'application/nodes'
        params = {}
        if include is not None:
            params['include'] = include
        response = self._api_request(endpoint=endpoint, params=params)
        return PaginatedResponse(self, endpoint, response)
예제 #4
0
파일: nodes.py 프로젝트: iamkubi/pydactyl
    def list_node_allocations(self, node_id):
        """Retrieves all allocations for a specified node.

        Args:
            node_id(int): Pterodactyl Node ID.

        Returns:
            obj: Iterable response that fetches pages as required.
        """
        endpoint = 'application/nodes/%s/allocations' % node_id
        response = self._api_request(endpoint=endpoint)
        return PaginatedResponse(self, endpoint, response)
예제 #5
0
    def list_users(self, search=None):
        """List all users.

        Args:
            search(str): Filter user list by search term.
        """
        params = {}
        if search is not None:
            params = {'search': search}
        endpoint = 'application/users'
        response = self._api_request(endpoint=endpoint, params=params)
        return PaginatedResponse(self, endpoint, response)
예제 #6
0
파일: user.py 프로젝트: iamkubi/pydactyl
    def list_users(self,
                   email=None,
                   uuid=None,
                   username=None,
                   external_id=None):
        """List all users.

        Accepts optional filter parameters.  If multiple filters are specified
        only results that match all filters will be returned.

        Args:
            email(str): Filter by email
            uuid(str): Filter by uuid
            username(str): Filter by username
            external_id(int): Filter by external_id
        """
        params = {
            'filter[{}]'.format(k): v
            for k, v in locals().items() if v is not None and k != 'self'
        }
        endpoint = 'application/users'
        response = self._api_request(endpoint=endpoint, params=params)
        return PaginatedResponse(self, endpoint, response)
예제 #7
0
 def list_servers(self):
     """List all servers."""
     endpoint = 'application/servers'
     response = self._api_request(endpoint=endpoint)
     return PaginatedResponse(self, endpoint, response)
예제 #8
0
 def test_paginated_response_next_page_does_not_exist(self):
     data = deepcopy(TEST_META)
     self.assertTrue(PaginatedResponse._next_page_exists(data))
     del data['pagination']['links']['next']
     self.assertFalse(PaginatedResponse._next_page_exists(data))
예제 #9
0
 def test_paginated_response_next_page_exists(self):
     self.assertTrue(PaginatedResponse._next_page_exists(TEST_META))
예제 #10
0
 def test_paginated_response_get_previous_page_link(self):
     response = PaginatedResponse(self.client, 'anyendpoint', TEST_DATA)
     self.assertEqual(
         response.get_previous_page_link(),
         'https://panel.mydomain.com/api/application/nodes/1/allocations'
         '?page=1')
예제 #11
0
 def test_paginated_response_get_with_default(self):
     response = PaginatedResponse(self.client, 'anyendpoint', TEST_DATA)
     self.assertEqual(response.get('badname', 'test_default'),
                      'test_default')
예제 #12
0
 def test_paginated_response_get(self):
     response = PaginatedResponse(self.client, 'anyendpoint', TEST_DATA)
     self.assertEqual(response.get('meta'), TEST_META)
예제 #13
0
    def test_paginated_response_init(self):
        response = PaginatedResponse(self.client, 'anyendpoint', TEST_DATA)

        self.assertEqual(response[0]['dummy'], 'data1')
        self.assertEqual(response[1]['dummy'], 'data2')
예제 #14
0
 def list_servers(self):
     """List all servers the client has access to."""
     endpoint = 'client'
     response = self._api_request(endpoint=endpoint)
     return PaginatedResponse(self, endpoint, response)
예제 #15
0
 def list_servers(self):
     """List all servers."""
     endpoint = 'application/servers'
     response = base.parse_response(self._api_request(endpoint=endpoint),
                                    detail=True)
     return PaginatedResponse(self, endpoint, response)