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

com.azure.resourcemanager.billing.models.BillingAccountPolicyProperties 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 java.io.IOException;
import java.util.List;

/**
 * A policy at billing account scope.
 */
@Fluent
public final class BillingAccountPolicyProperties implements JsonSerializable {
    /*
     * The provisioning state of the resource during a long-running operation.
     */
    private ProvisioningState provisioningState;

    /*
     * The policies for Enterprise Agreement enrollments.
     */
    private BillingAccountPolicyPropertiesEnterpriseAgreementPolicies enterpriseAgreementPolicies;

    /*
     * The policy that controls whether Azure marketplace purchases are allowed.
     */
    private MarketplacePurchasesPolicy marketplacePurchases;

    /*
     * The policy that controls whether Azure reservation purchases are allowed.
     */
    private ReservationPurchasesPolicy reservationPurchases;

    /*
     * The policy that controls whether users with Azure savings plan purchase are allowed.
     */
    private SavingsPlanPurchasesPolicy savingsPlanPurchases;

    /*
     * List of all policies defined at the billing scope.
     */
    private List policies;

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

    /**
     * Get the provisioningState property: The provisioning state of the resource during a long-running operation.
     * 
     * @return the provisioningState value.
     */
    public ProvisioningState provisioningState() {
        return this.provisioningState;
    }

    /**
     * Get the enterpriseAgreementPolicies property: The policies for Enterprise Agreement enrollments.
     * 
     * @return the enterpriseAgreementPolicies value.
     */
    public BillingAccountPolicyPropertiesEnterpriseAgreementPolicies enterpriseAgreementPolicies() {
        return this.enterpriseAgreementPolicies;
    }

    /**
     * Set the enterpriseAgreementPolicies property: The policies for Enterprise Agreement enrollments.
     * 
     * @param enterpriseAgreementPolicies the enterpriseAgreementPolicies value to set.
     * @return the BillingAccountPolicyProperties object itself.
     */
    public BillingAccountPolicyProperties withEnterpriseAgreementPolicies(
        BillingAccountPolicyPropertiesEnterpriseAgreementPolicies enterpriseAgreementPolicies) {
        this.enterpriseAgreementPolicies = enterpriseAgreementPolicies;
        return this;
    }

    /**
     * Get the marketplacePurchases property: The policy that controls whether Azure marketplace purchases are allowed.
     * 
     * @return the marketplacePurchases value.
     */
    public MarketplacePurchasesPolicy marketplacePurchases() {
        return this.marketplacePurchases;
    }

    /**
     * Set the marketplacePurchases property: The policy that controls whether Azure marketplace purchases are allowed.
     * 
     * @param marketplacePurchases the marketplacePurchases value to set.
     * @return the BillingAccountPolicyProperties object itself.
     */
    public BillingAccountPolicyProperties withMarketplacePurchases(MarketplacePurchasesPolicy marketplacePurchases) {
        this.marketplacePurchases = marketplacePurchases;
        return this;
    }

    /**
     * Get the reservationPurchases property: The policy that controls whether Azure reservation purchases are allowed.
     * 
     * @return the reservationPurchases value.
     */
    public ReservationPurchasesPolicy reservationPurchases() {
        return this.reservationPurchases;
    }

    /**
     * Set the reservationPurchases property: The policy that controls whether Azure reservation purchases are allowed.
     * 
     * @param reservationPurchases the reservationPurchases value to set.
     * @return the BillingAccountPolicyProperties object itself.
     */
    public BillingAccountPolicyProperties withReservationPurchases(ReservationPurchasesPolicy reservationPurchases) {
        this.reservationPurchases = reservationPurchases;
        return this;
    }

    /**
     * Get the savingsPlanPurchases property: The policy that controls whether users with Azure savings plan purchase
     * are allowed.
     * 
     * @return the savingsPlanPurchases value.
     */
    public SavingsPlanPurchasesPolicy savingsPlanPurchases() {
        return this.savingsPlanPurchases;
    }

    /**
     * Set the savingsPlanPurchases property: The policy that controls whether users with Azure savings plan purchase
     * are allowed.
     * 
     * @param savingsPlanPurchases the savingsPlanPurchases value to set.
     * @return the BillingAccountPolicyProperties object itself.
     */
    public BillingAccountPolicyProperties withSavingsPlanPurchases(SavingsPlanPurchasesPolicy savingsPlanPurchases) {
        this.savingsPlanPurchases = savingsPlanPurchases;
        return this;
    }

    /**
     * Get the policies property: List of all policies defined at the billing scope.
     * 
     * @return the policies value.
     */
    public List policies() {
        return this.policies;
    }

    /**
     * Set the policies property: List of all policies defined at the billing scope.
     * 
     * @param policies the policies value to set.
     * @return the BillingAccountPolicyProperties object itself.
     */
    public BillingAccountPolicyProperties withPolicies(List policies) {
        this.policies = policies;
        return this;
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeJsonField("enterpriseAgreementPolicies", this.enterpriseAgreementPolicies);
        jsonWriter.writeStringField("marketplacePurchases",
            this.marketplacePurchases == null ? null : this.marketplacePurchases.toString());
        jsonWriter.writeStringField("reservationPurchases",
            this.reservationPurchases == null ? null : this.reservationPurchases.toString());
        jsonWriter.writeStringField("savingsPlanPurchases",
            this.savingsPlanPurchases == null ? null : this.savingsPlanPurchases.toString());
        jsonWriter.writeArrayField("policies", this.policies, (writer, element) -> writer.writeJson(element));
        return jsonWriter.writeEndObject();
    }

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

                if ("provisioningState".equals(fieldName)) {
                    deserializedBillingAccountPolicyProperties.provisioningState
                        = ProvisioningState.fromString(reader.getString());
                } else if ("enterpriseAgreementPolicies".equals(fieldName)) {
                    deserializedBillingAccountPolicyProperties.enterpriseAgreementPolicies
                        = BillingAccountPolicyPropertiesEnterpriseAgreementPolicies.fromJson(reader);
                } else if ("marketplacePurchases".equals(fieldName)) {
                    deserializedBillingAccountPolicyProperties.marketplacePurchases
                        = MarketplacePurchasesPolicy.fromString(reader.getString());
                } else if ("reservationPurchases".equals(fieldName)) {
                    deserializedBillingAccountPolicyProperties.reservationPurchases
                        = ReservationPurchasesPolicy.fromString(reader.getString());
                } else if ("savingsPlanPurchases".equals(fieldName)) {
                    deserializedBillingAccountPolicyProperties.savingsPlanPurchases
                        = SavingsPlanPurchasesPolicy.fromString(reader.getString());
                } else if ("policies".equals(fieldName)) {
                    List policies = reader.readArray(reader1 -> PolicySummary.fromJson(reader1));
                    deserializedBillingAccountPolicyProperties.policies = policies;
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedBillingAccountPolicyProperties;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy