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

com.azure.resourcemanager.machinelearning.models.EstimatedVMPrice Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for Machine Learning Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. These APIs allow end users to operate on Azure Machine Learning Workspace resources. Package tag package-2024-04.

The 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.machinelearning.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;

/**
 * The estimated price info for using a VM of a particular OS type, tier, etc.
 */
@Fluent
public final class EstimatedVMPrice implements JsonSerializable {
    /*
     * The price charged for using the VM.
     */
    private double retailPrice;

    /*
     * Operating system type used by the VM.
     */
    private VMPriceOSType osType;

    /*
     * The type of the VM.
     */
    private VMTier vmTier;

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

    /**
     * Get the retailPrice property: The price charged for using the VM.
     * 
     * @return the retailPrice value.
     */
    public double retailPrice() {
        return this.retailPrice;
    }

    /**
     * Set the retailPrice property: The price charged for using the VM.
     * 
     * @param retailPrice the retailPrice value to set.
     * @return the EstimatedVMPrice object itself.
     */
    public EstimatedVMPrice withRetailPrice(double retailPrice) {
        this.retailPrice = retailPrice;
        return this;
    }

    /**
     * Get the osType property: Operating system type used by the VM.
     * 
     * @return the osType value.
     */
    public VMPriceOSType osType() {
        return this.osType;
    }

    /**
     * Set the osType property: Operating system type used by the VM.
     * 
     * @param osType the osType value to set.
     * @return the EstimatedVMPrice object itself.
     */
    public EstimatedVMPrice withOsType(VMPriceOSType osType) {
        this.osType = osType;
        return this;
    }

    /**
     * Get the vmTier property: The type of the VM.
     * 
     * @return the vmTier value.
     */
    public VMTier vmTier() {
        return this.vmTier;
    }

    /**
     * Set the vmTier property: The type of the VM.
     * 
     * @param vmTier the vmTier value to set.
     * @return the EstimatedVMPrice object itself.
     */
    public EstimatedVMPrice withVmTier(VMTier vmTier) {
        this.vmTier = vmTier;
        return this;
    }

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

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeDoubleField("retailPrice", this.retailPrice);
        jsonWriter.writeStringField("osType", this.osType == null ? null : this.osType.toString());
        jsonWriter.writeStringField("vmTier", this.vmTier == null ? null : this.vmTier.toString());
        return jsonWriter.writeEndObject();
    }

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

                if ("retailPrice".equals(fieldName)) {
                    deserializedEstimatedVMPrice.retailPrice = reader.getDouble();
                } else if ("osType".equals(fieldName)) {
                    deserializedEstimatedVMPrice.osType = VMPriceOSType.fromString(reader.getString());
                } else if ("vmTier".equals(fieldName)) {
                    deserializedEstimatedVMPrice.vmTier = VMTier.fromString(reader.getString());
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedEstimatedVMPrice;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy