diff --git a/auth0/v3/management/device_credentials.py b/auth0/v3/management/device_credentials.py index fda6c81f..23c2c9dc 100644 --- a/auth0/v3/management/device_credentials.py +++ b/auth0/v3/management/device_credentials.py @@ -34,7 +34,7 @@ def _url(self, id=None): return '{}/{}'.format(url, id) return url - def get(self, user_id, client_id, type, fields=None, include_fields=True): + def get(self, user_id, client_id, type, fields=None, include_fields=True, page=None, per_page=None, include_totals=False): """List device credentials. Args: @@ -51,6 +51,14 @@ def get(self, user_id, client_id, type, fields=None, include_fields=True): include_fields (bool, optional): True if the fields specified are to be included in the result, False otherwise. Defaults to True. + page (int, optional): Page index of the results to return. First page is 0. + + per_page (int, optional): Number of results per page. + + include_totals (bool, optional): True to return results inside an object + that contains the total result count (True) or as a direct array of + results (False, default). + See: https://auth0.com/docs/api/management/v2#!/Device_Credentials/get_device_credentials """ @@ -60,6 +68,9 @@ def get(self, user_id, client_id, type, fields=None, include_fields=True): 'user_id': user_id, 'client_id': client_id, 'type': type, + 'page': page, + 'per_page': per_page, + 'include_totals': str(include_totals).lower() } return self.client.get(self._url(), params=params) diff --git a/auth0/v3/test/management/test_device_credentials.py b/auth0/v3/test/management/test_device_credentials.py index 6aa854d1..036067f3 100644 --- a/auth0/v3/test/management/test_device_credentials.py +++ b/auth0/v3/test/management/test_device_credentials.py @@ -16,7 +16,7 @@ def test_get(self, mock_rc): mock_instance = mock_rc.return_value c = DeviceCredentials(domain='domain', token='jwttoken') - c.get(user_id='uid', client_id='cid', type='type') + c.get(user_id='uid', client_id='cid', type='type', page=0, per_page=20) args, kwargs = mock_instance.get.call_args @@ -25,7 +25,24 @@ def test_get(self, mock_rc): 'include_fields': 'true', 'user_id': 'uid', 'client_id': 'cid', - 'type': 'type'}) + 'type': 'type', + 'page': 0, + 'per_page': 20, + 'include_totals': 'false'}) + + c.get(user_id='uid', client_id='cid', type='type', page=5, per_page=50, include_totals=True) + + args, kwargs = mock_instance.get.call_args + + self.assertEqual('https://domain/api/v2/device-credentials', args[0]) + self.assertEqual(kwargs['params'], {'fields': None, + 'include_fields': 'true', + 'user_id': 'uid', + 'client_id': 'cid', + 'type': 'type', + 'page': 5, + 'per_page': 50, + 'include_totals': 'true'}) @mock.patch('auth0.v3.management.device_credentials.RestClient') def test_create(self, mock_rc):