package armmanagementgroups

import (
	"encoding/json"
	"reflect"
	"time"

	"github.com/Azure/azure-sdk-for-go/sdk/azcore"
)

type AzureAsyncOperationResults struct {

	Properties *ManagementGroupInfoProperties `json:"properties,omitempty"`

	ID *string `json:"id,omitempty" azure:"ro"`

	Name *string `json:"name,omitempty" azure:"ro"`

	Status *string `json:"status,omitempty" azure:"ro"`

	Type *string `json:"type,omitempty" azure:"ro"`
}

type CheckNameAvailabilityRequest struct {

	Name *string `json:"name,omitempty"`

	Type *string `json:"type,omitempty"`
}

type CheckNameAvailabilityResult struct {

	Message *string `json:"message,omitempty" azure:"ro"`

	NameAvailable *bool `json:"nameAvailable,omitempty" azure:"ro"`

	Reason *Reason `json:"reason,omitempty" azure:"ro"`
}

type CreateManagementGroupChildInfo struct {

	Children []*CreateManagementGroupChildInfo `json:"children,omitempty" azure:"ro"`

	DisplayName *string `json:"displayName,omitempty" azure:"ro"`

	ID *string `json:"id,omitempty" azure:"ro"`

	Name *string `json:"name,omitempty" azure:"ro"`

	Type *ManagementGroupChildType `json:"type,omitempty" azure:"ro"`
}

func (c CreateManagementGroupChildInfo) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "children", c.Children)
	populate(objectMap, "displayName", c.DisplayName)
	populate(objectMap, "id", c.ID)
	populate(objectMap, "name", c.Name)
	populate(objectMap, "type", c.Type)
	return json.Marshal(objectMap)
}

type CreateManagementGroupDetails struct {

	Parent *CreateParentGroupInfo `json:"parent,omitempty"`

	UpdatedBy *string `json:"updatedBy,omitempty" azure:"ro"`

	UpdatedTime *time.Time `json:"updatedTime,omitempty" azure:"ro"`

	Version *int32 `json:"version,omitempty" azure:"ro"`
}

func (c CreateManagementGroupDetails) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "parent", c.Parent)
	populate(objectMap, "updatedBy", c.UpdatedBy)
	populate(objectMap, "updatedTime", (*timeRFC3339)(c.UpdatedTime))
	populate(objectMap, "version", c.Version)
	return json.Marshal(objectMap)
}

func (c *CreateManagementGroupDetails) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return err
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "parent":
			err = unpopulate(val, &c.Parent)
			delete(rawMsg, key)
		case "updatedBy":
			err = unpopulate(val, &c.UpdatedBy)
			delete(rawMsg, key)
		case "updatedTime":
			var aux timeRFC3339
			err = unpopulate(val, &aux)
			c.UpdatedTime = (*time.Time)(&aux)
			delete(rawMsg, key)
		case "version":
			err = unpopulate(val, &c.Version)
			delete(rawMsg, key)
		}
		if err != nil {
			return err
		}
	}
	return nil
}

type CreateManagementGroupProperties struct {

	Details *CreateManagementGroupDetails `json:"details,omitempty"`

	DisplayName *string `json:"displayName,omitempty"`

	Children []*CreateManagementGroupChildInfo `json:"children,omitempty" azure:"ro"`

	TenantID *string `json:"tenantId,omitempty" azure:"ro"`
}

func (c CreateManagementGroupProperties) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "children", c.Children)
	populate(objectMap, "details", c.Details)
	populate(objectMap, "displayName", c.DisplayName)
	populate(objectMap, "tenantId", c.TenantID)
	return json.Marshal(objectMap)
}

type CreateManagementGroupRequest struct {

	Name *string `json:"name,omitempty"`

	Properties *CreateManagementGroupProperties `json:"properties,omitempty"`

	ID *string `json:"id,omitempty" azure:"ro"`

	Type *string `json:"type,omitempty" azure:"ro"`
}

type CreateOrUpdateSettingsProperties struct {

	DefaultManagementGroup *string `json:"defaultManagementGroup,omitempty"`

	RequireAuthorizationForGroupCreation *bool `json:"requireAuthorizationForGroupCreation,omitempty"`
}

type CreateOrUpdateSettingsRequest struct {

	Properties *CreateOrUpdateSettingsProperties `json:"properties,omitempty"`
}

func (c CreateOrUpdateSettingsRequest) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "properties", c.Properties)
	return json.Marshal(objectMap)
}

type CreateParentGroupInfo struct {

	ID *string `json:"id,omitempty"`

	DisplayName *string `json:"displayName,omitempty" azure:"ro"`

	Name *string `json:"name,omitempty" azure:"ro"`
}

type DescendantInfo struct {

	Properties *DescendantInfoProperties `json:"properties,omitempty"`

	ID *string `json:"id,omitempty" azure:"ro"`

	Name *string `json:"name,omitempty" azure:"ro"`

	Type *string `json:"type,omitempty" azure:"ro"`
}

type DescendantInfoProperties struct {

	DisplayName *string `json:"displayName,omitempty"`

	Parent *DescendantParentGroupInfo `json:"parent,omitempty"`
}

type DescendantListResult struct {

	Value []*DescendantInfo `json:"value,omitempty"`

	NextLink *string `json:"nextLink,omitempty" azure:"ro"`
}

func (d DescendantListResult) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "nextLink", d.NextLink)
	populate(objectMap, "value", d.Value)
	return json.Marshal(objectMap)
}

type DescendantParentGroupInfo struct {

	ID *string `json:"id,omitempty"`
}

type EntitiesListOptions struct {

	CacheControl *string

	Filter *string

	GroupName *string

	Search *Enum2

	Select *string

	Skip *int32

	Skiptoken *string

	Top *int32

	View *Enum3
}

type EntityHierarchyItem struct {

	Properties *EntityHierarchyItemProperties `json:"properties,omitempty"`

	ID *string `json:"id,omitempty" azure:"ro"`

	Name *string `json:"name,omitempty" azure:"ro"`

	Type *string `json:"type,omitempty" azure:"ro"`
}

type EntityHierarchyItemProperties struct {

	Children []*EntityHierarchyItem `json:"children,omitempty"`

	DisplayName *string `json:"displayName,omitempty"`

	Permissions *Permissions `json:"permissions,omitempty"`
}

func (e EntityHierarchyItemProperties) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "children", e.Children)
	populate(objectMap, "displayName", e.DisplayName)
	populate(objectMap, "permissions", e.Permissions)
	return json.Marshal(objectMap)
}

type EntityInfo struct {

	Properties *EntityInfoProperties `json:"properties,omitempty"`

	ID *string `json:"id,omitempty" azure:"ro"`

	Name *string `json:"name,omitempty" azure:"ro"`

	Type *string `json:"type,omitempty" azure:"ro"`
}

type EntityInfoProperties struct {

	DisplayName *string `json:"displayName,omitempty"`

	InheritedPermissions *Permissions `json:"inheritedPermissions,omitempty"`

	NumberOfChildGroups *int32 `json:"numberOfChildGroups,omitempty"`

	NumberOfChildren *int32 `json:"numberOfChildren,omitempty"`

	NumberOfDescendants *int32 `json:"numberOfDescendants,omitempty"`

	Parent *EntityParentGroupInfo `json:"parent,omitempty"`

	ParentDisplayNameChain []*string `json:"parentDisplayNameChain,omitempty"`

	ParentNameChain []*string `json:"parentNameChain,omitempty"`

	Permissions *Permissions `json:"permissions,omitempty"`

	TenantID *string `json:"tenantId,omitempty"`
}

func (e EntityInfoProperties) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "displayName", e.DisplayName)
	populate(objectMap, "inheritedPermissions", e.InheritedPermissions)
	populate(objectMap, "numberOfChildGroups", e.NumberOfChildGroups)
	populate(objectMap, "numberOfChildren", e.NumberOfChildren)
	populate(objectMap, "numberOfDescendants", e.NumberOfDescendants)
	populate(objectMap, "parent", e.Parent)
	populate(objectMap, "parentDisplayNameChain", e.ParentDisplayNameChain)
	populate(objectMap, "parentNameChain", e.ParentNameChain)
	populate(objectMap, "permissions", e.Permissions)
	populate(objectMap, "tenantId", e.TenantID)
	return json.Marshal(objectMap)
}

type EntityListResult struct {

	Value []*EntityInfo `json:"value,omitempty"`

	Count *int32 `json:"count,omitempty" azure:"ro"`

	NextLink *string `json:"nextLink,omitempty" azure:"ro"`
}

func (e EntityListResult) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "count", e.Count)
	populate(objectMap, "nextLink", e.NextLink)
	populate(objectMap, "value", e.Value)
	return json.Marshal(objectMap)
}

type EntityParentGroupInfo struct {

	ID *string `json:"id,omitempty"`
}

type ErrorDetails struct {

	Code *string `json:"code,omitempty"`

	Details *string `json:"details,omitempty"`

	Message *string `json:"message,omitempty"`
}

type ErrorResponse struct {
	raw string

	InnerError *ErrorDetails `json:"error,omitempty"`
}

func (e ErrorResponse) Error() string {
	return e.raw
}

type HierarchySettings struct {

	Properties *HierarchySettingsProperties `json:"properties,omitempty"`

	ID *string `json:"id,omitempty" azure:"ro"`

	Name *string `json:"name,omitempty" azure:"ro"`

	Type *string `json:"type,omitempty" azure:"ro"`
}

type HierarchySettingsCreateOrUpdateOptions struct {

}

type HierarchySettingsDeleteOptions struct {

}

type HierarchySettingsGetOptions struct {

}

type HierarchySettingsInfo struct {

	Properties *HierarchySettingsProperties `json:"properties,omitempty"`

	ID *string `json:"id,omitempty" azure:"ro"`

	Name *string `json:"name,omitempty" azure:"ro"`

	Type *string `json:"type,omitempty" azure:"ro"`
}

type HierarchySettingsList struct {

	Value []*HierarchySettingsInfo `json:"value,omitempty"`

	NextLink *string `json:"nextLink,omitempty" azure:"ro"`
}

func (h HierarchySettingsList) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "nextLink", h.NextLink)
	populate(objectMap, "value", h.Value)
	return json.Marshal(objectMap)
}

type HierarchySettingsListOptions struct {

}

type HierarchySettingsProperties struct {

	DefaultManagementGroup *string `json:"defaultManagementGroup,omitempty"`

	RequireAuthorizationForGroupCreation *bool `json:"requireAuthorizationForGroupCreation,omitempty"`

	TenantID *string `json:"tenantId,omitempty"`
}

type HierarchySettingsUpdateOptions struct {

}

type ListSubscriptionUnderManagementGroup struct {

	Value []*SubscriptionUnderManagementGroup `json:"value,omitempty"`

	NextLink *string `json:"nextLink,omitempty" azure:"ro"`
}

func (l ListSubscriptionUnderManagementGroup) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "nextLink", l.NextLink)
	populate(objectMap, "value", l.Value)
	return json.Marshal(objectMap)
}

type ManagementGroup struct {

	Properties *ManagementGroupProperties `json:"properties,omitempty"`

	ID *string `json:"id,omitempty" azure:"ro"`

	Name *string `json:"name,omitempty" azure:"ro"`

	Type *string `json:"type,omitempty" azure:"ro"`
}

type ManagementGroupChildInfo struct {

	Children []*ManagementGroupChildInfo `json:"children,omitempty"`

	DisplayName *string `json:"displayName,omitempty"`

	ID *string `json:"id,omitempty"`

	Name *string `json:"name,omitempty"`

	Type *ManagementGroupChildType `json:"type,omitempty"`
}

func (m ManagementGroupChildInfo) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "children", m.Children)
	populate(objectMap, "displayName", m.DisplayName)
	populate(objectMap, "id", m.ID)
	populate(objectMap, "name", m.Name)
	populate(objectMap, "type", m.Type)
	return json.Marshal(objectMap)
}

type ManagementGroupDetails struct {

	ManagementGroupAncestors []*string `json:"managementGroupAncestors,omitempty"`

	ManagementGroupAncestorsChain []*ManagementGroupPathElement `json:"managementGroupAncestorsChain,omitempty"`

	Parent *ParentGroupInfo `json:"parent,omitempty"`

	Path []*ManagementGroupPathElement `json:"path,omitempty"`

	UpdatedBy *string `json:"updatedBy,omitempty"`

	UpdatedTime *time.Time `json:"updatedTime,omitempty"`

	Version *int32 `json:"version,omitempty"`
}

func (m ManagementGroupDetails) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "managementGroupAncestors", m.ManagementGroupAncestors)
	populate(objectMap, "managementGroupAncestorsChain", m.ManagementGroupAncestorsChain)
	populate(objectMap, "parent", m.Parent)
	populate(objectMap, "path", m.Path)
	populate(objectMap, "updatedBy", m.UpdatedBy)
	populate(objectMap, "updatedTime", (*timeRFC3339)(m.UpdatedTime))
	populate(objectMap, "version", m.Version)
	return json.Marshal(objectMap)
}

func (m *ManagementGroupDetails) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return err
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "managementGroupAncestors":
			err = unpopulate(val, &m.ManagementGroupAncestors)
			delete(rawMsg, key)
		case "managementGroupAncestorsChain":
			err = unpopulate(val, &m.ManagementGroupAncestorsChain)
			delete(rawMsg, key)
		case "parent":
			err = unpopulate(val, &m.Parent)
			delete(rawMsg, key)
		case "path":
			err = unpopulate(val, &m.Path)
			delete(rawMsg, key)
		case "updatedBy":
			err = unpopulate(val, &m.UpdatedBy)
			delete(rawMsg, key)
		case "updatedTime":
			var aux timeRFC3339
			err = unpopulate(val, &aux)
			m.UpdatedTime = (*time.Time)(&aux)
			delete(rawMsg, key)
		case "version":
			err = unpopulate(val, &m.Version)
			delete(rawMsg, key)
		}
		if err != nil {
			return err
		}
	}
	return nil
}

type ManagementGroupInfo struct {

	Properties *ManagementGroupInfoProperties `json:"properties,omitempty"`

	ID *string `json:"id,omitempty" azure:"ro"`

	Name *string `json:"name,omitempty" azure:"ro"`

	Type *string `json:"type,omitempty" azure:"ro"`
}

type ManagementGroupInfoProperties struct {

	DisplayName *string `json:"displayName,omitempty"`

	TenantID *string `json:"tenantId,omitempty"`
}

type ManagementGroupListResult struct {

	Value []*ManagementGroupInfo `json:"value,omitempty"`

	NextLink *string `json:"nextLink,omitempty" azure:"ro"`
}

func (m ManagementGroupListResult) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "nextLink", m.NextLink)
	populate(objectMap, "value", m.Value)
	return json.Marshal(objectMap)
}

type ManagementGroupPathElement struct {

	DisplayName *string `json:"displayName,omitempty"`

	Name *string `json:"name,omitempty"`
}

type ManagementGroupProperties struct {

	Children []*ManagementGroupChildInfo `json:"children,omitempty"`

	Details *ManagementGroupDetails `json:"details,omitempty"`

	DisplayName *string `json:"displayName,omitempty"`

	TenantID *string `json:"tenantId,omitempty"`
}

func (m ManagementGroupProperties) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "children", m.Children)
	populate(objectMap, "details", m.Details)
	populate(objectMap, "displayName", m.DisplayName)
	populate(objectMap, "tenantId", m.TenantID)
	return json.Marshal(objectMap)
}

type ManagementGroupSubscriptionsCreateOptions struct {

	CacheControl *string
}

type ManagementGroupSubscriptionsDeleteOptions struct {

	CacheControl *string
}

type ManagementGroupSubscriptionsGetSubscriptionOptions struct {

	CacheControl *string
}

type ManagementGroupSubscriptionsGetSubscriptionsUnderManagementGroupOptions struct {

	Skiptoken *string
}

type ManagementGroupsAPICheckNameAvailabilityOptions struct {

}

type ManagementGroupsAPIStartTenantBackfillOptions struct {

}

type ManagementGroupsAPITenantBackfillStatusOptions struct {

}

type ManagementGroupsBeginCreateOrUpdateOptions struct {

	CacheControl *string
}

type ManagementGroupsBeginDeleteOptions struct {

	CacheControl *string
}

type ManagementGroupsGetDescendantsOptions struct {

	Skiptoken *string

	Top *int32
}

type ManagementGroupsGetOptions struct {

	CacheControl *string

	Expand *Enum0

	Filter *string

	Recurse *bool
}

type ManagementGroupsListOptions struct {

	CacheControl *string

	Skiptoken *string
}

type ManagementGroupsUpdateOptions struct {

	CacheControl *string
}

type Operation struct {

	Display *OperationDisplayProperties `json:"display,omitempty"`

	Name *string `json:"name,omitempty" azure:"ro"`
}

type OperationDisplayProperties struct {

	Description *string `json:"description,omitempty" azure:"ro"`

	Operation *string `json:"operation,omitempty" azure:"ro"`

	Provider *string `json:"provider,omitempty" azure:"ro"`

	Resource *string `json:"resource,omitempty" azure:"ro"`
}

type OperationListResult struct {

	NextLink *string `json:"nextLink,omitempty" azure:"ro"`

	Value []*Operation `json:"value,omitempty" azure:"ro"`
}

func (o OperationListResult) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "nextLink", o.NextLink)
	populate(objectMap, "value", o.Value)
	return json.Marshal(objectMap)
}

type OperationResults struct {

	Properties *ManagementGroupInfoProperties `json:"properties,omitempty"`

	ID *string `json:"id,omitempty" azure:"ro"`

	Name *string `json:"name,omitempty" azure:"ro"`

	Type *string `json:"type,omitempty" azure:"ro"`
}

type OperationsListOptions struct {

}

type ParentGroupInfo struct {

	DisplayName *string `json:"displayName,omitempty"`

	ID *string `json:"id,omitempty"`

	Name *string `json:"name,omitempty"`
}

type PatchManagementGroupRequest struct {

	DisplayName *string `json:"displayName,omitempty"`

	ParentGroupID *string `json:"parentGroupId,omitempty"`
}

func (p PatchManagementGroupRequest) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "displayName", p.DisplayName)
	populate(objectMap, "parentGroupId", p.ParentGroupID)
	return json.Marshal(objectMap)
}

type SubscriptionUnderManagementGroup struct {

	Properties *SubscriptionUnderManagementGroupProperties `json:"properties,omitempty"`

	ID *string `json:"id,omitempty" azure:"ro"`

	Name *string `json:"name,omitempty" azure:"ro"`

	Type *string `json:"type,omitempty" azure:"ro"`
}

type SubscriptionUnderManagementGroupProperties struct {

	DisplayName *string `json:"displayName,omitempty"`

	Parent *DescendantParentGroupInfo `json:"parent,omitempty"`

	State *string `json:"state,omitempty"`

	Tenant *string `json:"tenant,omitempty"`
}

type TenantBackfillStatusResult struct {

	Status *Status `json:"status,omitempty" azure:"ro"`

	TenantID *string `json:"tenantId,omitempty" azure:"ro"`
}

func populate(m map[string]interface{}, k string, v interface{}) {
	if v == nil {
		return
	} else if azcore.IsNullValue(v) {
		m[k] = nil
	} else if !reflect.ValueOf(v).IsNil() {
		m[k] = v
	}
}

func unpopulate(data json.RawMessage, v interface{}) error {
	if data == nil {
		return nil
	}
	return json.Unmarshal(data, v)
}
//go:build go1.16
// +build go1.16

// 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.

package armmanagementgroups

import (
	"encoding/json"
	"reflect"
	"time"

	"github.com/Azure/azure-sdk-for-go/sdk/azcore"
)

// AzureAsyncOperationResults - The results of Azure-AsyncOperation.
type AzureAsyncOperationResults struct {
	// The generic properties of a management group.
	Properties *ManagementGroupInfoProperties `json:"properties,omitempty"`

	// READ-ONLY; The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
	ID *string `json:"id,omitempty" azure:"ro"`

	// READ-ONLY; The name of the management group. For example, 00000000-0000-0000-0000-000000000000
	Name *string `json:"name,omitempty" azure:"ro"`

	// READ-ONLY; The current status of the asynchronous operation performed . For example, Running, Succeeded, Failed
	Status *string `json:"status,omitempty" azure:"ro"`

	// READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups
	Type *string `json:"type,omitempty" azure:"ro"`
}

// CheckNameAvailabilityRequest - Management group name availability check parameters.
type CheckNameAvailabilityRequest struct {
	// the name to check for availability
	Name *string `json:"name,omitempty"`

	// fully qualified resource type which includes provider namespace
	Type *string `json:"type,omitempty"`
}

// CheckNameAvailabilityResult - Describes the result of the request to check management group name availability.
type CheckNameAvailabilityResult struct {
	// READ-ONLY; 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.
	Message *string `json:"message,omitempty" azure:"ro"`

	// READ-ONLY; Required. True indicates name is valid and available. False indicates the name is invalid, unavailable, or both.
	NameAvailable *bool `json:"nameAvailable,omitempty" azure:"ro"`

	// READ-ONLY; 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.
	Reason *Reason `json:"reason,omitempty" azure:"ro"`
}

// CreateManagementGroupChildInfo - The child information of a management group used during creation.
type CreateManagementGroupChildInfo struct {
	// READ-ONLY; The list of children.
	Children []*CreateManagementGroupChildInfo `json:"children,omitempty" azure:"ro"`

	// READ-ONLY; The friendly name of the child resource.
	DisplayName *string `json:"displayName,omitempty" azure:"ro"`

	// READ-ONLY; The fully qualified ID for the child resource (management group or subscription). For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
	ID *string `json:"id,omitempty" azure:"ro"`

	// READ-ONLY; The name of the child entity.
	Name *string `json:"name,omitempty" azure:"ro"`

	// READ-ONLY; The fully qualified resource type which includes provider namespace (e.g. Microsoft.Management/managementGroups)
	Type *ManagementGroupChildType `json:"type,omitempty" azure:"ro"`
}

// MarshalJSON implements the json.Marshaller interface for type CreateManagementGroupChildInfo.
func (c CreateManagementGroupChildInfo) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "children", c.Children)
	populate(objectMap, "displayName", c.DisplayName)
	populate(objectMap, "id", c.ID)
	populate(objectMap, "name", c.Name)
	populate(objectMap, "type", c.Type)
	return json.Marshal(objectMap)
}

// CreateManagementGroupDetails - The details of a management group used during creation.
type CreateManagementGroupDetails struct {
	// (Optional) The ID of the parent management group used during creation.
	Parent *CreateParentGroupInfo `json:"parent,omitempty"`

	// READ-ONLY; The identity of the principal or process that updated the object.
	UpdatedBy *string `json:"updatedBy,omitempty" azure:"ro"`

	// READ-ONLY; The date and time when this object was last updated.
	UpdatedTime *time.Time `json:"updatedTime,omitempty" azure:"ro"`

	// READ-ONLY; The version number of the object.
	Version *int32 `json:"version,omitempty" azure:"ro"`
}

// MarshalJSON implements the json.Marshaller interface for type CreateManagementGroupDetails.
func (c CreateManagementGroupDetails) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "parent", c.Parent)
	populate(objectMap, "updatedBy", c.UpdatedBy)
	populate(objectMap, "updatedTime", (*timeRFC3339)(c.UpdatedTime))
	populate(objectMap, "version", c.Version)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type CreateManagementGroupDetails.
func (c *CreateManagementGroupDetails) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return err
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "parent":
			err = unpopulate(val, &c.Parent)
			delete(rawMsg, key)
		case "updatedBy":
			err = unpopulate(val, &c.UpdatedBy)
			delete(rawMsg, key)
		case "updatedTime":
			var aux timeRFC3339
			err = unpopulate(val, &aux)
			c.UpdatedTime = (*time.Time)(&aux)
			delete(rawMsg, key)
		case "version":
			err = unpopulate(val, &c.Version)
			delete(rawMsg, key)
		}
		if err != nil {
			return err
		}
	}
	return nil
}

// CreateManagementGroupProperties - The generic properties of a management group used during creation.
type CreateManagementGroupProperties struct {
	// The details of a management group used during creation.
	Details *CreateManagementGroupDetails `json:"details,omitempty"`

	// The friendly name of the management group. If no value is passed then this field will be set to the groupId.
	DisplayName *string `json:"displayName,omitempty"`

	// READ-ONLY; The list of children.
	Children []*CreateManagementGroupChildInfo `json:"children,omitempty" azure:"ro"`

	// READ-ONLY; The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000
	TenantID *string `json:"tenantId,omitempty" azure:"ro"`
}

// MarshalJSON implements the json.Marshaller interface for type CreateManagementGroupProperties.
func (c CreateManagementGroupProperties) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "children", c.Children)
	populate(objectMap, "details", c.Details)
	populate(objectMap, "displayName", c.DisplayName)
	populate(objectMap, "tenantId", c.TenantID)
	return json.Marshal(objectMap)
}

// CreateManagementGroupRequest - Management group creation parameters.
type CreateManagementGroupRequest struct {
	// The name of the management group. For example, 00000000-0000-0000-0000-000000000000
	Name *string `json:"name,omitempty"`

	// The generic properties of a management group used during creation.
	Properties *CreateManagementGroupProperties `json:"properties,omitempty"`

	// READ-ONLY; The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
	ID *string `json:"id,omitempty" azure:"ro"`

	// READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups
	Type *string `json:"type,omitempty" azure:"ro"`
}

// CreateOrUpdateSettingsProperties - The properties of the request to create or update Management Group settings
type CreateOrUpdateSettingsProperties struct {
	// Settings that sets the default Management Group under which new subscriptions get added in this tenant. For example, /providers/Microsoft.Management/managementGroups/defaultGroup
	DefaultManagementGroup *string `json:"defaultManagementGroup,omitempty"`

	// 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.
	RequireAuthorizationForGroupCreation *bool `json:"requireAuthorizationForGroupCreation,omitempty"`
}

// CreateOrUpdateSettingsRequest - Parameters for creating or updating Management Group settings
type CreateOrUpdateSettingsRequest struct {
	// The properties of the request to create or update Management Group settings
	Properties *CreateOrUpdateSettingsProperties `json:"properties,omitempty"`
}

// MarshalJSON implements the json.Marshaller interface for type CreateOrUpdateSettingsRequest.
func (c CreateOrUpdateSettingsRequest) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "properties", c.Properties)
	return json.Marshal(objectMap)
}

// CreateParentGroupInfo - (Optional) The ID of the parent management group used during creation.
type CreateParentGroupInfo struct {
	// The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
	ID *string `json:"id,omitempty"`

	// READ-ONLY; The friendly name of the parent management group.
	DisplayName *string `json:"displayName,omitempty" azure:"ro"`

	// READ-ONLY; The name of the parent management group
	Name *string `json:"name,omitempty" azure:"ro"`
}

// DescendantInfo - The descendant.
type DescendantInfo struct {
	// The generic properties of an descendant.
	Properties *DescendantInfoProperties `json:"properties,omitempty"`

	// READ-ONLY; 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
	ID *string `json:"id,omitempty" azure:"ro"`

	// READ-ONLY; The name of the descendant. For example, 00000000-0000-0000-0000-000000000000
	Name *string `json:"name,omitempty" azure:"ro"`

	// READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups or /subscriptions
	Type *string `json:"type,omitempty" azure:"ro"`
}

// DescendantInfoProperties - The generic properties of an descendant.
type DescendantInfoProperties struct {
	// The friendly name of the management group.
	DisplayName *string `json:"displayName,omitempty"`

	// The ID of the parent management group.
	Parent *DescendantParentGroupInfo `json:"parent,omitempty"`
}

// DescendantListResult - Describes the result of the request to view descendants.
type DescendantListResult struct {
	// The list of descendants.
	Value []*DescendantInfo `json:"value,omitempty"`

	// READ-ONLY; The URL to use for getting the next set of results.
	NextLink *string `json:"nextLink,omitempty" azure:"ro"`
}

// MarshalJSON implements the json.Marshaller interface for type DescendantListResult.
func (d DescendantListResult) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "nextLink", d.NextLink)
	populate(objectMap, "value", d.Value)
	return json.Marshal(objectMap)
}

// DescendantParentGroupInfo - The ID of the parent management group.
type DescendantParentGroupInfo struct {
	// The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
	ID *string `json:"id,omitempty"`
}

// EntitiesListOptions contains the optional parameters for the Entities.List method.
type EntitiesListOptions struct {
	// Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches.
	CacheControl *string
	// The filter parameter allows you to filter on the the name or display name fields. You can check for equality on the name field (e.g. name eq '{entityName}')
	// and you can check for substrings on either the name or display name fields(e.g. contains(name, '{substringToSearch}'), contains(displayName, '{substringToSearch')).
	// Note that the '{entityName}' and '{substringToSearch}' fields are checked case insensitively.
	Filter *string
	// A filter which allows the get entities call to focus on a particular group (i.e. "$filter=name eq 'groupName'")
	GroupName *string
	// The $search parameter is used in conjunction with the $filter parameter to return three different outputs depending on the parameter passed in.
	// With $search=AllowedParents the API will return the entity info of all groups that the requested entity will be able to reparent to as determined by
	// the user's permissions.
	// With $search=AllowedChildren the API will return the entity info of all entities that can be added as children of the requested entity.
	// With $search=ParentAndFirstLevelChildren the API will return the parent and first level of children that the user has either direct access to or indirect
	// access via one of their descendants.
	// With $search=ParentOnly the API will return only the group if the user has access to at least one of the descendants of the group.
	// With $search=ChildrenOnly the API will return only the first level of children of the group entity info specified in $filter. The user must have direct
	// access to the children entities or one of it's descendants for it to show up in the results.
	Search *Enum2
	// This parameter specifies the fields to include in the response. Can include any combination of Name,DisplayName,Type,ParentDisplayNameChain,ParentChain,
	// e.g. '$select=Name,DisplayName,Type,ParentDisplayNameChain,ParentNameChain'. When specified the $select parameter can override select in $skipToken.
	Select *string
	// Number of entities to skip over when retrieving results. Passing this in will override $skipToken.
	Skip *int32
	// 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.
	Skiptoken *string
	// Number of elements to return when retrieving results. Passing this in will override $skipToken.
	Top *int32
	// The view parameter allows clients to filter the type of data that is returned by the getEntities call.
	View *Enum3
}

// EntityHierarchyItem - The management group details for the hierarchy view.
type EntityHierarchyItem struct {
	// The generic properties of a management group.
	Properties *EntityHierarchyItemProperties `json:"properties,omitempty"`

	// READ-ONLY; The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
	ID *string `json:"id,omitempty" azure:"ro"`

	// READ-ONLY; The name of the management group. For example, 00000000-0000-0000-0000-000000000000
	Name *string `json:"name,omitempty" azure:"ro"`

	// READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups
	Type *string `json:"type,omitempty" azure:"ro"`
}

// EntityHierarchyItemProperties - The generic properties of a management group.
type EntityHierarchyItemProperties struct {
	// The list of children.
	Children []*EntityHierarchyItem `json:"children,omitempty"`

	// The friendly name of the management group.
	DisplayName *string `json:"displayName,omitempty"`

	// The users specific permissions to this item.
	Permissions *Permissions `json:"permissions,omitempty"`
}

// MarshalJSON implements the json.Marshaller interface for type EntityHierarchyItemProperties.
func (e EntityHierarchyItemProperties) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "children", e.Children)
	populate(objectMap, "displayName", e.DisplayName)
	populate(objectMap, "permissions", e.Permissions)
	return json.Marshal(objectMap)
}

// EntityInfo - The entity.
type EntityInfo struct {
	// The generic properties of an entity.
	Properties *EntityInfoProperties `json:"properties,omitempty"`

	// READ-ONLY; The fully qualified ID for the entity. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
	ID *string `json:"id,omitempty" azure:"ro"`

	// READ-ONLY; The name of the entity. For example, 00000000-0000-0000-0000-000000000000
	Name *string `json:"name,omitempty" azure:"ro"`

	// READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups
	Type *string `json:"type,omitempty" azure:"ro"`
}

// EntityInfoProperties - The generic properties of an entity.
type EntityInfoProperties struct {
	// The friendly name of the management group.
	DisplayName *string `json:"displayName,omitempty"`

	// The users specific permissions to this item.
	InheritedPermissions *Permissions `json:"inheritedPermissions,omitempty"`

	// Number of children is the number of Groups that are exactly one level underneath the current Group.
	NumberOfChildGroups *int32 `json:"numberOfChildGroups,omitempty"`

	// Number of children is the number of Groups and Subscriptions that are exactly one level underneath the current Group.
	NumberOfChildren *int32 `json:"numberOfChildren,omitempty"`

	// Number of Descendants
	NumberOfDescendants *int32 `json:"numberOfDescendants,omitempty"`

	// (Optional) The ID of the parent management group.
	Parent *EntityParentGroupInfo `json:"parent,omitempty"`

	// The parent display name chain from the root group to the immediate parent
	ParentDisplayNameChain []*string `json:"parentDisplayNameChain,omitempty"`

	// The parent name chain from the root group to the immediate parent
	ParentNameChain []*string `json:"parentNameChain,omitempty"`

	// The users specific permissions to this item.
	Permissions *Permissions `json:"permissions,omitempty"`

	// The AAD Tenant ID associated with the entity. For example, 00000000-0000-0000-0000-000000000000
	TenantID *string `json:"tenantId,omitempty"`
}

// MarshalJSON implements the json.Marshaller interface for type EntityInfoProperties.
func (e EntityInfoProperties) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "displayName", e.DisplayName)
	populate(objectMap, "inheritedPermissions", e.InheritedPermissions)
	populate(objectMap, "numberOfChildGroups", e.NumberOfChildGroups)
	populate(objectMap, "numberOfChildren", e.NumberOfChildren)
	populate(objectMap, "numberOfDescendants", e.NumberOfDescendants)
	populate(objectMap, "parent", e.Parent)
	populate(objectMap, "parentDisplayNameChain", e.ParentDisplayNameChain)
	populate(objectMap, "parentNameChain", e.ParentNameChain)
	populate(objectMap, "permissions", e.Permissions)
	populate(objectMap, "tenantId", e.TenantID)
	return json.Marshal(objectMap)
}

// EntityListResult - Describes the result of the request to view entities.
type EntityListResult struct {
	// The list of entities.
	Value []*EntityInfo `json:"value,omitempty"`

	// READ-ONLY; Total count of records that match the filter
	Count *int32 `json:"count,omitempty" azure:"ro"`

	// READ-ONLY; The URL to use for getting the next set of results.
	NextLink *string `json:"nextLink,omitempty" azure:"ro"`
}

// MarshalJSON implements the json.Marshaller interface for type EntityListResult.
func (e EntityListResult) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "count", e.Count)
	populate(objectMap, "nextLink", e.NextLink)
	populate(objectMap, "value", e.Value)
	return json.Marshal(objectMap)
}

// EntityParentGroupInfo - (Optional) The ID of the parent management group.
type EntityParentGroupInfo struct {
	// The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
	ID *string `json:"id,omitempty"`
}

// ErrorDetails - The details of the error.
type ErrorDetails struct {
	// One of a server-defined set of error codes.
	Code *string `json:"code,omitempty"`

	// A human-readable representation of the error's details.
	Details *string `json:"details,omitempty"`

	// A human-readable representation of the error.
	Message *string `json:"message,omitempty"`
}

// ErrorResponse - The error object.
// Implements the error and azcore.HTTPResponse interfaces.
type ErrorResponse struct {
	raw string
	// The details of the error.
	InnerError *ErrorDetails `json:"error,omitempty"`
}

// Error implements the error interface for type ErrorResponse.
// The contents of the error text are not contractual and subject to change.
func (e ErrorResponse) Error() string {
	return e.raw
}

// HierarchySettings - Settings defined at the Management Group scope.
type HierarchySettings struct {
	// The generic properties of hierarchy settings.
	Properties *HierarchySettingsProperties `json:"properties,omitempty"`

	// READ-ONLY; The fully qualified ID for the settings object. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000/settings/default.
	ID *string `json:"id,omitempty" azure:"ro"`

	// READ-ONLY; The name of the object. In this case, default.
	Name *string `json:"name,omitempty" azure:"ro"`

	// READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups/settings.
	Type *string `json:"type,omitempty" azure:"ro"`
}

// HierarchySettingsCreateOrUpdateOptions contains the optional parameters for the HierarchySettings.CreateOrUpdate method.
type HierarchySettingsCreateOrUpdateOptions struct {
	// placeholder for future optional parameters
}

// HierarchySettingsDeleteOptions contains the optional parameters for the HierarchySettings.Delete method.
type HierarchySettingsDeleteOptions struct {
	// placeholder for future optional parameters
}

// HierarchySettingsGetOptions contains the optional parameters for the HierarchySettings.Get method.
type HierarchySettingsGetOptions struct {
	// placeholder for future optional parameters
}

// HierarchySettingsInfo - The hierarchy settings resource.
type HierarchySettingsInfo struct {
	// The generic properties of hierarchy settings.
	Properties *HierarchySettingsProperties `json:"properties,omitempty"`

	// READ-ONLY; The fully qualified ID for the settings object. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000/settings/default.
	ID *string `json:"id,omitempty" azure:"ro"`

	// READ-ONLY; The name of the object. In this case, default.
	Name *string `json:"name,omitempty" azure:"ro"`

	// READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups/settings.
	Type *string `json:"type,omitempty" azure:"ro"`
}

// HierarchySettingsList - Lists all hierarchy settings.
type HierarchySettingsList struct {
	// The list of hierarchy settings.
	Value []*HierarchySettingsInfo `json:"value,omitempty"`

	// READ-ONLY; The URL to use for getting the next set of results.
	NextLink *string `json:"nextLink,omitempty" azure:"ro"`
}

// MarshalJSON implements the json.Marshaller interface for type HierarchySettingsList.
func (h HierarchySettingsList) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "nextLink", h.NextLink)
	populate(objectMap, "value", h.Value)
	return json.Marshal(objectMap)
}

// HierarchySettingsListOptions contains the optional parameters for the HierarchySettings.List method.
type HierarchySettingsListOptions struct {
	// placeholder for future optional parameters
}

// HierarchySettingsProperties - The generic properties of hierarchy settings.
type HierarchySettingsProperties struct {
	// Settings that sets the default Management Group under which new subscriptions get added in this tenant. For example, /providers/Microsoft.Management/managementGroups/defaultGroup
	DefaultManagementGroup *string `json:"defaultManagementGroup,omitempty"`

	// 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.
	RequireAuthorizationForGroupCreation *bool `json:"requireAuthorizationForGroupCreation,omitempty"`

	// The AAD Tenant ID associated with the hierarchy settings. For example, 00000000-0000-0000-0000-000000000000
	TenantID *string `json:"tenantId,omitempty"`
}

// HierarchySettingsUpdateOptions contains the optional parameters for the HierarchySettings.Update method.
type HierarchySettingsUpdateOptions struct {
	// placeholder for future optional parameters
}

// ListSubscriptionUnderManagementGroup - The details of all subscriptions under management group.
type ListSubscriptionUnderManagementGroup struct {
	// The list of subscriptions.
	Value []*SubscriptionUnderManagementGroup `json:"value,omitempty"`

	// READ-ONLY; The URL to use for getting the next set of results.
	NextLink *string `json:"nextLink,omitempty" azure:"ro"`
}

// MarshalJSON implements the json.Marshaller interface for type ListSubscriptionUnderManagementGroup.
func (l ListSubscriptionUnderManagementGroup) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "nextLink", l.NextLink)
	populate(objectMap, "value", l.Value)
	return json.Marshal(objectMap)
}

// ManagementGroup - The management group details.
type ManagementGroup struct {
	// The generic properties of a management group.
	Properties *ManagementGroupProperties `json:"properties,omitempty"`

	// READ-ONLY; The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
	ID *string `json:"id,omitempty" azure:"ro"`

	// READ-ONLY; The name of the management group. For example, 00000000-0000-0000-0000-000000000000
	Name *string `json:"name,omitempty" azure:"ro"`

	// READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups
	Type *string `json:"type,omitempty" azure:"ro"`
}

// ManagementGroupChildInfo - The child information of a management group.
type ManagementGroupChildInfo struct {
	// The list of children.
	Children []*ManagementGroupChildInfo `json:"children,omitempty"`

	// The friendly name of the child resource.
	DisplayName *string `json:"displayName,omitempty"`

	// The fully qualified ID for the child resource (management group or subscription). For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
	ID *string `json:"id,omitempty"`

	// The name of the child entity.
	Name *string `json:"name,omitempty"`

	// The fully qualified resource type which includes provider namespace (e.g. Microsoft.Management/managementGroups)
	Type *ManagementGroupChildType `json:"type,omitempty"`
}

// MarshalJSON implements the json.Marshaller interface for type ManagementGroupChildInfo.
func (m ManagementGroupChildInfo) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "children", m.Children)
	populate(objectMap, "displayName", m.DisplayName)
	populate(objectMap, "id", m.ID)
	populate(objectMap, "name", m.Name)
	populate(objectMap, "type", m.Type)
	return json.Marshal(objectMap)
}

// ManagementGroupDetails - The details of a management group.
type ManagementGroupDetails struct {
	// The ancestors of the management group.
	ManagementGroupAncestors []*string `json:"managementGroupAncestors,omitempty"`

	// The ancestors of the management group displayed in reversed order, from immediate parent to the root.
	ManagementGroupAncestorsChain []*ManagementGroupPathElement `json:"managementGroupAncestorsChain,omitempty"`

	// (Optional) The ID of the parent management group.
	Parent *ParentGroupInfo `json:"parent,omitempty"`

	// The path from the root to the current group.
	Path []*ManagementGroupPathElement `json:"path,omitempty"`

	// The identity of the principal or process that updated the object.
	UpdatedBy *string `json:"updatedBy,omitempty"`

	// The date and time when this object was last updated.
	UpdatedTime *time.Time `json:"updatedTime,omitempty"`

	// The version number of the object.
	Version *int32 `json:"version,omitempty"`
}

// MarshalJSON implements the json.Marshaller interface for type ManagementGroupDetails.
func (m ManagementGroupDetails) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "managementGroupAncestors", m.ManagementGroupAncestors)
	populate(objectMap, "managementGroupAncestorsChain", m.ManagementGroupAncestorsChain)
	populate(objectMap, "parent", m.Parent)
	populate(objectMap, "path", m.Path)
	populate(objectMap, "updatedBy", m.UpdatedBy)
	populate(objectMap, "updatedTime", (*timeRFC3339)(m.UpdatedTime))
	populate(objectMap, "version", m.Version)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type ManagementGroupDetails.
func (m *ManagementGroupDetails) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return err
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "managementGroupAncestors":
			err = unpopulate(val, &m.ManagementGroupAncestors)
			delete(rawMsg, key)
		case "managementGroupAncestorsChain":
			err = unpopulate(val, &m.ManagementGroupAncestorsChain)
			delete(rawMsg, key)
		case "parent":
			err = unpopulate(val, &m.Parent)
			delete(rawMsg, key)
		case "path":
			err = unpopulate(val, &m.Path)
			delete(rawMsg, key)
		case "updatedBy":
			err = unpopulate(val, &m.UpdatedBy)
			delete(rawMsg, key)
		case "updatedTime":
			var aux timeRFC3339
			err = unpopulate(val, &aux)
			m.UpdatedTime = (*time.Time)(&aux)
			delete(rawMsg, key)
		case "version":
			err = unpopulate(val, &m.Version)
			delete(rawMsg, key)
		}
		if err != nil {
			return err
		}
	}
	return nil
}

// ManagementGroupInfo - The management group resource.
type ManagementGroupInfo struct {
	// The generic properties of a management group.
	Properties *ManagementGroupInfoProperties `json:"properties,omitempty"`

	// READ-ONLY; The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
	ID *string `json:"id,omitempty" azure:"ro"`

	// READ-ONLY; The name of the management group. For example, 00000000-0000-0000-0000-000000000000
	Name *string `json:"name,omitempty" azure:"ro"`

	// READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups
	Type *string `json:"type,omitempty" azure:"ro"`
}

// ManagementGroupInfoProperties - The generic properties of a management group.
type ManagementGroupInfoProperties struct {
	// The friendly name of the management group.
	DisplayName *string `json:"displayName,omitempty"`

	// The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000
	TenantID *string `json:"tenantId,omitempty"`
}

// ManagementGroupListResult - Describes the result of the request to list management groups.
type ManagementGroupListResult struct {
	// The list of management groups.
	Value []*ManagementGroupInfo `json:"value,omitempty"`

	// READ-ONLY; The URL to use for getting the next set of results.
	NextLink *string `json:"nextLink,omitempty" azure:"ro"`
}

// MarshalJSON implements the json.Marshaller interface for type ManagementGroupListResult.
func (m ManagementGroupListResult) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "nextLink", m.NextLink)
	populate(objectMap, "value", m.Value)
	return json.Marshal(objectMap)
}

// ManagementGroupPathElement - A path element of a management group ancestors.
type ManagementGroupPathElement struct {
	// The friendly name of the group.
	DisplayName *string `json:"displayName,omitempty"`

	// The name of the group.
	Name *string `json:"name,omitempty"`
}

// ManagementGroupProperties - The generic properties of a management group.
type ManagementGroupProperties struct {
	// The list of children.
	Children []*ManagementGroupChildInfo `json:"children,omitempty"`

	// The details of a management group.
	Details *ManagementGroupDetails `json:"details,omitempty"`

	// The friendly name of the management group.
	DisplayName *string `json:"displayName,omitempty"`

	// The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000
	TenantID *string `json:"tenantId,omitempty"`
}

// MarshalJSON implements the json.Marshaller interface for type ManagementGroupProperties.
func (m ManagementGroupProperties) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "children", m.Children)
	populate(objectMap, "details", m.Details)
	populate(objectMap, "displayName", m.DisplayName)
	populate(objectMap, "tenantId", m.TenantID)
	return json.Marshal(objectMap)
}

// ManagementGroupSubscriptionsCreateOptions contains the optional parameters for the ManagementGroupSubscriptions.Create method.
type ManagementGroupSubscriptionsCreateOptions struct {
	// Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches.
	CacheControl *string
}

// ManagementGroupSubscriptionsDeleteOptions contains the optional parameters for the ManagementGroupSubscriptions.Delete method.
type ManagementGroupSubscriptionsDeleteOptions struct {
	// Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches.
	CacheControl *string
}

// ManagementGroupSubscriptionsGetSubscriptionOptions contains the optional parameters for the ManagementGroupSubscriptions.GetSubscription method.
type ManagementGroupSubscriptionsGetSubscriptionOptions struct {
	// Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches.
	CacheControl *string
}

// ManagementGroupSubscriptionsGetSubscriptionsUnderManagementGroupOptions contains the optional parameters for the ManagementGroupSubscriptions.GetSubscriptionsUnderManagementGroup
// method.
type ManagementGroupSubscriptionsGetSubscriptionsUnderManagementGroupOptions struct {
	// 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.
	Skiptoken *string
}

// ManagementGroupsAPICheckNameAvailabilityOptions contains the optional parameters for the ManagementGroupsAPI.CheckNameAvailability method.
type ManagementGroupsAPICheckNameAvailabilityOptions struct {
	// placeholder for future optional parameters
}

// ManagementGroupsAPIStartTenantBackfillOptions contains the optional parameters for the ManagementGroupsAPI.StartTenantBackfill method.
type ManagementGroupsAPIStartTenantBackfillOptions struct {
	// placeholder for future optional parameters
}

// ManagementGroupsAPITenantBackfillStatusOptions contains the optional parameters for the ManagementGroupsAPI.TenantBackfillStatus method.
type ManagementGroupsAPITenantBackfillStatusOptions struct {
	// placeholder for future optional parameters
}

// ManagementGroupsBeginCreateOrUpdateOptions contains the optional parameters for the ManagementGroups.BeginCreateOrUpdate method.
type ManagementGroupsBeginCreateOrUpdateOptions struct {
	// Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches.
	CacheControl *string
}

// ManagementGroupsBeginDeleteOptions contains the optional parameters for the ManagementGroups.BeginDelete method.
type ManagementGroupsBeginDeleteOptions struct {
	// Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches.
	CacheControl *string
}

// ManagementGroupsGetDescendantsOptions contains the optional parameters for the ManagementGroups.GetDescendants method.
type ManagementGroupsGetDescendantsOptions struct {
	// 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.
	Skiptoken *string
	// Number of elements to return when retrieving results. Passing this in will override $skipToken.
	Top *int32
}

// ManagementGroupsGetOptions contains the optional parameters for the ManagementGroups.Get method.
type ManagementGroupsGetOptions struct {
	// Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches.
	CacheControl *string
	// The $expand=children query string parameter allows clients to request inclusion of children in the response payload. $expand=path includes the path from
	// the root group to the current group. $expand=ancestors includes the ancestor Ids of the current group.
	Expand *Enum0
	// A filter which allows the exclusion of subscriptions from results (i.e. '$filter=children.childType ne Subscription')
	Filter *string
	// The $recurse=true query string parameter allows clients to request inclusion of entire hierarchy in the response payload. Note that $expand=children
	// must be passed up if $recurse is set to true.
	Recurse *bool
}

// ManagementGroupsListOptions contains the optional parameters for the ManagementGroups.List method.
type ManagementGroupsListOptions struct {
	// Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches.
	CacheControl *string
	// 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.
	Skiptoken *string
}

// ManagementGroupsUpdateOptions contains the optional parameters for the ManagementGroups.Update method.
type ManagementGroupsUpdateOptions struct {
	// Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches.
	CacheControl *string
}

// Operation supported by the Microsoft.Management resource provider.
type Operation struct {
	// The object that represents the operation.
	Display *OperationDisplayProperties `json:"display,omitempty"`

	// READ-ONLY; Operation name: {provider}/{resource}/{operation}.
	Name *string `json:"name,omitempty" azure:"ro"`
}

// OperationDisplayProperties - The object that represents the operation.
type OperationDisplayProperties struct {
	// READ-ONLY; Operation description.
	Description *string `json:"description,omitempty" azure:"ro"`

	// READ-ONLY; The operation that can be performed.
	Operation *string `json:"operation,omitempty" azure:"ro"`

	// READ-ONLY; The name of the provider.
	Provider *string `json:"provider,omitempty" azure:"ro"`

	// READ-ONLY; The resource on which the operation is performed.
	Resource *string `json:"resource,omitempty" azure:"ro"`
}

// OperationListResult - Describes the result of the request to list Microsoft.Management operations.
type OperationListResult struct {
	// READ-ONLY; URL to get the next set of operation list results if there are any.
	NextLink *string `json:"nextLink,omitempty" azure:"ro"`

	// READ-ONLY; List of operations supported by the Microsoft.Management resource provider.
	Value []*Operation `json:"value,omitempty" azure:"ro"`
}

// MarshalJSON implements the json.Marshaller interface for type OperationListResult.
func (o OperationListResult) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "nextLink", o.NextLink)
	populate(objectMap, "value", o.Value)
	return json.Marshal(objectMap)
}

// OperationResults - The results of an asynchronous operation.
type OperationResults struct {
	// The generic properties of a management group.
	Properties *ManagementGroupInfoProperties `json:"properties,omitempty"`

	// READ-ONLY; The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
	ID *string `json:"id,omitempty" azure:"ro"`

	// READ-ONLY; The name of the management group. For example, 00000000-0000-0000-0000-000000000000
	Name *string `json:"name,omitempty" azure:"ro"`

	// READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups
	Type *string `json:"type,omitempty" azure:"ro"`
}

// OperationsListOptions contains the optional parameters for the Operations.List method.
type OperationsListOptions struct {
	// placeholder for future optional parameters
}

// ParentGroupInfo - (Optional) The ID of the parent management group.
type ParentGroupInfo struct {
	// The friendly name of the parent management group.
	DisplayName *string `json:"displayName,omitempty"`

	// The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
	ID *string `json:"id,omitempty"`

	// The name of the parent management group
	Name *string `json:"name,omitempty"`
}

// PatchManagementGroupRequest - Management group patch parameters.
type PatchManagementGroupRequest struct {
	// The friendly name of the management group.
	DisplayName *string `json:"displayName,omitempty"`

	// (Optional) The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
	ParentGroupID *string `json:"parentGroupId,omitempty"`
}

// MarshalJSON implements the json.Marshaller interface for type PatchManagementGroupRequest.
func (p PatchManagementGroupRequest) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	populate(objectMap, "displayName", p.DisplayName)
	populate(objectMap, "parentGroupId", p.ParentGroupID)
	return json.Marshal(objectMap)
}

// SubscriptionUnderManagementGroup - The details of subscription under management group.
type SubscriptionUnderManagementGroup struct {
	// The generic properties of subscription under a management group.
	Properties *SubscriptionUnderManagementGroupProperties `json:"properties,omitempty"`

	// READ-ONLY; The fully qualified ID for the subscription. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000/subscriptions/0000000-0000-0000-0000-000000000001
	ID *string `json:"id,omitempty" azure:"ro"`

	// READ-ONLY; The stringified id of the subscription. For example, 00000000-0000-0000-0000-000000000000
	Name *string `json:"name,omitempty" azure:"ro"`

	// READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups/subscriptions
	Type *string `json:"type,omitempty" azure:"ro"`
}

// SubscriptionUnderManagementGroupProperties - The generic properties of subscription under a management group.
type SubscriptionUnderManagementGroupProperties struct {
	// The friendly name of the subscription.
	DisplayName *string `json:"displayName,omitempty"`

	// The ID of the parent management group.
	Parent *DescendantParentGroupInfo `json:"parent,omitempty"`

	// The state of the subscription.
	State *string `json:"state,omitempty"`

	// The AAD Tenant ID associated with the subscription. For example, 00000000-0000-0000-0000-000000000000
	Tenant *string `json:"tenant,omitempty"`
}

// TenantBackfillStatusResult - The tenant backfill status
type TenantBackfillStatusResult struct {
	// READ-ONLY; The status of the Tenant Backfill
	Status *Status `json:"status,omitempty" azure:"ro"`

	// READ-ONLY; The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000
	TenantID *string `json:"tenantId,omitempty" azure:"ro"`
}

func populate(m map[string]interface{}, k string, v interface{}) {
	if v == nil {
		return
	} else if azcore.IsNullValue(v) {
		m[k] = nil
	} else if !reflect.ValueOf(v).IsNil() {
		m[k] = v
	}
}

func unpopulate(data json.RawMessage, v interface{}) error {
	if data == nil {
		return nil
	}
	return json.Unmarshal(data, v)
}
