All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.resourcemanager.servicefabricmanagedclusters.models.VmssDataDisk Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for Service Fabric Managed Clusters Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Service Fabric Managed Clusters Management Client. Package tag package-2024-04.

There is a newer version: 1.0.0
Show 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.servicefabricmanagedclusters.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;

/**
 * Managed data disk description.
 */
@Fluent
public final class VmssDataDisk implements JsonSerializable {
    /*
     * Specifies the logical unit number of the data disk. This value is used to identify data disks within the VM and
     * therefore must be unique for each data disk attached to a VM. Lun 0 is reserved for the service fabric data disk.
     */
    private int lun;

    /*
     * Disk size for each vm in the node type in GBs.
     */
    private int diskSizeGB;

    /*
     * Managed data disk type. Specifies the storage account type for the managed disk
     */
    private DiskType diskType;

    /*
     * Managed data disk letter. It can not use the reserved letter C or D and it can not change after created.
     */
    private String diskLetter;

    /**
     * Creates an instance of VmssDataDisk class.
     */
    public VmssDataDisk() {
    }

    /**
     * Get the lun property: Specifies the logical unit number of the data disk. This value is used to identify data
     * disks within the VM and therefore must be unique for each data disk attached to a VM. Lun 0 is reserved for the
     * service fabric data disk.
     * 
     * @return the lun value.
     */
    public int lun() {
        return this.lun;
    }

    /**
     * Set the lun property: Specifies the logical unit number of the data disk. This value is used to identify data
     * disks within the VM and therefore must be unique for each data disk attached to a VM. Lun 0 is reserved for the
     * service fabric data disk.
     * 
     * @param lun the lun value to set.
     * @return the VmssDataDisk object itself.
     */
    public VmssDataDisk withLun(int lun) {
        this.lun = lun;
        return this;
    }

    /**
     * Get the diskSizeGB property: Disk size for each vm in the node type in GBs.
     * 
     * @return the diskSizeGB value.
     */
    public int diskSizeGB() {
        return this.diskSizeGB;
    }

    /**
     * Set the diskSizeGB property: Disk size for each vm in the node type in GBs.
     * 
     * @param diskSizeGB the diskSizeGB value to set.
     * @return the VmssDataDisk object itself.
     */
    public VmssDataDisk withDiskSizeGB(int diskSizeGB) {
        this.diskSizeGB = diskSizeGB;
        return this;
    }

    /**
     * Get the diskType property: Managed data disk type. Specifies the storage account type for the managed disk.
     * 
     * @return the diskType value.
     */
    public DiskType diskType() {
        return this.diskType;
    }

    /**
     * Set the diskType property: Managed data disk type. Specifies the storage account type for the managed disk.
     * 
     * @param diskType the diskType value to set.
     * @return the VmssDataDisk object itself.
     */
    public VmssDataDisk withDiskType(DiskType diskType) {
        this.diskType = diskType;
        return this;
    }

    /**
     * Get the diskLetter property: Managed data disk letter. It can not use the reserved letter C or D and it can not
     * change after created.
     * 
     * @return the diskLetter value.
     */
    public String diskLetter() {
        return this.diskLetter;
    }

    /**
     * Set the diskLetter property: Managed data disk letter. It can not use the reserved letter C or D and it can not
     * change after created.
     * 
     * @param diskLetter the diskLetter value to set.
     * @return the VmssDataDisk object itself.
     */
    public VmssDataDisk withDiskLetter(String diskLetter) {
        this.diskLetter = diskLetter;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (diskType() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Missing required property diskType in model VmssDataDisk"));
        }
        if (diskLetter() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Missing required property diskLetter in model VmssDataDisk"));
        }
    }

    private static final ClientLogger LOGGER = new ClientLogger(VmssDataDisk.class);

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeIntField("lun", this.lun);
        jsonWriter.writeIntField("diskSizeGB", this.diskSizeGB);
        jsonWriter.writeStringField("diskType", this.diskType == null ? null : this.diskType.toString());
        jsonWriter.writeStringField("diskLetter", this.diskLetter);
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of VmssDataDisk from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of VmssDataDisk 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 VmssDataDisk.
     */
    public static VmssDataDisk fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            VmssDataDisk deserializedVmssDataDisk = new VmssDataDisk();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("lun".equals(fieldName)) {
                    deserializedVmssDataDisk.lun = reader.getInt();
                } else if ("diskSizeGB".equals(fieldName)) {
                    deserializedVmssDataDisk.diskSizeGB = reader.getInt();
                } else if ("diskType".equals(fieldName)) {
                    deserializedVmssDataDisk.diskType = DiskType.fromString(reader.getString());
                } else if ("diskLetter".equals(fieldName)) {
                    deserializedVmssDataDisk.diskLetter = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedVmssDataDisk;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy