internal ManagementGroupData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, Guid?tenantId, string displayName, ManagementGroupInfo details, IReadOnlyList <ManagementGroupChildInfo> children) : base(id, name, resourceType, systemData)
 {
     TenantId    = tenantId;
     DisplayName = displayName;
     Details     = details;
     Children    = children;
 }
 public PSManagementGroupInfo(ManagementGroupInfo managementGroupInfo)
 {
     if (managementGroupInfo != null)
     {
         Id          = managementGroupInfo.Id;
         Type        = managementGroupInfo.Type;
         Name        = managementGroupInfo.Name;
         TenantId    = managementGroupInfo.TenantId;
         DisplayName = managementGroupInfo.DisplayName;
     }
 }
Example #3
0
        public async Task List()
        {
            var mgmtGroupContainer        = Client.GetManagementGroups();
            ManagementGroupInfo mgmtGroup = null;

            await foreach (var item in mgmtGroupContainer.ListAsync("no-cache"))
            {
                mgmtGroup = item;
                break;
            }
            Assert.IsNotNull(mgmtGroup, "No management groups found in list");
            Assert.IsNotNull(mgmtGroup.Data.DisplayName, "DisplayName was null");
            Assert.IsNotNull(mgmtGroup.Data.Id, "Id was null");
            Assert.IsNotNull(mgmtGroup.Data.Name, "Name was null");
            Assert.IsNotNull(mgmtGroup.Data.TenantId, "TenantId was null");
            Assert.IsNotNull(mgmtGroup.Data.Type, "Type was null");
        }
Example #4
0
        internal static ManagementGroupData DeserializeManagementGroupData(JsonElement element)
        {
            ResourceIdentifier             id          = default;
            string                         name        = default;
            ResourceType                   type        = default;
            SystemData                     systemData  = default;
            Optional <Guid>                tenantId    = default;
            Optional <string>              displayName = default;
            Optional <ManagementGroupInfo> details     = default;
            Optional <IReadOnlyList <ManagementGroupChildInfo> > children = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = new ResourceType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("systemData"))
                {
                    systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString());
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("tenantId"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            tenantId = property0.Value.GetGuid();
                            continue;
                        }
                        if (property0.NameEquals("displayName"))
                        {
                            displayName = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("details"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            details = ManagementGroupInfo.DeserializeManagementGroupInfo(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("children"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                children = null;
                                continue;
                            }
                            List <ManagementGroupChildInfo> array = new List <ManagementGroupChildInfo>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ManagementGroupChildInfo.DeserializeManagementGroupChildInfo(item));
                            }
                            children = array;
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new ManagementGroupData(id, name, type, systemData, Optional.ToNullable(tenantId), displayName.Value, details.Value, Optional.ToList(children)));
        }