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

[AutoPR] authorization/resource-manager #3262

Merged
merged 13 commits into from
Nov 12, 2018
Merged
24 changes: 12 additions & 12 deletions azure-keyvault/tests/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ class KeyVaultSecretTest(KeyvaultTestCase):
@StorageAccountPreparer(name_prefix='kvsa1')
@KeyVaultPreparer()
def test_e2e(self, vault, storage_account, resource_group, **kwargs):
# find the role definition for "Storage Account Key Operator Service Role"
filter_str = 'roleName eq \'Storage Account Key Operator Service Role\''
authorization_mgmt_client = self.create_mgmt_client(AuthorizationManagementClient)
role_id = list(authorization_mgmt_client.role_definitions.list(scope='/', filter=filter_str))[0].id

# create a role assignment granting the key vault service principal this role
role_params = RoleAssignmentCreateParameters(role_definition_id=role_id,
# the Azure Key Vault service id
principal_id='93c27d83-f79b-4cb2-8dd4-4aa716542e74')

if not self.is_live:
sa_id = '{}/providers/Microsoft.Storage/storageAccounts/{}'.format(resource_group.id, storage_account.name)
else:
sa_id = storage_account.id

authorization_mgmt_client.role_assignments.create(scope=sa_id,
role_assignment_name='d7607bd3-a467-4a14-ab5f-f4b016ffbfff',
parameters=role_params)
# find the role definition for "Storage Account Key Operator Service Role"
filter_str = 'roleName eq \'Storage Account Key Operator Service Role\''
authorization_mgmt_client = self.create_mgmt_client(AuthorizationManagementClient)
role_id = list(authorization_mgmt_client.role_definitions.list(scope='/', filter=filter_str))[0].id

# create a role assignment granting the key vault service principal this role
role_params = RoleAssignmentCreateParameters(role_definition_id=role_id,
# the Azure Key Vault service id
principal_id='93c27d83-f79b-4cb2-8dd4-4aa716542e74')

authorization_mgmt_client.role_assignments.create(scope=sa_id,
role_assignment_name='d7607bd3-a467-4a14-ab5f-f4b016ffbfff',
parameters=role_params)

# add the storage account to the vault using the users KeyVaultClient
attributes = StorageAccountAttributes(enabled=True)
Expand Down
14 changes: 14 additions & 0 deletions azure-mgmt-authorization/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
Release History
===============

0.51.0 (2018-11-12)
+++++++++++++++++++

**Features**

- Model RoleAssignmentCreateParameters has a new parameter principal_type

**Breaking changes**

- Parameter role_definition_id of model RoleAssignmentCreateParameters is now required
- Parameter principal_id of model RoleAssignmentCreateParameters is now required

Role Assignments API version is now 2018-09-01-preview

0.50.0 (2018-05-29)
+++++++++++++++++++

Expand Down
3 changes: 3 additions & 0 deletions azure-mgmt-authorization/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
include *.rst
include azure/__init__.py
include azure/mgmt/__init__.py

Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ class AuthorizationManagementClient(MultiApiClientMixin, SDKClient):
LATEST_PROFILE = ProfileDefinition({
_PROFILE_TAG: {
'classic_administrators': '2015-06-01',
'deny_assignments': '2018-07-01-preview',
'role_assignments': '2018-09-01-preview',
None: DEFAULT_API_VERSION
}},
_PROFILE_TAG + " latest"
Expand Down Expand Up @@ -110,6 +112,8 @@ def models(cls, api_version=DEFAULT_API_VERSION):
* 2015-06-01: :mod:`v2015_06_01.models<azure.mgmt.authorization.v2015_06_01.models>`
* 2015-07-01: :mod:`v2015_07_01.models<azure.mgmt.authorization.v2015_07_01.models>`
* 2018-01-01-preview: :mod:`v2018_01_01_preview.models<azure.mgmt.authorization.v2018_01_01_preview.models>`
* 2018-07-01-preview: :mod:`v2018_07_01_preview.models<azure.mgmt.authorization.v2018_07_01_preview.models>`
* 2018-09-01-preview: :mod:`v2018_09_01_preview.models<azure.mgmt.authorization.v2018_09_01_preview.models>`
"""
if api_version == '2015-06-01':
from .v2015_06_01 import models
Expand All @@ -120,8 +124,14 @@ def models(cls, api_version=DEFAULT_API_VERSION):
elif api_version == '2018-01-01-preview':
from .v2018_01_01_preview import models
return models
elif api_version == '2018-07-01-preview':
from .v2018_07_01_preview import models
return models
elif api_version == '2018-09-01-preview':
from .v2018_09_01_preview import models
return models
raise NotImplementedError("APIVersion {} is not available".format(api_version))

@property
def classic_administrators(self):
"""Instance depends on the API version:
Expand All @@ -135,6 +145,19 @@ def classic_administrators(self):
raise NotImplementedError("APIVersion {} is not available".format(api_version))
return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))

@property
def deny_assignments(self):
"""Instance depends on the API version:

* 2018-07-01-preview: :class:`DenyAssignmentsOperations<azure.mgmt.authorization.v2018_07_01_preview.operations.DenyAssignmentsOperations>`
"""
api_version = self._get_api_version('deny_assignments')
if api_version == '2018-07-01-preview':
from .v2018_07_01_preview.operations import DenyAssignmentsOperations as OperationClass
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))

@property
def permissions(self):
"""Instance depends on the API version:
Expand Down Expand Up @@ -173,12 +196,15 @@ def role_assignments(self):

* 2015-07-01: :class:`RoleAssignmentsOperations<azure.mgmt.authorization.v2015_07_01.operations.RoleAssignmentsOperations>`
* 2018-01-01-preview: :class:`RoleAssignmentsOperations<azure.mgmt.authorization.v2018_01_01_preview.operations.RoleAssignmentsOperations>`
* 2018-09-01-preview: :class:`RoleAssignmentsOperations<azure.mgmt.authorization.v2018_09_01_preview.operations.RoleAssignmentsOperations>`
"""
api_version = self._get_api_version('role_assignments')
if api_version == '2015-07-01':
from .v2015_07_01.operations import RoleAssignmentsOperations as OperationClass
elif api_version == '2018-01-01-preview':
from .v2018_01_01_preview.operations import RoleAssignmentsOperations as OperationClass
elif api_version == '2018-09-01-preview':
from .v2018_09_01_preview.operations import RoleAssignmentsOperations as OperationClass
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
Expand Down
4 changes: 3 additions & 1 deletion azure-mgmt-authorization/azure/mgmt/authorization/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
# license information.
# --------------------------------------------------------------------------
from .v2015_07_01.models import *
from .v2018_01_01_preview.models import *
from .v2018_01_01_preview.models import *
from .v2018_07_01_preview.models import *
from .v2018_09_01_preview.models import *
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def internal_paging(next_link=None, raw=False):

# Construct headers
header_parameters = {}
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
header_parameters['Accept'] = 'application/json'
if self.config.generate_client_request_id:
header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
if custom_headers:
Expand All @@ -81,9 +81,8 @@ def internal_paging(next_link=None, raw=False):
header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

# Construct and send request
request = self._client.get(url, query_parameters)
response = self._client.send(
request, header_parameters, stream=False, **operation_config)
request = self._client.get(url, query_parameters, header_parameters)
response = self._client.send(request, stream=False, **operation_config)

if response.status_code not in [200]:
exp = CloudError(response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@
class RoleAssignmentCreateParameters(Model):
"""Role assignment create parameters.

:param properties: Role assignment properties.
All required parameters must be populated in order to send to Azure.

:param properties: Required. Role assignment properties.
:type properties:
~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentProperties
"""

_validation = {
'properties': {'required': True},
}

_attribute_map = {
'properties': {'key': 'properties', 'type': 'RoleAssignmentProperties'},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,21 @@
class RoleAssignmentCreateParameters(Model):
"""Role assignment create parameters.

:param properties: Role assignment properties.
All required parameters must be populated in order to send to Azure.

:param properties: Required. Role assignment properties.
:type properties:
~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentProperties
"""

_validation = {
'properties': {'required': True},
}

_attribute_map = {
'properties': {'key': 'properties', 'type': 'RoleAssignmentProperties'},
}

def __init__(self, *, properties=None, **kwargs) -> None:
def __init__(self, *, properties, **kwargs) -> None:
super(RoleAssignmentCreateParameters, self).__init__(**kwargs)
self.properties = properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,22 @@
class RoleAssignmentProperties(Model):
"""Role assignment properties.

:param role_definition_id: The role definition ID used in the role
assignment.
All required parameters must be populated in order to send to Azure.

:param role_definition_id: Required. The role definition ID used in the
role assignment.
:type role_definition_id: str
:param principal_id: The principal ID assigned to the role. This maps to
the ID inside the Active Directory. It can point to a user, service
principal, or security group.
:param principal_id: Required. The principal ID assigned to the role. This
maps to the ID inside the Active Directory. It can point to a user,
service principal, or security group.
:type principal_id: str
"""

_validation = {
'role_definition_id': {'required': True},
'principal_id': {'required': True},
}

_attribute_map = {
'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'},
'principal_id': {'key': 'principalId', 'type': 'str'},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,28 @@
class RoleAssignmentProperties(Model):
"""Role assignment properties.

:param role_definition_id: The role definition ID used in the role
assignment.
All required parameters must be populated in order to send to Azure.

:param role_definition_id: Required. The role definition ID used in the
role assignment.
:type role_definition_id: str
:param principal_id: The principal ID assigned to the role. This maps to
the ID inside the Active Directory. It can point to a user, service
principal, or security group.
:param principal_id: Required. The principal ID assigned to the role. This
maps to the ID inside the Active Directory. It can point to a user,
service principal, or security group.
:type principal_id: str
"""

_validation = {
'role_definition_id': {'required': True},
'principal_id': {'required': True},
}

_attribute_map = {
'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'},
'principal_id': {'key': 'principalId', 'type': 'str'},
}

def __init__(self, *, role_definition_id: str=None, principal_id: str=None, **kwargs) -> None:
def __init__(self, *, role_definition_id: str, principal_id: str, **kwargs) -> None:
super(RoleAssignmentProperties, self).__init__(**kwargs)
self.role_definition_id = role_definition_id
self.principal_id = principal_id
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def internal_paging(next_link=None, raw=False):

# Construct headers
header_parameters = {}
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
header_parameters['Accept'] = 'application/json'
if self.config.generate_client_request_id:
header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
if custom_headers:
Expand All @@ -84,9 +84,8 @@ def internal_paging(next_link=None, raw=False):
header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

# Construct and send request
request = self._client.get(url, query_parameters)
response = self._client.send(
request, header_parameters, stream=False, **operation_config)
request = self._client.get(url, query_parameters, header_parameters)
response = self._client.send(request, stream=False, **operation_config)

if response.status_code not in [200]:
exp = CloudError(response)
Expand Down Expand Up @@ -158,7 +157,7 @@ def internal_paging(next_link=None, raw=False):

# Construct headers
header_parameters = {}
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
header_parameters['Accept'] = 'application/json'
if self.config.generate_client_request_id:
header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
if custom_headers:
Expand All @@ -167,9 +166,8 @@ def internal_paging(next_link=None, raw=False):
header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

# Construct and send request
request = self._client.get(url, query_parameters)
response = self._client.send(
request, header_parameters, stream=False, **operation_config)
request = self._client.get(url, query_parameters, header_parameters)
response = self._client.send(request, stream=False, **operation_config)

if response.status_code not in [200]:
exp = CloudError(response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def get(

# Construct headers
header_parameters = {}
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
header_parameters['Accept'] = 'application/json'
if self.config.generate_client_request_id:
header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
if custom_headers:
Expand All @@ -81,8 +81,8 @@ def get(
header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

# Construct and send request
request = self._client.get(url, query_parameters)
response = self._client.send(request, header_parameters, stream=False, **operation_config)
request = self._client.get(url, query_parameters, header_parameters)
response = self._client.send(request, stream=False, **operation_config)

if response.status_code not in [200]:
exp = CloudError(response)
Expand Down Expand Up @@ -137,7 +137,7 @@ def internal_paging(next_link=None, raw=False):

# Construct headers
header_parameters = {}
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
header_parameters['Accept'] = 'application/json'
if self.config.generate_client_request_id:
header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
if custom_headers:
Expand All @@ -146,9 +146,8 @@ def internal_paging(next_link=None, raw=False):
header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

# Construct and send request
request = self._client.get(url, query_parameters)
response = self._client.send(
request, header_parameters, stream=False, **operation_config)
request = self._client.get(url, query_parameters, header_parameters)
response = self._client.send(request, stream=False, **operation_config)

if response.status_code not in [200]:
exp = CloudError(response)
Expand Down
Loading