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
24 changes: 16 additions & 8 deletions duo_client/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2529,7 +2529,7 @@ def get_integrations_generator(self):
"""
return self.json_paging_api_call(
'GET',
'/admin/v2/integrations',
'/admin/v3/integrations',
{},
)

Expand All @@ -2549,7 +2549,7 @@ def get_integrations(self, limit=None, offset=0):
if limit:
return self.json_api_call(
'GET',
'/admin/v2/integrations',
'/admin/v3/integrations',
{'limit': limit, 'offset': offset},
)

Expand All @@ -2568,7 +2568,7 @@ def get_integration(self, integration_key):
params = {}
response = self.json_api_call(
'GET',
'/admin/v2/integrations/' + integration_key,
'/admin/v3/integrations/' + integration_key,
params,
)
return response
Expand All @@ -2593,7 +2593,8 @@ def create_integration(self,
ip_whitelist_enroll_policy=None,
groups_allowed=None,
self_service_allowed=None,
sso=None):
sso=None,
user_access=None):
"""Creates a new integration.

name - The name of the integration (required)
Expand Down Expand Up @@ -2671,8 +2672,11 @@ def create_integration(self,
params['self_service_allowed'] = '1' if self_service_allowed else '0'
if sso is not None:
params['sso'] = sso
if user_access is not None:
params['user_access'] = user_access

response = self.json_api_call('POST',
'/admin/v2/integrations',
'/admin/v3/integrations',
params,
)
return response
Expand Down Expand Up @@ -2766,7 +2770,7 @@ def delete_integration(self, integration_key):

"""
integration_key = urllib.parse.quote_plus(str(integration_key))
path = '/admin/v2/integrations/%s' % integration_key
path = '/admin/v3/integrations/%s' % integration_key
return self.json_api_call(
'DELETE',
path,
Expand Down Expand Up @@ -2794,7 +2798,9 @@ def update_integration(self,
ip_whitelist_enroll_policy=None,
groups_allowed=None,
self_service_allowed=None,
sso=None):
sso=None,
user_access=None
):
"""Updates an integration.

integration_key - The key of the integration to update. (required)
Expand Down Expand Up @@ -2833,7 +2839,7 @@ def update_integration(self,

"""
integration_key = urllib.parse.quote_plus(str(integration_key))
path = '/admin/v2/integrations/%s' % integration_key
path = '/admin/v3/integrations/%s' % integration_key
params = {}
if name is not None:
params['name'] = name
Expand Down Expand Up @@ -2877,6 +2883,8 @@ def update_integration(self,
params['self_service_allowed'] = '1' if self_service_allowed else '0'
if sso is not None:
params['sso'] = sso
if user_access is not None:
params['user_access'] = user_access

if not params:
raise TypeError("No new values were provided")
Expand Down
8 changes: 4 additions & 4 deletions tests/admin/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ def test_get_integration(self):
(uri, args) = response['uri'].split('?')

self.assertEqual(response['method'], 'GET')
self.assertEqual(uri, '/admin/v2/integrations/{}'.format(self.integration_key))
self.assertEqual(uri, '/admin/v3/integrations/{}'.format(self.integration_key))
self.assertEqual(util.params_to_dict(args), {'account_id': [self.client.account_id]})

def test_delete_integration(self):
response = self.client.delete_integration(self.integration_key)
(uri, args) = response['uri'].split('?')

self.assertEqual(response['method'], 'DELETE')
self.assertEqual(uri, '/admin/v2/integrations/{}'.format(self.integration_key))
self.assertEqual(uri, '/admin/v3/integrations/{}'.format(self.integration_key))
self.assertEqual(util.params_to_dict(args), {'account_id': [self.client.account_id]})

def test_create_integration(self):
Expand All @@ -38,7 +38,7 @@ def test_create_integration(self):
)

self.assertEqual(response['method'], 'POST')
self.assertEqual(response['uri'], '/admin/v2/integrations')
self.assertEqual(response['uri'], '/admin/v3/integrations')
self.assertEqual(json.loads(response['body']),
{
"account_id": self.client.account_id,
Expand All @@ -63,7 +63,7 @@ def test_update_integration_success(self):
)

self.assertEqual(response['method'], 'POST')
self.assertEqual(response['uri'], '/admin/v2/integrations/{}'.format(self.integration_key))
self.assertEqual(response['uri'], '/admin/v3/integrations/{}'.format(self.integration_key))
self.assertEqual(json.loads(response['body']),
{
"account_id": self.client.account_id,
Expand Down
10 changes: 5 additions & 5 deletions tests/admin/test_integrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def test_get_integrations_generator(self):
response = next(generator)
self.assertEqual(response['method'], 'GET')
(uri, args) = response['uri'].split('?')
self.assertEqual(uri, '/admin/v2/integrations')
self.assertEqual(uri, '/admin/v3/integrations')
self.assertEqual(
util.params_to_dict(args),
{
Expand All @@ -27,7 +27,7 @@ def test_get_integrations(self):
response = response[0]
self.assertEqual(response['method'], 'GET')
(uri, args) = response['uri'].split('?')
self.assertEqual(uri, '/admin/v2/integrations')
self.assertEqual(uri, '/admin/v3/integrations')
self.assertEqual(
util.params_to_dict(args),
{
Expand All @@ -43,7 +43,7 @@ def test_get_integrations_with_limit(self):
response = response[0]
self.assertEqual(response['method'], 'GET')
(uri, args) = response['uri'].split('?')
self.assertEqual(uri, '/admin/v2/integrations')
self.assertEqual(uri, '/admin/v3/integrations')
self.assertEqual(
util.params_to_dict(args),
{
Expand All @@ -59,7 +59,7 @@ def test_get_integrations_with_limit_offset(self):
response = response[0]
self.assertEqual(response['method'], 'GET')
(uri, args) = response['uri'].split('?')
self.assertEqual(uri, '/admin/v2/integrations')
self.assertEqual(uri, '/admin/v3/integrations')
self.assertEqual(
util.params_to_dict(args),
{
Expand All @@ -75,7 +75,7 @@ def test_get_integrations_with_offset(self):
response = response[0]
self.assertEqual(response['method'], 'GET')
(uri, args) = response['uri'].split('?')
self.assertEqual(uri, '/admin/v2/integrations')
self.assertEqual(uri, '/admin/v3/integrations')
self.assertEqual(
util.params_to_dict(args),
{
Expand Down