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
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,14 @@ class ManagementGroupsAPIConfiguration(AzureConfiguration):
:param credentials: Credentials needed for the client to connect to Azure.
:type credentials: :mod:`A msrestazure Credentials
object<msrestazure.azure_active_directory>`
:param operation_result_id: The id of the operation result. Possible
values include: 'create', 'delete'
:type operation_result_id: str
:param skiptoken: Page continuation token is only used if a previous
operation returned a partial result.
If a previous response contains a nextLink element, the value of the
nextLink element will include a token parameter that specifies a starting
point to use for subsequent calls.
:type skiptoken: str
:param str base_url: Service URL
"""

def __init__(
self, credentials, operation_result_id, skiptoken=None, base_url=None):
self, credentials, base_url=None):

if credentials is None:
raise ValueError("Parameter 'credentials' must not be None.")
if operation_result_id is None:
raise ValueError("Parameter 'operation_result_id' must not be None.")
if not base_url:
base_url = 'https://management.azure.com'

Expand All @@ -60,14 +49,10 @@ def __init__(
self.add_user_agent('Azure-SDK-For-Python')

self.credentials = credentials
self.operation_result_id = operation_result_id
self.skiptoken = skiptoken


class ManagementGroupsAPI(SDKClient):
"""The Azure Management Groups API enables consolidation of multiple
subscriptions/resources into an organizational hierarchy and centrally
manage access control, policies, alerting and reporting for those resources.
"""The Azure Management Groups API enables consolidation of multiple subscriptions/resources into an organizational hierarchy and centrally manage access control, policies, alerting and reporting for those resources.

:ivar config: Configuration for client.
:vartype config: ManagementGroupsAPIConfiguration
Expand All @@ -84,26 +69,17 @@ class ManagementGroupsAPI(SDKClient):
:param credentials: Credentials needed for the client to connect to Azure.
:type credentials: :mod:`A msrestazure Credentials
object<msrestazure.azure_active_directory>`
:param operation_result_id: The id of the operation result. Possible
values include: 'create', 'delete'
:type operation_result_id: str
:param skiptoken: Page continuation token is only used if a previous
operation returned a partial result.
If a previous response contains a nextLink element, the value of the
nextLink element will include a token parameter that specifies a starting
point to use for subsequent calls.
:type skiptoken: str
:param str base_url: Service URL
"""

def __init__(
self, credentials, operation_result_id, skiptoken=None, base_url=None):
self, credentials, base_url=None):

self.config = ManagementGroupsAPIConfiguration(credentials, operation_result_id, skiptoken, base_url)
self.config = ManagementGroupsAPIConfiguration(credentials, base_url)
super(ManagementGroupsAPI, self).__init__(self.config.credentials, self.config)

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self.api_version = '2018-01-01-preview'
self.api_version = '2018-03-01-preview'
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)

Expand Down Expand Up @@ -175,3 +151,105 @@ def check_name_availability(

return deserialized
check_name_availability.metadata = {'url': '/providers/Microsoft.Management/checkNameAvailability'}

def start_tenant_backfill(
self, custom_headers=None, raw=False, **operation_config):
"""Starts backfilling subscriptions for the Tenant.

:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
:param operation_config: :ref:`Operation configuration
overrides<msrest:optionsforoperations>`.
:return: TenantBackfillStatusResult or ClientRawResponse if raw=true
:rtype: ~azure.mgmt.managementgroups.models.TenantBackfillStatusResult
or ~msrest.pipeline.ClientRawResponse
:raises:
:class:`ErrorResponseException<azure.mgmt.managementgroups.models.ErrorResponseException>`
"""
# Construct URL
url = self.start_tenant_backfill.metadata['url']

# Construct parameters
query_parameters = {}
query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')

# Construct headers
header_parameters = {}
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
if self.config.generate_client_request_id:
header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
if custom_headers:
header_parameters.update(custom_headers)
if self.config.accept_language is not None:
header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

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

if response.status_code not in [200]:
raise models.ErrorResponseException(self._deserialize, response)

deserialized = None

if response.status_code == 200:
deserialized = self._deserialize('TenantBackfillStatusResult', response)

if raw:
client_raw_response = ClientRawResponse(deserialized, response)
return client_raw_response

return deserialized
start_tenant_backfill.metadata = {'url': '/providers/Microsoft.Management/startTenantBackfill'}

def tenant_backfill_status(
self, custom_headers=None, raw=False, **operation_config):
"""Gets tenant backfill status.

:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
:param operation_config: :ref:`Operation configuration
overrides<msrest:optionsforoperations>`.
:return: TenantBackfillStatusResult or ClientRawResponse if raw=true
:rtype: ~azure.mgmt.managementgroups.models.TenantBackfillStatusResult
or ~msrest.pipeline.ClientRawResponse
:raises:
:class:`ErrorResponseException<azure.mgmt.managementgroups.models.ErrorResponseException>`
"""
# Construct URL
url = self.tenant_backfill_status.metadata['url']

# Construct parameters
query_parameters = {}
query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')

# Construct headers
header_parameters = {}
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
if self.config.generate_client_request_id:
header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
if custom_headers:
header_parameters.update(custom_headers)
if self.config.accept_language is not None:
header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

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

if response.status_code not in [200]:
raise models.ErrorResponseException(self._deserialize, response)

deserialized = None

if response.status_code == 200:
deserialized = self._deserialize('TenantBackfillStatusResult', response)

if raw:
client_raw_response = ClientRawResponse(deserialized, response)
return client_raw_response

return deserialized
tenant_backfill_status.metadata = {'url': '/providers/Microsoft.Management/tenantBackfillStatus'}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from .operation_display_properties_py3 import OperationDisplayProperties
from .operation_py3 import Operation
from .check_name_availability_result_py3 import CheckNameAvailabilityResult
from .tenant_backfill_status_result_py3 import TenantBackfillStatusResult
from .management_group_info_py3 import ManagementGroupInfo
from .parent_group_info_py3 import ParentGroupInfo
from .management_group_details_py3 import ManagementGroupDetails
Expand All @@ -36,6 +37,7 @@
from .operation_display_properties import OperationDisplayProperties
from .operation import Operation
from .check_name_availability_result import CheckNameAvailabilityResult
from .tenant_backfill_status_result import TenantBackfillStatusResult
from .management_group_info import ManagementGroupInfo
from .parent_group_info import ParentGroupInfo
from .management_group_details import ManagementGroupDetails
Expand All @@ -56,6 +58,7 @@
from .entity_info_paged import EntityInfoPaged
from .management_groups_api_enums import (
Reason,
Status,
Type,
)

Expand All @@ -65,6 +68,7 @@
'OperationDisplayProperties',
'Operation',
'CheckNameAvailabilityResult',
'TenantBackfillStatusResult',
'ManagementGroupInfo',
'ParentGroupInfo',
'ManagementGroupDetails',
Expand All @@ -84,5 +88,6 @@
'OperationPaged',
'EntityInfoPaged',
'Reason',
'Status',
'Type',
]
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CheckNameAvailabilityRequest(Model):
:type name: str
:param type: fully qualified resource type which includes provider
namespace. Possible values include:
'/providers/Microsoft.Management/managementGroups'
'/providers/Microsoft.Management/managementGroup'
:type type: str or ~azure.mgmt.managementgroups.models.Type
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CheckNameAvailabilityRequest(Model):
:type name: str
:param type: fully qualified resource type which includes provider
namespace. Possible values include:
'/providers/Microsoft.Management/managementGroups'
'/providers/Microsoft.Management/managementGroup'
:type type: str or ~azure.mgmt.managementgroups.models.Type
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ class EntityInfo(Model):
:param permissions: Permissions. Possible values include: 'noaccess',
'view', 'edit', 'delete'
:type permissions: str or ~azure.mgmt.managementgroups.models.enum
:param inherited_permissions: Inherited Permissions. Possible values
include: 'noaccess', 'view', 'edit', 'delete'
:type inherited_permissions: str or
~azure.mgmt.managementgroups.models.enum
:param number_of_descendants: Number of Descendants.
:type number_of_descendants: int
:param parent_display_name_chain: The parent display name chain from the
root group to the immediate parent
:type parent_display_name_chain: list[str]
:param parent_name_chain: The parent name chain from the root group to the
immediate parent
:type parent_name_chain: list[str]
"""

_validation = {
Expand All @@ -53,6 +65,10 @@ class EntityInfo(Model):
'display_name': {'key': 'properties.displayName', 'type': 'str'},
'parent': {'key': 'properties.parent', 'type': 'EntityParentGroupInfo'},
'permissions': {'key': 'properties.permissions', 'type': 'str'},
'inherited_permissions': {'key': 'properties.inheritedPermissions', 'type': 'str'},
'number_of_descendants': {'key': 'properties.numberOfDescendants', 'type': 'int'},
'parent_display_name_chain': {'key': 'properties.parentDisplayNameChain', 'type': '[str]'},
'parent_name_chain': {'key': 'properties.parentNameChain', 'type': '[str]'},
}

def __init__(self, **kwargs):
Expand All @@ -64,3 +80,7 @@ def __init__(self, **kwargs):
self.display_name = kwargs.get('display_name', None)
self.parent = kwargs.get('parent', None)
self.permissions = kwargs.get('permissions', None)
self.inherited_permissions = kwargs.get('inherited_permissions', None)
self.number_of_descendants = kwargs.get('number_of_descendants', None)
self.parent_display_name_chain = kwargs.get('parent_display_name_chain', None)
self.parent_name_chain = kwargs.get('parent_name_chain', None)
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ class EntityInfo(Model):
:param permissions: Permissions. Possible values include: 'noaccess',
'view', 'edit', 'delete'
:type permissions: str or ~azure.mgmt.managementgroups.models.enum
:param inherited_permissions: Inherited Permissions. Possible values
include: 'noaccess', 'view', 'edit', 'delete'
:type inherited_permissions: str or
~azure.mgmt.managementgroups.models.enum
:param number_of_descendants: Number of Descendants.
:type number_of_descendants: int
:param parent_display_name_chain: The parent display name chain from the
root group to the immediate parent
:type parent_display_name_chain: list[str]
:param parent_name_chain: The parent name chain from the root group to the
immediate parent
:type parent_name_chain: list[str]
"""

