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

com.azure.resourcemanager.billing.models.ReservationPurchaseRequest 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.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import com.azure.resourcemanager.billing.fluent.models.ReservationPurchaseRequestProperties;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.util.List;

/**
 * The request for reservation purchase.
 */
@Fluent
public final class ReservationPurchaseRequest implements JsonSerializable {
    /*
     * The name of sku
     */
    private SkuName sku;

    /*
     * The Azure region where the reserved resource lives.
     */
    private String location;

    /*
     * Properties of reservation purchase request
     */
    private ReservationPurchaseRequestProperties innerProperties;

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

    /**
     * Get the sku property: The name of sku.
     * 
     * @return the sku value.
     */
    public SkuName sku() {
        return this.sku;
    }

    /**
     * Set the sku property: The name of sku.
     * 
     * @param sku the sku value to set.
     * @return the ReservationPurchaseRequest object itself.
     */
    public ReservationPurchaseRequest withSku(SkuName sku) {
        this.sku = sku;
        return this;
    }

    /**
     * Get the location property: The Azure region where the reserved resource lives.
     * 
     * @return the location value.
     */
    public String location() {
        return this.location;
    }

    /**
     * Set the location property: The Azure region where the reserved resource lives.
     * 
     * @param location the location value to set.
     * @return the ReservationPurchaseRequest object itself.
     */
    public ReservationPurchaseRequest withLocation(String location) {
        this.location = location;
        return this;
    }

    /**
     * Get the innerProperties property: Properties of reservation purchase request.
     * 
     * @return the innerProperties value.
     */
    private ReservationPurchaseRequestProperties innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the reservedResourceType property: The reserved source type of the reservation, e.g. virtual machine.
     * 
     * @return the reservedResourceType value.
     */
    public String reservedResourceType() {
        return this.innerProperties() == null ? null : this.innerProperties().reservedResourceType();
    }

    /**
     * Get the billingScopeId property: Subscription that will be charged for purchasing reservation or savings plan.
     * 
     * @return the billingScopeId value.
     */
    public String billingScopeId() {
        return this.innerProperties() == null ? null : this.innerProperties().billingScopeId();
    }

    /**
     * Get the term property: The term of the reservation, e.g. P1Y.
     * 
     * @return the term value.
     */
    public String term() {
        return this.innerProperties() == null ? null : this.innerProperties().term();
    }

    /**
     * Get the billingPlan property: Represent the billing plans.
     * 
     * @return the billingPlan value.
     */
    public ReservationBillingPlan billingPlan() {
        return this.innerProperties() == null ? null : this.innerProperties().billingPlan();
    }

    /**
     * Set the billingPlan property: Represent the billing plans.
     * 
     * @param billingPlan the billingPlan value to set.
     * @return the ReservationPurchaseRequest object itself.
     */
    public ReservationPurchaseRequest withBillingPlan(ReservationBillingPlan billingPlan) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ReservationPurchaseRequestProperties();
        }
        this.innerProperties().withBillingPlan(billingPlan);
        return this;
    }

    /**
     * Get the quantity property: Quantity of the skus that are part of the reservation. Must be greater than zero.
     * 
     * @return the quantity value.
     */
    public Integer quantity() {
        return this.innerProperties() == null ? null : this.innerProperties().quantity();
    }

    /**
     * Set the quantity property: Quantity of the skus that are part of the reservation. Must be greater than zero.
     * 
     * @param quantity the quantity value to set.
     * @return the ReservationPurchaseRequest object itself.
     */
    public ReservationPurchaseRequest withQuantity(Integer quantity) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ReservationPurchaseRequestProperties();
        }
        this.innerProperties().withQuantity(quantity);
        return this;
    }

    /**
     * Get the displayName property: Friendly name of the reservation.
     * 
     * @return the displayName value.
     */
    public String displayName() {
        return this.innerProperties() == null ? null : this.innerProperties().displayName();
    }

    /**
     * Set the displayName property: Friendly name of the reservation.
     * 
     * @param displayName the displayName value to set.
     * @return the ReservationPurchaseRequest object itself.
     */
    public ReservationPurchaseRequest withDisplayName(String displayName) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ReservationPurchaseRequestProperties();
        }
        this.innerProperties().withDisplayName(displayName);
        return this;
    }

    /**
     * Get the appliedScopeType property: Type of the Applied Scope.
     * 
     * @return the appliedScopeType value.
     */
    public AppliedScopeType appliedScopeType() {
        return this.innerProperties() == null ? null : this.innerProperties().appliedScopeType();
    }

    /**
     * Set the appliedScopeType property: Type of the Applied Scope.
     * 
     * @param appliedScopeType the appliedScopeType value to set.
     * @return the ReservationPurchaseRequest object itself.
     */
    public ReservationPurchaseRequest withAppliedScopeType(AppliedScopeType appliedScopeType) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ReservationPurchaseRequestProperties();
        }
        this.innerProperties().withAppliedScopeType(appliedScopeType);
        return this;
    }

    /**
     * Get the appliedScopes property: List of the subscriptions that the benefit will be applied. Do not specify if
     * AppliedScopeType is Shared.
     * 
     * @return the appliedScopes value.
     */
    public List appliedScopes() {
        return this.innerProperties() == null ? null : this.innerProperties().appliedScopes();
    }

    /**
     * Set the appliedScopes property: List of the subscriptions that the benefit will be applied. Do not specify if
     * AppliedScopeType is Shared.
     * 
     * @param appliedScopes the appliedScopes value to set.
     * @return the ReservationPurchaseRequest object itself.
     */
    public ReservationPurchaseRequest withAppliedScopes(List appliedScopes) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ReservationPurchaseRequestProperties();
        }
        this.innerProperties().withAppliedScopes(appliedScopes);
        return this;
    }

    /**
     * Get the appliedScopeProperties property: Properties specific to applied scope type. Not required if not
     * applicable. Required and need to provide tenantId and managementGroupId if AppliedScopeType is ManagementGroup.
     * 
     * @return the appliedScopeProperties value.
     */
    public ReservationAppliedScopeProperties appliedScopeProperties() {
        return this.innerProperties() == null ? null : this.innerProperties().appliedScopeProperties();
    }

    /**
     * Set the appliedScopeProperties property: Properties specific to applied scope type. Not required if not
     * applicable. Required and need to provide tenantId and managementGroupId if AppliedScopeType is ManagementGroup.
     * 
     * @param appliedScopeProperties the appliedScopeProperties value to set.
     * @return the ReservationPurchaseRequest object itself.
     */
    public ReservationPurchaseRequest
        withAppliedScopeProperties(ReservationAppliedScopeProperties appliedScopeProperties) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ReservationPurchaseRequestProperties();
        }
        this.innerProperties().withAppliedScopeProperties(appliedScopeProperties);
        return this;
    }

    /**
     * Get the renew property: Setting this to true will automatically purchase a new benefit on the expiration date
     * time.
     * 
     * @return the renew value.
     */
    public Boolean renew() {
        return this.innerProperties() == null ? null : this.innerProperties().renew();
    }

    /**
     * Set the renew property: Setting this to true will automatically purchase a new benefit on the expiration date
     * time.
     * 
     * @param renew the renew value to set.
     * @return the ReservationPurchaseRequest object itself.
     */
    public ReservationPurchaseRequest withRenew(Boolean renew) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ReservationPurchaseRequestProperties();
        }
        this.innerProperties().withRenew(renew);
        return this;
    }

    /**
     * Get the instanceFlexibility property: Allows reservation discount to be applied across skus within the same auto
     * fit group. Not all skus support instance size flexibility.
     * 
     * @return the instanceFlexibility value.
     */
    public InstanceFlexibility instanceFlexibility() {
        return this.innerProperties() == null ? null : this.innerProperties().instanceFlexibility();
    }

    /**
     * Set the instanceFlexibility property: Allows reservation discount to be applied across skus within the same auto
     * fit group. Not all skus support instance size flexibility.
     * 
     * @param instanceFlexibility the instanceFlexibility value to set.
     * @return the ReservationPurchaseRequest object itself.
     */
    public ReservationPurchaseRequest withInstanceFlexibility(InstanceFlexibility instanceFlexibility) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ReservationPurchaseRequestProperties();
        }
        this.innerProperties().withInstanceFlexibility(instanceFlexibility);
        return this;
    }

    /**
     * Get the reviewDateTime property: This is the date-time when the Azure hybrid benefit needs to be reviewed.
     * 
     * @return the reviewDateTime value.
     */
    public OffsetDateTime reviewDateTime() {
        return this.innerProperties() == null ? null : this.innerProperties().reviewDateTime();
    }

    /**
     * Set the reviewDateTime property: This is the date-time when the Azure hybrid benefit needs to be reviewed.
     * 
     * @param reviewDateTime the reviewDateTime value to set.
     * @return the ReservationPurchaseRequest object itself.
     */
    public ReservationPurchaseRequest withReviewDateTime(OffsetDateTime reviewDateTime) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ReservationPurchaseRequestProperties();
        }
        this.innerProperties().withReviewDateTime(reviewDateTime);
        return this;
    }

    /**
     * Get the instanceFlexibilityReservedResourcePropertiesInstanceFlexibility property: Turning this on will apply the
     * reservation discount to other VMs in the same VM size group. Only specify for VirtualMachines reserved resource
     * type.
     * 
     * @return the instanceFlexibilityReservedResourcePropertiesInstanceFlexibility value.
     */
    public InstanceFlexibility instanceFlexibilityReservedResourcePropertiesInstanceFlexibility() {
        return this.innerProperties() == null
            ? null
            : this.innerProperties().instanceFlexibilityReservedResourcePropertiesInstanceFlexibility();
    }

    /**
     * Set the instanceFlexibilityReservedResourcePropertiesInstanceFlexibility property: Turning this on will apply the
     * reservation discount to other VMs in the same VM size group. Only specify for VirtualMachines reserved resource
     * type.
     * 
     * @param instanceFlexibilityReservedResourcePropertiesInstanceFlexibility the
     * instanceFlexibilityReservedResourcePropertiesInstanceFlexibility value to set.
     * @return the ReservationPurchaseRequest object itself.
     */
    public ReservationPurchaseRequest withInstanceFlexibilityReservedResourcePropertiesInstanceFlexibility(
        InstanceFlexibility instanceFlexibilityReservedResourcePropertiesInstanceFlexibility) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ReservationPurchaseRequestProperties();
        }
        this.innerProperties()
            .withInstanceFlexibilityReservedResourcePropertiesInstanceFlexibility(
                instanceFlexibilityReservedResourcePropertiesInstanceFlexibility);
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (sku() != null) {
            sku().validate();
        }
        if (innerProperties() != null) {
            innerProperties().validate();
        }
    }

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

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

                if ("sku".equals(fieldName)) {
                    deserializedReservationPurchaseRequest.sku = SkuName.fromJson(reader);
                } else if ("location".equals(fieldName)) {
                    deserializedReservationPurchaseRequest.location = reader.getString();
                } else if ("properties".equals(fieldName)) {
                    deserializedReservationPurchaseRequest.innerProperties
                        = ReservationPurchaseRequestProperties.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedReservationPurchaseRequest;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy