com.azure.resourcemanager.elasticsan.fluent.models.SkuInformationInner 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.elasticsan.fluent.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 com.azure.resourcemanager.elasticsan.models.SkuCapability;
import com.azure.resourcemanager.elasticsan.models.SkuLocationInfo;
import com.azure.resourcemanager.elasticsan.models.SkuName;
import com.azure.resourcemanager.elasticsan.models.SkuTier;
import java.io.IOException;
import java.util.List;
/**
* ElasticSAN SKU and its properties.
*/
@Fluent
public final class SkuInformationInner implements JsonSerializable {
/*
* Sku Name
*/
private SkuName name;
/*
* Sku Tier
*/
private SkuTier tier;
/*
* The type of the resource.
*/
private String resourceType;
/*
* The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g.
* West US, East US, Southeast Asia, etc.).
*/
private List locations;
/*
* Availability of the SKU for the location/zone
*/
private List locationInfo;
/*
* The capability information in the specified SKU.
*/
private List capabilities;
/**
* Creates an instance of SkuInformationInner class.
*/
public SkuInformationInner() {
}
/**
* Get the name property: Sku Name.
*
* @return the name value.
*/
public SkuName name() {
return this.name;
}
/**
* Set the name property: Sku Name.
*
* @param name the name value to set.
* @return the SkuInformationInner object itself.
*/
public SkuInformationInner withName(SkuName name) {
this.name = name;
return this;
}
/**
* Get the tier property: Sku Tier.
*
* @return the tier value.
*/
public SkuTier tier() {
return this.tier;
}
/**
* Set the tier property: Sku Tier.
*
* @param tier the tier value to set.
* @return the SkuInformationInner object itself.
*/
public SkuInformationInner withTier(SkuTier tier) {
this.tier = tier;
return this;
}
/**
* Get the resourceType property: The type of the resource.
*
* @return the resourceType value.
*/
public String resourceType() {
return this.resourceType;
}
/**
* Get the locations property: The set of locations that the SKU is available. This will be supported and registered
* Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.).
*
* @return the locations value.
*/
public List locations() {
return this.locations;
}
/**
* Get the locationInfo property: Availability of the SKU for the location/zone.
*
* @return the locationInfo value.
*/
public List locationInfo() {
return this.locationInfo;
}
/**
* Get the capabilities property: The capability information in the specified SKU.
*
* @return the capabilities value.
*/
public List capabilities() {
return this.capabilities;
}
/**
* 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 SkuInformationInner"));
}
if (locationInfo() != null) {
locationInfo().forEach(e -> e.validate());
}
if (capabilities() != null) {
capabilities().forEach(e -> e.validate());
}
}
private static final ClientLogger LOGGER = new ClientLogger(SkuInformationInner.class);
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("name", this.name == null ? null : this.name.toString());
jsonWriter.writeStringField("tier", this.tier == null ? null : this.tier.toString());
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of SkuInformationInner from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of SkuInformationInner 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 SkuInformationInner.
*/
public static SkuInformationInner fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
SkuInformationInner deserializedSkuInformationInner = new SkuInformationInner();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("name".equals(fieldName)) {
deserializedSkuInformationInner.name = SkuName.fromString(reader.getString());
} else if ("tier".equals(fieldName)) {
deserializedSkuInformationInner.tier = SkuTier.fromString(reader.getString());
} else if ("resourceType".equals(fieldName)) {
deserializedSkuInformationInner.resourceType = reader.getString();
} else if ("locations".equals(fieldName)) {
List locations = reader.readArray(reader1 -> reader1.getString());
deserializedSkuInformationInner.locations = locations;
} else if ("locationInfo".equals(fieldName)) {
List locationInfo = reader.readArray(reader1 -> SkuLocationInfo.fromJson(reader1));
deserializedSkuInformationInner.locationInfo = locationInfo;
} else if ("capabilities".equals(fieldName)) {
List capabilities = reader.readArray(reader1 -> SkuCapability.fromJson(reader1));
deserializedSkuInformationInner.capabilities = capabilities;
} else {
reader.skipChildren();
}
}
return deserializedSkuInformationInner;
});
}
}