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

com.azure.resourcemanager.compute.fluent.models.CapacityReservationGroupProperties 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.46.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.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.compute.models.CapacityReservationGroupInstanceView;
import com.azure.resourcemanager.compute.models.ResourceSharingProfile;
import com.azure.resourcemanager.compute.models.SubResourceReadOnly;
import java.io.IOException;
import java.util.List;

/**
 * capacity reservation group Properties.
 */
@Fluent
public final class CapacityReservationGroupProperties implements JsonSerializable {
    /*
     * A list of all capacity reservation resource ids that belong to capacity reservation group.
     */
    private List capacityReservations;

    /*
     * A list of references to all virtual machines associated to the capacity reservation group.
     */
    private List virtualMachinesAssociated;

    /*
     * The capacity reservation group instance view which has the list of instance views for all the capacity
     * reservations that belong to the capacity reservation group.
     */
    private CapacityReservationGroupInstanceView instanceView;

    /*
     * Specifies the settings to enable sharing across subscriptions for the capacity reservation group resource. Pls.
     * keep in mind the capacity reservation group resource generally can be shared across subscriptions belonging to a
     * single azure AAD tenant or cross AAD tenant if there is a trust relationship established between the AAD tenants.
     * **Note:** Minimum api-version: 2023-09-01. Please refer to https://aka.ms/computereservationsharing for more
     * details.
     */
    private ResourceSharingProfile sharingProfile;

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

    /**
     * Get the capacityReservations property: A list of all capacity reservation resource ids that belong to capacity
     * reservation group.
     * 
     * @return the capacityReservations value.
     */
    public List capacityReservations() {
        return this.capacityReservations;
    }

    /**
     * Get the virtualMachinesAssociated property: A list of references to all virtual machines associated to the
     * capacity reservation group.
     * 
     * @return the virtualMachinesAssociated value.
     */
    public List virtualMachinesAssociated() {
        return this.virtualMachinesAssociated;
    }

    /**
     * Get the instanceView property: The capacity reservation group instance view which has the list of instance views
     * for all the capacity reservations that belong to the capacity reservation group.
     * 
     * @return the instanceView value.
     */
    public CapacityReservationGroupInstanceView instanceView() {
        return this.instanceView;
    }

    /**
     * Get the sharingProfile property: Specifies the settings to enable sharing across subscriptions for the capacity
     * reservation group resource. Pls. keep in mind the capacity reservation group resource generally can be shared
     * across subscriptions belonging to a single azure AAD tenant or cross AAD tenant if there is a trust relationship
     * established between the AAD tenants. **Note:** Minimum api-version: 2023-09-01. Please refer to
     * https://aka.ms/computereservationsharing for more details.
     * 
     * @return the sharingProfile value.
     */
    public ResourceSharingProfile sharingProfile() {
        return this.sharingProfile;
    }

    /**
     * Set the sharingProfile property: Specifies the settings to enable sharing across subscriptions for the capacity
     * reservation group resource. Pls. keep in mind the capacity reservation group resource generally can be shared
     * across subscriptions belonging to a single azure AAD tenant or cross AAD tenant if there is a trust relationship
     * established between the AAD tenants. **Note:** Minimum api-version: 2023-09-01. Please refer to
     * https://aka.ms/computereservationsharing for more details.
     * 
     * @param sharingProfile the sharingProfile value to set.
     * @return the CapacityReservationGroupProperties object itself.
     */
    public CapacityReservationGroupProperties withSharingProfile(ResourceSharingProfile sharingProfile) {
        this.sharingProfile = sharingProfile;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (capacityReservations() != null) {
            capacityReservations().forEach(e -> e.validate());
        }
        if (virtualMachinesAssociated() != null) {
            virtualMachinesAssociated().forEach(e -> e.validate());
        }
        if (instanceView() != null) {
            instanceView().validate();
        }
        if (sharingProfile() != null) {
            sharingProfile().validate();
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeJsonField("sharingProfile", this.sharingProfile);
        return jsonWriter.writeEndObject();
    }

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

                if ("capacityReservations".equals(fieldName)) {
                    List capacityReservations
                        = reader.readArray(reader1 -> SubResourceReadOnly.fromJson(reader1));
                    deserializedCapacityReservationGroupProperties.capacityReservations = capacityReservations;
                } else if ("virtualMachinesAssociated".equals(fieldName)) {
                    List virtualMachinesAssociated
                        = reader.readArray(reader1 -> SubResourceReadOnly.fromJson(reader1));
                    deserializedCapacityReservationGroupProperties.virtualMachinesAssociated
                        = virtualMachinesAssociated;
                } else if ("instanceView".equals(fieldName)) {
                    deserializedCapacityReservationGroupProperties.instanceView
                        = CapacityReservationGroupInstanceView.fromJson(reader);
                } else if ("sharingProfile".equals(fieldName)) {
                    deserializedCapacityReservationGroupProperties.sharingProfile
                        = ResourceSharingProfile.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedCapacityReservationGroupProperties;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy