
com.azure.resourcemanager.billing.models.PatchModel 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 com.azure.resourcemanager.billing.fluent.models.PatchProperties;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.util.Map;
/**
* The request for reservation patch.
*/
@Fluent
public final class PatchModel implements JsonSerializable {
/*
* Properties for reservation patch
*/
private PatchProperties innerProperties;
/*
* The sku information associated to this reservation
*/
private ReservationSkuProperty sku;
/*
* Tags for this reservation
*/
private Map tags;
/**
* Creates an instance of PatchModel class.
*/
public PatchModel() {
}
/**
* Get the innerProperties property: Properties for reservation patch.
*
* @return the innerProperties value.
*/
private PatchProperties innerProperties() {
return this.innerProperties;
}
/**
* Get the sku property: The sku information associated to this reservation.
*
* @return the sku value.
*/
public ReservationSkuProperty sku() {
return this.sku;
}
/**
* Set the sku property: The sku information associated to this reservation.
*
* @param sku the sku value to set.
* @return the PatchModel object itself.
*/
public PatchModel withSku(ReservationSkuProperty sku) {
this.sku = sku;
return this;
}
/**
* Get the tags property: Tags for this reservation.
*
* @return the tags value.
*/
public Map tags() {
return this.tags;
}
/**
* Set the tags property: Tags for this reservation.
*
* @param tags the tags value to set.
* @return the PatchModel object itself.
*/
public PatchModel withTags(Map tags) {
this.tags = tags;
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 PatchModel object itself.
*/
public PatchModel withAppliedScopeType(AppliedScopeType appliedScopeType) {
if (this.innerProperties() == null) {
this.innerProperties = new PatchProperties();
}
this.innerProperties().withAppliedScopeType(appliedScopeType);
return this;
}
/**
* Get the appliedScopeProperties property: Properties specific to applied scope type. Not required if not
* applicable. Required and need to provide tenantId and managementGroupId if AppliedScopeType is ManagementGroup.
*
* @return the appliedScopeProperties value.
*/
public ReservationAppliedScopeProperties appliedScopeProperties() {
return this.innerProperties() == null ? null : this.innerProperties().appliedScopeProperties();
}
/**
* Set the appliedScopeProperties property: Properties specific to applied scope type. Not required if not
* applicable. Required and need to provide tenantId and managementGroupId if AppliedScopeType is ManagementGroup.
*
* @param appliedScopeProperties the appliedScopeProperties value to set.
* @return the PatchModel object itself.
*/
public PatchModel withAppliedScopeProperties(ReservationAppliedScopeProperties appliedScopeProperties) {
if (this.innerProperties() == null) {
this.innerProperties = new PatchProperties();
}
this.innerProperties().withAppliedScopeProperties(appliedScopeProperties);
return this;
}
/**
* Get the instanceFlexibility property: Turning this on will apply the reservation discount to other VMs in the
* same VM size group. Only specify for VirtualMachines reserved resource type.
*
* @return the instanceFlexibility value.
*/
public InstanceFlexibility instanceFlexibility() {
return this.innerProperties() == null ? null : this.innerProperties().instanceFlexibility();
}
/**
* Set the instanceFlexibility property: Turning this on will apply the reservation discount to other VMs in the
* same VM size group. Only specify for VirtualMachines reserved resource type.
*
* @param instanceFlexibility the instanceFlexibility value to set.
* @return the PatchModel object itself.
*/
public PatchModel withInstanceFlexibility(InstanceFlexibility instanceFlexibility) {
if (this.innerProperties() == null) {
this.innerProperties = new PatchProperties();
}
this.innerProperties().withInstanceFlexibility(instanceFlexibility);
return this;
}
/**
* Get the displayName property: Display name of the reservation.
*
* @return the displayName value.
*/
public String displayName() {
return this.innerProperties() == null ? null : this.innerProperties().displayName();
}
/**
* Set the displayName property: Display name of the reservation.
*
* @param displayName the displayName value to set.
* @return the PatchModel object itself.
*/
public PatchModel withDisplayName(String displayName) {
if (this.innerProperties() == null) {
this.innerProperties = new PatchProperties();
}
this.innerProperties().withDisplayName(displayName);
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 PatchModel object itself.
*/
public PatchModel withRenew(Boolean renew) {
if (this.innerProperties() == null) {
this.innerProperties = new PatchProperties();
}
this.innerProperties().withRenew(renew);
return this;
}
/**
* Get the reviewDateTime property: This is the date-time when the Azure hybrid benefit needs to be reviewed.
*
* @return the reviewDateTime value.
*/
public OffsetDateTime reviewDateTime() {
return this.innerProperties() == null ? null : this.innerProperties().reviewDateTime();
}
/**
* Set the reviewDateTime property: This is the date-time when the Azure hybrid benefit needs to be reviewed.
*
* @param reviewDateTime the reviewDateTime value to set.
* @return the PatchModel object itself.
*/
public PatchModel withReviewDateTime(OffsetDateTime reviewDateTime) {
if (this.innerProperties() == null) {
this.innerProperties = new PatchProperties();
}
this.innerProperties().withReviewDateTime(reviewDateTime);
return this;
}
/**
* Get the purchaseProperties property: The request for reservation purchase.
*
* @return the purchaseProperties value.
*/
public ReservationPurchaseRequest purchaseProperties() {
return this.innerProperties() == null ? null : this.innerProperties().purchaseProperties();
}
/**
* Set the purchaseProperties property: The request for reservation purchase.
*
* @param purchaseProperties the purchaseProperties value to set.
* @return the PatchModel object itself.
*/
public PatchModel withPurchaseProperties(ReservationPurchaseRequest purchaseProperties) {
if (this.innerProperties() == null) {
this.innerProperties = new PatchProperties();
}
this.innerProperties().withPurchaseProperties(purchaseProperties);
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (innerProperties() != null) {
innerProperties().validate();
}
if (sku() != null) {
sku().validate();
}
}
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeJsonField("properties", this.innerProperties);
jsonWriter.writeJsonField("sku", this.sku);
jsonWriter.writeMapField("tags", this.tags, (writer, element) -> writer.writeString(element));
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of PatchModel from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of PatchModel 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 PatchModel.
*/
public static PatchModel fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
PatchModel deserializedPatchModel = new PatchModel();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("properties".equals(fieldName)) {
deserializedPatchModel.innerProperties = PatchProperties.fromJson(reader);
} else if ("sku".equals(fieldName)) {
deserializedPatchModel.sku = ReservationSkuProperty.fromJson(reader);
} else if ("tags".equals(fieldName)) {
Map tags = reader.readMap(reader1 -> reader1.getString());
deserializedPatchModel.tags = tags;
} else {
reader.skipChildren();
}
}
return deserializedPatchModel;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy