
com.azure.resourcemanager.billing.fluent.models.PurchaseRequestProperties 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.json.JsonReader;
import com.azure.json.JsonSerializable;
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.SavingsPlanTerm;
import java.io.IOException;
/**
* Purchase request properties.
*/
@Fluent
public final class PurchaseRequestProperties implements JsonSerializable {
/*
* Friendly name of the savings plan
*/
private String displayName;
/*
* Subscription that will be charged for purchasing SavingsPlan
*/
private String billingScopeId;
/*
* Represents the Savings plan term in ISO 8601 format.
*/
private SavingsPlanTerm term;
/*
* Represents the billing plan in ISO 8601 format. Required only for monthly purchases.
*/
private BillingPlan billingPlan;
/*
* Type of the Applied Scope.
*/
private AppliedScopeType appliedScopeType;
/*
* Commitment towards the benefit.
*/
private Commitment commitment;
/*
* Setting this to true will automatically purchase a new benefit on the expiration date time.
*/
private Boolean renew;
/*
* Properties specific to applied scope type. Not required if not applicable.
*/
private AppliedScopeProperties appliedScopeProperties;
/**
* Creates an instance of PurchaseRequestProperties class.
*/
public PurchaseRequestProperties() {
}
/**
* Get the displayName property: Friendly name of the savings plan.
*
* @return the displayName value.
*/
public String displayName() {
return this.displayName;
}
/**
* Set the displayName property: Friendly name of the savings plan.
*
* @param displayName the displayName value to set.
* @return the PurchaseRequestProperties object itself.
*/
public PurchaseRequestProperties withDisplayName(String displayName) {
this.displayName = displayName;
return this;
}
/**
* Get the billingScopeId property: Subscription that will be charged for purchasing SavingsPlan.
*
* @return the billingScopeId value.
*/
public String billingScopeId() {
return this.billingScopeId;
}
/**
* Set the billingScopeId property: Subscription that will be charged for purchasing SavingsPlan.
*
* @param billingScopeId the billingScopeId value to set.
* @return the PurchaseRequestProperties object itself.
*/
public PurchaseRequestProperties withBillingScopeId(String billingScopeId) {
this.billingScopeId = billingScopeId;
return this;
}
/**
* Get the term property: Represents the Savings plan term in ISO 8601 format.
*
* @return the term value.
*/
public SavingsPlanTerm term() {
return this.term;
}
/**
* Set the term property: Represents the Savings plan term in ISO 8601 format.
*
* @param term the term value to set.
* @return the PurchaseRequestProperties object itself.
*/
public PurchaseRequestProperties withTerm(SavingsPlanTerm term) {
this.term = term;
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.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 PurchaseRequestProperties object itself.
*/
public PurchaseRequestProperties withBillingPlan(BillingPlan billingPlan) {
this.billingPlan = billingPlan;
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 PurchaseRequestProperties object itself.
*/
public PurchaseRequestProperties withAppliedScopeType(AppliedScopeType appliedScopeType) {
this.appliedScopeType = appliedScopeType;
return this;
}
/**
* Get the commitment property: Commitment towards the benefit.
*
* @return the commitment value.
*/
public Commitment commitment() {
return this.commitment;
}
/**
* Set the commitment property: Commitment towards the benefit.
*
* @param commitment the commitment value to set.
* @return the PurchaseRequestProperties object itself.
*/
public PurchaseRequestProperties withCommitment(Commitment commitment) {
this.commitment = commitment;
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 PurchaseRequestProperties object itself.
*/
public PurchaseRequestProperties withRenew(Boolean renew) {
this.renew = renew;
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 PurchaseRequestProperties object itself.
*/
public PurchaseRequestProperties withAppliedScopeProperties(AppliedScopeProperties appliedScopeProperties) {
this.appliedScopeProperties = appliedScopeProperties;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (commitment() != null) {
commitment().validate();
}
if (appliedScopeProperties() != null) {
appliedScopeProperties().validate();
}
}
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("displayName", this.displayName);
jsonWriter.writeStringField("billingScopeId", this.billingScopeId);
jsonWriter.writeStringField("term", this.term == null ? null : this.term.toString());
jsonWriter.writeStringField("billingPlan", this.billingPlan == null ? null : this.billingPlan.toString());
jsonWriter.writeStringField("appliedScopeType",
this.appliedScopeType == null ? null : this.appliedScopeType.toString());
jsonWriter.writeJsonField("commitment", this.commitment);
jsonWriter.writeBooleanField("renew", this.renew);
jsonWriter.writeJsonField("appliedScopeProperties", this.appliedScopeProperties);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of PurchaseRequestProperties from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of PurchaseRequestProperties 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 PurchaseRequestProperties.
*/
public static PurchaseRequestProperties fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
PurchaseRequestProperties deserializedPurchaseRequestProperties = new PurchaseRequestProperties();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("displayName".equals(fieldName)) {
deserializedPurchaseRequestProperties.displayName = reader.getString();
} else if ("billingScopeId".equals(fieldName)) {
deserializedPurchaseRequestProperties.billingScopeId = reader.getString();
} else if ("term".equals(fieldName)) {
deserializedPurchaseRequestProperties.term = SavingsPlanTerm.fromString(reader.getString());
} else if ("billingPlan".equals(fieldName)) {
deserializedPurchaseRequestProperties.billingPlan = BillingPlan.fromString(reader.getString());
} else if ("appliedScopeType".equals(fieldName)) {
deserializedPurchaseRequestProperties.appliedScopeType
= AppliedScopeType.fromString(reader.getString());
} else if ("commitment".equals(fieldName)) {
deserializedPurchaseRequestProperties.commitment = Commitment.fromJson(reader);
} else if ("renew".equals(fieldName)) {
deserializedPurchaseRequestProperties.renew = reader.getNullable(JsonReader::getBoolean);
} else if ("appliedScopeProperties".equals(fieldName)) {
deserializedPurchaseRequestProperties.appliedScopeProperties
= AppliedScopeProperties.fromJson(reader);
} else {
reader.skipChildren();
}
}
return deserializedPurchaseRequestProperties;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy