Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds user export job creation. #112

Merged
merged 3 commits into from Oct 5, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions auth0/v3/management/jobs.py
Expand Up @@ -41,6 +41,17 @@ def get_failed_job(self, id):
url = self._url('%s/errors' % (id))
return self.client.get(url)

def export_users(self, body):
"""Export all users to a file using a long running job.

Check job status with get(). URL pointing to the export file will be
included in the status once the job is complete.

Args:
body (dict): Please see: https://auth0.com/docs/api/management/v2#!/Jobs/post_users_exports
"""
return self.client.post(self._url('users-exports'), data=body)

def import_users(self, connection_id, file_obj, upsert=False):
"""Imports users to a connection from a file.

Expand Down
12 changes: 12 additions & 0 deletions auth0/v3/test/management/test_jobs.py
Expand Up @@ -27,6 +27,18 @@ def get_failed_job(self, mock_rc):
'https://domain/api/v2/jobs/an-id/errors',
)

@mock.patch('auth0.v3.management.jobs.RestClient')
def test_export_users(self, mock_rc):
mock_instance = mock_rc.return_value

j = Jobs(domain='domain', token='jwttoken')
j.export_users({'connection_id': 'cxn_id', 'format': 'json'})

mock_instance.post.assert_called_with(
'https://domain/api/v2/jobs/users-exports',
data={'connection_id': 'cxn_id', 'format': 'json'}
)

@mock.patch('auth0.v3.management.jobs.RestClient')
def test_import_users(self, mock_rc):
mock_instance = mock_rc.return_value
Expand Down