All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.resourcemanager.elasticsan.models.EncryptionProperties 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.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 java.io.IOException;

/**
 * The encryption settings on the volume group.
 */
@Fluent
public final class EncryptionProperties implements JsonSerializable {
    /*
     * Properties provided by key vault.
     */
    private KeyVaultProperties keyVaultProperties;

    /*
     * The identity to be used with service-side encryption at rest.
     */
    private EncryptionIdentity encryptionIdentity;

    /**
     * Creates an instance of EncryptionProperties class.
     */
    public EncryptionProperties() {
    }

    /**
     * Get the keyVaultProperties property: Properties provided by key vault.
     * 
     * @return the keyVaultProperties value.
     */
    public KeyVaultProperties keyVaultProperties() {
        return this.keyVaultProperties;
    }

    /**
     * Set the keyVaultProperties property: Properties provided by key vault.
     * 
     * @param keyVaultProperties the keyVaultProperties value to set.
     * @return the EncryptionProperties object itself.
     */
    public EncryptionProperties withKeyVaultProperties(KeyVaultProperties keyVaultProperties) {
        this.keyVaultProperties = keyVaultProperties;
        return this;
    }

    /**
     * Get the encryptionIdentity property: The identity to be used with service-side encryption at rest.
     * 
     * @return the encryptionIdentity value.
     */
    public EncryptionIdentity encryptionIdentity() {
        return this.encryptionIdentity;
    }

    /**
     * Set the encryptionIdentity property: The identity to be used with service-side encryption at rest.
     * 
     * @param encryptionIdentity the encryptionIdentity value to set.
     * @return the EncryptionProperties object itself.
     */
    public EncryptionProperties withEncryptionIdentity(EncryptionIdentity encryptionIdentity) {
        this.encryptionIdentity = encryptionIdentity;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (keyVaultProperties() != null) {
            keyVaultProperties().validate();
        }
        if (encryptionIdentity() != null) {
            encryptionIdentity().validate();
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeJsonField("keyVaultProperties", this.keyVaultProperties);
        jsonWriter.writeJsonField("identity", this.encryptionIdentity);
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of EncryptionProperties from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of EncryptionProperties 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 EncryptionProperties.
     */
    public static EncryptionProperties fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            EncryptionProperties deserializedEncryptionProperties = new EncryptionProperties();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("keyVaultProperties".equals(fieldName)) {
                    deserializedEncryptionProperties.keyVaultProperties = KeyVaultProperties.fromJson(reader);
                } else if ("identity".equals(fieldName)) {
                    deserializedEncryptionProperties.encryptionIdentity = EncryptionIdentity.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedEncryptionProperties;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy