internal MetricDefinition(bool?isDimensionRequired, string resourceId, string @namespace, LocalizableString localizedName, string displayDescription, string category, MetricClass?metricClass, MetricUnit?unit, MetricAggregationType?primaryAggregationType, IReadOnlyList <MetricAggregationType> supportedAggregationTypes, IReadOnlyList <MetricAvailability> metricAvailabilities, string id, IReadOnlyList <LocalizableString> localizedDimensions)
 {
     IsDimensionRequired = isDimensionRequired;
     ResourceId          = resourceId;
     Namespace           = @namespace;
     LocalizedName       = localizedName;
     DisplayDescription  = displayDescription;
     Category            = category;
     MetricClass         = metricClass;
     Unit = unit;
     PrimaryAggregationType    = primaryAggregationType;
     SupportedAggregationTypes = supportedAggregationTypes;
     MetricAvailabilities      = metricAvailabilities;
     Id = id;
     LocalizedDimensions = localizedDimensions;
 }
        internal static MetricDefinition DeserializeMetricDefinition(JsonElement element)
        {
            Optional <bool>                  isDimensionRequired = default;
            Optional <string>                resourceId          = default;
            Optional <string>                @namespace          = default;
            Optional <LocalizableString>     name = default;
            Optional <MetricUnit>            unit = default;
            Optional <MetricAggregationType> primaryAggregationType = default;
            Optional <IReadOnlyList <MetricAggregationType> > supportedAggregationTypes = default;
            Optional <IReadOnlyList <MetricAvailability> >    metricAvailabilities      = default;
            Optional <string> id = default;
            Optional <IReadOnlyList <LocalizableString> > dimensions = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("isDimensionRequired"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    isDimensionRequired = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("resourceId"))
                {
                    resourceId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("namespace"))
                {
                    @namespace = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    name = LocalizableString.DeserializeLocalizableString(property.Value);
                    continue;
                }
                if (property.NameEquals("unit"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    unit = new MetricUnit(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("primaryAggregationType"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    primaryAggregationType = property.Value.GetString().ToMetricAggregationType();
                    continue;
                }
                if (property.NameEquals("supportedAggregationTypes"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <MetricAggregationType> array = new List <MetricAggregationType>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString().ToMetricAggregationType());
                    }
                    supportedAggregationTypes = array;
                    continue;
                }
                if (property.NameEquals("metricAvailabilities"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <MetricAvailability> array = new List <MetricAvailability>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(MetricAvailability.DeserializeMetricAvailability(item));
                    }
                    metricAvailabilities = array;
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("dimensions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <LocalizableString> array = new List <LocalizableString>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(LocalizableString.DeserializeLocalizableString(item));
                    }
                    dimensions = array;
                    continue;
                }
            }
            return(new MetricDefinition(Optional.ToNullable(isDimensionRequired), resourceId.Value, @namespace.Value, name.Value, Optional.ToNullable(unit), Optional.ToNullable(primaryAggregationType), Optional.ToList(supportedAggregationTypes), Optional.ToList(metricAvailabilities), id.Value, Optional.ToList(dimensions)));
        }