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

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

/**
 * Savings plan patch request.
 */
@Fluent
public final class SavingsPlanUpdateRequestProperties implements JsonSerializable {
    /*
     * Display name
     */
    private String displayName;

    /*
     * Type of the Applied Scope.
     */
    private AppliedScopeType appliedScopeType;

    /*
     * Properties specific to applied scope type. Not required if not applicable.
     */
    private AppliedScopeProperties appliedScopeProperties;

    /*
     * Setting this to true will automatically purchase a new benefit on the expiration date time.
     */
    private Boolean renew;

    /*
     * Properties specific to renew.
     */
    private RenewProperties renewProperties;

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

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

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

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

    /**
     * Set the appliedScopeType property: Type of the Applied Scope.
     * 
     * @param appliedScopeType the appliedScopeType value to set.
     * @return the SavingsPlanUpdateRequestProperties object itself.
     */
    public SavingsPlanUpdateRequestProperties withAppliedScopeType(AppliedScopeType appliedScopeType) {
        this.appliedScopeType = 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.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 SavingsPlanUpdateRequestProperties object itself.
     */
    public SavingsPlanUpdateRequestProperties
        withAppliedScopeProperties(AppliedScopeProperties appliedScopeProperties) {
        this.appliedScopeProperties = 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.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 SavingsPlanUpdateRequestProperties object itself.
     */
    public SavingsPlanUpdateRequestProperties withRenew(Boolean renew) {
        this.renew = renew;
        return this;
    }

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

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

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("displayName", this.displayName);
        jsonWriter.writeStringField("appliedScopeType",
            this.appliedScopeType == null ? null : this.appliedScopeType.toString());
        jsonWriter.writeJsonField("appliedScopeProperties", this.appliedScopeProperties);
        jsonWriter.writeBooleanField("renew", this.renew);
        jsonWriter.writeJsonField("renewProperties", this.renewProperties);
        return jsonWriter.writeEndObject();
    }

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

                if ("displayName".equals(fieldName)) {
                    deserializedSavingsPlanUpdateRequestProperties.displayName = reader.getString();
                } else if ("appliedScopeType".equals(fieldName)) {
                    deserializedSavingsPlanUpdateRequestProperties.appliedScopeType
                        = AppliedScopeType.fromString(reader.getString());
                } else if ("appliedScopeProperties".equals(fieldName)) {
                    deserializedSavingsPlanUpdateRequestProperties.appliedScopeProperties
                        = AppliedScopeProperties.fromJson(reader);
                } else if ("renew".equals(fieldName)) {
                    deserializedSavingsPlanUpdateRequestProperties.renew = reader.getNullable(JsonReader::getBoolean);
                } else if ("renewProperties".equals(fieldName)) {
                    deserializedSavingsPlanUpdateRequestProperties.renewProperties = RenewProperties.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedSavingsPlanUpdateRequestProperties;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy