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

com.azure.resourcemanager.compute.models.ImageDiskReference Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure Compute Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt

There is a newer version: 2.44.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.compute.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 java.io.IOException;

/**
 * The source image used for creating the disk.
 */
@Fluent
public final class ImageDiskReference implements JsonSerializable {
    /*
     * A relative uri containing either a Platform Image Repository, user image, or Azure Compute Gallery image
     * reference.
     */
    private String id;

    /*
     * A relative uri containing a direct shared Azure Compute Gallery image reference.
     */
    private String sharedGalleryImageId;

    /*
     * A relative uri containing a community Azure Compute Gallery image reference.
     */
    private String communityGalleryImageId;

    /*
     * If the disk is created from an image's data disk, this is an index that indicates which of the data disks in the
     * image to use. For OS disks, this field is null.
     */
    private Integer lun;

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

    /**
     * Get the id property: A relative uri containing either a Platform Image Repository, user image, or Azure Compute
     * Gallery image reference.
     * 
     * @return the id value.
     */
    public String id() {
        return this.id;
    }

    /**
     * Set the id property: A relative uri containing either a Platform Image Repository, user image, or Azure Compute
     * Gallery image reference.
     * 
     * @param id the id value to set.
     * @return the ImageDiskReference object itself.
     */
    public ImageDiskReference withId(String id) {
        this.id = id;
        return this;
    }

    /**
     * Get the sharedGalleryImageId property: A relative uri containing a direct shared Azure Compute Gallery image
     * reference.
     * 
     * @return the sharedGalleryImageId value.
     */
    public String sharedGalleryImageId() {
        return this.sharedGalleryImageId;
    }

    /**
     * Set the sharedGalleryImageId property: A relative uri containing a direct shared Azure Compute Gallery image
     * reference.
     * 
     * @param sharedGalleryImageId the sharedGalleryImageId value to set.
     * @return the ImageDiskReference object itself.
     */
    public ImageDiskReference withSharedGalleryImageId(String sharedGalleryImageId) {
        this.sharedGalleryImageId = sharedGalleryImageId;
        return this;
    }

    /**
     * Get the communityGalleryImageId property: A relative uri containing a community Azure Compute Gallery image
     * reference.
     * 
     * @return the communityGalleryImageId value.
     */
    public String communityGalleryImageId() {
        return this.communityGalleryImageId;
    }

    /**
     * Set the communityGalleryImageId property: A relative uri containing a community Azure Compute Gallery image
     * reference.
     * 
     * @param communityGalleryImageId the communityGalleryImageId value to set.
     * @return the ImageDiskReference object itself.
     */
    public ImageDiskReference withCommunityGalleryImageId(String communityGalleryImageId) {
        this.communityGalleryImageId = communityGalleryImageId;
        return this;
    }

    /**
     * Get the lun property: If the disk is created from an image's data disk, this is an index that indicates which of
     * the data disks in the image to use. For OS disks, this field is null.
     * 
     * @return the lun value.
     */
    public Integer lun() {
        return this.lun;
    }

    /**
     * Set the lun property: If the disk is created from an image's data disk, this is an index that indicates which of
     * the data disks in the image to use. For OS disks, this field is null.
     * 
     * @param lun the lun value to set.
     * @return the ImageDiskReference object itself.
     */
    public ImageDiskReference withLun(Integer lun) {
        this.lun = lun;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("id", this.id);
        jsonWriter.writeStringField("sharedGalleryImageId", this.sharedGalleryImageId);
        jsonWriter.writeStringField("communityGalleryImageId", this.communityGalleryImageId);
        jsonWriter.writeNumberField("lun", this.lun);
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of ImageDiskReference from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of ImageDiskReference if the JsonReader was pointing to an instance of it, or null if it was
     * pointing to JSON null.
     * @throws IOException If an error occurs while reading the ImageDiskReference.
     */
    public static ImageDiskReference fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            ImageDiskReference deserializedImageDiskReference = new ImageDiskReference();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("id".equals(fieldName)) {
                    deserializedImageDiskReference.id = reader.getString();
                } else if ("sharedGalleryImageId".equals(fieldName)) {
                    deserializedImageDiskReference.sharedGalleryImageId = reader.getString();
                } else if ("communityGalleryImageId".equals(fieldName)) {
                    deserializedImageDiskReference.communityGalleryImageId = reader.getString();
                } else if ("lun".equals(fieldName)) {
                    deserializedImageDiskReference.lun = reader.getNullable(JsonReader::getInt);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedImageDiskReference;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy