예제 #1
0
        internal static ApplicationGatewayData DeserializeApplicationGatewayData(JsonElement element)
        {
            Optional <string>           etag     = default;
            Optional <IList <string> >  zones    = default;
            Optional <ResourceIdentity> identity = default;
            Optional <string>           id       = default;
            Optional <string>           name     = default;
            Optional <string>           type     = default;
            Optional <string>           location = default;
            Optional <IDictionary <string, string> >                         tags                                = default;
            Optional <ApplicationGatewaySku>                                 sku                                 = default;
            Optional <ApplicationGatewaySslPolicy>                           sslPolicy                           = default;
            Optional <ApplicationGatewayOperationalState>                    operationalState                    = default;
            Optional <IList <ApplicationGatewayIPConfiguration> >            gatewayIPConfigurations             = default;
            Optional <IList <ApplicationGatewayAuthenticationCertificate> >  authenticationCertificates          = default;
            Optional <IList <ApplicationGatewayTrustedRootCertificate> >     trustedRootCertificates             = default;
            Optional <IList <ApplicationGatewayTrustedClientCertificate> >   trustedClientCertificates           = default;
            Optional <IList <ApplicationGatewaySslCertificate> >             sslCertificates                     = default;
            Optional <IList <ApplicationGatewayFrontendIPConfiguration> >    frontendIPConfigurations            = default;
            Optional <IList <ApplicationGatewayFrontendPort> >               frontendPorts                       = default;
            Optional <IList <ApplicationGatewayProbe> >                      probes                              = default;
            Optional <IList <ApplicationGatewayBackendAddressPool> >         backendAddressPools                 = default;
            Optional <IList <ApplicationGatewayBackendHttpSettings> >        backendHttpSettingsCollection       = default;
            Optional <IList <ApplicationGatewayHttpListener> >               httpListeners                       = default;
            Optional <IList <ApplicationGatewaySslProfile> >                 sslProfiles                         = default;
            Optional <IList <ApplicationGatewayUrlPathMap> >                 urlPathMaps                         = default;
            Optional <IList <ApplicationGatewayRequestRoutingRule> >         requestRoutingRules                 = default;
            Optional <IList <ApplicationGatewayRewriteRuleSet> >             rewriteRuleSets                     = default;
            Optional <IList <ApplicationGatewayRedirectConfiguration> >      redirectConfigurations              = default;
            Optional <ApplicationGatewayWebApplicationFirewallConfiguration> webApplicationFirewallConfiguration = default;
            Optional <WritableSubResource> firewallPolicy = default;
            Optional <bool> enableHttp2 = default;
            Optional <bool> enableFips  = default;
            Optional <ApplicationGatewayAutoscaleConfiguration>            autoscaleConfiguration    = default;
            Optional <IList <ApplicationGatewayPrivateLinkConfiguration> > privateLinkConfigurations = default;
            Optional <IReadOnlyList <ApplicationGatewayPrivateEndpointConnectionData> > privateEndpointConnections = default;
            Optional <string>            resourceGuid      = default;
            Optional <ProvisioningState> provisioningState = default;
            Optional <IList <ApplicationGatewayCustomError> > customErrorConfigurations = default;
            Optional <bool> forceFirewallPolicyAssociation = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("etag"))
                {
                    etag = property.Value.GetString();
                    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("identity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    identity = JsonSerializer.Deserialize <ResourceIdentity>(property.Value.ToString());
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("location"))
                {
                    location = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    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("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("sku"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            sku = ApplicationGatewaySku.DeserializeApplicationGatewaySku(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("sslPolicy"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            sslPolicy = ApplicationGatewaySslPolicy.DeserializeApplicationGatewaySslPolicy(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("operationalState"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            operationalState = new ApplicationGatewayOperationalState(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("gatewayIPConfigurations"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ApplicationGatewayIPConfiguration> array = new List <ApplicationGatewayIPConfiguration>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ApplicationGatewayIPConfiguration.DeserializeApplicationGatewayIPConfiguration(item));
                            }
                            gatewayIPConfigurations = array;
                            continue;
                        }
                        if (property0.NameEquals("authenticationCertificates"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ApplicationGatewayAuthenticationCertificate> array = new List <ApplicationGatewayAuthenticationCertificate>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ApplicationGatewayAuthenticationCertificate.DeserializeApplicationGatewayAuthenticationCertificate(item));
                            }
                            authenticationCertificates = array;
                            continue;
                        }
                        if (property0.NameEquals("trustedRootCertificates"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ApplicationGatewayTrustedRootCertificate> array = new List <ApplicationGatewayTrustedRootCertificate>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ApplicationGatewayTrustedRootCertificate.DeserializeApplicationGatewayTrustedRootCertificate(item));
                            }
                            trustedRootCertificates = array;
                            continue;
                        }
                        if (property0.NameEquals("trustedClientCertificates"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ApplicationGatewayTrustedClientCertificate> array = new List <ApplicationGatewayTrustedClientCertificate>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ApplicationGatewayTrustedClientCertificate.DeserializeApplicationGatewayTrustedClientCertificate(item));
                            }
                            trustedClientCertificates = array;
                            continue;
                        }
                        if (property0.NameEquals("sslCertificates"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ApplicationGatewaySslCertificate> array = new List <ApplicationGatewaySslCertificate>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ApplicationGatewaySslCertificate.DeserializeApplicationGatewaySslCertificate(item));
                            }
                            sslCertificates = array;
                            continue;
                        }
                        if (property0.NameEquals("frontendIPConfigurations"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ApplicationGatewayFrontendIPConfiguration> array = new List <ApplicationGatewayFrontendIPConfiguration>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ApplicationGatewayFrontendIPConfiguration.DeserializeApplicationGatewayFrontendIPConfiguration(item));
                            }
                            frontendIPConfigurations = array;
                            continue;
                        }
                        if (property0.NameEquals("frontendPorts"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ApplicationGatewayFrontendPort> array = new List <ApplicationGatewayFrontendPort>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ApplicationGatewayFrontendPort.DeserializeApplicationGatewayFrontendPort(item));
                            }
                            frontendPorts = array;
                            continue;
                        }
                        if (property0.NameEquals("probes"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ApplicationGatewayProbe> array = new List <ApplicationGatewayProbe>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ApplicationGatewayProbe.DeserializeApplicationGatewayProbe(item));
                            }
                            probes = array;
                            continue;
                        }
                        if (property0.NameEquals("backendAddressPools"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ApplicationGatewayBackendAddressPool> array = new List <ApplicationGatewayBackendAddressPool>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ApplicationGatewayBackendAddressPool.DeserializeApplicationGatewayBackendAddressPool(item));
                            }
                            backendAddressPools = array;
                            continue;
                        }
                        if (property0.NameEquals("backendHttpSettingsCollection"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ApplicationGatewayBackendHttpSettings> array = new List <ApplicationGatewayBackendHttpSettings>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ApplicationGatewayBackendHttpSettings.DeserializeApplicationGatewayBackendHttpSettings(item));
                            }
                            backendHttpSettingsCollection = array;
                            continue;
                        }
                        if (property0.NameEquals("httpListeners"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ApplicationGatewayHttpListener> array = new List <ApplicationGatewayHttpListener>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ApplicationGatewayHttpListener.DeserializeApplicationGatewayHttpListener(item));
                            }
                            httpListeners = array;
                            continue;
                        }
                        if (property0.NameEquals("sslProfiles"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ApplicationGatewaySslProfile> array = new List <ApplicationGatewaySslProfile>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ApplicationGatewaySslProfile.DeserializeApplicationGatewaySslProfile(item));
                            }
                            sslProfiles = array;
                            continue;
                        }
                        if (property0.NameEquals("urlPathMaps"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ApplicationGatewayUrlPathMap> array = new List <ApplicationGatewayUrlPathMap>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ApplicationGatewayUrlPathMap.DeserializeApplicationGatewayUrlPathMap(item));
                            }
                            urlPathMaps = array;
                            continue;
                        }
                        if (property0.NameEquals("requestRoutingRules"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ApplicationGatewayRequestRoutingRule> array = new List <ApplicationGatewayRequestRoutingRule>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ApplicationGatewayRequestRoutingRule.DeserializeApplicationGatewayRequestRoutingRule(item));
                            }
                            requestRoutingRules = array;
                            continue;
                        }
                        if (property0.NameEquals("rewriteRuleSets"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ApplicationGatewayRewriteRuleSet> array = new List <ApplicationGatewayRewriteRuleSet>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ApplicationGatewayRewriteRuleSet.DeserializeApplicationGatewayRewriteRuleSet(item));
                            }
                            rewriteRuleSets = array;
                            continue;
                        }
                        if (property0.NameEquals("redirectConfigurations"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ApplicationGatewayRedirectConfiguration> array = new List <ApplicationGatewayRedirectConfiguration>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ApplicationGatewayRedirectConfiguration.DeserializeApplicationGatewayRedirectConfiguration(item));
                            }
                            redirectConfigurations = array;
                            continue;
                        }
                        if (property0.NameEquals("webApplicationFirewallConfiguration"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            webApplicationFirewallConfiguration = ApplicationGatewayWebApplicationFirewallConfiguration.DeserializeApplicationGatewayWebApplicationFirewallConfiguration(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("firewallPolicy"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            firewallPolicy = JsonSerializer.Deserialize <WritableSubResource>(property0.Value.ToString());
                            continue;
                        }
                        if (property0.NameEquals("enableHttp2"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            enableHttp2 = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("enableFips"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            enableFips = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("autoscaleConfiguration"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            autoscaleConfiguration = ApplicationGatewayAutoscaleConfiguration.DeserializeApplicationGatewayAutoscaleConfiguration(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("privateLinkConfigurations"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ApplicationGatewayPrivateLinkConfiguration> array = new List <ApplicationGatewayPrivateLinkConfiguration>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ApplicationGatewayPrivateLinkConfiguration.DeserializeApplicationGatewayPrivateLinkConfiguration(item));
                            }
                            privateLinkConfigurations = array;
                            continue;
                        }
                        if (property0.NameEquals("privateEndpointConnections"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ApplicationGatewayPrivateEndpointConnectionData> array = new List <ApplicationGatewayPrivateEndpointConnectionData>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ApplicationGatewayPrivateEndpointConnectionData.DeserializeApplicationGatewayPrivateEndpointConnectionData(item));
                            }
                            privateEndpointConnections = array;
                            continue;
                        }
                        if (property0.NameEquals("resourceGuid"))
                        {
                            resourceGuid = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("provisioningState"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            provisioningState = new ProvisioningState(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("customErrorConfigurations"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ApplicationGatewayCustomError> array = new List <ApplicationGatewayCustomError>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ApplicationGatewayCustomError.DeserializeApplicationGatewayCustomError(item));
                            }
                            customErrorConfigurations = array;
                            continue;
                        }
                        if (property0.NameEquals("forceFirewallPolicyAssociation"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            forceFirewallPolicyAssociation = property0.Value.GetBoolean();
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new ApplicationGatewayData(id.Value, name.Value, type.Value, location.Value, Optional.ToDictionary(tags), etag.Value, Optional.ToList(zones), identity, sku.Value, sslPolicy.Value, Optional.ToNullable(operationalState), Optional.ToList(gatewayIPConfigurations), Optional.ToList(authenticationCertificates), Optional.ToList(trustedRootCertificates), Optional.ToList(trustedClientCertificates), Optional.ToList(sslCertificates), Optional.ToList(frontendIPConfigurations), Optional.ToList(frontendPorts), Optional.ToList(probes), Optional.ToList(backendAddressPools), Optional.ToList(backendHttpSettingsCollection), Optional.ToList(httpListeners), Optional.ToList(sslProfiles), Optional.ToList(urlPathMaps), Optional.ToList(requestRoutingRules), Optional.ToList(rewriteRuleSets), Optional.ToList(redirectConfigurations), webApplicationFirewallConfiguration.Value, firewallPolicy, Optional.ToNullable(enableHttp2), Optional.ToNullable(enableFips), autoscaleConfiguration.Value, Optional.ToList(privateLinkConfigurations), Optional.ToList(privateEndpointConnections), resourceGuid.Value, Optional.ToNullable(provisioningState), Optional.ToList(customErrorConfigurations), Optional.ToNullable(forceFirewallPolicyAssociation)));
        }
예제 #2
0
        internal static SubnetData DeserializeSubnetData(JsonElement element)
        {
            Optional <string>                   name                                    = default;
            Optional <string>                   etag                                    = default;
            Optional <string>                   type                                    = default;
            Optional <string>                   id                                      = default;
            Optional <string>                   addressPrefix                           = default;
            Optional <IList <string> >          addressPrefixes                         = default;
            Optional <NetworkSecurityGroupData> networkSecurityGroup                    = default;
            Optional <RouteTableData>           routeTable                              = default;
            Optional <WritableSubResource>      natGateway                              = default;
            Optional <IList <ServiceEndpointPropertiesFormat> > serviceEndpoints        = default;
            Optional <IList <ServiceEndpointPolicyData> >       serviceEndpointPolicies = default;
            Optional <IReadOnlyList <PrivateEndpointData> >     privateEndpoints        = default;
            Optional <IReadOnlyList <IPConfiguration> >         ipConfigurations        = default;
            Optional <IReadOnlyList <IPConfigurationProfile> >  ipConfigurationProfiles = default;
            Optional <IList <WritableSubResource> >             ipAllocations           = default;
            Optional <IReadOnlyList <ResourceNavigationLink> >  resourceNavigationLinks = default;
            Optional <IReadOnlyList <ServiceAssociationLink> >  serviceAssociationLinks = default;
            Optional <IList <Delegation> > delegations                                  = default;
            Optional <string>            purpose           = default;
            Optional <ProvisioningState> provisioningState = default;
            Optional <VirtualNetworkPrivateEndpointNetworkPolicies>    privateEndpointNetworkPolicies     = default;
            Optional <VirtualNetworkPrivateLinkServiceNetworkPolicies> privateLinkServiceNetworkPolicies  = default;
            Optional <IList <ApplicationGatewayIPConfiguration> >      applicationGatewayIpConfigurations = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("etag"))
                {
                    etag = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("addressPrefix"))
                        {
                            addressPrefix = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("addressPrefixes"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <string> array = new List <string>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(item.GetString());
                            }
                            addressPrefixes = array;
                            continue;
                        }
                        if (property0.NameEquals("networkSecurityGroup"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            networkSecurityGroup = NetworkSecurityGroupData.DeserializeNetworkSecurityGroupData(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("routeTable"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            routeTable = RouteTableData.DeserializeRouteTableData(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("natGateway"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            natGateway = JsonSerializer.Deserialize <WritableSubResource>(property0.Value.ToString());
                            continue;
                        }
                        if (property0.NameEquals("serviceEndpoints"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ServiceEndpointPropertiesFormat> array = new List <ServiceEndpointPropertiesFormat>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ServiceEndpointPropertiesFormat.DeserializeServiceEndpointPropertiesFormat(item));
                            }
                            serviceEndpoints = array;
                            continue;
                        }
                        if (property0.NameEquals("serviceEndpointPolicies"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ServiceEndpointPolicyData> array = new List <ServiceEndpointPolicyData>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ServiceEndpointPolicyData.DeserializeServiceEndpointPolicyData(item));
                            }
                            serviceEndpointPolicies = array;
                            continue;
                        }
                        if (property0.NameEquals("privateEndpoints"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <PrivateEndpointData> array = new List <PrivateEndpointData>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(PrivateEndpointData.DeserializePrivateEndpointData(item));
                            }
                            privateEndpoints = array;
                            continue;
                        }
                        if (property0.NameEquals("ipConfigurations"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <IPConfiguration> array = new List <IPConfiguration>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(IPConfiguration.DeserializeIPConfiguration(item));
                            }
                            ipConfigurations = array;
                            continue;
                        }
                        if (property0.NameEquals("ipConfigurationProfiles"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <IPConfigurationProfile> array = new List <IPConfigurationProfile>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(IPConfigurationProfile.DeserializeIPConfigurationProfile(item));
                            }
                            ipConfigurationProfiles = array;
                            continue;
                        }
                        if (property0.NameEquals("ipAllocations"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <WritableSubResource> array = new List <WritableSubResource>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(JsonSerializer.Deserialize <WritableSubResource>(item.ToString()));
                            }
                            ipAllocations = array;
                            continue;
                        }
                        if (property0.NameEquals("resourceNavigationLinks"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ResourceNavigationLink> array = new List <ResourceNavigationLink>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ResourceNavigationLink.DeserializeResourceNavigationLink(item));
                            }
                            resourceNavigationLinks = array;
                            continue;
                        }
                        if (property0.NameEquals("serviceAssociationLinks"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ServiceAssociationLink> array = new List <ServiceAssociationLink>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ServiceAssociationLink.DeserializeServiceAssociationLink(item));
                            }
                            serviceAssociationLinks = array;
                            continue;
                        }
                        if (property0.NameEquals("delegations"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <Delegation> array = new List <Delegation>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(Delegation.DeserializeDelegation(item));
                            }
                            delegations = array;
                            continue;
                        }
                        if (property0.NameEquals("purpose"))
                        {
                            purpose = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("provisioningState"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            provisioningState = new ProvisioningState(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("privateEndpointNetworkPolicies"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            privateEndpointNetworkPolicies = new VirtualNetworkPrivateEndpointNetworkPolicies(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("privateLinkServiceNetworkPolicies"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            privateLinkServiceNetworkPolicies = new VirtualNetworkPrivateLinkServiceNetworkPolicies(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("applicationGatewayIpConfigurations"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ApplicationGatewayIPConfiguration> array = new List <ApplicationGatewayIPConfiguration>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ApplicationGatewayIPConfiguration.DeserializeApplicationGatewayIPConfiguration(item));
                            }
                            applicationGatewayIpConfigurations = array;
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new SubnetData(id.Value, name.Value, etag.Value, type.Value, addressPrefix.Value, Optional.ToList(addressPrefixes), networkSecurityGroup.Value, routeTable.Value, natGateway, Optional.ToList(serviceEndpoints), Optional.ToList(serviceEndpointPolicies), Optional.ToList(privateEndpoints), Optional.ToList(ipConfigurations), Optional.ToList(ipConfigurationProfiles), Optional.ToList(ipAllocations), Optional.ToList(resourceNavigationLinks), Optional.ToList(serviceAssociationLinks), Optional.ToList(delegations), purpose.Value, Optional.ToNullable(provisioningState), Optional.ToNullable(privateEndpointNetworkPolicies), Optional.ToNullable(privateLinkServiceNetworkPolicies), Optional.ToList(applicationGatewayIpConfigurations)));
        }
예제 #3
0
        protected ApplicationGateway CreateApplicationGateway(string rgName, Subnet subnet, string gatewayName = null)
        {
            gatewayName = gatewayName ?? ComputeManagementTestUtilities.GenerateName("gw");
            var gatewayIPConfigName     = ComputeManagementTestUtilities.GenerateName("gwIp");
            var frontendIPConfigName    = ComputeManagementTestUtilities.GenerateName("fIp");
            var frontendPortName        = ComputeManagementTestUtilities.GenerateName("fPort");
            var backendAddressPoolName  = ComputeManagementTestUtilities.GenerateName("pool");
            var backendHttpSettingsName = ComputeManagementTestUtilities.GenerateName("setting");
            var requestRoutingRuleName  = ComputeManagementTestUtilities.GenerateName("rule");
            var httpListenerName        = ComputeManagementTestUtilities.GenerateName("listener");

            var gatewayIPConfig = new ApplicationGatewayIPConfiguration()
            {
                Name   = gatewayIPConfigName,
                Subnet = new Microsoft.Azure.Management.Network.Models.SubResource {
                    Id = subnet.Id
                },
            };

            var frontendIPConfig = new ApplicationGatewayFrontendIPConfiguration()
            {
                Name = frontendIPConfigName,
                PrivateIPAllocationMethod = IPAllocationMethod.Dynamic,
                Subnet = new Microsoft.Azure.Management.Network.Models.SubResource {
                    Id = subnet.Id
                }
            };

            ApplicationGatewayFrontendPort frontendPort = new ApplicationGatewayFrontendPort()
            {
                Name = frontendPortName,
                Port = 80
            };

            var backendAddressPool = new ApplicationGatewayBackendAddressPool()
            {
                Name = backendAddressPoolName,
            };

            var backendHttpSettings = new ApplicationGatewayBackendHttpSettings()
            {
                Name                = backendHttpSettingsName,
                Port                = 80,
                Protocol            = ApplicationGatewayProtocol.Http,
                CookieBasedAffinity = ApplicationGatewayCookieBasedAffinity.Disabled,
            };

            var httpListener = new ApplicationGatewayHttpListener()
            {
                Name         = httpListenerName,
                FrontendPort = new Microsoft.Azure.Management.Network.Models.SubResource
                {
                    Id = GetChildAppGwResourceId(m_subId, rgName, gatewayName, "frontendPorts", frontendPortName)
                },
                FrontendIPConfiguration = new Microsoft.Azure.Management.Network.Models.SubResource
                {
                    Id = GetChildAppGwResourceId(m_subId, rgName, gatewayName, "frontendIPConfigurations", frontendIPConfigName)
                },
                SslCertificate = null,
                Protocol       = ApplicationGatewayProtocol.Http
            };

            var requestRoutingRules = new ApplicationGatewayRequestRoutingRule()
            {
                Name         = requestRoutingRuleName,
                RuleType     = ApplicationGatewayRequestRoutingRuleType.Basic,
                HttpListener = new Microsoft.Azure.Management.Network.Models.SubResource
                {
                    Id = GetChildAppGwResourceId(m_subId, rgName, gatewayName, "httpListeners", httpListenerName)
                },
                BackendAddressPool = new Microsoft.Azure.Management.Network.Models.SubResource
                {
                    Id = GetChildAppGwResourceId(m_subId, rgName, gatewayName, "backendAddressPools", backendAddressPoolName)
                },
                BackendHttpSettings = new Microsoft.Azure.Management.Network.Models.SubResource
                {
                    Id = GetChildAppGwResourceId(m_subId, rgName, gatewayName, "backendHttpSettingsCollection", backendHttpSettingsName)
                }
            };

            var appGw = new ApplicationGateway()
            {
                Location = m_location,
                Sku      = new ApplicationGatewaySku()
                {
                    Name     = ApplicationGatewaySkuName.StandardSmall,
                    Tier     = ApplicationGatewayTier.Standard,
                    Capacity = 2
                },
                GatewayIPConfigurations = new List <ApplicationGatewayIPConfiguration>()
                {
                    gatewayIPConfig,
                },
                FrontendIPConfigurations = new List <ApplicationGatewayFrontendIPConfiguration>()
                {
                    frontendIPConfig,
                },
                FrontendPorts = new List <ApplicationGatewayFrontendPort>
                {
                    frontendPort,
                },
                BackendAddressPools = new List <ApplicationGatewayBackendAddressPool>
                {
                    backendAddressPool,
                },
                BackendHttpSettingsCollection = new List <ApplicationGatewayBackendHttpSettings>
                {
                    backendHttpSettings,
                },
                HttpListeners = new List <ApplicationGatewayHttpListener>
                {
                    httpListener,
                },
                RequestRoutingRules = new List <ApplicationGatewayRequestRoutingRule>()
                {
                    requestRoutingRules,
                }
            };

            var putGwResponse = m_NrpClient.ApplicationGateways.CreateOrUpdate(rgName, gatewayName, appGw);
            var getGwResponse = m_NrpClient.ApplicationGateways.Get(rgName, gatewayName);

            return(getGwResponse);
        }