Example #1
0
        internal static RecommendedElasticPoolListMetricsResult DeserializeRecommendedElasticPoolListMetricsResult(JsonElement element)
        {
            IReadOnlyList <RecommendedElasticPoolMetric> value = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("value"))
                {
                    List <RecommendedElasticPoolMetric> array = new List <RecommendedElasticPoolMetric>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(RecommendedElasticPoolMetric.DeserializeRecommendedElasticPoolMetric(item));
                    }
                    value = array;
                    continue;
                }
            }
            return(new RecommendedElasticPoolListMetricsResult(value));
        }
        internal static RecommendedElasticPool DeserializeRecommendedElasticPool(JsonElement element)
        {
            Optional <string>             id                                 = default;
            Optional <string>             name                               = default;
            Optional <string>             type                               = default;
            Optional <ElasticPoolEdition> databaseEdition                    = default;
            Optional <double>             dtu                                = default;
            Optional <double>             databaseDtuMin                     = default;
            Optional <double>             databaseDtuMax                     = default;
            Optional <double>             storageMB                          = default;
            Optional <DateTimeOffset>     observationPeriodStart             = default;
            Optional <DateTimeOffset>     observationPeriodEnd               = default;
            Optional <double>             maxObservedDtu                     = default;
            Optional <double>             maxObservedStorageMB               = default;
            Optional <IReadOnlyList <TrackedResource> > databases            = default;
            Optional <IReadOnlyList <RecommendedElasticPoolMetric> > metrics = default;

            foreach (var property in element.EnumerateObject())
            {
                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("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("databaseEdition"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            databaseEdition = new ElasticPoolEdition(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("dtu"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            dtu = property0.Value.GetDouble();
                            continue;
                        }
                        if (property0.NameEquals("databaseDtuMin"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            databaseDtuMin = property0.Value.GetDouble();
                            continue;
                        }
                        if (property0.NameEquals("databaseDtuMax"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            databaseDtuMax = property0.Value.GetDouble();
                            continue;
                        }
                        if (property0.NameEquals("storageMB"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            storageMB = property0.Value.GetDouble();
                            continue;
                        }
                        if (property0.NameEquals("observationPeriodStart"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            observationPeriodStart = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("observationPeriodEnd"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            observationPeriodEnd = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("maxObservedDtu"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            maxObservedDtu = property0.Value.GetDouble();
                            continue;
                        }
                        if (property0.NameEquals("maxObservedStorageMB"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            maxObservedStorageMB = property0.Value.GetDouble();
                            continue;
                        }
                        if (property0.NameEquals("databases"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <TrackedResource> array = new List <TrackedResource>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(TrackedResource.DeserializeTrackedResource(item));
                            }
                            databases = array;
                            continue;
                        }
                        if (property0.NameEquals("metrics"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <RecommendedElasticPoolMetric> array = new List <RecommendedElasticPoolMetric>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(RecommendedElasticPoolMetric.DeserializeRecommendedElasticPoolMetric(item));
                            }
                            metrics = array;
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new RecommendedElasticPool(id.Value, name.Value, type.Value, Optional.ToNullable(databaseEdition), Optional.ToNullable(dtu), Optional.ToNullable(databaseDtuMin), Optional.ToNullable(databaseDtuMax), Optional.ToNullable(storageMB), Optional.ToNullable(observationPeriodStart), Optional.ToNullable(observationPeriodEnd), Optional.ToNullable(maxObservedDtu), Optional.ToNullable(maxObservedStorageMB), Optional.ToList(databases), Optional.ToList(metrics)));
        }