// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.reservations.models;

import com.azure.core.annotation.Fluent;
import com.azure.resourcemanager.reservations.fluent.models.PurchaseRequestProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;
import java.util.List;

/** The request for reservation purchase. */
@Fluent
public final class PurchaseRequest {
    /*
     * The name of sku
     */
    @JsonProperty(value = "sku")
    private SkuName sku;

    /*
     * The Azure region where the reserved resource lives.
     */
    @JsonProperty(value = "location")
    private String location;

    /*
     * Properties of reservation purchase request
     */
    @JsonProperty(value = "properties")
    private PurchaseRequestProperties innerProperties;

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

    /**
     * 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 PurchaseRequest object itself.
     */
    public PurchaseRequest 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 PurchaseRequest object itself.
     */
    public PurchaseRequest withLocation(String location) {
        this.location = location;
        return this;
    }

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

    /**
     * Get the reservedResourceType property: The type of the resource that is being reserved.
     *
     * @return the reservedResourceType value.
     */
    public ReservedResourceType reservedResourceType() {
        return this.innerProperties() == null ? null : this.innerProperties().reservedResourceType();
    }

    /**
     * Set the reservedResourceType property: The type of the resource that is being reserved.
     *
     * @param reservedResourceType the reservedResourceType value to set.
     * @return the PurchaseRequest object itself.
     */
    public PurchaseRequest withReservedResourceType(ReservedResourceType reservedResourceType) {
        if (this.innerProperties() == null) {
            this.innerProperties = new PurchaseRequestProperties();
        }
        this.innerProperties().withReservedResourceType(reservedResourceType);
        return this;
    }

    /**
     * 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();
    }

    /**
     * Set the billingScopeId property: Subscription that will be charged for purchasing reservation or savings plan.
     *
     * @param billingScopeId the billingScopeId value to set.
     * @return the PurchaseRequest object itself.
     */
    public PurchaseRequest withBillingScopeId(String billingScopeId) {
        if (this.innerProperties() == null) {
            this.innerProperties = new PurchaseRequestProperties();
        }
        this.innerProperties().withBillingScopeId(billingScopeId);
        return this;
    }

    /**
     * Get the term property: Represent the term of reservation.
     *
     * @return the term value.
     */
    public ReservationTerm term() {
        return this.innerProperties() == null ? null : this.innerProperties().term();
    }

    /**
     * Set the term property: Represent the term of reservation.
     *
     * @param term the term value to set.
     * @return the PurchaseRequest object itself.
     */
    public PurchaseRequest withTerm(ReservationTerm term) {
        if (this.innerProperties() == null) {
            this.innerProperties = new PurchaseRequestProperties();
        }
        this.innerProperties().withTerm(term);
        return this;
    }

    /**
     * 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 PurchaseRequest object itself.
     */
    public PurchaseRequest withBillingPlan(ReservationBillingPlan billingPlan) {
        if (this.innerProperties() == null) {
            this.innerProperties = new PurchaseRequestProperties();
        }
        this.innerProperties().withBillingPlan(billingPlan);
        return this;
    }

    /**
     * Get the quantity property: Quantity of the skus that are part of the reservation.
     *
     * @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.
     *
     * @param quantity the quantity value to set.
     * @return the PurchaseRequest object itself.
     */
    public PurchaseRequest withQuantity(Integer quantity) {
        if (this.innerProperties() == null) {
            this.innerProperties = new PurchaseRequestProperties();
        }
        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 PurchaseRequest object itself.
     */
    public PurchaseRequest withDisplayName(String displayName) {
        if (this.innerProperties() == null) {
            this.innerProperties = new PurchaseRequestProperties();
        }
        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 PurchaseRequest object itself.
     */
    public PurchaseRequest withAppliedScopeType(AppliedScopeType appliedScopeType) {
        if (this.innerProperties() == null) {
            this.innerProperties = new PurchaseRequestProperties();
        }
        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. This property will be deprecated and replaced by appliedScopeProperties instead for
     * Single AppliedScopeType.
     *
     * @return the appliedScopes value.
     */
    public List<String> 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. This property will be deprecated and replaced by appliedScopeProperties instead for
     * Single AppliedScopeType.
     *
     * @param appliedScopes the appliedScopes value to set.
     * @return the PurchaseRequest object itself.
     */
    public PurchaseRequest withAppliedScopes(List<String> appliedScopes) {
        if (this.innerProperties() == null) {
            this.innerProperties = new PurchaseRequestProperties();
        }
        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 AppliedScopeProperties 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 PurchaseRequest object itself.
     */
    public PurchaseRequest withAppliedScopeProperties(AppliedScopeProperties appliedScopeProperties) {
        if (this.innerProperties() == null) {
            this.innerProperties = new PurchaseRequestProperties();
        }
        this.innerProperties().withAppliedScopeProperties(appliedScopeProperties);
        return this;
    }

    /**
     * Get the renew property: Setting this to true will automatically purchase a new reservation 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 reservation on the expiration date
     * time.
     *
     * @param renew the renew value to set.
     * @return the PurchaseRequest object itself.
     */
    public PurchaseRequest withRenew(Boolean renew) {
        if (this.innerProperties() == null) {
            this.innerProperties = new PurchaseRequestProperties();
        }
        this.innerProperties().withRenew(renew);
        return this;
    }

    /**
     * Get the reservedResourceProperties property: Properties specific to each reserved resource type. Not required if
     * not applicable.
     *
     * @return the reservedResourceProperties value.
     */
    public PurchaseRequestPropertiesReservedResourceProperties reservedResourceProperties() {
        return this.innerProperties() == null ? null : this.innerProperties().reservedResourceProperties();
    }

    /**
     * Set the reservedResourceProperties property: Properties specific to each reserved resource type. Not required if
     * not applicable.
     *
     * @param reservedResourceProperties the reservedResourceProperties value to set.
     * @return the PurchaseRequest object itself.
     */
    public PurchaseRequest withReservedResourceProperties(
        PurchaseRequestPropertiesReservedResourceProperties reservedResourceProperties) {
        if (this.innerProperties() == null) {
            this.innerProperties = new PurchaseRequestProperties();
        }
        this.innerProperties().withReservedResourceProperties(reservedResourceProperties);
        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 PurchaseRequest object itself.
     */
    public PurchaseRequest withReviewDateTime(OffsetDateTime reviewDateTime) {
        if (this.innerProperties() == null) {
            this.innerProperties = new PurchaseRequestProperties();
        }
        this.innerProperties().withReviewDateTime(reviewDateTime);
        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();
        }
    }
}
