Skip to content

Commit

Permalink
Fix default UUID setting, run black
Browse files Browse the repository at this point in the history
  • Loading branch information
mccoyp committed Oct 2, 2020
1 parent dc75603 commit 0f3ad38
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ class KeyVaultAccessControlClient(KeyVaultClientBase):
# pylint:disable=protected-access

@distributed_trace
def create_role_assignment(self, role_scope, role_definition_id, principal_id, **kwargs):
def create_role_assignment(
self, role_scope, role_definition_id, principal_id, **kwargs
):
# type: (Union[str, KeyVaultRoleScope], str, str, **Any) -> KeyVaultRoleAssignment
"""Create a role assignment.
Expand All @@ -50,7 +52,7 @@ def create_role_assignment(self, role_scope, role_definition_id, principal_id, *
assignment = self._client.role_assignments.create(
vault_base_url=self._vault_url,
scope=role_scope,
role_assignment_name=kwargs.pop("role_assignment_name", uuid4()),
role_assignment_name=kwargs.pop("role_assignment_name", None) or uuid4(),
parameters=create_parameters,
**kwargs
)
Expand All @@ -70,7 +72,10 @@ def delete_role_assignment(self, role_scope, role_assignment_name, **kwargs):
:rtype: KeyVaultRoleAssignment
"""
assignment = self._client.role_assignments.delete(
vault_base_url=self._vault_url, scope=role_scope, role_assignment_name=str(role_assignment_name), **kwargs
vault_base_url=self._vault_url,
scope=role_scope,
role_assignment_name=str(role_assignment_name),
**kwargs
)
return KeyVaultRoleAssignment._from_generated(assignment)

Expand All @@ -87,7 +92,10 @@ def get_role_assignment(self, role_scope, role_assignment_name, **kwargs):
:rtype: KeyVaultRoleAssignment
"""
assignment = self._client.role_assignments.get(
vault_base_url=self._vault_url, scope=role_scope, role_assignment_name=str(role_assignment_name), **kwargs
vault_base_url=self._vault_url,
scope=role_scope,
role_assignment_name=str(role_assignment_name),
**kwargs
)
return KeyVaultRoleAssignment._from_generated(assignment)

Expand All @@ -104,7 +112,9 @@ def list_role_assignments(self, role_scope, **kwargs):
return self._client.role_assignments.list_for_scope(
self._vault_url,
role_scope,
cls=lambda result: [KeyVaultRoleAssignment._from_generated(a) for a in result],
cls=lambda result: [
KeyVaultRoleAssignment._from_generated(a) for a in result
],
**kwargs
)

Expand All @@ -121,6 +131,8 @@ def list_role_definitions(self, role_scope, **kwargs):
return self._client.role_definitions.list(
self._vault_url,
role_scope,
cls=lambda result: [KeyVaultRoleDefinition._from_generated(d) for d in result],
cls=lambda result: [
KeyVaultRoleDefinition._from_generated(d) for d in result
],
**kwargs
)
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,18 @@ async def create_role_assignment(
assignment = await self._client.role_assignments.create(
vault_base_url=self._vault_url,
scope=role_scope,
role_assignment_name=kwargs.pop("role_assignment_name", uuid4),
role_assignment_name=kwargs.pop("role_assignment_name", None) or uuid4(),
parameters=create_parameters,
**kwargs
)
return KeyVaultRoleAssignment._from_generated(assignment)

@distributed_trace_async
async def delete_role_assignment(
self, role_scope: "Union[str, KeyVaultRoleScope]", role_assignment_name: "Union[str, UUID]", **kwargs: "Any"
self,
role_scope: "Union[str, KeyVaultRoleScope]",
role_assignment_name: "Union[str, UUID]",
**kwargs: "Any"
) -> KeyVaultRoleAssignment:
"""Delete a role assignment.
Expand All @@ -77,13 +80,19 @@ async def delete_role_assignment(
:rtype: KeyVaultRoleAssignment
"""
assignment = await self._client.role_assignments.delete(
vault_base_url=self._vault_url, scope=role_scope, role_assignment_name=str(role_assignment_name), **kwargs
vault_base_url=self._vault_url,
scope=role_scope,
role_assignment_name=str(role_assignment_name),
**kwargs
)
return KeyVaultRoleAssignment._from_generated(assignment)

@distributed_trace_async
async def get_role_assignment(
self, role_scope: "Union[str, KeyVaultRoleScope]", role_assignment_name: "Union[str, UUID]", **kwargs: "Any"
self,
role_scope: "Union[str, KeyVaultRoleScope]",
role_assignment_name: "Union[str, UUID]",
**kwargs: "Any"
) -> KeyVaultRoleAssignment:
"""Get a role assignment.
Expand All @@ -95,7 +104,10 @@ async def get_role_assignment(
:rtype: KeyVaultRoleAssignment
"""
assignment = await self._client.role_assignments.get(
vault_base_url=self._vault_url, scope=role_scope, role_assignment_name=str(role_assignment_name), **kwargs
vault_base_url=self._vault_url,
scope=role_scope,
role_assignment_name=str(role_assignment_name),
**kwargs
)
return KeyVaultRoleAssignment._from_generated(assignment)

Expand All @@ -113,7 +125,9 @@ def list_role_assignments(
return self._client.role_assignments.list_for_scope(
self._vault_url,
role_scope,
cls=lambda result: [KeyVaultRoleAssignment._from_generated(a) for a in result],
cls=lambda result: [
KeyVaultRoleAssignment._from_generated(a) for a in result
],
**kwargs
)

Expand All @@ -131,6 +145,8 @@ def list_role_definitions(
return self._client.role_definitions.list(
self._vault_url,
role_scope,
cls=lambda result: [KeyVaultRoleDefinition._from_generated(d) for d in result],
cls=lambda result: [
KeyVaultRoleDefinition._from_generated(d) for d in result
],
**kwargs
)

0 comments on commit 0f3ad38

Please sign in to comment.