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

package com.azure.resourcemanager.consumption.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.management.ProxyResource;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.consumption.models.BudgetFilter;
import com.azure.resourcemanager.consumption.models.BudgetTimePeriod;
import com.azure.resourcemanager.consumption.models.CategoryType;
import com.azure.resourcemanager.consumption.models.CurrentSpend;
import com.azure.resourcemanager.consumption.models.ForecastSpend;
import com.azure.resourcemanager.consumption.models.Notification;
import com.azure.resourcemanager.consumption.models.TimeGrainType;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.math.BigDecimal;
import java.util.Map;

/** A budget resource. */
@Fluent
public final class BudgetInner extends ProxyResource {
    @JsonIgnore private final ClientLogger logger = new ClientLogger(BudgetInner.class);

    /*
     * The properties of the budget.
     */
    @JsonProperty(value = "properties")
    private BudgetProperties innerProperties;

    /*
     * eTag of the resource. To handle concurrent update scenario, this field
     * will be used to determine whether the user is updating the latest
     * version or not.
     */
    @JsonProperty(value = "eTag")
    private String etag;

    /**
     * Get the innerProperties property: The properties of the budget.
     *
     * @return the innerProperties value.
     */
    private BudgetProperties innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the etag property: eTag of the resource. To handle concurrent update scenario, this field will be used to
     * determine whether the user is updating the latest version or not.
     *
     * @return the etag value.
     */
    public String etag() {
        return this.etag;
    }

    /**
     * Set the etag property: eTag of the resource. To handle concurrent update scenario, this field will be used to
     * determine whether the user is updating the latest version or not.
     *
     * @param etag the etag value to set.
     * @return the BudgetInner object itself.
     */
    public BudgetInner withEtag(String etag) {
        this.etag = etag;
        return this;
    }

    /**
     * Get the category property: The category of the budget, whether the budget tracks cost or usage.
     *
     * @return the category value.
     */
    public CategoryType category() {
        return this.innerProperties() == null ? null : this.innerProperties().category();
    }

    /**
     * Set the category property: The category of the budget, whether the budget tracks cost or usage.
     *
     * @param category the category value to set.
     * @return the BudgetInner object itself.
     */
    public BudgetInner withCategory(CategoryType category) {
        if (this.innerProperties() == null) {
            this.innerProperties = new BudgetProperties();
        }
        this.innerProperties().withCategory(category);
        return this;
    }

    /**
     * Get the amount property: The total amount of cost to track with the budget.
     *
     * @return the amount value.
     */
    public BigDecimal amount() {
        return this.innerProperties() == null ? null : this.innerProperties().amount();
    }

    /**
     * Set the amount property: The total amount of cost to track with the budget.
     *
     * @param amount the amount value to set.
     * @return the BudgetInner object itself.
     */
    public BudgetInner withAmount(BigDecimal amount) {
        if (this.innerProperties() == null) {
            this.innerProperties = new BudgetProperties();
        }
        this.innerProperties().withAmount(amount);
        return this;
    }

    /**
     * Get the timeGrain property: The time covered by a budget. Tracking of the amount will be reset based on the time
     * grain. BillingMonth, BillingQuarter, and BillingAnnual are only supported by WD customers.
     *
     * @return the timeGrain value.
     */
    public TimeGrainType timeGrain() {
        return this.innerProperties() == null ? null : this.innerProperties().timeGrain();
    }

    /**
     * Set the timeGrain property: The time covered by a budget. Tracking of the amount will be reset based on the time
     * grain. BillingMonth, BillingQuarter, and BillingAnnual are only supported by WD customers.
     *
     * @param timeGrain the timeGrain value to set.
     * @return the BudgetInner object itself.
     */
    public BudgetInner withTimeGrain(TimeGrainType timeGrain) {
        if (this.innerProperties() == null) {
            this.innerProperties = new BudgetProperties();
        }
        this.innerProperties().withTimeGrain(timeGrain);
        return this;
    }

    /**
     * Get the timePeriod property: Has start and end date of the budget. The start date must be first of the month and
     * should be less than the end date. Budget start date must be on or after June 1, 2017. Future start date should
     * not be more than twelve months. Past start date should be selected within the timegrain period. There are no
     * restrictions on the end date.
     *
     * @return the timePeriod value.
     */
    public BudgetTimePeriod timePeriod() {
        return this.innerProperties() == null ? null : this.innerProperties().timePeriod();
    }

    /**
     * Set the timePeriod property: Has start and end date of the budget. The start date must be first of the month and
     * should be less than the end date. Budget start date must be on or after June 1, 2017. Future start date should
     * not be more than twelve months. Past start date should be selected within the timegrain period. There are no
     * restrictions on the end date.
     *
     * @param timePeriod the timePeriod value to set.
     * @return the BudgetInner object itself.
     */
    public BudgetInner withTimePeriod(BudgetTimePeriod timePeriod) {
        if (this.innerProperties() == null) {
            this.innerProperties = new BudgetProperties();
        }
        this.innerProperties().withTimePeriod(timePeriod);
        return this;
    }

    /**
     * Get the filter property: May be used to filter budgets by user-specified dimensions and/or tags.
     *
     * @return the filter value.
     */
    public BudgetFilter filter() {
        return this.innerProperties() == null ? null : this.innerProperties().filter();
    }

    /**
     * Set the filter property: May be used to filter budgets by user-specified dimensions and/or tags.
     *
     * @param filter the filter value to set.
     * @return the BudgetInner object itself.
     */
    public BudgetInner withFilter(BudgetFilter filter) {
        if (this.innerProperties() == null) {
            this.innerProperties = new BudgetProperties();
        }
        this.innerProperties().withFilter(filter);
        return this;
    }

    /**
     * Get the currentSpend property: The current amount of cost which is being tracked for a budget.
     *
     * @return the currentSpend value.
     */
    public CurrentSpend currentSpend() {
        return this.innerProperties() == null ? null : this.innerProperties().currentSpend();
    }

    /**
     * Get the notifications property: Dictionary of notifications associated with the budget. Budget can have up to
     * five notifications.
     *
     * @return the notifications value.
     */
    public Map<String, Notification> notifications() {
        return this.innerProperties() == null ? null : this.innerProperties().notifications();
    }

    /**
     * Set the notifications property: Dictionary of notifications associated with the budget. Budget can have up to
     * five notifications.
     *
     * @param notifications the notifications value to set.
     * @return the BudgetInner object itself.
     */
    public BudgetInner withNotifications(Map<String, Notification> notifications) {
        if (this.innerProperties() == null) {
            this.innerProperties = new BudgetProperties();
        }
        this.innerProperties().withNotifications(notifications);
        return this;
    }

    /**
     * Get the forecastSpend property: The forecasted cost which is being tracked for a budget.
     *
     * @return the forecastSpend value.
     */
    public ForecastSpend forecastSpend() {
        return this.innerProperties() == null ? null : this.innerProperties().forecastSpend();
    }

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