예제 #1
0
 internal NetworkProfile(ResourceIdentifier serviceRuntimeSubnetId, ResourceIdentifier appSubnetId, string serviceCidr, string serviceRuntimeNetworkResourceGroup, string appNetworkResourceGroup, NetworkProfileOutboundIPs outboundIPs, IReadOnlyList <RequiredTraffic> requiredTraffics)
 {
     ServiceRuntimeSubnetId             = serviceRuntimeSubnetId;
     AppSubnetId                        = appSubnetId;
     ServiceCidr                        = serviceCidr;
     ServiceRuntimeNetworkResourceGroup = serviceRuntimeNetworkResourceGroup;
     AppNetworkResourceGroup            = appNetworkResourceGroup;
     OutboundIPs                        = outboundIPs;
     RequiredTraffics                   = requiredTraffics;
 }
예제 #2
0
        internal static NetworkProfile DeserializeNetworkProfile(JsonElement element)
        {
            Optional <ResourceIdentifier>               serviceRuntimeSubnetId             = default;
            Optional <ResourceIdentifier>               appSubnetId                        = default;
            Optional <string>                           serviceCidr                        = default;
            Optional <string>                           serviceRuntimeNetworkResourceGroup = default;
            Optional <string>                           appNetworkResourceGroup            = default;
            Optional <NetworkProfileOutboundIPs>        outboundIPs                        = default;
            Optional <IReadOnlyList <RequiredTraffic> > requiredTraffics                   = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("serviceRuntimeSubnetId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    serviceRuntimeSubnetId = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("appSubnetId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    appSubnetId = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("serviceCidr"))
                {
                    serviceCidr = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("serviceRuntimeNetworkResourceGroup"))
                {
                    serviceRuntimeNetworkResourceGroup = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("appNetworkResourceGroup"))
                {
                    appNetworkResourceGroup = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("outboundIPs"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    outboundIPs = NetworkProfileOutboundIPs.DeserializeNetworkProfileOutboundIPs(property.Value);
                    continue;
                }
                if (property.NameEquals("requiredTraffics"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <RequiredTraffic> array = new List <RequiredTraffic>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(RequiredTraffic.DeserializeRequiredTraffic(item));
                    }
                    requiredTraffics = array;
                    continue;
                }
            }
            return(new NetworkProfile(serviceRuntimeSubnetId.Value, appSubnetId.Value, serviceCidr.Value, serviceRuntimeNetworkResourceGroup.Value, appNetworkResourceGroup.Value, outboundIPs.Value, Optional.ToList(requiredTraffics)));
        }