_validation = {
Expand All @@ -53,9 +65,13 @@ class EntityInfo(Model):
'display_name': {'key': 'properties.displayName', 'type': 'str'},
'parent': {'key': 'properties.parent', 'type': 'EntityParentGroupInfo'},
'permissions': {'key': 'properties.permissions', 'type': 'str'},
'inherited_permissions': {'key': 'properties.inheritedPermissions', 'type': 'str'},
'number_of_descendants': {'key': 'properties.numberOfDescendants', 'type': 'int'},
'parent_display_name_chain': {'key': 'properties.parentDisplayNameChain', 'type': '[str]'},
'parent_name_chain': {'key': 'properties.parentNameChain', 'type': '[str]'},
}

def __init__(self, *, tenant_id: str=None, display_name: str=None, parent=None, permissions=None, **kwargs) -> None:
def __init__(self, *, tenant_id: str=None, display_name: str=None, parent=None, permissions=None, inherited_permissions=None, number_of_descendants: int=None, parent_display_name_chain=None, parent_name_chain=None, **kwargs) -> None:
super(EntityInfo, self).__init__(**kwargs)
self.id = None
self.type = None
Expand All @@ -64,3 +80,7 @@ def __init__(self, *, tenant_id: str=None, display_name: str=None, parent=None,
self.display_name = display_name
self.parent = parent
self.permissions = permissions
self.inherited_permissions = inherited_permissions
self.number_of_descendants = number_of_descendants
self.parent_display_name_chain = parent_display_name_chain
self.parent_name_chain = parent_name_chain
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ class Reason(str, Enum):
already_exists = "AlreadyExists"


class Status(str, Enum):

not_started = "NotStarted"
not_started_but_groups_exist = "NotStartedButGroupsExist"
started = "Started"
failed = "Failed"
cancelled = "Cancelled"
completed = "Completed"


class Type(str, Enum):

providers_microsoft_managementmanagement_groups = "/providers/Microsoft.Management/managementGroups"
providers_microsoft_managementmanagement_group = "/providers/Microsoft.Management/managementGroup"
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

from msrest.serialization import Model


class TenantBackfillStatusResult(Model):
"""The tenant backfill status.

Variables are only populated by the server, and will be ignored when
sending a request.

:ivar tenant_id: The AAD Tenant ID associated with the management group.
For example, 00000000-0000-0000-0000-000000000000
:vartype tenant_id: str
:ivar status: The status of the Tenant Backfill. Possible values include:
'NotStarted', 'NotStartedButGroupsExist', 'Started', 'Failed',
'Cancelled', 'Completed'
:vartype status: str or ~azure.mgmt.managementgroups.models.Status
"""

_validation = {
'tenant_id': {'readonly': True},
'status': {'readonly': True},
}

_attribute_map = {
'tenant_id': {'key': 'tenantId', 'type': 'str'},
'status': {'key': 'status', 'type': 'Status'},
}

def __init__(self, **kwargs):
super(TenantBackfillStatusResult, self).__init__(**kwargs)
self.tenant_id = None
self.status = None
Loading