Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion auth0/v3/management/device_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
"""

Expand All @@ -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)

Expand Down
21 changes: 19 additions & 2 deletions auth0/v3/test/management/test_device_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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):
Expand Down