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

com.azure.resourcemanager.billing.models.RenewalTermDetails 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.billing.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.CoreUtils;
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.time.OffsetDateTime;

/**
 * Details for the next renewal term of a subscription.
 */
@Fluent
public final class RenewalTermDetails implements JsonSerializable {
    /*
     * The billing frequency in ISO8601 format of product in the subscription. Example: P1M, P3M, P1Y
     */
    private String billingFrequency;

    /*
     * Id of the product for which the subscription is purchased.
     */
    private String productId;

    /*
     * Type Id of the product for which the subscription is purchased.
     */
    private String productTypeId;

    /*
     * The SKU ID of the product for which the subscription is purchased. This field is is only available for Microsoft
     * Customer Agreement billing accounts.
     */
    private String skuId;

    /*
     * The duration in ISO8601 format for which you can use the subscription. Example: P1M, P3M, P1Y
     */
    private String termDuration;

    /*
     * The quantity of licenses or fulfillment units for the subscription.
     */
    private Long quantity;

    /*
     * End date of the term in UTC time.
     */
    private OffsetDateTime termEndDate;

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

    /**
     * Get the billingFrequency property: The billing frequency in ISO8601 format of product in the subscription.
     * Example: P1M, P3M, P1Y.
     * 
     * @return the billingFrequency value.
     */
    public String billingFrequency() {
        return this.billingFrequency;
    }

    /**
     * Get the productId property: Id of the product for which the subscription is purchased.
     * 
     * @return the productId value.
     */
    public String productId() {
        return this.productId;
    }

    /**
     * Get the productTypeId property: Type Id of the product for which the subscription is purchased.
     * 
     * @return the productTypeId value.
     */
    public String productTypeId() {
        return this.productTypeId;
    }

    /**
     * Get the skuId property: The SKU ID of the product for which the subscription is purchased. This field is is only
     * available for Microsoft Customer Agreement billing accounts.
     * 
     * @return the skuId value.
     */
    public String skuId() {
        return this.skuId;
    }

    /**
     * Get the termDuration property: The duration in ISO8601 format for which you can use the subscription. Example:
     * P1M, P3M, P1Y.
     * 
     * @return the termDuration value.
     */
    public String termDuration() {
        return this.termDuration;
    }

    /**
     * Get the quantity property: The quantity of licenses or fulfillment units for the subscription.
     * 
     * @return the quantity value.
     */
    public Long quantity() {
        return this.quantity;
    }

    /**
     * Set the quantity property: The quantity of licenses or fulfillment units for the subscription.
     * 
     * @param quantity the quantity value to set.
     * @return the RenewalTermDetails object itself.
     */
    public RenewalTermDetails withQuantity(Long quantity) {
        this.quantity = quantity;
        return this;
    }

    /**
     * Get the termEndDate property: End date of the term in UTC time.
     * 
     * @return the termEndDate value.
     */
    public OffsetDateTime termEndDate() {
        return this.termEndDate;
    }

    /**
     * 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.writeNumberField("quantity", this.quantity);
        return jsonWriter.writeEndObject();
    }

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

                if ("billingFrequency".equals(fieldName)) {
                    deserializedRenewalTermDetails.billingFrequency = reader.getString();
                } else if ("productId".equals(fieldName)) {
                    deserializedRenewalTermDetails.productId = reader.getString();
                } else if ("productTypeId".equals(fieldName)) {
                    deserializedRenewalTermDetails.productTypeId = reader.getString();
                } else if ("skuId".equals(fieldName)) {
                    deserializedRenewalTermDetails.skuId = reader.getString();
                } else if ("termDuration".equals(fieldName)) {
                    deserializedRenewalTermDetails.termDuration = reader.getString();
                } else if ("quantity".equals(fieldName)) {
                    deserializedRenewalTermDetails.quantity = reader.getNullable(JsonReader::getLong);
                } else if ("termEndDate".equals(fieldName)) {
                    deserializedRenewalTermDetails.termEndDate = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedRenewalTermDetails;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy