
com.azure.resourcemanager.storagepool.models.IscsiLun 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.storagepool.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;
/**
* LUN to expose the Azure Managed Disk.
*/
@Fluent
public final class IscsiLun implements JsonSerializable {
/*
* User defined name for iSCSI LUN; example: "lun0"
*/
private String name;
/*
* Azure Resource ID of the Managed Disk.
*/
private String managedDiskAzureResourceId;
/*
* Specifies the Logical Unit Number of the iSCSI LUN.
*/
private Integer lun;
/**
* Creates an instance of IscsiLun class.
*/
public IscsiLun() {
}
/**
* Get the name property: User defined name for iSCSI LUN; example: "lun0".
*
* @return the name value.
*/
public String name() {
return this.name;
}
/**
* Set the name property: User defined name for iSCSI LUN; example: "lun0".
*
* @param name the name value to set.
* @return the IscsiLun object itself.
*/
public IscsiLun withName(String name) {
this.name = name;
return this;
}
/**
* Get the managedDiskAzureResourceId property: Azure Resource ID of the Managed Disk.
*
* @return the managedDiskAzureResourceId value.
*/
public String managedDiskAzureResourceId() {
return this.managedDiskAzureResourceId;
}
/**
* Set the managedDiskAzureResourceId property: Azure Resource ID of the Managed Disk.
*
* @param managedDiskAzureResourceId the managedDiskAzureResourceId value to set.
* @return the IscsiLun object itself.
*/
public IscsiLun withManagedDiskAzureResourceId(String managedDiskAzureResourceId) {
this.managedDiskAzureResourceId = managedDiskAzureResourceId;
return this;
}
/**
* Get the lun property: Specifies the Logical Unit Number of the iSCSI LUN.
*
* @return the lun value.
*/
public Integer lun() {
return this.lun;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (name() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException("Missing required property name in model IscsiLun"));
}
if (managedDiskAzureResourceId() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property managedDiskAzureResourceId in model IscsiLun"));
}
}
private static final ClientLogger LOGGER = new ClientLogger(IscsiLun.class);
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("name", this.name);
jsonWriter.writeStringField("managedDiskAzureResourceId", this.managedDiskAzureResourceId);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of IscsiLun from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of IscsiLun 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 IscsiLun.
*/
public static IscsiLun fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
IscsiLun deserializedIscsiLun = new IscsiLun();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("name".equals(fieldName)) {
deserializedIscsiLun.name = reader.getString();
} else if ("managedDiskAzureResourceId".equals(fieldName)) {
deserializedIscsiLun.managedDiskAzureResourceId = reader.getString();
} else if ("lun".equals(fieldName)) {
deserializedIscsiLun.lun = reader.getNullable(JsonReader::getInt);
} else {
reader.skipChildren();
}
}
return deserializedIscsiLun;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy