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

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

import com.azure.core.annotation.Fluent;
import com.azure.core.management.SystemData;
import com.azure.core.util.logging.ClientLogger;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import com.azure.resourcemanager.billing.models.AppliedScopeProperties;
import com.azure.resourcemanager.billing.models.AppliedScopeType;
import com.azure.resourcemanager.billing.models.BillingPlan;
import com.azure.resourcemanager.billing.models.Commitment;
import com.azure.resourcemanager.billing.models.ExtendedStatusInfo;
import com.azure.resourcemanager.billing.models.ProvisioningState;
import com.azure.resourcemanager.billing.models.ProxyResourceWithTags;
import com.azure.resourcemanager.billing.models.RenewProperties;
import com.azure.resourcemanager.billing.models.SavingsPlanTerm;
import com.azure.resourcemanager.billing.models.Sku;
import com.azure.resourcemanager.billing.models.Utilization;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.util.Map;

/**
 * Savings plan.
 */
@Fluent
public final class SavingsPlanModelInner extends ProxyResourceWithTags {
    /*
     * Savings plan SKU
     */
    private Sku sku;

    /*
     * Savings plan properties
     */
    private SavingsPlanModelProperties innerProperties;

    /*
     * Azure Resource Manager metadata containing createdBy and modifiedBy information.
     */
    private SystemData systemData;

    /*
     * The type of the resource.
     */
    private String type;

    /*
     * The name of the resource.
     */
    private String name;

    /*
     * Fully qualified resource Id for the resource.
     */
    private String id;

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

    /**
     * Get the sku property: Savings plan SKU.
     * 
     * @return the sku value.
     */
    public Sku sku() {
        return this.sku;
    }

    /**
     * Set the sku property: Savings plan SKU.
     * 
     * @param sku the sku value to set.
     * @return the SavingsPlanModelInner object itself.
     */
    public SavingsPlanModelInner withSku(Sku sku) {
        this.sku = sku;
        return this;
    }

    /**
     * Get the innerProperties property: Savings plan properties.
     * 
     * @return the innerProperties value.
     */
    private SavingsPlanModelProperties innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information.
     * 
     * @return the systemData value.
     */
    @Override
    public SystemData systemData() {
        return this.systemData;
    }

    /**
     * Get the type property: The type of the resource.
     * 
     * @return the type value.
     */
    @Override
    public String type() {
        return this.type;
    }

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

    /**
     * Get the id property: Fully qualified resource Id for the resource.
     * 
     * @return the id value.
     */
    @Override
    public String id() {
        return this.id;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public SavingsPlanModelInner withTags(Map tags) {
        super.withTags(tags);
        return this;
    }

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

    /**
     * Set the displayName property: Display name.
     * 
     * @param displayName the displayName value to set.
     * @return the SavingsPlanModelInner object itself.
     */
    public SavingsPlanModelInner withDisplayName(String displayName) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SavingsPlanModelProperties();
        }
        this.innerProperties().withDisplayName(displayName);
        return this;
    }

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

    /**
     * Set the provisioningState property: The provisioning state of the resource during a long-running operation.
     * 
     * @param provisioningState the provisioningState value to set.
     * @return the SavingsPlanModelInner object itself.
     */
    public SavingsPlanModelInner withProvisioningState(ProvisioningState provisioningState) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SavingsPlanModelProperties();
        }
        this.innerProperties().withProvisioningState(provisioningState);
        return this;
    }

    /**
     * Get the displayProvisioningState property: The provisioning state of the savings plan for display, e.g.
     * Succeeded.
     * 
     * @return the displayProvisioningState value.
     */
    public String displayProvisioningState() {
        return this.innerProperties() == null ? null : this.innerProperties().displayProvisioningState();
    }

    /**
     * Get the userFriendlyAppliedScopeType property: The applied scope type of the savings plan for display, e.g.
     * Shared.
     * 
     * @return the userFriendlyAppliedScopeType value.
     */
    public String userFriendlyAppliedScopeType() {
        return this.innerProperties() == null ? null : this.innerProperties().userFriendlyAppliedScopeType();
    }

    /**
     * Get the billingScopeId property: Subscription that will be charged for purchasing SavingsPlan.
     * 
     * @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 SavingsPlan.
     * 
     * @param billingScopeId the billingScopeId value to set.
     * @return the SavingsPlanModelInner object itself.
     */
    public SavingsPlanModelInner withBillingScopeId(String billingScopeId) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SavingsPlanModelProperties();
        }
        this.innerProperties().withBillingScopeId(billingScopeId);
        return this;
    }

    /**
     * Get the billingProfileId property: Fully-qualified identifier of the billing profile where the savings plan is
     * applied. Present only for Field-led or Customer-led customers.
     * 
     * @return the billingProfileId value.
     */
    public String billingProfileId() {
        return this.innerProperties() == null ? null : this.innerProperties().billingProfileId();
    }

    /**
     * Get the customerId property: Fully-qualified identifier of the customer where the savings plan is applied.
     * Present only for Partner-led customers.
     * 
     * @return the customerId value.
     */
    public String customerId() {
        return this.innerProperties() == null ? null : this.innerProperties().customerId();
    }

    /**
     * Get the billingAccountId property: Fully-qualified identifier of the billing account where the savings plan is
     * applied.
     * 
     * @return the billingAccountId value.
     */
    public String billingAccountId() {
        return this.innerProperties() == null ? null : this.innerProperties().billingAccountId();
    }

    /**
     * Get the term property: Represents the Savings plan term in ISO 8601 format.
     * 
     * @return the term value.
     */
    public SavingsPlanTerm term() {
        return this.innerProperties() == null ? null : this.innerProperties().term();
    }

    /**
     * Set the term property: Represents the Savings plan term in ISO 8601 format.
     * 
     * @param term the term value to set.
     * @return the SavingsPlanModelInner object itself.
     */
    public SavingsPlanModelInner withTerm(SavingsPlanTerm term) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SavingsPlanModelProperties();
        }
        this.innerProperties().withTerm(term);
        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 SavingsPlanModelInner object itself.
     */
    public SavingsPlanModelInner withRenew(Boolean renew) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SavingsPlanModelProperties();
        }
        this.innerProperties().withRenew(renew);
        return this;
    }

    /**
     * Get the renewSource property: SavingsPlan Id of the SavingsPlan from which this SavingsPlan is renewed.
     * 
     * @return the renewSource value.
     */
    public String renewSource() {
        return this.innerProperties() == null ? null : this.innerProperties().renewSource();
    }

    /**
     * Set the renewSource property: SavingsPlan Id of the SavingsPlan from which this SavingsPlan is renewed.
     * 
     * @param renewSource the renewSource value to set.
     * @return the SavingsPlanModelInner object itself.
     */
    public SavingsPlanModelInner withRenewSource(String renewSource) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SavingsPlanModelProperties();
        }
        this.innerProperties().withRenewSource(renewSource);
        return this;
    }

    /**
     * Get the renewDestination property: SavingsPlan Id of the SavingsPlan which is purchased because of renew.
     * 
     * @return the renewDestination value.
     */
    public String renewDestination() {
        return this.innerProperties() == null ? null : this.innerProperties().renewDestination();
    }

    /**
     * Set the renewDestination property: SavingsPlan Id of the SavingsPlan which is purchased because of renew.
     * 
     * @param renewDestination the renewDestination value to set.
     * @return the SavingsPlanModelInner object itself.
     */
    public SavingsPlanModelInner withRenewDestination(String renewDestination) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SavingsPlanModelProperties();
        }
        this.innerProperties().withRenewDestination(renewDestination);
        return this;
    }

    /**
     * Get the renewProperties property: Properties specific to renew.
     * 
     * @return the renewProperties value.
     */
    public RenewProperties renewProperties() {
        return this.innerProperties() == null ? null : this.innerProperties().renewProperties();
    }

    /**
     * Set the renewProperties property: Properties specific to renew.
     * 
     * @param renewProperties the renewProperties value to set.
     * @return the SavingsPlanModelInner object itself.
     */
    public SavingsPlanModelInner withRenewProperties(RenewProperties renewProperties) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SavingsPlanModelProperties();
        }
        this.innerProperties().withRenewProperties(renewProperties);
        return this;
    }

    /**
     * Get the billingPlan property: Represents the billing plan in ISO 8601 format. Required only for monthly
     * purchases.
     * 
     * @return the billingPlan value.
     */
    public BillingPlan billingPlan() {
        return this.innerProperties() == null ? null : this.innerProperties().billingPlan();
    }

    /**
     * Set the billingPlan property: Represents the billing plan in ISO 8601 format. Required only for monthly
     * purchases.
     * 
     * @param billingPlan the billingPlan value to set.
     * @return the SavingsPlanModelInner object itself.
     */
    public SavingsPlanModelInner withBillingPlan(BillingPlan billingPlan) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SavingsPlanModelProperties();
        }
        this.innerProperties().withBillingPlan(billingPlan);
        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 SavingsPlanModelInner object itself.
     */
    public SavingsPlanModelInner withAppliedScopeType(AppliedScopeType appliedScopeType) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SavingsPlanModelProperties();
        }
        this.innerProperties().withAppliedScopeType(appliedScopeType);
        return this;
    }

    /**
     * Get the appliedScopeProperties property: Properties specific to applied scope type. Not required if not
     * applicable.
     * 
     * @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.
     * 
     * @param appliedScopeProperties the appliedScopeProperties value to set.
     * @return the SavingsPlanModelInner object itself.
     */
    public SavingsPlanModelInner withAppliedScopeProperties(AppliedScopeProperties appliedScopeProperties) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SavingsPlanModelProperties();
        }
        this.innerProperties().withAppliedScopeProperties(appliedScopeProperties);
        return this;
    }

    /**
     * Get the commitment property: Commitment towards the benefit.
     * 
     * @return the commitment value.
     */
    public Commitment commitment() {
        return this.innerProperties() == null ? null : this.innerProperties().commitment();
    }

    /**
     * Set the commitment property: Commitment towards the benefit.
     * 
     * @param commitment the commitment value to set.
     * @return the SavingsPlanModelInner object itself.
     */
    public SavingsPlanModelInner withCommitment(Commitment commitment) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SavingsPlanModelProperties();
        }
        this.innerProperties().withCommitment(commitment);
        return this;
    }

    /**
     * Get the effectiveDateTime property: DateTime of the savings plan starting when this version is effective from.
     * 
     * @return the effectiveDateTime value.
     */
    public OffsetDateTime effectiveDateTime() {
        return this.innerProperties() == null ? null : this.innerProperties().effectiveDateTime();
    }

    /**
     * Get the benefitStartTime property: This is the DateTime when the savings plan benefit starts.
     * 
     * @return the benefitStartTime value.
     */
    public OffsetDateTime benefitStartTime() {
        return this.innerProperties() == null ? null : this.innerProperties().benefitStartTime();
    }

    /**
     * Get the expiryDateTime property: This is the date-time when the savings plan will expire.
     * 
     * @return the expiryDateTime value.
     */
    public OffsetDateTime expiryDateTime() {
        return this.innerProperties() == null ? null : this.innerProperties().expiryDateTime();
    }

    /**
     * Get the purchaseDateTime property: Date time when the savings plan was purchased.
     * 
     * @return the purchaseDateTime value.
     */
    public OffsetDateTime purchaseDateTime() {
        return this.innerProperties() == null ? null : this.innerProperties().purchaseDateTime();
    }

    /**
     * Get the utilization property: Savings plan utilization.
     * 
     * @return the utilization value.
     */
    public Utilization utilization() {
        return this.innerProperties() == null ? null : this.innerProperties().utilization();
    }

    /**
     * Get the extendedStatusInfo property: Extended status information.
     * 
     * @return the extendedStatusInfo value.
     */
    public ExtendedStatusInfo extendedStatusInfo() {
        return this.innerProperties() == null ? null : this.innerProperties().extendedStatusInfo();
    }

    /**
     * Get the productCode property: Represents UPN.
     * 
     * @return the productCode value.
     */
    public String productCode() {
        return this.innerProperties() == null ? null : this.innerProperties().productCode();
    }

    /**
     * Set the productCode property: Represents UPN.
     * 
     * @param productCode the productCode value to set.
     * @return the SavingsPlanModelInner object itself.
     */
    public SavingsPlanModelInner withProductCode(String productCode) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SavingsPlanModelProperties();
        }
        this.innerProperties().withProductCode(productCode);
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        if (sku() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Missing required property sku in model SavingsPlanModelInner"));
        } else {
            sku().validate();
        }
        if (innerProperties() != null) {
            innerProperties().validate();
        }
    }

    private static final ClientLogger LOGGER = new ClientLogger(SavingsPlanModelInner.class);

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeMapField("tags", tags(), (writer, element) -> writer.writeString(element));
        jsonWriter.writeJsonField("sku", this.sku);
        jsonWriter.writeJsonField("properties", this.innerProperties);
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of SavingsPlanModelInner from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of SavingsPlanModelInner if the JsonReader was pointing to an instance of it, or null if it
     * was pointing to JSON null.
     * @throws IllegalStateException If the deserialized JSON object was missing any required properties.
     * @throws IOException If an error occurs while reading the SavingsPlanModelInner.
     */
    public static SavingsPlanModelInner fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            SavingsPlanModelInner deserializedSavingsPlanModelInner = new SavingsPlanModelInner();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("id".equals(fieldName)) {
                    deserializedSavingsPlanModelInner.id = reader.getString();
                } else if ("name".equals(fieldName)) {
                    deserializedSavingsPlanModelInner.name = reader.getString();
                } else if ("type".equals(fieldName)) {
                    deserializedSavingsPlanModelInner.type = reader.getString();
                } else if ("tags".equals(fieldName)) {
                    Map tags = reader.readMap(reader1 -> reader1.getString());
                    deserializedSavingsPlanModelInner.withTags(tags);
                } else if ("systemData".equals(fieldName)) {
                    deserializedSavingsPlanModelInner.systemData = SystemData.fromJson(reader);
                } else if ("sku".equals(fieldName)) {
                    deserializedSavingsPlanModelInner.sku = Sku.fromJson(reader);
                } else if ("properties".equals(fieldName)) {
                    deserializedSavingsPlanModelInner.innerProperties = SavingsPlanModelProperties.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedSavingsPlanModelInner;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy