Exemple #1
0
        internal static GatewayRouteConfigProperties DeserializeGatewayRouteConfigProperties(JsonElement element)
        {
            Optional <GatewayProvisioningState> provisioningState = default;
            Optional <string> appResourceId            = default;
            Optional <IList <GatewayApiRoute> > routes = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("provisioningState"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    provisioningState = new GatewayProvisioningState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("appResourceId"))
                {
                    appResourceId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("routes"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <GatewayApiRoute> array = new List <GatewayApiRoute>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(GatewayApiRoute.DeserializeGatewayApiRoute(item));
                    }
                    routes = array;
                    continue;
                }
            }
            return(new GatewayRouteConfigProperties(Optional.ToNullable(provisioningState), appResourceId.Value, Optional.ToList(routes)));
        }
Exemple #2
0
        internal static GatewayProperties DeserializeGatewayProperties(JsonElement element)
        {
            Optional <GatewayProvisioningState> provisioningState = default;
            Optional <bool>          @public       = default;
            Optional <Uri>           url           = default;
            Optional <bool>          httpsOnly     = default;
            Optional <SsoProperties> ssoProperties = default;
            Optional <GatewayApiMetadataProperties>     apiMetadataProperties = default;
            Optional <GatewayCorsProperties>            corsProperties        = default;
            Optional <GatewayResourceRequests>          resourceRequests      = default;
            Optional <IReadOnlyList <GatewayInstance> > instances             = default;
            Optional <GatewayOperatorProperties>        operatorProperties    = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("provisioningState"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    provisioningState = new GatewayProvisioningState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("public"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    @public = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("url"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        url = null;
                        continue;
                    }
                    url = new Uri(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("httpsOnly"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    httpsOnly = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("ssoProperties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    ssoProperties = SsoProperties.DeserializeSsoProperties(property.Value);
                    continue;
                }
                if (property.NameEquals("apiMetadataProperties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    apiMetadataProperties = GatewayApiMetadataProperties.DeserializeGatewayApiMetadataProperties(property.Value);
                    continue;
                }
                if (property.NameEquals("corsProperties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    corsProperties = GatewayCorsProperties.DeserializeGatewayCorsProperties(property.Value);
                    continue;
                }
                if (property.NameEquals("resourceRequests"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    resourceRequests = GatewayResourceRequests.DeserializeGatewayResourceRequests(property.Value);
                    continue;
                }
                if (property.NameEquals("instances"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <GatewayInstance> array = new List <GatewayInstance>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(GatewayInstance.DeserializeGatewayInstance(item));
                    }
                    instances = array;
                    continue;
                }
                if (property.NameEquals("operatorProperties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    operatorProperties = GatewayOperatorProperties.DeserializeGatewayOperatorProperties(property.Value);
                    continue;
                }
            }
            return(new GatewayProperties(Optional.ToNullable(provisioningState), Optional.ToNullable(@public), url.Value, Optional.ToNullable(httpsOnly), ssoProperties.Value, apiMetadataProperties.Value, corsProperties.Value, resourceRequests.Value, Optional.ToList(instances), operatorProperties.Value));
        }