com.azure.resourcemanager.elasticsan.fluent.models.VolumeProperties 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.elasticsan.fluent.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 com.azure.resourcemanager.elasticsan.models.IscsiTargetInfo;
import com.azure.resourcemanager.elasticsan.models.ManagedByInfo;
import com.azure.resourcemanager.elasticsan.models.ProvisioningStates;
import com.azure.resourcemanager.elasticsan.models.SourceCreationData;
import java.io.IOException;
/**
* Volume response properties.
*/
@Fluent
public final class VolumeProperties implements JsonSerializable {
/*
* Unique Id of the volume in GUID format
*/
private String volumeId;
/*
* State of the operation on the resource.
*/
private SourceCreationData creationData;
/*
* Volume size.
*/
private long sizeGiB;
/*
* Storage target information
*/
private IscsiTargetInfo storageTarget;
/*
* Parent resource information.
*/
private ManagedByInfo managedBy;
/*
* State of the operation on the resource.
*/
private ProvisioningStates provisioningState;
/**
* Creates an instance of VolumeProperties class.
*/
public VolumeProperties() {
}
/**
* Get the volumeId property: Unique Id of the volume in GUID format.
*
* @return the volumeId value.
*/
public String volumeId() {
return this.volumeId;
}
/**
* Get the creationData property: State of the operation on the resource.
*
* @return the creationData value.
*/
public SourceCreationData creationData() {
return this.creationData;
}
/**
* Set the creationData property: State of the operation on the resource.
*
* @param creationData the creationData value to set.
* @return the VolumeProperties object itself.
*/
public VolumeProperties withCreationData(SourceCreationData creationData) {
this.creationData = creationData;
return this;
}
/**
* Get the sizeGiB property: Volume size.
*
* @return the sizeGiB value.
*/
public long sizeGiB() {
return this.sizeGiB;
}
/**
* Set the sizeGiB property: Volume size.
*
* @param sizeGiB the sizeGiB value to set.
* @return the VolumeProperties object itself.
*/
public VolumeProperties withSizeGiB(long sizeGiB) {
this.sizeGiB = sizeGiB;
return this;
}
/**
* Get the storageTarget property: Storage target information.
*
* @return the storageTarget value.
*/
public IscsiTargetInfo storageTarget() {
return this.storageTarget;
}
/**
* Get the managedBy property: Parent resource information.
*
* @return the managedBy value.
*/
public ManagedByInfo managedBy() {
return this.managedBy;
}
/**
* Set the managedBy property: Parent resource information.
*
* @param managedBy the managedBy value to set.
* @return the VolumeProperties object itself.
*/
public VolumeProperties withManagedBy(ManagedByInfo managedBy) {
this.managedBy = managedBy;
return this;
}
/**
* Get the provisioningState property: State of the operation on the resource.
*
* @return the provisioningState value.
*/
public ProvisioningStates provisioningState() {
return this.provisioningState;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (creationData() != null) {
creationData().validate();
}
if (storageTarget() != null) {
storageTarget().validate();
}
if (managedBy() != null) {
managedBy().validate();
}
}
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeLongField("sizeGiB", this.sizeGiB);
jsonWriter.writeJsonField("creationData", this.creationData);
jsonWriter.writeJsonField("managedBy", this.managedBy);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of VolumeProperties from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of VolumeProperties 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 VolumeProperties.
*/
public static VolumeProperties fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
VolumeProperties deserializedVolumeProperties = new VolumeProperties();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("sizeGiB".equals(fieldName)) {
deserializedVolumeProperties.sizeGiB = reader.getLong();
} else if ("volumeId".equals(fieldName)) {
deserializedVolumeProperties.volumeId = reader.getString();
} else if ("creationData".equals(fieldName)) {
deserializedVolumeProperties.creationData = SourceCreationData.fromJson(reader);
} else if ("storageTarget".equals(fieldName)) {
deserializedVolumeProperties.storageTarget = IscsiTargetInfo.fromJson(reader);
} else if ("managedBy".equals(fieldName)) {
deserializedVolumeProperties.managedBy = ManagedByInfo.fromJson(reader);
} else if ("provisioningState".equals(fieldName)) {
deserializedVolumeProperties.provisioningState = ProvisioningStates.fromString(reader.getString());
} else {
reader.skipChildren();
}
}
return deserializedVolumeProperties;
});
}
}