com.azure.resourcemanager.dataprotection.models.AdHocBackupRuleOptions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-dataprotection Show documentation
Show all versions of azure-resourcemanager-dataprotection Show documentation
This package contains Microsoft Azure SDK for DataProtection Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Open API 2.0 Specs for Azure Data Protection service. Package tag package-2024-04.
The newest version!
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.dataprotection.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 java.io.IOException;
/**
* AdHocBackupRuleOptions
*
* Adhoc backup rules.
*/
@Fluent
public final class AdHocBackupRuleOptions implements JsonSerializable {
/*
* The ruleName property.
*/
private String ruleName;
/*
* Adhoc backup trigger option
*/
private AdhocBackupTriggerOption triggerOption;
/**
* Creates an instance of AdHocBackupRuleOptions class.
*/
public AdHocBackupRuleOptions() {
}
/**
* Get the ruleName property: The ruleName property.
*
* @return the ruleName value.
*/
public String ruleName() {
return this.ruleName;
}
/**
* Set the ruleName property: The ruleName property.
*
* @param ruleName the ruleName value to set.
* @return the AdHocBackupRuleOptions object itself.
*/
public AdHocBackupRuleOptions withRuleName(String ruleName) {
this.ruleName = ruleName;
return this;
}
/**
* Get the triggerOption property: Adhoc backup trigger option.
*
* @return the triggerOption value.
*/
public AdhocBackupTriggerOption triggerOption() {
return this.triggerOption;
}
/**
* Set the triggerOption property: Adhoc backup trigger option.
*
* @param triggerOption the triggerOption value to set.
* @return the AdHocBackupRuleOptions object itself.
*/
public AdHocBackupRuleOptions withTriggerOption(AdhocBackupTriggerOption triggerOption) {
this.triggerOption = triggerOption;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (ruleName() == null) {
throw LOGGER.atError()
.log(
new IllegalArgumentException("Missing required property ruleName in model AdHocBackupRuleOptions"));
}
if (triggerOption() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property triggerOption in model AdHocBackupRuleOptions"));
} else {
triggerOption().validate();
}
}
private static final ClientLogger LOGGER = new ClientLogger(AdHocBackupRuleOptions.class);
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("ruleName", this.ruleName);
jsonWriter.writeJsonField("triggerOption", this.triggerOption);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of AdHocBackupRuleOptions from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of AdHocBackupRuleOptions 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 AdHocBackupRuleOptions.
*/
public static AdHocBackupRuleOptions fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
AdHocBackupRuleOptions deserializedAdHocBackupRuleOptions = new AdHocBackupRuleOptions();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("ruleName".equals(fieldName)) {
deserializedAdHocBackupRuleOptions.ruleName = reader.getString();
} else if ("triggerOption".equals(fieldName)) {
deserializedAdHocBackupRuleOptions.triggerOption = AdhocBackupTriggerOption.fromJson(reader);
} else {
reader.skipChildren();
}
}
return deserializedAdHocBackupRuleOptions;
});
}
}