func()

in deployment/managementgroup.go [575:616]


func (mg HierarchyManagementGroup) MarshalJSON() ([]byte, error) {
	type marshalHierarchyManagementGroup struct {
		Children              []string                               `json:"children,omitempty"`                // The ids of the children of the management group.
		DisplayName           string                                 `json:"display_name,omitempty"`            // The display name of the management group.
		Exists                bool                                   `json:"exists,omitempty"`                  // Whether the management group already exists in the hierarchy.
		Id                    string                                 `json:"id,omitempty"`                      // The name of the management group, forming the last part of the resource id.
		Level                 int                                    `json:"level,omitempty"`                   // The level of the management group in the hierarchy.
		Location              string                                 `json:"location,omitempty"`                // The default location to use for artifacts in the management group.
		Parent                *string                                `json:"parent,omitempty"`                  // The id of the parent management group.
		PolicyAssignments     map[string]*assets.PolicyAssignment    `json:"policy_assignments,omitempty"`      // The policy assignments in the management group.
		PolicyDefinitions     map[string]*assets.PolicyDefinition    `json:"policy_definitions,omitempty"`      // The policy definitions in the management group.
		PolicyRoleAssignments []PolicyRoleAssignment                 `json:"policy_role_assignments,omitempty"` // The additional role assignments needed for the policy assignments.
		PolicySetDefinitions  map[string]*assets.PolicySetDefinition `json:"policy_set_definitions,omitempty"`  // The policy set definitions in the management group.
		RoleDefinitions       map[string]*assets.RoleDefinition      `json:"role_definitions,omitempty"`        // The role definitions in the management group.
	}
	childrenIds := make([]string, mg.children.Cardinality())
	for i, child := range mg.children.ToSlice() {
		childrenIds[i] = child.id
	}
	var parentId *string
	switch {
	case mg.parentExternal != nil:
		parentId = mg.parentExternal
	case mg.parent != nil:
		parentId = &mg.parent.id
	}
	tmp := marshalHierarchyManagementGroup{
		Children:              childrenIds,
		DisplayName:           mg.displayName,
		Exists:                mg.exists,
		Id:                    mg.id,
		Level:                 mg.level,
		Location:              mg.location,
		Parent:                parentId,
		PolicyAssignments:     mg.policyAssignments,
		PolicyDefinitions:     mg.policyDefinitions,
		PolicyRoleAssignments: mg.policyRoleAssignments.ToSlice(),
		PolicySetDefinitions:  mg.policySetDefinitions,
		RoleDefinitions:       mg.roleDefinitions,
	}
	return json.Marshal(tmp)
}