// *** WARNING: this file was generated by pulumi-java-gen. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

package com.pulumi.azure.appconfiguration;

import com.pulumi.azure.Utilities;
import com.pulumi.azure.appconfiguration.ConfigurationKeyArgs;
import com.pulumi.azure.appconfiguration.inputs.ConfigurationKeyState;
import com.pulumi.core.Output;
import com.pulumi.core.annotations.Export;
import com.pulumi.core.annotations.ResourceType;
import com.pulumi.core.internal.Codegen;
import java.lang.Boolean;
import java.lang.String;
import java.util.Map;
import java.util.Optional;
import javax.annotation.Nullable;

/**
 * Manages an Azure App Configuration Key.
 * 
 * &gt; **Note:** App Configuration Keys are provisioned using a Data Plane API which requires the role `App Configuration Data Owner` on either the App Configuration or a parent scope (such as the Resource Group/Subscription). [More information can be found in the Azure Documentation for App Configuration](https://docs.microsoft.com/azure/azure-app-configuration/concept-enable-rbac#azure-built-in-roles-for-azure-app-configuration).
 * 
 * ## Example Usage
 * ### `Kv` Type
 * ```java
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.azure.core.ResourceGroup;
 * import com.pulumi.azure.core.ResourceGroupArgs;
 * import com.pulumi.azure.appconfiguration.ConfigurationStore;
 * import com.pulumi.azure.appconfiguration.ConfigurationStoreArgs;
 * import com.pulumi.azure.core.CoreFunctions;
 * import com.pulumi.azure.authorization.Assignment;
 * import com.pulumi.azure.authorization.AssignmentArgs;
 * import com.pulumi.azure.appconfiguration.ConfigurationKey;
 * import com.pulumi.azure.appconfiguration.ConfigurationKeyArgs;
 * import com.pulumi.resources.CustomResourceOptions;
 * import java.util.List;
 * import java.util.ArrayList;
 * import java.util.Map;
 * import java.io.File;
 * import java.nio.file.Files;
 * import java.nio.file.Paths;
 * 
 * public class App {
 *     public static void main(String[] args) {
 *         Pulumi.run(App::stack);
 *     }
 * 
 *     public static void stack(Context ctx) {
 *         var example = new ResourceGroup(&#34;example&#34;, ResourceGroupArgs.builder()        
 *             .location(&#34;West Europe&#34;)
 *             .build());
 * 
 *         var appconf = new ConfigurationStore(&#34;appconf&#34;, ConfigurationStoreArgs.builder()        
 *             .resourceGroupName(example.name())
 *             .location(example.location())
 *             .build());
 * 
 *         final var current = CoreFunctions.getClientConfig();
 * 
 *         var appconfDataowner = new Assignment(&#34;appconfDataowner&#34;, AssignmentArgs.builder()        
 *             .scope(appconf.id())
 *             .roleDefinitionName(&#34;App Configuration Data Owner&#34;)
 *             .principalId(current.applyValue(getClientConfigResult -&gt; getClientConfigResult.objectId()))
 *             .build());
 * 
 *         var test = new ConfigurationKey(&#34;test&#34;, ConfigurationKeyArgs.builder()        
 *             .configurationStoreId(appconf.id())
 *             .key(&#34;appConfKey1&#34;)
 *             .label(&#34;somelabel&#34;)
 *             .value(&#34;a test&#34;)
 *             .build(), CustomResourceOptions.builder()
 *                 .dependsOn(appconfDataowner)
 *                 .build());
 * 
 *     }
 * }
 * ```
 * ### `Vault` Type
 * ```java
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.azure.core.ResourceGroup;
 * import com.pulumi.azure.core.ResourceGroupArgs;
 * import com.pulumi.azure.appconfiguration.ConfigurationStore;
 * import com.pulumi.azure.appconfiguration.ConfigurationStoreArgs;
 * import com.pulumi.azure.core.CoreFunctions;
 * import com.pulumi.azure.keyvault.KeyVault;
 * import com.pulumi.azure.keyvault.KeyVaultArgs;
 * import com.pulumi.azure.keyvault.inputs.KeyVaultAccessPolicyArgs;
 * import com.pulumi.azure.keyvault.Secret;
 * import com.pulumi.azure.keyvault.SecretArgs;
 * import com.pulumi.azure.authorization.Assignment;
 * import com.pulumi.azure.authorization.AssignmentArgs;
 * import com.pulumi.azure.appconfiguration.ConfigurationKey;
 * import com.pulumi.azure.appconfiguration.ConfigurationKeyArgs;
 * import com.pulumi.resources.CustomResourceOptions;
 * import java.util.List;
 * import java.util.ArrayList;
 * import java.util.Map;
 * import java.io.File;
 * import java.nio.file.Files;
 * import java.nio.file.Paths;
 * 
 * public class App {
 *     public static void main(String[] args) {
 *         Pulumi.run(App::stack);
 *     }
 * 
 *     public static void stack(Context ctx) {
 *         var example = new ResourceGroup(&#34;example&#34;, ResourceGroupArgs.builder()        
 *             .location(&#34;West Europe&#34;)
 *             .build());
 * 
 *         var appconf = new ConfigurationStore(&#34;appconf&#34;, ConfigurationStoreArgs.builder()        
 *             .resourceGroupName(example.name())
 *             .location(example.location())
 *             .build());
 * 
 *         final var current = CoreFunctions.getClientConfig();
 * 
 *         var kv = new KeyVault(&#34;kv&#34;, KeyVaultArgs.builder()        
 *             .location(azurerm_resource_group.test().location())
 *             .resourceGroupName(azurerm_resource_group.test().name())
 *             .tenantId(current.applyValue(getClientConfigResult -&gt; getClientConfigResult.tenantId()))
 *             .skuName(&#34;premium&#34;)
 *             .softDeleteRetentionDays(7)
 *             .accessPolicies(KeyVaultAccessPolicyArgs.builder()
 *                 .tenantId(current.applyValue(getClientConfigResult -&gt; getClientConfigResult.tenantId()))
 *                 .objectId(current.applyValue(getClientConfigResult -&gt; getClientConfigResult.objectId()))
 *                 .keyPermissions(                
 *                     &#34;Create&#34;,
 *                     &#34;Get&#34;)
 *                 .secretPermissions(                
 *                     &#34;Set&#34;,
 *                     &#34;Get&#34;,
 *                     &#34;Delete&#34;,
 *                     &#34;Purge&#34;,
 *                     &#34;Recover&#34;)
 *                 .build())
 *             .build());
 * 
 *         var kvs = new Secret(&#34;kvs&#34;, SecretArgs.builder()        
 *             .value(&#34;szechuan&#34;)
 *             .keyVaultId(kv.id())
 *             .build());
 * 
 *         var appconfDataowner = new Assignment(&#34;appconfDataowner&#34;, AssignmentArgs.builder()        
 *             .scope(appconf.id())
 *             .roleDefinitionName(&#34;App Configuration Data Owner&#34;)
 *             .principalId(current.applyValue(getClientConfigResult -&gt; getClientConfigResult.objectId()))
 *             .build());
 * 
 *         var test = new ConfigurationKey(&#34;test&#34;, ConfigurationKeyArgs.builder()        
 *             .configurationStoreId(azurerm_app_configuration.test().id())
 *             .key(&#34;key1&#34;)
 *             .type(&#34;vault&#34;)
 *             .label(&#34;label1&#34;)
 *             .vaultKeyReference(kvs.versionlessId())
 *             .build(), CustomResourceOptions.builder()
 *                 .dependsOn(appconfDataowner)
 *                 .build());
 * 
 *     }
 * }
 * ```
 * 
 * ## Import
 * 
 * App Configuration Keys can be imported using the `resource id`, e.g.
 * 
 * ```sh
 *  $ pulumi import azure:appconfiguration/configurationKey:ConfigurationKey test https://appconfname1.azconfig.io/kv/keyName?label=labelName
 * ```
 * 
 *  If you wish to import a key with an empty label then simply leave label&#39;s name blank
 * 
 * ```sh
 *  $ pulumi import azure:appconfiguration/configurationKey:ConfigurationKey test https://appconfname1.azconfig.io/kv/keyName?label=
 * ```
 * 
 */
@ResourceType(type="azure:appconfiguration/configurationKey:ConfigurationKey")
public class ConfigurationKey extends com.pulumi.resources.CustomResource {
    /**
     * Specifies the id of the App Configuration. Changing this forces a new resource to be created.
     * 
     */
    @Export(name="configurationStoreId", refs={String.class}, tree="[0]")
    private Output<String> configurationStoreId;

    /**
     * @return Specifies the id of the App Configuration. Changing this forces a new resource to be created.
     * 
     */
    public Output<String> configurationStoreId() {
        return this.configurationStoreId;
    }
    /**
     * The content type of the App Configuration Key. This should only be set when type is set to `kv`.
     * 
     */
    @Export(name="contentType", refs={String.class}, tree="[0]")
    private Output<String> contentType;

    /**
     * @return The content type of the App Configuration Key. This should only be set when type is set to `kv`.
     * 
     */
    public Output<String> contentType() {
        return this.contentType;
    }
    /**
     * (Optional) The ETag of the key.
     * 
     */
    @Export(name="etag", refs={String.class}, tree="[0]")
    private Output<String> etag;

    /**
     * @return (Optional) The ETag of the key.
     * 
     */
    public Output<String> etag() {
        return this.etag;
    }
    /**
     * The name of the App Configuration Key to create. Changing this forces a new resource to be created.
     * 
     */
    @Export(name="key", refs={String.class}, tree="[0]")
    private Output<String> key;

    /**
     * @return The name of the App Configuration Key to create. Changing this forces a new resource to be created.
     * 
     */
    public Output<String> key() {
        return this.key;
    }
    /**
     * The label of the App Configuration Key. Changing this forces a new resource to be created.
     * 
     */
    @Export(name="label", refs={String.class}, tree="[0]")
    private Output</* @Nullable */ String> label;

    /**
     * @return The label of the App Configuration Key. Changing this forces a new resource to be created.
     * 
     */
    public Output<Optional<String>> label() {
        return Codegen.optional(this.label);
    }
    /**
     * Should this App Configuration Key be Locked to prevent changes?
     * 
     */
    @Export(name="locked", refs={Boolean.class}, tree="[0]")
    private Output</* @Nullable */ Boolean> locked;

    /**
     * @return Should this App Configuration Key be Locked to prevent changes?
     * 
     */
    public Output<Optional<Boolean>> locked() {
        return Codegen.optional(this.locked);
    }
    /**
     * A mapping of tags to assign to the resource.
     * 
     */
    @Export(name="tags", refs={Map.class,String.class}, tree="[0,1,1]")
    private Output</* @Nullable */ Map<String,String>> tags;

    /**
     * @return A mapping of tags to assign to the resource.
     * 
     */
    public Output<Optional<Map<String,String>>> tags() {
        return Codegen.optional(this.tags);
    }
    /**
     * The type of the App Configuration Key. It can either be `kv` (simple [key/value](https://docs.microsoft.com/azure/azure-app-configuration/concept-key-value)) or `vault` (where the value is a reference to a [Key Vault Secret](https://azure.microsoft.com/en-gb/services/key-vault/).
     * 
     */
    @Export(name="type", refs={String.class}, tree="[0]")
    private Output</* @Nullable */ String> type;

    /**
     * @return The type of the App Configuration Key. It can either be `kv` (simple [key/value](https://docs.microsoft.com/azure/azure-app-configuration/concept-key-value)) or `vault` (where the value is a reference to a [Key Vault Secret](https://azure.microsoft.com/en-gb/services/key-vault/).
     * 
     */
    public Output<Optional<String>> type() {
        return Codegen.optional(this.type);
    }
    /**
     * The value of the App Configuration Key. This should only be set when type is set to `kv`.
     * 
     */
    @Export(name="value", refs={String.class}, tree="[0]")
    private Output<String> value;

    /**
     * @return The value of the App Configuration Key. This should only be set when type is set to `kv`.
     * 
     */
    public Output<String> value() {
        return this.value;
    }
    /**
     * The ID of the vault secret this App Configuration Key refers to, when `type` is set to `vault`.
     * 
     * &gt; **NOTE:** When setting the `vault_key_reference` using the `id` will pin the value to specific version of the secret, to reference latest secret value use `versionless_id`
     * 
     */
    @Export(name="vaultKeyReference", refs={String.class}, tree="[0]")
    private Output</* @Nullable */ String> vaultKeyReference;

    /**
     * @return The ID of the vault secret this App Configuration Key refers to, when `type` is set to `vault`.
     * 
     * &gt; **NOTE:** When setting the `vault_key_reference` using the `id` will pin the value to specific version of the secret, to reference latest secret value use `versionless_id`
     * 
     */
    public Output<Optional<String>> vaultKeyReference() {
        return Codegen.optional(this.vaultKeyReference);
    }

    /**
     *
     * @param name The _unique_ name of the resulting resource.
     */
    public ConfigurationKey(String name) {
        this(name, ConfigurationKeyArgs.Empty);
    }
    /**
     *
     * @param name The _unique_ name of the resulting resource.
     * @param args The arguments to use to populate this resource's properties.
     */
    public ConfigurationKey(String name, ConfigurationKeyArgs args) {
        this(name, args, null);
    }
    /**
     *
     * @param name The _unique_ name of the resulting resource.
     * @param args The arguments to use to populate this resource's properties.
     * @param options A bag of options that control this resource's behavior.
     */
    public ConfigurationKey(String name, ConfigurationKeyArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) {
        super("azure:appconfiguration/configurationKey:ConfigurationKey", name, args == null ? ConfigurationKeyArgs.Empty : args, makeResourceOptions(options, Codegen.empty()));
    }

    private ConfigurationKey(String name, Output<String> id, @Nullable ConfigurationKeyState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
        super("azure:appconfiguration/configurationKey:ConfigurationKey", name, state, makeResourceOptions(options, id));
    }

    private static com.pulumi.resources.CustomResourceOptions makeResourceOptions(@Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output<String> id) {
        var defaultOptions = com.pulumi.resources.CustomResourceOptions.builder()
            .version(Utilities.getVersion())
            .build();
        return com.pulumi.resources.CustomResourceOptions.merge(defaultOptions, options, id);
    }

    /**
     * Get an existing Host resource's state with the given name, ID, and optional extra
     * properties used to qualify the lookup.
     *
     * @param name The _unique_ name of the resulting resource.
     * @param id The _unique_ provider ID of the resource to lookup.
     * @param state
     * @param options Optional settings to control the behavior of the CustomResource.
     */
    public static ConfigurationKey get(String name, Output<String> id, @Nullable ConfigurationKeyState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
        return new ConfigurationKey(name, id, state, options);
    }
}
