# pylint: disable=line-too-long,useless-suppression,too-many-lines
# 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) Python Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
# pylint: disable=useless-super-delegation

import datetime
from typing import Any, Literal, Mapping, Optional, TYPE_CHECKING, Union, overload

from .._utils.model_base import Model as _Model, rest_field

if TYPE_CHECKING:
    from .. import models as _models


class CheckNameAvailabilityRequest(_Model):
    """Management group name availability check parameters.

    :ivar name: the name to check for availability.
    :vartype name: str
    :ivar type: fully qualified resource type which includes provider namespace. Default value is
     "Microsoft.Management/managementGroups".
    :vartype type: str
    """

    name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"])
    """the name to check for availability."""
    type: Optional[Literal["Microsoft.Management/managementGroups"]] = rest_field(
        visibility=["read", "create", "update", "delete", "query"]
    )
    """fully qualified resource type which includes provider namespace. Default value is
     \"Microsoft.Management/managementGroups\"."""

    @overload
    def __init__(
        self,
        *,
        name: Optional[str] = None,
        type: Optional[Literal["Microsoft.Management/managementGroups"]] = None,
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        super().__init__(*args, **kwargs)


class CheckNameAvailabilityResult(_Model):
    """Describes the result of the request to check management group name availability.

    :ivar name_available: Required. True indicates name is valid and available. False indicates the
     name is invalid, unavailable, or both.
    :vartype name_available: bool
    :ivar reason: Required if nameAvailable == false. Invalid indicates the name provided does not
     match the resource provider's naming requirements (incorrect length, unsupported characters,
     etc.) AlreadyExists indicates that the name is already in use and is therefore unavailable.
     Known values are: "Invalid" and "AlreadyExists".
    :vartype reason: str or ~azure.mgmt.managementgroups.models.Reason
    :ivar message: Required if nameAvailable == false. Localized. If reason == invalid, provide the
     user with the reason why the given name is invalid, and provide the resource naming
     requirements so that the user can select a valid name. If reason == AlreadyExists, explain that
     is already in use, and direct them to select a different name.
    :vartype message: str
    """

    name_available: Optional[bool] = rest_field(name="nameAvailable", visibility=["read"])
    """Required. True indicates name is valid and available. False indicates the name is invalid,
     unavailable, or both."""
    reason: Optional[Union[str, "_models.Reason"]] = rest_field(visibility=["read"])
    """Required if nameAvailable == false. Invalid indicates the name provided does not match the
     resource provider's naming requirements (incorrect length, unsupported characters, etc.)
     AlreadyExists indicates that the name is already in use and is therefore unavailable. Known
     values are: \"Invalid\" and \"AlreadyExists\"."""
    message: Optional[str] = rest_field(visibility=["read"])
    """Required if nameAvailable == false. Localized. If reason == invalid, provide the user with the
     reason why the given name is invalid, and provide the resource naming requirements so that the
     user can select a valid name. If reason == AlreadyExists, explain that is already in use, and
     direct them to select a different name."""


class CreateManagementGroupChildInfo(_Model):
    """The child information of a management group used during creation.

    :ivar type: The fully qualified resource type which includes provider namespace (e.g.
     Microsoft.Management/managementGroups). Known values are:
     "Microsoft.Management/managementGroups" and "/subscriptions".
    :vartype type: str or ~azure.mgmt.managementgroups.models.ManagementGroupChildType
    :ivar id: The fully qualified ID for the child resource (management group or subscription).
     For example,
     /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000.
    :vartype id: str
    :ivar name: The name of the child entity.
    :vartype name: str
    :ivar display_name: The friendly name of the child resource.
    :vartype display_name: str
    :ivar children: The list of children.
    :vartype children: list[~azure.mgmt.managementgroups.models.CreateManagementGroupChildInfo]
    """

    type: Optional[Union[str, "_models.ManagementGroupChildType"]] = rest_field(visibility=["read"])
    """The fully qualified resource type which includes provider namespace (e.g.
     Microsoft.Management/managementGroups). Known values are:
     \"Microsoft.Management/managementGroups\" and \"/subscriptions\"."""
    id: Optional[str] = rest_field(visibility=["read"])
    """The fully qualified ID for the child resource (management group or subscription).  For example,
     /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000."""
    name: Optional[str] = rest_field(visibility=["read"])
    """The name of the child entity."""
    display_name: Optional[str] = rest_field(name="displayName", visibility=["read"])
    """The friendly name of the child resource."""
    children: Optional[list["_models.CreateManagementGroupChildInfo"]] = rest_field(visibility=["read"])
    """The list of children."""


class CreateManagementGroupDetails(_Model):
    """The details of a management group used during creation.

    :ivar version: The version number of the object.
    :vartype version: int
    :ivar updated_time: The date and time when this object was last updated.
    :vartype updated_time: ~datetime.datetime
    :ivar updated_by: The identity of the principal or process that updated the object.
    :vartype updated_by: str
    :ivar parent: (Optional) The ID of the parent management group used during creation.
    :vartype parent: ~azure.mgmt.managementgroups.models.CreateParentGroupInfo
    """

    version: Optional[int] = rest_field(visibility=["read"])
    """The version number of the object."""
    updated_time: Optional[datetime.datetime] = rest_field(name="updatedTime", visibility=["read"], format="rfc3339")
    """The date and time when this object was last updated."""
    updated_by: Optional[str] = rest_field(name="updatedBy", visibility=["read"])
    """The identity of the principal or process that updated the object."""
    parent: Optional["_models.CreateParentGroupInfo"] = rest_field(
        visibility=["read", "create", "update", "delete", "query"]
    )
    """(Optional) The ID of the parent management group used during creation."""

    @overload
    def __init__(
        self,
        *,
        parent: Optional["_models.CreateParentGroupInfo"] = None,
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        super().__init__(*args, **kwargs)


class CreateManagementGroupProperties(_Model):
    """The generic properties of a management group used during creation.

    :ivar tenant_id: The AAD Tenant ID associated with the management group. For example,
     00000000-0000-0000-0000-000000000000.
    :vartype tenant_id: str
    :ivar display_name: The friendly name of the management group. If no value is passed then this
     field will be set to the groupId.
    :vartype display_name: str
    :ivar details: The details of a management group used during creation.
    :vartype details: ~azure.mgmt.managementgroups.models.CreateManagementGroupDetails
    :ivar children: The list of children.
    :vartype children: list[~azure.mgmt.managementgroups.models.CreateManagementGroupChildInfo]
    """

    tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read"])
    """The AAD Tenant ID associated with the management group. For example,
     00000000-0000-0000-0000-000000000000."""
    display_name: Optional[str] = rest_field(
        name="displayName", visibility=["read", "create", "update", "delete", "query"]
    )
    """The friendly name of the management group. If no value is passed then this  field will be set
     to the groupId."""
    details: Optional["_models.CreateManagementGroupDetails"] = rest_field(
        visibility=["read", "create", "update", "delete", "query"]
    )
    """The details of a management group used during creation."""
    children: Optional[list["_models.CreateManagementGroupChildInfo"]] = rest_field(visibility=["read"])
    """The list of children."""

    @overload
    def __init__(
        self,
        *,
        display_name: Optional[str] = None,
        details: Optional["_models.CreateManagementGroupDetails"] = None,
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        super().__init__(*args, **kwargs)


class CreateManagementGroupRequest(_Model):
    """Management group creation parameters.

    :ivar id: The fully qualified ID for the management group.  For example,
     /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000.
    :vartype id: str
    :ivar type: The type of the resource.  For example, Microsoft.Management/managementGroups.
    :vartype type: str
    :ivar name: The name of the management group. For example,
     00000000-0000-0000-0000-000000000000.
    :vartype name: str
    :ivar properties: The generic properties of a management group used during creation.
    :vartype properties: ~azure.mgmt.managementgroups.models.CreateManagementGroupProperties
    """

    id: Optional[str] = rest_field(visibility=["read"])
    """The fully qualified ID for the management group.  For example,
     /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000."""
    type: Optional[str] = rest_field(visibility=["read"])
    """The type of the resource.  For example, Microsoft.Management/managementGroups."""
    name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"])
    """The name of the management group. For example, 00000000-0000-0000-0000-000000000000."""
    properties: Optional["_models.CreateManagementGroupProperties"] = rest_field(
        visibility=["read", "create", "update", "delete", "query"]
    )
    """The generic properties of a management group used during creation."""

    __flattened_items = ["tenant_id", "display_name", "details", "children"]

    @overload
    def __init__(
        self,
        *,
        name: Optional[str] = None,
        properties: Optional["_models.CreateManagementGroupProperties"] = None,
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items}
        super().__init__(*args, **kwargs)
        for k, v in _flattened_input.items():
            setattr(self, k, v)

    def __getattr__(self, name: str) -> Any:
        if name in self.__flattened_items:
            if self.properties is None:
                return None
            return getattr(self.properties, name)
        raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'")

    def __setattr__(self, key: str, value: Any) -> None:
        if key in self.__flattened_items:
            if self.properties is None:
                self.properties = self._attr_to_rest_field["properties"]._class_type()
            setattr(self.properties, key, value)
        else:
            super().__setattr__(key, value)


class CreateOrUpdateSettingsProperties(_Model):
    """The properties of the request to create or update Management Group settings.

    :ivar require_authorization_for_group_creation: Indicates whether RBAC access is required upon
     group creation under the root Management Group. If set to true, user will require
     Microsoft.Management/managementGroups/write action on the root Management Group scope in order
     to create new Groups directly under the root. This will prevent new users from creating new
     Management Groups, unless they are given access.
    :vartype require_authorization_for_group_creation: bool
    :ivar default_management_group: Settings that sets the default Management Group under which new
     subscriptions get added in this tenant. For example,
     /providers/Microsoft.Management/managementGroups/defaultGroup.
    :vartype default_management_group: str
    """

    require_authorization_for_group_creation: Optional[bool] = rest_field(
        name="requireAuthorizationForGroupCreation", visibility=["read", "create", "update", "delete", "query"]
    )
    """Indicates whether RBAC access is required upon group creation under the root Management Group.
     If set to true, user will require Microsoft.Management/managementGroups/write action on the
     root Management Group scope in order to create new Groups directly under the root. This will
     prevent new users from creating new Management Groups, unless they are given access."""
    default_management_group: Optional[str] = rest_field(
        name="defaultManagementGroup", visibility=["read", "create", "update", "delete", "query"]
    )
    """Settings that sets the default Management Group under which new subscriptions get added in this
     tenant. For example, /providers/Microsoft.Management/managementGroups/defaultGroup."""

    @overload
    def __init__(
        self,
        *,
        require_authorization_for_group_creation: Optional[bool] = None,
        default_management_group: Optional[str] = None,
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        super().__init__(*args, **kwargs)


class CreateOrUpdateSettingsRequest(_Model):
    """Parameters for creating or updating Management Group settings.

    :ivar properties: The properties of the request to create or update Management Group settings.
    :vartype properties: ~azure.mgmt.managementgroups.models.CreateOrUpdateSettingsProperties
    """

    properties: Optional["_models.CreateOrUpdateSettingsProperties"] = rest_field(
        visibility=["read", "create", "update", "delete", "query"]
    )
    """The properties of the request to create or update Management Group settings."""

    __flattened_items = ["require_authorization_for_group_creation", "default_management_group"]

    @overload
    def __init__(
        self,
        *,
        properties: Optional["_models.CreateOrUpdateSettingsProperties"] = None,
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items}
        super().__init__(*args, **kwargs)
        for k, v in _flattened_input.items():
            setattr(self, k, v)

    def __getattr__(self, name: str) -> Any:
        if name in self.__flattened_items:
            if self.properties is None:
                return None
            return getattr(self.properties, name)
        raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'")

    def __setattr__(self, key: str, value: Any) -> None:
        if key in self.__flattened_items:
            if self.properties is None:
                self.properties = self._attr_to_rest_field["properties"]._class_type()
            setattr(self.properties, key, value)
        else:
            super().__setattr__(key, value)


class CreateParentGroupInfo(_Model):
    """(Optional) The ID of the parent management group used during creation.

    :ivar id: The fully qualified ID for the parent management group.  For example,
     /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000.
    :vartype id: str
    :ivar name: The name of the parent management group.
    :vartype name: str
    :ivar display_name: The friendly name of the parent management group.
    :vartype display_name: str
    """

    id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"])
    """The fully qualified ID for the parent management group.  For example,
     /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000."""
    name: Optional[str] = rest_field(visibility=["read"])
    """The name of the parent management group."""
    display_name: Optional[str] = rest_field(name="displayName", visibility=["read"])
    """The friendly name of the parent management group."""

    @overload
    def __init__(
        self,
        *,
        id: Optional[str] = None,  # pylint: disable=redefined-builtin
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        super().__init__(*args, **kwargs)


class DescendantInfo(_Model):
    """The descendant.

    :ivar id: The fully qualified ID for the descendant.  For example,
     /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 or
     /subscriptions/0000000-0000-0000-0000-000000000000.
    :vartype id: str
    :ivar type: The type of the resource. For example, Microsoft.Management/managementGroups or
     /subscriptions.
    :vartype type: str
    :ivar name: The name of the descendant. For example, 00000000-0000-0000-0000-000000000000.
    :vartype name: str
    :ivar properties: The generic properties of an descendant.
    :vartype properties: ~azure.mgmt.managementgroups.models.DescendantInfoProperties
    """

    id: Optional[str] = rest_field(visibility=["read"])
    """The fully qualified ID for the descendant.  For example,
     /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 or
     /subscriptions/0000000-0000-0000-0000-000000000000."""
    type: Optional[str] = rest_field(visibility=["read"])
    """The type of the resource. For example, Microsoft.Management/managementGroups or /subscriptions."""
    name: Optional[str] = rest_field(visibility=["read"])
    """The name of the descendant. For example, 00000000-0000-0000-0000-000000000000."""
    properties: Optional["_models.DescendantInfoProperties"] = rest_field(
        visibility=["read", "create", "update", "delete", "query"]
    )
    """The generic properties of an descendant."""

    __flattened_items = ["display_name", "parent"]

    @overload
    def __init__(
        self,
        *,
        properties: Optional["_models.DescendantInfoProperties"] = None,
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items}
        super().__init__(*args, **kwargs)
        for k, v in _flattened_input.items():
            setattr(self, k, v)

    def __getattr__(self, name: str) -> Any:
        if name in self.__flattened_items:
            if self.properties is None:
                return None
            return getattr(self.properties, name)
        raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'")

    def __setattr__(self, key: str, value: Any) -> None:
        if key in self.__flattened_items:
            if self.properties is None:
                self.properties = self._attr_to_rest_field["properties"]._class_type()
            setattr(self.properties, key, value)
        else:
            super().__setattr__(key, value)


class DescendantInfoProperties(_Model):
    """The generic properties of an descendant.

    :ivar display_name: The friendly name of the management group.
    :vartype display_name: str
    :ivar parent: The ID of the parent management group.
    :vartype parent: ~azure.mgmt.managementgroups.models.DescendantParentGroupInfo
    """

    display_name: Optional[str] = rest_field(
        name="displayName", visibility=["read", "create", "update", "delete", "query"]
    )
    """The friendly name of the management group."""
    parent: Optional["_models.DescendantParentGroupInfo"] = rest_field(
        visibility=["read", "create", "update", "delete", "query"]
    )
    """The ID of the parent management group."""

    @overload
    def __init__(
        self,
        *,
        display_name: Optional[str] = None,
        parent: Optional["_models.DescendantParentGroupInfo"] = None,
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        super().__init__(*args, **kwargs)


class DescendantParentGroupInfo(_Model):
    """The ID of the parent management group.

    :ivar id: The fully qualified ID for the parent management group.  For example,
     /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000.
    :vartype id: str
    """

    id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"])
    """The fully qualified ID for the parent management group.  For example,
     /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000."""

    @overload
    def __init__(
        self,
        *,
        id: Optional[str] = None,  # pylint: disable=redefined-builtin
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        super().__init__(*args, **kwargs)


class EntityInfo(_Model):
    """The entity.

    :ivar id: The fully qualified ID for the entity.  For example,
     /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000.
    :vartype id: str
    :ivar type: The type of the resource. For example, Microsoft.Management/managementGroups.
    :vartype type: str
    :ivar name: The name of the entity. For example, 00000000-0000-0000-0000-000000000000.
    :vartype name: str
    :ivar properties: The generic properties of an entity.
    :vartype properties: ~azure.mgmt.managementgroups.models.EntityInfoProperties
    """

    id: Optional[str] = rest_field(visibility=["read"])
    """The fully qualified ID for the entity.  For example,
     /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000."""
    type: Optional[str] = rest_field(visibility=["read"])
    """The type of the resource. For example, Microsoft.Management/managementGroups."""
    name: Optional[str] = rest_field(visibility=["read"])
    """The name of the entity. For example, 00000000-0000-0000-0000-000000000000."""
    properties: Optional["_models.EntityInfoProperties"] = rest_field(
        visibility=["read", "create", "update", "delete", "query"]
    )
    """The generic properties of an entity."""

    __flattened_items = [
        "tenant_id",
        "display_name",
        "parent",
        "permissions",
        "inherited_permissions",
        "number_of_descendants",
        "number_of_children",
        "number_of_child_groups",
        "parent_display_name_chain",
        "parent_name_chain",
    ]

    @overload
    def __init__(
        self,
        *,
        properties: Optional["_models.EntityInfoProperties"] = None,
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items}
        super().__init__(*args, **kwargs)
        for k, v in _flattened_input.items():
            setattr(self, k, v)

    def __getattr__(self, name: str) -> Any:
        if name in self.__flattened_items:
            if self.properties is None:
                return None
            return getattr(self.properties, name)
        raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'")

    def __setattr__(self, key: str, value: Any) -> None:
        if key in self.__flattened_items:
            if self.properties is None:
                self.properties = self._attr_to_rest_field["properties"]._class_type()
            setattr(self.properties, key, value)
        else:
            super().__setattr__(key, value)


class EntityInfoProperties(_Model):
    """The generic properties of an entity.

    :ivar tenant_id: The AAD Tenant ID associated with the entity. For example,
     00000000-0000-0000-0000-000000000000.
    :vartype tenant_id: str
    :ivar display_name: The friendly name of the management group.
    :vartype display_name: str
    :ivar parent: (Optional) The ID of the parent management group.
    :vartype parent: ~azure.mgmt.managementgroups.models.EntityParentGroupInfo
    :ivar permissions: The users specific permissions to this item. Known values are: "noaccess",
     "view", "edit", and "delete".
    :vartype permissions: str or ~azure.mgmt.managementgroups.models.Permissions
    :ivar inherited_permissions: The users specific permissions to this item. Known values are:
     "noaccess", "view", "edit", and "delete".
    :vartype inherited_permissions: str or ~azure.mgmt.managementgroups.models.Permissions
    :ivar number_of_descendants: Number of Descendants.
    :vartype number_of_descendants: int
    :ivar number_of_children: Number of children is the number of Groups and Subscriptions that are
     exactly one level underneath the current Group.
    :vartype number_of_children: int
    :ivar number_of_child_groups: Number of children is the number of Groups that are exactly one
     level underneath the current Group.
    :vartype number_of_child_groups: int
    :ivar parent_display_name_chain: The parent display name chain from the root group to the
     immediate parent.
    :vartype parent_display_name_chain: list[str]
    :ivar parent_name_chain: The parent name chain from the root group to the immediate parent.
    :vartype parent_name_chain: list[str]
    """

    tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read", "create", "update", "delete", "query"])
    """The AAD Tenant ID associated with the entity. For example,
     00000000-0000-0000-0000-000000000000."""
    display_name: Optional[str] = rest_field(
        name="displayName", visibility=["read", "create", "update", "delete", "query"]
    )
    """The friendly name of the management group."""
    parent: Optional["_models.EntityParentGroupInfo"] = rest_field(
        visibility=["read", "create", "update", "delete", "query"]
    )
    """(Optional) The ID of the parent management group."""
    permissions: Optional[Union[str, "_models.Permissions"]] = rest_field(
        visibility=["read", "create", "update", "delete", "query"]
    )
    """The users specific permissions to this item. Known values are: \"noaccess\", \"view\",
     \"edit\", and \"delete\"."""
    inherited_permissions: Optional[Union[str, "_models.Permissions"]] = rest_field(
        name="inheritedPermissions", visibility=["read", "create", "update", "delete", "query"]
    )
    """The users specific permissions to this item. Known values are: \"noaccess\", \"view\",
     \"edit\", and \"delete\"."""
    number_of_descendants: Optional[int] = rest_field(
        name="numberOfDescendants", visibility=["read", "create", "update", "delete", "query"]
    )
    """Number of Descendants."""
    number_of_children: Optional[int] = rest_field(
        name="numberOfChildren", visibility=["read", "create", "update", "delete", "query"]
    )
    """Number of children is the number of Groups and Subscriptions that are exactly one level
     underneath the current Group."""
    number_of_child_groups: Optional[int] = rest_field(
        name="numberOfChildGroups", visibility=["read", "create", "update", "delete", "query"]
    )
    """Number of children is the number of Groups that are exactly one level underneath the current
     Group."""
    parent_display_name_chain: Optional[list[str]] = rest_field(
        name="parentDisplayNameChain", visibility=["read", "create", "update", "delete", "query"]
    )
    """The parent display name chain from the root group to the immediate parent."""
    parent_name_chain: Optional[list[str]] = rest_field(
        name="parentNameChain", visibility=["read", "create", "update", "delete", "query"]
    )
    """The parent name chain from the root group to the immediate parent."""

    @overload
    def __init__(
        self,
        *,
        tenant_id: Optional[str] = None,
        display_name: Optional[str] = None,
        parent: Optional["_models.EntityParentGroupInfo"] = None,
        permissions: Optional[Union[str, "_models.Permissions"]] = None,
        inherited_permissions: Optional[Union[str, "_models.Permissions"]] = None,
        number_of_descendants: Optional[int] = None,
        number_of_children: Optional[int] = None,
        number_of_child_groups: Optional[int] = None,
        parent_display_name_chain: Optional[list[str]] = None,
        parent_name_chain: Optional[list[str]] = None,
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        super().__init__(*args, **kwargs)


class EntityParentGroupInfo(_Model):
    """(Optional) The ID of the parent management group.

    :ivar id: The fully qualified ID for the parent management group.  For example,
     /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000.
    :vartype id: str
    """

    id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"])
    """The fully qualified ID for the parent management group.  For example,
     /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000."""

    @overload
    def __init__(
        self,
        *,
        id: Optional[str] = None,  # pylint: disable=redefined-builtin
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        super().__init__(*args, **kwargs)


class ErrorAdditionalInfo(_Model):
    """The resource management error additional info.

    :ivar type: The additional info type.
    :vartype type: str
    :ivar info: The additional info.
    :vartype info: any
    """

    type: Optional[str] = rest_field(visibility=["read"])
    """The additional info type."""
    info: Optional[Any] = rest_field(visibility=["read"])
    """The additional info."""


class ErrorDetail(_Model):
    """The error detail.

    :ivar code: The error code.
    :vartype code: str
    :ivar message: The error message.
    :vartype message: str
    :ivar target: The error target.
    :vartype target: str
    :ivar details: The error details.
    :vartype details: list[~azure.mgmt.managementgroups.models.ErrorDetail]
    :ivar additional_info: The error additional info.
    :vartype additional_info: list[~azure.mgmt.managementgroups.models.ErrorAdditionalInfo]
    """

    code: Optional[str] = rest_field(visibility=["read"])
    """The error code."""
    message: Optional[str] = rest_field(visibility=["read"])
    """The error message."""
    target: Optional[str] = rest_field(visibility=["read"])
    """The error target."""
    details: Optional[list["_models.ErrorDetail"]] = rest_field(visibility=["read"])
    """The error details."""
    additional_info: Optional[list["_models.ErrorAdditionalInfo"]] = rest_field(
        name="additionalInfo", visibility=["read"]
    )
    """The error additional info."""


class ErrorResponse(_Model):
    """Error response.

    :ivar error: The error object.
    :vartype error: ~azure.mgmt.managementgroups.models.ErrorDetail
    """

    error: Optional["_models.ErrorDetail"] = rest_field(visibility=["read", "create", "update", "delete", "query"])
    """The error object."""

    @overload
    def __init__(
        self,
        *,
        error: Optional["_models.ErrorDetail"] = None,
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        super().__init__(*args, **kwargs)


class Resource(_Model):
    """Resource.

    :ivar id: Fully qualified resource ID for the resource. Ex -
     /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
    :vartype id: str
    :ivar name: The name of the resource.
    :vartype name: str
    :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
     "Microsoft.Storage/storageAccounts".
    :vartype type: str
    :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy
     information.
    :vartype system_data: ~azure.mgmt.managementgroups.models.SystemData
    """

    id: Optional[str] = rest_field(visibility=["read"])
    """Fully qualified resource ID for the resource. Ex -
     /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}."""
    name: Optional[str] = rest_field(visibility=["read"])
    """The name of the resource."""
    type: Optional[str] = rest_field(visibility=["read"])
    """The type of the resource. E.g. \"Microsoft.Compute/virtualMachines\" or
     \"Microsoft.Storage/storageAccounts\"."""
    system_data: Optional["_models.SystemData"] = rest_field(name="systemData", visibility=["read"])
    """Azure Resource Manager metadata containing createdBy and modifiedBy information."""


class ProxyResource(Resource):
    """Proxy Resource.

    :ivar id: Fully qualified resource ID for the resource. Ex -
     /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
    :vartype id: str
    :ivar name: The name of the resource.
    :vartype name: str
    :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
     "Microsoft.Storage/storageAccounts".
    :vartype type: str
    :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy
     information.
    :vartype system_data: ~azure.mgmt.managementgroups.models.SystemData
    """


class HierarchySettings(ProxyResource):
    """Settings defined at the Management Group scope.

    :ivar id: Fully qualified resource ID for the resource. Ex -
     /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
    :vartype id: str
    :ivar name: The name of the resource.
    :vartype name: str
    :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
     "Microsoft.Storage/storageAccounts".
    :vartype type: str
    :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy
     information.
    :vartype system_data: ~azure.mgmt.managementgroups.models.SystemData
    :ivar properties: The generic properties of hierarchy settings.
    :vartype properties: ~azure.mgmt.managementgroups.models.HierarchySettingsProperties
    """

    properties: Optional["_models.HierarchySettingsProperties"] = rest_field(
        visibility=["read", "create", "update", "delete", "query"]
    )
    """The generic properties of hierarchy settings."""

    __flattened_items = ["tenant_id", "require_authorization_for_group_creation", "default_management_group"]

    @overload
    def __init__(
        self,
        *,
        properties: Optional["_models.HierarchySettingsProperties"] = None,
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items}
        super().__init__(*args, **kwargs)
        for k, v in _flattened_input.items():
            setattr(self, k, v)

    def __getattr__(self, name: str) -> Any:
        if name in self.__flattened_items:
            if self.properties is None:
                return None
            return getattr(self.properties, name)
        raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'")

    def __setattr__(self, key: str, value: Any) -> None:
        if key in self.__flattened_items:
            if self.properties is None:
                self.properties = self._attr_to_rest_field["properties"]._class_type()
            setattr(self.properties, key, value)
        else:
            super().__setattr__(key, value)


class HierarchySettingsInfo(_Model):
    """The hierarchy settings resource.

    :ivar id: The fully qualified ID for the settings object.  For example,
     /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000/settings/default.
    :vartype id: str
    :ivar type: The type of the resource.  For example,
     Microsoft.Management/managementGroups/settings.
    :vartype type: str
    :ivar name: The name of the object. In this case, default.
    :vartype name: str
    :ivar properties: The generic properties of hierarchy settings.
    :vartype properties: ~azure.mgmt.managementgroups.models.HierarchySettingsProperties
    """

    id: Optional[str] = rest_field(visibility=["read"])
    """The fully qualified ID for the settings object.  For example,
     /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000/settings/default."""
    type: Optional[str] = rest_field(visibility=["read"])
    """The type of the resource.  For example, Microsoft.Management/managementGroups/settings."""
    name: Optional[str] = rest_field(visibility=["read"])
    """The name of the object. In this case, default."""
    properties: Optional["_models.HierarchySettingsProperties"] = rest_field(
        visibility=["read", "create", "update", "delete", "query"]
    )
    """The generic properties of hierarchy settings."""

    __flattened_items = ["tenant_id", "require_authorization_for_group_creation", "default_management_group"]

    @overload
    def __init__(
        self,
        *,
        properties: Optional["_models.HierarchySettingsProperties"] = None,
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items}
        super().__init__(*args, **kwargs)
        for k, v in _flattened_input.items():
            setattr(self, k, v)

    def __getattr__(self, name: str) -> Any:
        if name in self.__flattened_items:
            if self.properties is None:
                return None
            return getattr(self.properties, name)
        raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'")

    def __setattr__(self, key: str, value: Any) -> None:
        if key in self.__flattened_items:
            if self.properties is None:
                self.properties = self._attr_to_rest_field["properties"]._class_type()
            setattr(self.properties, key, value)
        else:
            super().__setattr__(key, value)


class HierarchySettingsList(_Model):
    """Lists all hierarchy settings.

    :ivar value: The list of hierarchy settings.
    :vartype value: list[~azure.mgmt.managementgroups.models.HierarchySettingsInfo]
    :ivar next_link: The URL to use for getting the next set of results.
    :vartype next_link: str
    """

    value: Optional[list["_models.HierarchySettingsInfo"]] = rest_field(
        visibility=["read", "create", "update", "delete", "query"]
    )
    """The list of hierarchy settings."""
    next_link: Optional[str] = rest_field(name="@nextLink", visibility=["read"])
    """The URL to use for getting the next set of results."""

    @overload
    def __init__(
        self,
        *,
        value: Optional[list["_models.HierarchySettingsInfo"]] = None,
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        super().__init__(*args, **kwargs)


class HierarchySettingsProperties(_Model):
    """The generic properties of hierarchy settings.

    :ivar tenant_id: The AAD Tenant ID associated with the hierarchy settings. For example,
     00000000-0000-0000-0000-000000000000.
    :vartype tenant_id: str
    :ivar require_authorization_for_group_creation: Indicates whether RBAC access is required upon
     group creation under the root Management Group. If set to true, user will require
     Microsoft.Management/managementGroups/write action on the root Management Group scope in order
     to create new Groups directly under the root. This will prevent new users from creating new
     Management Groups, unless they are given access.
    :vartype require_authorization_for_group_creation: bool
    :ivar default_management_group: Settings that sets the default Management Group under which new
     subscriptions get added in this tenant. For example,
     /providers/Microsoft.Management/managementGroups/defaultGroup.
    :vartype default_management_group: str
    """

    tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read", "create", "update", "delete", "query"])
    """The AAD Tenant ID associated with the hierarchy settings. For example,
     00000000-0000-0000-0000-000000000000."""
    require_authorization_for_group_creation: Optional[bool] = rest_field(
        name="requireAuthorizationForGroupCreation", visibility=["read", "create", "update", "delete", "query"]
    )
    """Indicates whether RBAC access is required upon group creation under the root Management Group.
     If set to true, user will require Microsoft.Management/managementGroups/write action on the
     root Management Group scope in order to create new Groups directly under the root. This will
     prevent new users from creating new Management Groups, unless they are given access."""
    default_management_group: Optional[str] = rest_field(
        name="defaultManagementGroup", visibility=["read", "create", "update", "delete", "query"]
    )
    """Settings that sets the default Management Group under which new subscriptions get added in this
     tenant. For example, /providers/Microsoft.Management/managementGroups/defaultGroup."""

    @overload
    def __init__(
        self,
        *,
        tenant_id: Optional[str] = None,
        require_authorization_for_group_creation: Optional[bool] = None,
        default_management_group: Optional[str] = None,
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        super().__init__(*args, **kwargs)


class ManagementGroup(ProxyResource):
    """The management group details.

    :ivar id: Fully qualified resource ID for the resource. Ex -
     /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
    :vartype id: str
    :ivar name: The name of the resource.
    :vartype name: str
    :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
     "Microsoft.Storage/storageAccounts".
    :vartype type: str
    :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy
     information.
    :vartype system_data: ~azure.mgmt.managementgroups.models.SystemData
    :ivar properties: The generic properties of a management group.
    :vartype properties: ~azure.mgmt.managementgroups.models.ManagementGroupProperties
    """

    properties: Optional["_models.ManagementGroupProperties"] = rest_field(
        visibility=["read", "create", "update", "delete", "query"]
    )
    """The generic properties of a management group."""

    __flattened_items = ["tenant_id", "display_name", "details", "children"]

    @overload
    def __init__(
        self,
        *,
        properties: Optional["_models.ManagementGroupProperties"] = None,
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items}
        super().__init__(*args, **kwargs)
        for k, v in _flattened_input.items():
            setattr(self, k, v)

    def __getattr__(self, name: str) -> Any:
        if name in self.__flattened_items:
            if self.properties is None:
                return None
            return getattr(self.properties, name)
        raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'")

    def __setattr__(self, key: str, value: Any) -> None:
        if key in self.__flattened_items:
            if self.properties is None:
                self.properties = self._attr_to_rest_field["properties"]._class_type()
            setattr(self.properties, key, value)
        else:
            super().__setattr__(key, value)


class ManagementGroupChildInfo(_Model):
    """The child information of a management group.

    :ivar type: The fully qualified resource type which includes provider namespace (e.g.
     Microsoft.Management/managementGroups). Known values are:
     "Microsoft.Management/managementGroups" and "/subscriptions".
    :vartype type: str or ~azure.mgmt.managementgroups.models.ManagementGroupChildType
    :ivar id: The fully qualified ID for the child resource (management group or subscription).
     For example,
     /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000.
    :vartype id: str
    :ivar name: The name of the child entity.
    :vartype name: str
    :ivar display_name: The friendly name of the child resource.
    :vartype display_name: str
    :ivar children: The list of children.
    :vartype children: list[~azure.mgmt.managementgroups.models.ManagementGroupChildInfo]
    """

    type: Optional[Union[str, "_models.ManagementGroupChildType"]] = rest_field(
        visibility=["read", "create", "update", "delete", "query"]
    )
    """The fully qualified resource type which includes provider namespace (e.g.
     Microsoft.Management/managementGroups). Known values are:
     \"Microsoft.Management/managementGroups\" and \"/subscriptions\"."""
    id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"])
    """The fully qualified ID for the child resource (management group or subscription).  For example,
     /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000."""
    name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"])
    """The name of the child entity."""
    display_name: Optional[str] = rest_field(
        name="displayName", visibility=["read", "create", "update", "delete", "query"]
    )
    """The friendly name of the child resource."""
    children: Optional[list["_models.ManagementGroupChildInfo"]] = rest_field(
        visibility=["read", "create", "update", "delete", "query"]
    )
    """The list of children."""

    @overload
    def __init__(
        self,
        *,
        type: Optional[Union[str, "_models.ManagementGroupChildType"]] = None,
        id: Optional[str] = None,  # pylint: disable=redefined-builtin
        name: Optional[str] = None,
        display_name: Optional[str] = None,
        children: Optional[list["_models.ManagementGroupChildInfo"]] = None,
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        super().__init__(*args, **kwargs)


class ManagementGroupDetails(_Model):
    """The details of a management group.

    :ivar version: The version number of the object.
    :vartype version: int
    :ivar updated_time: The date and time when this object was last updated.
    :vartype updated_time: ~datetime.datetime
    :ivar updated_by: The identity of the principal or process that updated the object.
    :vartype updated_by: str
    :ivar parent: (Optional) The ID of the parent management group.
    :vartype parent: ~azure.mgmt.managementgroups.models.ParentGroupInfo
    :ivar path: The path from the root to the current group.
    :vartype path: list[~azure.mgmt.managementgroups.models.ManagementGroupPathElement]
    :ivar management_group_ancestors: The ancestors of the management group.
    :vartype management_group_ancestors: list[str]
    :ivar management_group_ancestors_chain: The ancestors of the management group displayed in
     reversed order, from immediate parent to the root.
    :vartype management_group_ancestors_chain:
     list[~azure.mgmt.managementgroups.models.ManagementGroupPathElement]
    """

    version: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"])
    """The version number of the object."""
    updated_time: Optional[datetime.datetime] = rest_field(
        name="updatedTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339"
    )
    """The date and time when this object was last updated."""
    updated_by: Optional[str] = rest_field(name="updatedBy", visibility=["read", "create", "update", "delete", "query"])
    """The identity of the principal or process that updated the object."""
    parent: Optional["_models.ParentGroupInfo"] = rest_field(visibility=["read", "create", "update", "delete", "query"])
    """(Optional) The ID of the parent management group."""
    path: Optional[list["_models.ManagementGroupPathElement"]] = rest_field(
        visibility=["read", "create", "update", "delete", "query"]
    )
    """The path from the root to the current group."""
    management_group_ancestors: Optional[list[str]] = rest_field(
        name="managementGroupAncestors", visibility=["read", "create", "update", "delete", "query"]
    )
    """The ancestors of the management group."""
    management_group_ancestors_chain: Optional[list["_models.ManagementGroupPathElement"]] = rest_field(
        name="managementGroupAncestorsChain", visibility=["read", "create", "update", "delete", "query"]
    )
    """The ancestors of the management group displayed in reversed order, from immediate parent to the
     root."""

    @overload
    def __init__(
        self,
        *,
        version: Optional[int] = None,
        updated_time: Optional[datetime.datetime] = None,
        updated_by: Optional[str] = None,
        parent: Optional["_models.ParentGroupInfo"] = None,
        path: Optional[list["_models.ManagementGroupPathElement"]] = None,
        management_group_ancestors: Optional[list[str]] = None,
        management_group_ancestors_chain: Optional[list["_models.ManagementGroupPathElement"]] = None,
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        super().__init__(*args, **kwargs)


class ManagementGroupInfo(_Model):
    """The management group resource.

    :ivar id: The fully qualified ID for the management group.  For example,
     /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000.
    :vartype id: str
    :ivar type: The type of the resource. For example, Microsoft.Management/managementGroups.
    :vartype type: str
    :ivar name: The name of the management group. For example,
     00000000-0000-0000-0000-000000000000.
    :vartype name: str
    :ivar properties: The generic properties of a management group.
    :vartype properties: ~azure.mgmt.managementgroups.models.ManagementGroupInfoProperties
    """

    id: Optional[str] = rest_field(visibility=["read"])
    """The fully qualified ID for the management group.  For example,
     /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000."""
    type: Optional[str] = rest_field(visibility=["read"])
    """The type of the resource. For example, Microsoft.Management/managementGroups."""
    name: Optional[str] = rest_field(visibility=["read"])
    """The name of the management group. For example, 00000000-0000-0000-0000-000000000000."""
    properties: Optional["_models.ManagementGroupInfoProperties"] = rest_field(
        visibility=["read", "create", "update", "delete", "query"]
    )
    """The generic properties of a management group."""

    __flattened_items = ["tenant_id", "display_name"]

    @overload
    def __init__(
        self,
        *,
        properties: Optional["_models.ManagementGroupInfoProperties"] = None,
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items}
        super().__init__(*args, **kwargs)
        for k, v in _flattened_input.items():
            setattr(self, k, v)

    def __getattr__(self, name: str) -> Any:
        if name in self.__flattened_items:
            if self.properties is None:
                return None
            return getattr(self.properties, name)
        raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'")

    def __setattr__(self, key: str, value: Any) -> None:
        if key in self.__flattened_items:
            if self.properties is None:
                self.properties = self._attr_to_rest_field["properties"]._class_type()
            setattr(self.properties, key, value)
        else:
            super().__setattr__(key, value)


class ManagementGroupInfoProperties(_Model):
    """The generic properties of a management group.

    :ivar tenant_id: The AAD Tenant ID associated with the management group. For example,
     00000000-0000-0000-0000-000000000000.
    :vartype tenant_id: str
    :ivar display_name: The friendly name of the management group.
    :vartype display_name: str
    """

    tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read", "create", "update", "delete", "query"])
    """The AAD Tenant ID associated with the management group. For example,
     00000000-0000-0000-0000-000000000000."""
    display_name: Optional[str] = rest_field(
        name="displayName", visibility=["read", "create", "update", "delete", "query"]
    )
    """The friendly name of the management group."""

    @overload
    def __init__(
        self,
        *,
        tenant_id: Optional[str] = None,
        display_name: Optional[str] = None,
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        super().__init__(*args, **kwargs)


class ManagementGroupPathElement(_Model):
    """A path element of a management group ancestors.

    :ivar name: The name of the group.
    :vartype name: str
    :ivar display_name: The friendly name of the group.
    :vartype display_name: str
    """

    name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"])
    """The name of the group."""
    display_name: Optional[str] = rest_field(
        name="displayName", visibility=["read", "create", "update", "delete", "query"]
    )
    """The friendly name of the group."""

    @overload
    def __init__(
        self,
        *,
        name: Optional[str] = None,
        display_name: Optional[str] = None,
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        super().__init__(*args, **kwargs)


class ManagementGroupProperties(_Model):
    """The generic properties of a management group.

    :ivar tenant_id: The AAD Tenant ID associated with the management group. For example,
     00000000-0000-0000-0000-000000000000.
    :vartype tenant_id: str
    :ivar display_name: The friendly name of the management group.
    :vartype display_name: str
    :ivar details: The details of a management group.
    :vartype details: ~azure.mgmt.managementgroups.models.ManagementGroupDetails
    :ivar children: The list of children.
    :vartype children: list[~azure.mgmt.managementgroups.models.ManagementGroupChildInfo]
    """

    tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read", "create", "update", "delete", "query"])
    """The AAD Tenant ID associated with the management group. For example,
     00000000-0000-0000-0000-000000000000."""
    display_name: Optional[str] = rest_field(
        name="displayName", visibility=["read", "create", "update", "delete", "query"]
    )
    """The friendly name of the management group."""
    details: Optional["_models.ManagementGroupDetails"] = rest_field(
        visibility=["read", "create", "update", "delete", "query"]
    )
    """The details of a management group."""
    children: Optional[list["_models.ManagementGroupChildInfo"]] = rest_field(
        visibility=["read", "create", "update", "delete", "query"]
    )
    """The list of children."""

    @overload
    def __init__(
        self,
        *,
        tenant_id: Optional[str] = None,
        display_name: Optional[str] = None,
        details: Optional["_models.ManagementGroupDetails"] = None,
        children: Optional[list["_models.ManagementGroupChildInfo"]] = None,
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        super().__init__(*args, **kwargs)


class Operation(_Model):
    """REST API Operation.

    :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples:
     "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action".
    :vartype name: str
    :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for
     data-plane operations and "false" for Azure Resource Manager/control-plane operations.
    :vartype is_data_action: bool
    :ivar display: Localized display information for this particular operation.
    :vartype display: ~azure.mgmt.managementgroups.models.OperationDisplay
    :ivar origin: The intended executor of the operation; as in Resource Based Access Control
     (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system",
     and "user,system".
    :vartype origin: str or ~azure.mgmt.managementgroups.models.Origin
    :ivar action_type: Extensible enum. Indicates the action type. "Internal" refers to actions
     that are for internal only APIs. "Internal"
    :vartype action_type: str or ~azure.mgmt.managementgroups.models.ActionType
    """

    name: Optional[str] = rest_field(visibility=["read"])
    """The name of the operation, as per Resource-Based Access Control (RBAC). Examples:
     \"Microsoft.Compute/virtualMachines/write\",
     \"Microsoft.Compute/virtualMachines/capture/action\"."""
    is_data_action: Optional[bool] = rest_field(name="isDataAction", visibility=["read"])
    """Whether the operation applies to data-plane. This is \"true\" for data-plane operations and
     \"false\" for Azure Resource Manager/control-plane operations."""
    display: Optional["_models.OperationDisplay"] = rest_field(
        visibility=["read", "create", "update", "delete", "query"]
    )
    """Localized display information for this particular operation."""
    origin: Optional[Union[str, "_models.Origin"]] = rest_field(visibility=["read"])
    """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit
     logs UX. Default value is \"user,system\". Known values are: \"user\", \"system\", and
     \"user,system\"."""
    action_type: Optional[Union[str, "_models.ActionType"]] = rest_field(name="actionType", visibility=["read"])
    """Extensible enum. Indicates the action type. \"Internal\" refers to actions that are for
     internal only APIs. \"Internal\""""

    @overload
    def __init__(
        self,
        *,
        display: Optional["_models.OperationDisplay"] = None,
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        super().__init__(*args, **kwargs)


class OperationDisplay(_Model):
    """Localized display information for an operation.

    :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft
     Monitoring Insights" or "Microsoft Compute".
    :vartype provider: str
    :ivar resource: The localized friendly name of the resource type related to this operation.
     E.g. "Virtual Machines" or "Job Schedule Collections".
    :vartype resource: str
    :ivar operation: The concise, localized friendly name for the operation; suitable for
     dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine".
    :vartype operation: str
    :ivar description: The short, localized friendly description of the operation; suitable for
     tool tips and detailed views.
    :vartype description: str
    """

    provider: Optional[str] = rest_field(visibility=["read"])
    """The localized friendly form of the resource provider name, e.g. \"Microsoft Monitoring
     Insights\" or \"Microsoft Compute\"."""
    resource: Optional[str] = rest_field(visibility=["read"])
    """The localized friendly name of the resource type related to this operation. E.g. \"Virtual
     Machines\" or \"Job Schedule Collections\"."""
    operation: Optional[str] = rest_field(visibility=["read"])
    """The concise, localized friendly name for the operation; suitable for dropdowns. E.g. \"Create
     or Update Virtual Machine\", \"Restart Virtual Machine\"."""
    description: Optional[str] = rest_field(visibility=["read"])
    """The short, localized friendly description of the operation; suitable for tool tips and detailed
     views."""


class ParentGroupInfo(_Model):
    """(Optional) The ID of the parent management group.

    :ivar id: The fully qualified ID for the parent management group.  For example,
     /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000.
    :vartype id: str
    :ivar name: The name of the parent management group.
    :vartype name: str
    :ivar display_name: The friendly name of the parent management group.
    :vartype display_name: str
    """

    id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"])
    """The fully qualified ID for the parent management group.  For example,
     /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000."""
    name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"])
    """The name of the parent management group."""
    display_name: Optional[str] = rest_field(
        name="displayName", visibility=["read", "create", "update", "delete", "query"]
    )
    """The friendly name of the parent management group."""

    @overload
    def __init__(
        self,
        *,
        id: Optional[str] = None,  # pylint: disable=redefined-builtin
        name: Optional[str] = None,
        display_name: Optional[str] = None,
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        super().__init__(*args, **kwargs)


class PatchManagementGroupRequest(_Model):
    """Management group patch parameters.

    :ivar display_name: The friendly name of the management group.
    :vartype display_name: str
    :ivar parent_group_id: (Optional) The fully qualified ID for the parent management group.  For
     example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000.
    :vartype parent_group_id: str
    """

    display_name: Optional[str] = rest_field(
        name="displayName", visibility=["read", "create", "update", "delete", "query"]
    )
    """The friendly name of the management group."""
    parent_group_id: Optional[str] = rest_field(
        name="parentGroupId", visibility=["read", "create", "update", "delete", "query"]
    )
    """(Optional) The fully qualified ID for the parent management group.  For example,
     /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000."""

    @overload
    def __init__(
        self,
        *,
        display_name: Optional[str] = None,
        parent_group_id: Optional[str] = None,
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        super().__init__(*args, **kwargs)


class SubscriptionUnderManagementGroup(ProxyResource):
    """The details of subscription under management group.

    :ivar id: Fully qualified resource ID for the resource. Ex -
     /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
    :vartype id: str
    :ivar name: The name of the resource.
    :vartype name: str
    :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
     "Microsoft.Storage/storageAccounts".
    :vartype type: str
    :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy
     information.
    :vartype system_data: ~azure.mgmt.managementgroups.models.SystemData
    :ivar properties: The generic properties of subscription under a management group.
    :vartype properties:
     ~azure.mgmt.managementgroups.models.SubscriptionUnderManagementGroupProperties
    """

    properties: Optional["_models.SubscriptionUnderManagementGroupProperties"] = rest_field(
        visibility=["read", "create", "update", "delete", "query"]
    )
    """The generic properties of subscription under a management group."""

    __flattened_items = ["tenant", "display_name", "parent", "state"]

    @overload
    def __init__(
        self,
        *,
        properties: Optional["_models.SubscriptionUnderManagementGroupProperties"] = None,
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items}
        super().__init__(*args, **kwargs)
        for k, v in _flattened_input.items():
            setattr(self, k, v)

    def __getattr__(self, name: str) -> Any:
        if name in self.__flattened_items:
            if self.properties is None:
                return None
            return getattr(self.properties, name)
        raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'")

    def __setattr__(self, key: str, value: Any) -> None:
        if key in self.__flattened_items:
            if self.properties is None:
                self.properties = self._attr_to_rest_field["properties"]._class_type()
            setattr(self.properties, key, value)
        else:
            super().__setattr__(key, value)


class SubscriptionUnderManagementGroupProperties(_Model):  # pylint: disable=name-too-long
    """The generic properties of subscription under a management group.

    :ivar tenant: The AAD Tenant ID associated with the subscription. For example,
     00000000-0000-0000-0000-000000000000.
    :vartype tenant: str
    :ivar display_name: The friendly name of the subscription.
    :vartype display_name: str
    :ivar parent: The ID of the parent management group.
    :vartype parent: ~azure.mgmt.managementgroups.models.DescendantParentGroupInfo
    :ivar state: The state of the subscription.
    :vartype state: str
    """

    tenant: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"])
    """The AAD Tenant ID associated with the subscription. For example,
     00000000-0000-0000-0000-000000000000."""
    display_name: Optional[str] = rest_field(
        name="displayName", visibility=["read", "create", "update", "delete", "query"]
    )
    """The friendly name of the subscription."""
    parent: Optional["_models.DescendantParentGroupInfo"] = rest_field(
        visibility=["read", "create", "update", "delete", "query"]
    )
    """The ID of the parent management group."""
    state: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"])
    """The state of the subscription."""

    @overload
    def __init__(
        self,
        *,
        tenant: Optional[str] = None,
        display_name: Optional[str] = None,
        parent: Optional["_models.DescendantParentGroupInfo"] = None,
        state: Optional[str] = None,
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        super().__init__(*args, **kwargs)


class SystemData(_Model):
    """Metadata pertaining to creation and last modification of the resource.

    :ivar created_by: The identity that created the resource.
    :vartype created_by: str
    :ivar created_by_type: The type of identity that created the resource. Known values are:
     "User", "Application", "ManagedIdentity", and "Key".
    :vartype created_by_type: str or ~azure.mgmt.managementgroups.models.CreatedByType
    :ivar created_at: The timestamp of resource creation (UTC).
    :vartype created_at: ~datetime.datetime
    :ivar last_modified_by: The identity that last modified the resource.
    :vartype last_modified_by: str
    :ivar last_modified_by_type: The type of identity that last modified the resource. Known values
     are: "User", "Application", "ManagedIdentity", and "Key".
    :vartype last_modified_by_type: str or ~azure.mgmt.managementgroups.models.CreatedByType
    :ivar last_modified_at: The timestamp of resource last modification (UTC).
    :vartype last_modified_at: ~datetime.datetime
    """

    created_by: Optional[str] = rest_field(name="createdBy", visibility=["read", "create", "update", "delete", "query"])
    """The identity that created the resource."""
    created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field(
        name="createdByType", visibility=["read", "create", "update", "delete", "query"]
    )
    """The type of identity that created the resource. Known values are: \"User\", \"Application\",
     \"ManagedIdentity\", and \"Key\"."""
    created_at: Optional[datetime.datetime] = rest_field(
        name="createdAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339"
    )
    """The timestamp of resource creation (UTC)."""
    last_modified_by: Optional[str] = rest_field(
        name="lastModifiedBy", visibility=["read", "create", "update", "delete", "query"]
    )
    """The identity that last modified the resource."""
    last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field(
        name="lastModifiedByType", visibility=["read", "create", "update", "delete", "query"]
    )
    """The type of identity that last modified the resource. Known values are: \"User\",
     \"Application\", \"ManagedIdentity\", and \"Key\"."""
    last_modified_at: Optional[datetime.datetime] = rest_field(
        name="lastModifiedAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339"
    )
    """The timestamp of resource last modification (UTC)."""

    @overload
    def __init__(
        self,
        *,
        created_by: Optional[str] = None,
        created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None,
        created_at: Optional[datetime.datetime] = None,
        last_modified_by: Optional[str] = None,
        last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None,
        last_modified_at: Optional[datetime.datetime] = None,
    ) -> None: ...

    @overload
    def __init__(self, mapping: Mapping[str, Any]) -> None:
        """
        :param mapping: raw JSON to initialize the model.
        :type mapping: Mapping[str, Any]
        """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        super().__init__(*args, **kwargs)


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

    :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. Known values are: "NotStarted",
     "NotStartedButGroupsExist", "Started", "Failed", "Cancelled", and "Completed".
    :vartype status: str or ~azure.mgmt.managementgroups.models.Status
    """

    tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read"])
    """The AAD Tenant ID associated with the management group. For example,
     00000000-0000-0000-0000-000000000000."""
    status: Optional[Union[str, "_models.Status"]] = rest_field(visibility=["read"])
    """The status of the Tenant Backfill. Known values are: \"NotStarted\",
     \"NotStartedButGroupsExist\", \"Started\", \"Failed\", \"Cancelled\", and \"Completed\"."""
