com.azure.resourcemanager.monitor.fluent.models.AutoscaleSetting Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-monitor Show documentation
Show all versions of azure-resourcemanager-monitor Show documentation
This package contains Microsoft Azure Monitor SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.monitor.fluent.models;
import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import com.azure.resourcemanager.monitor.models.AutoscaleNotification;
import com.azure.resourcemanager.monitor.models.PredictiveAutoscalePolicy;
import java.io.IOException;
import java.util.List;
/**
* A setting that contains all of the configuration for the automatic scaling of a resource.
*/
@Fluent
public final class AutoscaleSetting implements JsonSerializable {
/*
* the collection of automatic scaling profiles that specify different scaling parameters for different time
* periods. A maximum of 20 profiles can be specified.
*/
private List profiles;
/*
* the collection of notifications.
*/
private List notifications;
/*
* the enabled flag. Specifies whether automatic scaling is enabled for the resource. The default value is 'false'.
*/
private Boolean enabled;
/*
* the predictive autoscale policy mode.
*/
private PredictiveAutoscalePolicy predictiveAutoscalePolicy;
/*
* the name of the autoscale setting.
*/
private String name;
/*
* the resource identifier of the resource that the autoscale setting should be added to.
*/
private String targetResourceUri;
/*
* the location of the resource that the autoscale setting should be added to.
*/
private String targetResourceLocation;
/**
* Creates an instance of AutoscaleSetting class.
*/
public AutoscaleSetting() {
}
/**
* Get the profiles property: the collection of automatic scaling profiles that specify different scaling parameters
* for different time periods. A maximum of 20 profiles can be specified.
*
* @return the profiles value.
*/
public List profiles() {
return this.profiles;
}
/**
* Set the profiles property: the collection of automatic scaling profiles that specify different scaling parameters
* for different time periods. A maximum of 20 profiles can be specified.
*
* @param profiles the profiles value to set.
* @return the AutoscaleSetting object itself.
*/
public AutoscaleSetting withProfiles(List profiles) {
this.profiles = profiles;
return this;
}
/**
* Get the notifications property: the collection of notifications.
*
* @return the notifications value.
*/
public List notifications() {
return this.notifications;
}
/**
* Set the notifications property: the collection of notifications.
*
* @param notifications the notifications value to set.
* @return the AutoscaleSetting object itself.
*/
public AutoscaleSetting withNotifications(List notifications) {
this.notifications = notifications;
return this;
}
/**
* Get the enabled property: the enabled flag. Specifies whether automatic scaling is enabled for the resource. The
* default value is 'false'.
*
* @return the enabled value.
*/
public Boolean enabled() {
return this.enabled;
}
/**
* Set the enabled property: the enabled flag. Specifies whether automatic scaling is enabled for the resource. The
* default value is 'false'.
*
* @param enabled the enabled value to set.
* @return the AutoscaleSetting object itself.
*/
public AutoscaleSetting withEnabled(Boolean enabled) {
this.enabled = enabled;
return this;
}
/**
* Get the predictiveAutoscalePolicy property: the predictive autoscale policy mode.
*
* @return the predictiveAutoscalePolicy value.
*/
public PredictiveAutoscalePolicy predictiveAutoscalePolicy() {
return this.predictiveAutoscalePolicy;
}
/**
* Set the predictiveAutoscalePolicy property: the predictive autoscale policy mode.
*
* @param predictiveAutoscalePolicy the predictiveAutoscalePolicy value to set.
* @return the AutoscaleSetting object itself.
*/
public AutoscaleSetting withPredictiveAutoscalePolicy(PredictiveAutoscalePolicy predictiveAutoscalePolicy) {
this.predictiveAutoscalePolicy = predictiveAutoscalePolicy;
return this;
}
/**
* Get the name property: the name of the autoscale setting.
*
* @return the name value.
*/
public String name() {
return this.name;
}
/**
* Set the name property: the name of the autoscale setting.
*
* @param name the name value to set.
* @return the AutoscaleSetting object itself.
*/
public AutoscaleSetting withName(String name) {
this.name = name;
return this;
}
/**
* Get the targetResourceUri property: the resource identifier of the resource that the autoscale setting should be
* added to.
*
* @return the targetResourceUri value.
*/
public String targetResourceUri() {
return this.targetResourceUri;
}
/**
* Set the targetResourceUri property: the resource identifier of the resource that the autoscale setting should be
* added to.
*
* @param targetResourceUri the targetResourceUri value to set.
* @return the AutoscaleSetting object itself.
*/
public AutoscaleSetting withTargetResourceUri(String targetResourceUri) {
this.targetResourceUri = targetResourceUri;
return this;
}
/**
* Get the targetResourceLocation property: the location of the resource that the autoscale setting should be added
* to.
*
* @return the targetResourceLocation value.
*/
public String targetResourceLocation() {
return this.targetResourceLocation;
}
/**
* Set the targetResourceLocation property: the location of the resource that the autoscale setting should be added
* to.
*
* @param targetResourceLocation the targetResourceLocation value to set.
* @return the AutoscaleSetting object itself.
*/
public AutoscaleSetting withTargetResourceLocation(String targetResourceLocation) {
this.targetResourceLocation = targetResourceLocation;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (profiles() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException("Missing required property profiles in model AutoscaleSetting"));
} else {
profiles().forEach(e -> e.validate());
}
if (notifications() != null) {
notifications().forEach(e -> e.validate());
}
if (predictiveAutoscalePolicy() != null) {
predictiveAutoscalePolicy().validate();
}
}
private static final ClientLogger LOGGER = new ClientLogger(AutoscaleSetting.class);
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeArrayField("profiles", this.profiles, (writer, element) -> writer.writeJson(element));
jsonWriter.writeArrayField("notifications", this.notifications, (writer, element) -> writer.writeJson(element));
jsonWriter.writeBooleanField("enabled", this.enabled);
jsonWriter.writeJsonField("predictiveAutoscalePolicy", this.predictiveAutoscalePolicy);
jsonWriter.writeStringField("name", this.name);
jsonWriter.writeStringField("targetResourceUri", this.targetResourceUri);
jsonWriter.writeStringField("targetResourceLocation", this.targetResourceLocation);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of AutoscaleSetting from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of AutoscaleSetting if the JsonReader was pointing to an instance of it, or null if it was
* pointing to JSON null.
* @throws IllegalStateException If the deserialized JSON object was missing any required properties.
* @throws IOException If an error occurs while reading the AutoscaleSetting.
*/
public static AutoscaleSetting fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
AutoscaleSetting deserializedAutoscaleSetting = new AutoscaleSetting();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("profiles".equals(fieldName)) {
List profiles
= reader.readArray(reader1 -> AutoscaleProfileInner.fromJson(reader1));
deserializedAutoscaleSetting.profiles = profiles;
} else if ("notifications".equals(fieldName)) {
List notifications
= reader.readArray(reader1 -> AutoscaleNotification.fromJson(reader1));
deserializedAutoscaleSetting.notifications = notifications;
} else if ("enabled".equals(fieldName)) {
deserializedAutoscaleSetting.enabled = reader.getNullable(JsonReader::getBoolean);
} else if ("predictiveAutoscalePolicy".equals(fieldName)) {
deserializedAutoscaleSetting.predictiveAutoscalePolicy = PredictiveAutoscalePolicy.fromJson(reader);
} else if ("name".equals(fieldName)) {
deserializedAutoscaleSetting.name = reader.getString();
} else if ("targetResourceUri".equals(fieldName)) {
deserializedAutoscaleSetting.targetResourceUri = reader.getString();
} else if ("targetResourceLocation".equals(fieldName)) {
deserializedAutoscaleSetting.targetResourceLocation = reader.getString();
} else {
reader.skipChildren();
}
}
return deserializedAutoscaleSetting;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy