internal static PartitionMetric DeserializePartitionMetric(JsonElement element)
        {
            Optional <string>         partitionId         = default;
            Optional <string>         partitionKeyRangeId = default;
            Optional <DateTimeOffset> startTime           = default;
            Optional <DateTimeOffset> endTime             = default;
            Optional <string>         timeGrain           = default;
            Optional <UnitType>       unit = default;
            Optional <MetricName>     name = default;
            Optional <IReadOnlyList <MetricValue> > metricValues = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("partitionId"))
                {
                    partitionId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("partitionKeyRangeId"))
                {
                    partitionKeyRangeId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("startTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    startTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("endTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    endTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("timeGrain"))
                {
                    timeGrain = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("unit"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    unit = new UnitType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    name = MetricName.DeserializeMetricName(property.Value);
                    continue;
                }
                if (property.NameEquals("metricValues"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <MetricValue> array = new List <MetricValue>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(MetricValue.DeserializeMetricValue(item));
                    }
                    metricValues = array;
                    continue;
                }
            }
            return(new PartitionMetric(Optional.ToNullable(startTime), Optional.ToNullable(endTime), timeGrain.Value, Optional.ToNullable(unit), name.Value, Optional.ToList(metricValues), partitionId.Value, partitionKeyRangeId.Value));
        }