internal ManagementGroupDetails(int?version, DateTimeOffset?updatedTime, string updatedBy, ParentGroupInfo parent, IReadOnlyList <ManagementGroupPathElement> path, IReadOnlyList <string> managementGroupAncestors, IReadOnlyList <ManagementGroupPathElement> managementGroupAncestorsChain)
 {
     Version     = version;
     UpdatedTime = updatedTime;
     UpdatedBy   = updatedBy;
     Parent      = parent;
     Path        = path;
     ManagementGroupAncestors      = managementGroupAncestors;
     ManagementGroupAncestorsChain = managementGroupAncestorsChain;
 }
Esempio n. 2
0
        internal static ManagementGroupDetails DeserializeManagementGroupDetails(JsonElement element)
        {
            Optional <int>             version     = default;
            Optional <DateTimeOffset>  updatedTime = default;
            Optional <string>          updatedBy   = default;
            Optional <ParentGroupInfo> parent      = default;
            Optional <IReadOnlyList <ManagementGroupPathElement> > path = default;
            Optional <IReadOnlyList <string> > managementGroupAncestors = default;
            Optional <IReadOnlyList <ManagementGroupPathElement> > managementGroupAncestorsChain = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("version"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    version = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("updatedTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    updatedTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("updatedBy"))
                {
                    updatedBy = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("parent"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    parent = ParentGroupInfo.DeserializeParentGroupInfo(property.Value);
                    continue;
                }
                if (property.NameEquals("path"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        path = null;
                        continue;
                    }
                    List <ManagementGroupPathElement> array = new List <ManagementGroupPathElement>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ManagementGroupPathElement.DeserializeManagementGroupPathElement(item));
                    }
                    path = array;
                    continue;
                }
                if (property.NameEquals("managementGroupAncestors"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        managementGroupAncestors = null;
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    managementGroupAncestors = array;
                    continue;
                }
                if (property.NameEquals("managementGroupAncestorsChain"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        managementGroupAncestorsChain = null;
                        continue;
                    }
                    List <ManagementGroupPathElement> array = new List <ManagementGroupPathElement>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ManagementGroupPathElement.DeserializeManagementGroupPathElement(item));
                    }
                    managementGroupAncestorsChain = array;
                    continue;
                }
            }
            return(new ManagementGroupDetails(Optional.ToNullable(version), Optional.ToNullable(updatedTime), updatedBy.Value, parent.Value, Optional.ToList(path), Optional.ToList(managementGroupAncestors), Optional.ToList(managementGroupAncestorsChain)));
        }