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

com.azure.resourcemanager.hdinsight.models.BillingResources Maven / Gradle / Ivy

Go to download

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

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.hdinsight.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;
import java.util.List;

/**
 * The billing resources.
 */
@Fluent
public final class BillingResources implements JsonSerializable {
    /*
     * The region or location.
     */
    private String region;

    /*
     * The billing meter information.
     */
    private List billingMeters;

    /*
     * The managed disk billing information.
     */
    private List diskBillingMeters;

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

    /**
     * Get the region property: The region or location.
     * 
     * @return the region value.
     */
    public String region() {
        return this.region;
    }

    /**
     * Set the region property: The region or location.
     * 
     * @param region the region value to set.
     * @return the BillingResources object itself.
     */
    public BillingResources withRegion(String region) {
        this.region = region;
        return this;
    }

    /**
     * Get the billingMeters property: The billing meter information.
     * 
     * @return the billingMeters value.
     */
    public List billingMeters() {
        return this.billingMeters;
    }

    /**
     * Set the billingMeters property: The billing meter information.
     * 
     * @param billingMeters the billingMeters value to set.
     * @return the BillingResources object itself.
     */
    public BillingResources withBillingMeters(List billingMeters) {
        this.billingMeters = billingMeters;
        return this;
    }

    /**
     * Get the diskBillingMeters property: The managed disk billing information.
     * 
     * @return the diskBillingMeters value.
     */
    public List diskBillingMeters() {
        return this.diskBillingMeters;
    }

    /**
     * Set the diskBillingMeters property: The managed disk billing information.
     * 
     * @param diskBillingMeters the diskBillingMeters value to set.
     * @return the BillingResources object itself.
     */
    public BillingResources withDiskBillingMeters(List diskBillingMeters) {
        this.diskBillingMeters = diskBillingMeters;
        return this;
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("region", this.region);
        jsonWriter.writeArrayField("billingMeters", this.billingMeters, (writer, element) -> writer.writeJson(element));
        jsonWriter.writeArrayField("diskBillingMeters", this.diskBillingMeters,
            (writer, element) -> writer.writeJson(element));
        return jsonWriter.writeEndObject();
    }

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

                if ("region".equals(fieldName)) {
                    deserializedBillingResources.region = reader.getString();
                } else if ("billingMeters".equals(fieldName)) {
                    List billingMeters = reader.readArray(reader1 -> BillingMeters.fromJson(reader1));
                    deserializedBillingResources.billingMeters = billingMeters;
                } else if ("diskBillingMeters".equals(fieldName)) {
                    List diskBillingMeters
                        = reader.readArray(reader1 -> DiskBillingMeters.fromJson(reader1));
                    deserializedBillingResources.diskBillingMeters = diskBillingMeters;
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedBillingResources;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy