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

com.azure.resourcemanager.datafactory.models.EncryptionConfiguration 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.datafactory.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;

/**
 * Definition of CMK for the factory.
 */
@Fluent
public final class EncryptionConfiguration implements JsonSerializable {
    /*
     * The name of the key in Azure Key Vault to use as Customer Managed Key.
     */
    private String keyName;

    /*
     * The url of the Azure Key Vault used for CMK.
     */
    private String vaultBaseUrl;

    /*
     * The version of the key used for CMK. If not provided, latest version will be used.
     */
    private String keyVersion;

    /*
     * User assigned identity to use to authenticate to customer's key vault. If not provided Managed Service Identity
     * will be used.
     */
    private CmkIdentityDefinition identity;

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

    /**
     * Get the keyName property: The name of the key in Azure Key Vault to use as Customer Managed Key.
     * 
     * @return the keyName value.
     */
    public String keyName() {
        return this.keyName;
    }

    /**
     * Set the keyName property: The name of the key in Azure Key Vault to use as Customer Managed Key.
     * 
     * @param keyName the keyName value to set.
     * @return the EncryptionConfiguration object itself.
     */
    public EncryptionConfiguration withKeyName(String keyName) {
        this.keyName = keyName;
        return this;
    }

    /**
     * Get the vaultBaseUrl property: The url of the Azure Key Vault used for CMK.
     * 
     * @return the vaultBaseUrl value.
     */
    public String vaultBaseUrl() {
        return this.vaultBaseUrl;
    }

    /**
     * Set the vaultBaseUrl property: The url of the Azure Key Vault used for CMK.
     * 
     * @param vaultBaseUrl the vaultBaseUrl value to set.
     * @return the EncryptionConfiguration object itself.
     */
    public EncryptionConfiguration withVaultBaseUrl(String vaultBaseUrl) {
        this.vaultBaseUrl = vaultBaseUrl;
        return this;
    }

    /**
     * Get the keyVersion property: The version of the key used for CMK. If not provided, latest version will be used.
     * 
     * @return the keyVersion value.
     */
    public String keyVersion() {
        return this.keyVersion;
    }

    /**
     * Set the keyVersion property: The version of the key used for CMK. If not provided, latest version will be used.
     * 
     * @param keyVersion the keyVersion value to set.
     * @return the EncryptionConfiguration object itself.
     */
    public EncryptionConfiguration withKeyVersion(String keyVersion) {
        this.keyVersion = keyVersion;
        return this;
    }

    /**
     * Get the identity property: User assigned identity to use to authenticate to customer's key vault. If not provided
     * Managed Service Identity will be used.
     * 
     * @return the identity value.
     */
    public CmkIdentityDefinition identity() {
        return this.identity;
    }

    /**
     * Set the identity property: User assigned identity to use to authenticate to customer's key vault. If not provided
     * Managed Service Identity will be used.
     * 
     * @param identity the identity value to set.
     * @return the EncryptionConfiguration object itself.
     */
    public EncryptionConfiguration withIdentity(CmkIdentityDefinition identity) {
        this.identity = identity;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (keyName() == null) {
            throw LOGGER.atError()
                .log(
                    new IllegalArgumentException("Missing required property keyName in model EncryptionConfiguration"));
        }
        if (vaultBaseUrl() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property vaultBaseUrl in model EncryptionConfiguration"));
        }
        if (identity() != null) {
            identity().validate();
        }
    }

    private static final ClientLogger LOGGER = new ClientLogger(EncryptionConfiguration.class);

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

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

                if ("keyName".equals(fieldName)) {
                    deserializedEncryptionConfiguration.keyName = reader.getString();
                } else if ("vaultBaseUrl".equals(fieldName)) {
                    deserializedEncryptionConfiguration.vaultBaseUrl = reader.getString();
                } else if ("keyVersion".equals(fieldName)) {
                    deserializedEncryptionConfiguration.keyVersion = reader.getString();
                } else if ("identity".equals(fieldName)) {
                    deserializedEncryptionConfiguration.identity = CmkIdentityDefinition.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedEncryptionConfiguration;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy