com.azure.resourcemanager.compute.models.ManagedDiskParameters 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.management.SubResource;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
/**
* The parameters of a managed disk.
*/
@Fluent
public final class ManagedDiskParameters extends SubResource {
/*
* Specifies the storage account type for the managed disk. NOTE: UltraSSD_LRS can only be used with data disks, it
* cannot be used with OS Disk.
*/
private StorageAccountTypes storageAccountType;
/*
* Specifies the customer managed disk encryption set resource id for the managed disk.
*/
private DiskEncryptionSetParameters diskEncryptionSet;
/*
* Specifies the security profile for the managed disk.
*/
private VMDiskSecurityProfile securityProfile;
/**
* Creates an instance of ManagedDiskParameters class.
*/
public ManagedDiskParameters() {
}
/**
* Get the storageAccountType property: Specifies the storage account type for the managed disk. NOTE: UltraSSD_LRS
* can only be used with data disks, it cannot be used with OS Disk.
*
* @return the storageAccountType value.
*/
public StorageAccountTypes storageAccountType() {
return this.storageAccountType;
}
/**
* Set the storageAccountType property: Specifies the storage account type for the managed disk. NOTE: UltraSSD_LRS
* can only be used with data disks, it cannot be used with OS Disk.
*
* @param storageAccountType the storageAccountType value to set.
* @return the ManagedDiskParameters object itself.
*/
public ManagedDiskParameters withStorageAccountType(StorageAccountTypes storageAccountType) {
this.storageAccountType = storageAccountType;
return this;
}
/**
* Get the diskEncryptionSet property: Specifies the customer managed disk encryption set resource id for the
* managed disk.
*
* @return the diskEncryptionSet value.
*/
public DiskEncryptionSetParameters diskEncryptionSet() {
return this.diskEncryptionSet;
}
/**
* Set the diskEncryptionSet property: Specifies the customer managed disk encryption set resource id for the
* managed disk.
*
* @param diskEncryptionSet the diskEncryptionSet value to set.
* @return the ManagedDiskParameters object itself.
*/
public ManagedDiskParameters withDiskEncryptionSet(DiskEncryptionSetParameters diskEncryptionSet) {
this.diskEncryptionSet = diskEncryptionSet;
return this;
}
/**
* Get the securityProfile property: Specifies the security profile for the managed disk.
*
* @return the securityProfile value.
*/
public VMDiskSecurityProfile securityProfile() {
return this.securityProfile;
}
/**
* Set the securityProfile property: Specifies the security profile for the managed disk.
*
* @param securityProfile the securityProfile value to set.
* @return the ManagedDiskParameters object itself.
*/
public ManagedDiskParameters withSecurityProfile(VMDiskSecurityProfile securityProfile) {
this.securityProfile = securityProfile;
return this;
}
/**
* {@inheritDoc}
*/
@Override
public ManagedDiskParameters withId(String id) {
super.withId(id);
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (diskEncryptionSet() != null) {
diskEncryptionSet().validate();
}
if (securityProfile() != null) {
securityProfile().validate();
}
}
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("id", id());
jsonWriter.writeStringField("storageAccountType",
this.storageAccountType == null ? null : this.storageAccountType.toString());
jsonWriter.writeJsonField("diskEncryptionSet", this.diskEncryptionSet);
jsonWriter.writeJsonField("securityProfile", this.securityProfile);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of ManagedDiskParameters from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of ManagedDiskParameters 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 ManagedDiskParameters.
*/
public static ManagedDiskParameters fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
ManagedDiskParameters deserializedManagedDiskParameters = new ManagedDiskParameters();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("id".equals(fieldName)) {
deserializedManagedDiskParameters.withId(reader.getString());
} else if ("storageAccountType".equals(fieldName)) {
deserializedManagedDiskParameters.storageAccountType
= StorageAccountTypes.fromString(reader.getString());
} else if ("diskEncryptionSet".equals(fieldName)) {
deserializedManagedDiskParameters.diskEncryptionSet = DiskEncryptionSetParameters.fromJson(reader);
} else if ("securityProfile".equals(fieldName)) {
deserializedManagedDiskParameters.securityProfile = VMDiskSecurityProfile.fromJson(reader);
} else {
reader.skipChildren();
}
}
return deserializedManagedDiskParameters;
});
}
}