com.azure.resourcemanager.databoxedge.models.MetricSpecificationV1 Maven / Gradle / Ivy
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.databoxedge.models;
import com.azure.core.annotation.Fluent;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import java.util.List;
/**
* Metric specification version 1.
*/
@Fluent
public final class MetricSpecificationV1 implements JsonSerializable {
/*
* Name of the metric.
*/
private String name;
/*
* Display name of the metric.
*/
private String displayName;
/*
* Description of the metric to be displayed.
*/
private String displayDescription;
/*
* Metric units.
*/
private MetricUnit unit;
/*
* Metric aggregation type.
*/
private MetricAggregationType aggregationType;
/*
* Metric dimensions, other than default dimension which is resource.
*/
private List dimensions;
/*
* Set true to fill the gaps with zero.
*/
private Boolean fillGapWithZero;
/*
* Metric category.
*/
private MetricCategory category;
/*
* Resource name override.
*/
private String resourceIdDimensionNameOverride;
/*
* Support granularity of metrics.
*/
private List supportedTimeGrainTypes;
/*
* Support metric aggregation type.
*/
private List supportedAggregationTypes;
/**
* Creates an instance of MetricSpecificationV1 class.
*/
public MetricSpecificationV1() {
}
/**
* Get the name property: Name of the metric.
*
* @return the name value.
*/
public String name() {
return this.name;
}
/**
* Set the name property: Name of the metric.
*
* @param name the name value to set.
* @return the MetricSpecificationV1 object itself.
*/
public MetricSpecificationV1 withName(String name) {
this.name = name;
return this;
}
/**
* Get the displayName property: Display name of the metric.
*
* @return the displayName value.
*/
public String displayName() {
return this.displayName;
}
/**
* Set the displayName property: Display name of the metric.
*
* @param displayName the displayName value to set.
* @return the MetricSpecificationV1 object itself.
*/
public MetricSpecificationV1 withDisplayName(String displayName) {
this.displayName = displayName;
return this;
}
/**
* Get the displayDescription property: Description of the metric to be displayed.
*
* @return the displayDescription value.
*/
public String displayDescription() {
return this.displayDescription;
}
/**
* Set the displayDescription property: Description of the metric to be displayed.
*
* @param displayDescription the displayDescription value to set.
* @return the MetricSpecificationV1 object itself.
*/
public MetricSpecificationV1 withDisplayDescription(String displayDescription) {
this.displayDescription = displayDescription;
return this;
}
/**
* Get the unit property: Metric units.
*
* @return the unit value.
*/
public MetricUnit unit() {
return this.unit;
}
/**
* Set the unit property: Metric units.
*
* @param unit the unit value to set.
* @return the MetricSpecificationV1 object itself.
*/
public MetricSpecificationV1 withUnit(MetricUnit unit) {
this.unit = unit;
return this;
}
/**
* Get the aggregationType property: Metric aggregation type.
*
* @return the aggregationType value.
*/
public MetricAggregationType aggregationType() {
return this.aggregationType;
}
/**
* Set the aggregationType property: Metric aggregation type.
*
* @param aggregationType the aggregationType value to set.
* @return the MetricSpecificationV1 object itself.
*/
public MetricSpecificationV1 withAggregationType(MetricAggregationType aggregationType) {
this.aggregationType = aggregationType;
return this;
}
/**
* Get the dimensions property: Metric dimensions, other than default dimension which is resource.
*
* @return the dimensions value.
*/
public List dimensions() {
return this.dimensions;
}
/**
* Set the dimensions property: Metric dimensions, other than default dimension which is resource.
*
* @param dimensions the dimensions value to set.
* @return the MetricSpecificationV1 object itself.
*/
public MetricSpecificationV1 withDimensions(List dimensions) {
this.dimensions = dimensions;
return this;
}
/**
* Get the fillGapWithZero property: Set true to fill the gaps with zero.
*
* @return the fillGapWithZero value.
*/
public Boolean fillGapWithZero() {
return this.fillGapWithZero;
}
/**
* Set the fillGapWithZero property: Set true to fill the gaps with zero.
*
* @param fillGapWithZero the fillGapWithZero value to set.
* @return the MetricSpecificationV1 object itself.
*/
public MetricSpecificationV1 withFillGapWithZero(Boolean fillGapWithZero) {
this.fillGapWithZero = fillGapWithZero;
return this;
}
/**
* Get the category property: Metric category.
*
* @return the category value.
*/
public MetricCategory category() {
return this.category;
}
/**
* Set the category property: Metric category.
*
* @param category the category value to set.
* @return the MetricSpecificationV1 object itself.
*/
public MetricSpecificationV1 withCategory(MetricCategory category) {
this.category = category;
return this;
}
/**
* Get the resourceIdDimensionNameOverride property: Resource name override.
*
* @return the resourceIdDimensionNameOverride value.
*/
public String resourceIdDimensionNameOverride() {
return this.resourceIdDimensionNameOverride;
}
/**
* Set the resourceIdDimensionNameOverride property: Resource name override.
*
* @param resourceIdDimensionNameOverride the resourceIdDimensionNameOverride value to set.
* @return the MetricSpecificationV1 object itself.
*/
public MetricSpecificationV1 withResourceIdDimensionNameOverride(String resourceIdDimensionNameOverride) {
this.resourceIdDimensionNameOverride = resourceIdDimensionNameOverride;
return this;
}
/**
* Get the supportedTimeGrainTypes property: Support granularity of metrics.
*
* @return the supportedTimeGrainTypes value.
*/
public List supportedTimeGrainTypes() {
return this.supportedTimeGrainTypes;
}
/**
* Set the supportedTimeGrainTypes property: Support granularity of metrics.
*
* @param supportedTimeGrainTypes the supportedTimeGrainTypes value to set.
* @return the MetricSpecificationV1 object itself.
*/
public MetricSpecificationV1 withSupportedTimeGrainTypes(List supportedTimeGrainTypes) {
this.supportedTimeGrainTypes = supportedTimeGrainTypes;
return this;
}
/**
* Get the supportedAggregationTypes property: Support metric aggregation type.
*
* @return the supportedAggregationTypes value.
*/
public List supportedAggregationTypes() {
return this.supportedAggregationTypes;
}
/**
* Set the supportedAggregationTypes property: Support metric aggregation type.
*
* @param supportedAggregationTypes the supportedAggregationTypes value to set.
* @return the MetricSpecificationV1 object itself.
*/
public MetricSpecificationV1 withSupportedAggregationTypes(List supportedAggregationTypes) {
this.supportedAggregationTypes = supportedAggregationTypes;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (dimensions() != null) {
dimensions().forEach(e -> e.validate());
}
}
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("name", this.name);
jsonWriter.writeStringField("displayName", this.displayName);
jsonWriter.writeStringField("displayDescription", this.displayDescription);
jsonWriter.writeStringField("unit", this.unit == null ? null : this.unit.toString());
jsonWriter.writeStringField("aggregationType",
this.aggregationType == null ? null : this.aggregationType.toString());
jsonWriter.writeArrayField("dimensions", this.dimensions, (writer, element) -> writer.writeJson(element));
jsonWriter.writeBooleanField("fillGapWithZero", this.fillGapWithZero);
jsonWriter.writeStringField("category", this.category == null ? null : this.category.toString());
jsonWriter.writeStringField("resourceIdDimensionNameOverride", this.resourceIdDimensionNameOverride);
jsonWriter.writeArrayField("supportedTimeGrainTypes", this.supportedTimeGrainTypes,
(writer, element) -> writer.writeString(element == null ? null : element.toString()));
jsonWriter.writeArrayField("supportedAggregationTypes", this.supportedAggregationTypes,
(writer, element) -> writer.writeString(element == null ? null : element.toString()));
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of MetricSpecificationV1 from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of MetricSpecificationV1 if the JsonReader was pointing to an instance of it, or null if it
* was pointing to JSON null.
* @throws IOException If an error occurs while reading the MetricSpecificationV1.
*/
public static MetricSpecificationV1 fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
MetricSpecificationV1 deserializedMetricSpecificationV1 = new MetricSpecificationV1();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("name".equals(fieldName)) {
deserializedMetricSpecificationV1.name = reader.getString();
} else if ("displayName".equals(fieldName)) {
deserializedMetricSpecificationV1.displayName = reader.getString();
} else if ("displayDescription".equals(fieldName)) {
deserializedMetricSpecificationV1.displayDescription = reader.getString();
} else if ("unit".equals(fieldName)) {
deserializedMetricSpecificationV1.unit = MetricUnit.fromString(reader.getString());
} else if ("aggregationType".equals(fieldName)) {
deserializedMetricSpecificationV1.aggregationType
= MetricAggregationType.fromString(reader.getString());
} else if ("dimensions".equals(fieldName)) {
List dimensions
= reader.readArray(reader1 -> MetricDimensionV1.fromJson(reader1));
deserializedMetricSpecificationV1.dimensions = dimensions;
} else if ("fillGapWithZero".equals(fieldName)) {
deserializedMetricSpecificationV1.fillGapWithZero = reader.getNullable(JsonReader::getBoolean);
} else if ("category".equals(fieldName)) {
deserializedMetricSpecificationV1.category = MetricCategory.fromString(reader.getString());
} else if ("resourceIdDimensionNameOverride".equals(fieldName)) {
deserializedMetricSpecificationV1.resourceIdDimensionNameOverride = reader.getString();
} else if ("supportedTimeGrainTypes".equals(fieldName)) {
List supportedTimeGrainTypes
= reader.readArray(reader1 -> TimeGrain.fromString(reader1.getString()));
deserializedMetricSpecificationV1.supportedTimeGrainTypes = supportedTimeGrainTypes;
} else if ("supportedAggregationTypes".equals(fieldName)) {
List supportedAggregationTypes
= reader.readArray(reader1 -> MetricAggregationType.fromString(reader1.getString()));
deserializedMetricSpecificationV1.supportedAggregationTypes = supportedAggregationTypes;
} else {
reader.skipChildren();
}
}
return deserializedMetricSpecificationV1;
});
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy