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

com.azure.resourcemanager.storagepool.models.DiskPoolUpdate 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 com.azure.resourcemanager.storagepool.fluent.models.DiskPoolUpdateProperties;
import com.azure.resourcemanager.storagepool.fluent.models.Sku;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * Request payload for Update Disk Pool request.
 */
@Fluent
public final class DiskPoolUpdate implements JsonSerializable {
    /*
     * Azure resource id. Indicates if this resource is managed by another Azure resource.
     */
    private String managedBy;

    /*
     * List of Azure resource ids that manage this resource.
     */
    private List managedByExtended;

    /*
     * Properties for Disk Pool update request.
     */
    private DiskPoolUpdateProperties innerProperties = new DiskPoolUpdateProperties();

    /*
     * Determines the SKU of the Disk Pool
     */
    private Sku sku;

    /*
     * Resource tags.
     */
    private Map tags;

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

    /**
     * Get the managedBy property: Azure resource id. Indicates if this resource is managed by another Azure resource.
     * 
     * @return the managedBy value.
     */
    public String managedBy() {
        return this.managedBy;
    }

    /**
     * Set the managedBy property: Azure resource id. Indicates if this resource is managed by another Azure resource.
     * 
     * @param managedBy the managedBy value to set.
     * @return the DiskPoolUpdate object itself.
     */
    public DiskPoolUpdate withManagedBy(String managedBy) {
        this.managedBy = managedBy;
        return this;
    }

    /**
     * Get the managedByExtended property: List of Azure resource ids that manage this resource.
     * 
     * @return the managedByExtended value.
     */
    public List managedByExtended() {
        return this.managedByExtended;
    }

    /**
     * Set the managedByExtended property: List of Azure resource ids that manage this resource.
     * 
     * @param managedByExtended the managedByExtended value to set.
     * @return the DiskPoolUpdate object itself.
     */
    public DiskPoolUpdate withManagedByExtended(List managedByExtended) {
        this.managedByExtended = managedByExtended;
        return this;
    }

    /**
     * Get the innerProperties property: Properties for Disk Pool update request.
     * 
     * @return the innerProperties value.
     */
    private DiskPoolUpdateProperties innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the sku property: Determines the SKU of the Disk Pool.
     * 
     * @return the sku value.
     */
    public Sku sku() {
        return this.sku;
    }

    /**
     * Set the sku property: Determines the SKU of the Disk Pool.
     * 
     * @param sku the sku value to set.
     * @return the DiskPoolUpdate object itself.
     */
    public DiskPoolUpdate withSku(Sku sku) {
        this.sku = sku;
        return this;
    }

    /**
     * Get the tags property: Resource tags.
     * 
     * @return the tags value.
     */
    public Map tags() {
        return this.tags;
    }

    /**
     * Set the tags property: Resource tags.
     * 
     * @param tags the tags value to set.
     * @return the DiskPoolUpdate object itself.
     */
    public DiskPoolUpdate withTags(Map tags) {
        this.tags = tags;
        return this;
    }

    /**
     * Get the disks property: List of Azure Managed Disks to attach to a Disk Pool.
     * 
     * @return the disks value.
     */
    public List disks() {
        return this.innerProperties() == null ? null : this.innerProperties().disks();
    }

    /**
     * Set the disks property: List of Azure Managed Disks to attach to a Disk Pool.
     * 
     * @param disks the disks value to set.
     * @return the DiskPoolUpdate object itself.
     */
    public DiskPoolUpdate withDisks(List disks) {
        if (this.innerProperties() == null) {
            this.innerProperties = new DiskPoolUpdateProperties();
        }
        this.innerProperties().withDisks(disks);
        return this;
    }

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

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeJsonField("properties", this.innerProperties);
        jsonWriter.writeStringField("managedBy", this.managedBy);
        jsonWriter.writeArrayField("managedByExtended", this.managedByExtended,
            (writer, element) -> writer.writeString(element));
        jsonWriter.writeJsonField("sku", this.sku);
        jsonWriter.writeMapField("tags", this.tags, (writer, element) -> writer.writeString(element));
        return jsonWriter.writeEndObject();
    }

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

                if ("properties".equals(fieldName)) {
                    deserializedDiskPoolUpdate.innerProperties = DiskPoolUpdateProperties.fromJson(reader);
                } else if ("managedBy".equals(fieldName)) {
                    deserializedDiskPoolUpdate.managedBy = reader.getString();
                } else if ("managedByExtended".equals(fieldName)) {
                    List managedByExtended = reader.readArray(reader1 -> reader1.getString());
                    deserializedDiskPoolUpdate.managedByExtended = managedByExtended;
                } else if ("sku".equals(fieldName)) {
                    deserializedDiskPoolUpdate.sku = Sku.fromJson(reader);
                } else if ("tags".equals(fieldName)) {
                    Map tags = reader.readMap(reader1 -> reader1.getString());
                    deserializedDiskPoolUpdate.tags = tags;
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedDiskPoolUpdate;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy