示例#1
0
        internal static ContainerGroupData DeserializeContainerGroupData(JsonElement element)
        {
            Optional <ManagedServiceIdentity> identity = default;
            Optional <IList <string> >        zones    = default;
            IDictionary <string, string>      tags     = default;
            AzureLocation      location          = default;
            ResourceIdentifier id                = default;
            string             name              = default;
            ResourceType       type              = default;
            SystemData         systemData        = default;
            Optional <string>  provisioningState = default;
            IList <ContainerInstanceContainer>          containers = default;
            Optional <IList <ImageRegistryCredential> > imageRegistryCredentials = default;
            Optional <ContainerGroupRestartPolicy>      restartPolicy            = default;
            Optional <IPAddress> ipAddress = default;
            OperatingSystemTypes osType    = default;
            Optional <IList <ContainerInstanceVolume> >     volumes                 = default;
            Optional <ContainerGroupPropertiesInstanceView> instanceView            = default;
            Optional <ContainerGroupDiagnostics>            diagnostics             = default;
            Optional <IList <ContainerGroupSubnetId> >      subnetIds               = default;
            Optional <DnsConfiguration>                        dnsConfig            = default;
            Optional <ContainerGroupSku>                       sku                  = default;
            Optional <Models.EncryptionProperties>             encryptionProperties = default;
            Optional <IList <InitContainerDefinitionContent> > initContainers       = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("identity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    identity = JsonSerializer.Deserialize <ManagedServiceIdentity>(property.Value.ToString());
                    continue;
                }
                if (property.NameEquals("zones"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    zones = array;
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    tags = dictionary;
                    continue;
                }
                if (property.NameEquals("location"))
                {
                    location = new AzureLocation(property.Value.GetString());
                    continue;
                }
                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("provisioningState"))
                        {
                            provisioningState = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("containers"))
                        {
                            List <ContainerInstanceContainer> array = new List <ContainerInstanceContainer>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ContainerInstanceContainer.DeserializeContainerInstanceContainer(item));
                            }
                            containers = array;
                            continue;
                        }
                        if (property0.NameEquals("imageRegistryCredentials"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ImageRegistryCredential> array = new List <ImageRegistryCredential>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ImageRegistryCredential.DeserializeImageRegistryCredential(item));
                            }
                            imageRegistryCredentials = array;
                            continue;
                        }
                        if (property0.NameEquals("restartPolicy"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            restartPolicy = new ContainerGroupRestartPolicy(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("ipAddress"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            ipAddress = IPAddress.DeserializeIPAddress(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("osType"))
                        {
                            osType = new OperatingSystemTypes(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("volumes"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ContainerInstanceVolume> array = new List <ContainerInstanceVolume>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ContainerInstanceVolume.DeserializeContainerInstanceVolume(item));
                            }
                            volumes = array;
                            continue;
                        }
                        if (property0.NameEquals("instanceView"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            instanceView = ContainerGroupPropertiesInstanceView.DeserializeContainerGroupPropertiesInstanceView(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("diagnostics"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            diagnostics = ContainerGroupDiagnostics.DeserializeContainerGroupDiagnostics(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("subnetIds"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ContainerGroupSubnetId> array = new List <ContainerGroupSubnetId>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ContainerGroupSubnetId.DeserializeContainerGroupSubnetId(item));
                            }
                            subnetIds = array;
                            continue;
                        }
                        if (property0.NameEquals("dnsConfig"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            dnsConfig = DnsConfiguration.DeserializeDnsConfiguration(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("sku"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            sku = new ContainerGroupSku(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("encryptionProperties"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            encryptionProperties = Models.EncryptionProperties.DeserializeEncryptionProperties(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("initContainers"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <InitContainerDefinitionContent> array = new List <InitContainerDefinitionContent>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(InitContainerDefinitionContent.DeserializeInitContainerDefinitionContent(item));
                            }
                            initContainers = array;
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new ContainerGroupData(id, name, type, systemData, tags, location, Optional.ToList(zones), identity, provisioningState.Value, containers, Optional.ToList(imageRegistryCredentials), Optional.ToNullable(restartPolicy), ipAddress.Value, osType, Optional.ToList(volumes), instanceView.Value, diagnostics.Value, Optional.ToList(subnetIds), dnsConfig.Value, Optional.ToNullable(sku), encryptionProperties.Value, Optional.ToList(initContainers)));
        }