com.azure.resourcemanager.compute.models.PurchasePlanAutoGenerated Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-compute Show documentation
Show all versions of azure-resourcemanager-compute Show documentation
This package contains Microsoft Azure Compute Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.compute.models;
import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
/**
* Used for establishing the purchase context of any 3rd Party artifact through MarketPlace.
*/
@Fluent
public final class PurchasePlanAutoGenerated implements JsonSerializable {
/*
* The plan ID.
*/
private String name;
/*
* The publisher ID.
*/
private String publisher;
/*
* Specifies the product of the image from the marketplace. This is the same value as Offer under the imageReference
* element.
*/
private String product;
/*
* The Offer Promotion Code.
*/
private String promotionCode;
/**
* Creates an instance of PurchasePlanAutoGenerated class.
*/
public PurchasePlanAutoGenerated() {
}
/**
* Get the name property: The plan ID.
*
* @return the name value.
*/
public String name() {
return this.name;
}
/**
* Set the name property: The plan ID.
*
* @param name the name value to set.
* @return the PurchasePlanAutoGenerated object itself.
*/
public PurchasePlanAutoGenerated withName(String name) {
this.name = name;
return this;
}
/**
* Get the publisher property: The publisher ID.
*
* @return the publisher value.
*/
public String publisher() {
return this.publisher;
}
/**
* Set the publisher property: The publisher ID.
*
* @param publisher the publisher value to set.
* @return the PurchasePlanAutoGenerated object itself.
*/
public PurchasePlanAutoGenerated withPublisher(String publisher) {
this.publisher = publisher;
return this;
}
/**
* Get the product property: Specifies the product of the image from the marketplace. This is the same value as
* Offer under the imageReference element.
*
* @return the product value.
*/
public String product() {
return this.product;
}
/**
* Set the product property: Specifies the product of the image from the marketplace. This is the same value as
* Offer under the imageReference element.
*
* @param product the product value to set.
* @return the PurchasePlanAutoGenerated object itself.
*/
public PurchasePlanAutoGenerated withProduct(String product) {
this.product = product;
return this;
}
/**
* Get the promotionCode property: The Offer Promotion Code.
*
* @return the promotionCode value.
*/
public String promotionCode() {
return this.promotionCode;
}
/**
* Set the promotionCode property: The Offer Promotion Code.
*
* @param promotionCode the promotionCode value to set.
* @return the PurchasePlanAutoGenerated object itself.
*/
public PurchasePlanAutoGenerated withPromotionCode(String promotionCode) {
this.promotionCode = promotionCode;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (name() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException("Missing required property name in model PurchasePlanAutoGenerated"));
}
if (publisher() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property publisher in model PurchasePlanAutoGenerated"));
}
if (product() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property product in model PurchasePlanAutoGenerated"));
}
}
private static final ClientLogger LOGGER = new ClientLogger(PurchasePlanAutoGenerated.class);
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("name", this.name);
jsonWriter.writeStringField("publisher", this.publisher);
jsonWriter.writeStringField("product", this.product);
jsonWriter.writeStringField("promotionCode", this.promotionCode);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of PurchasePlanAutoGenerated from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of PurchasePlanAutoGenerated 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 PurchasePlanAutoGenerated.
*/
public static PurchasePlanAutoGenerated fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
PurchasePlanAutoGenerated deserializedPurchasePlanAutoGenerated = new PurchasePlanAutoGenerated();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("name".equals(fieldName)) {
deserializedPurchasePlanAutoGenerated.name = reader.getString();
} else if ("publisher".equals(fieldName)) {
deserializedPurchasePlanAutoGenerated.publisher = reader.getString();
} else if ("product".equals(fieldName)) {
deserializedPurchasePlanAutoGenerated.product = reader.getString();
} else if ("promotionCode".equals(fieldName)) {
deserializedPurchasePlanAutoGenerated.promotionCode = reader.getString();
} else {
reader.skipChildren();
}
}
return deserializedPurchasePlanAutoGenerated;
});
}
}