// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.datalakestore.generated;

import com.azure.resourcemanager.datalakestore.models.CreateFirewallRuleWithAccountParameters;
import com.azure.resourcemanager.datalakestore.models.CreateTrustedIdProviderWithAccountParameters;
import com.azure.resourcemanager.datalakestore.models.EncryptionConfig;
import com.azure.resourcemanager.datalakestore.models.EncryptionConfigType;
import com.azure.resourcemanager.datalakestore.models.EncryptionIdentity;
import com.azure.resourcemanager.datalakestore.models.EncryptionState;
import com.azure.resourcemanager.datalakestore.models.FirewallAllowAzureIpsState;
import com.azure.resourcemanager.datalakestore.models.FirewallState;
import com.azure.resourcemanager.datalakestore.models.KeyVaultMetaInfo;
import com.azure.resourcemanager.datalakestore.models.TierType;
import com.azure.resourcemanager.datalakestore.models.TrustedIdProviderState;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/** Samples for Accounts Create. */
public final class AccountsCreateSamples {
    /*
     * x-ms-original-file: specification/datalake-store/resource-manager/Microsoft.DataLakeStore/stable/2016-11-01/examples/Accounts_Create.json
     */
    /**
     * Sample code: Creates the specified Data Lake Store account.
     *
     * @param manager Entry point to DataLakeStoreManager.
     */
    public static void createsTheSpecifiedDataLakeStoreAccount(
        com.azure.resourcemanager.datalakestore.DataLakeStoreManager manager) {
        manager
            .accounts()
            .define("contosoadla")
            .withRegion("eastus2")
            .withExistingResourceGroup("contosorg")
            .withTags(mapOf("test_key", "test_value"))
            .withIdentity(new EncryptionIdentity())
            .withDefaultGroup("test_default_group")
            .withEncryptionConfig(
                new EncryptionConfig()
                    .withType(EncryptionConfigType.USER_MANAGED)
                    .withKeyVaultMetaInfo(
                        new KeyVaultMetaInfo()
                            .withKeyVaultResourceId("fakeTokenPlaceholder")
                            .withEncryptionKeyName("fakeTokenPlaceholder")
                            .withEncryptionKeyVersion("fakeTokenPlaceholder")))
            .withEncryptionState(EncryptionState.ENABLED)
            .withFirewallRules(
                Arrays
                    .asList(
                        new CreateFirewallRuleWithAccountParameters()
                            .withName("test_rule")
                            .withStartIpAddress("1.1.1.1")
                            .withEndIpAddress("2.2.2.2")))
            .withFirewallState(FirewallState.ENABLED)
            .withFirewallAllowAzureIps(FirewallAllowAzureIpsState.ENABLED)
            .withTrustedIdProviders(
                Arrays
                    .asList(
                        new CreateTrustedIdProviderWithAccountParameters()
                            .withName("test_trusted_id_provider_name")
                            .withIdProvider("https://sts.windows.net/ea9ec534-a3e3-4e45-ad36-3afc5bb291c1")))
            .withTrustedIdProviderState(TrustedIdProviderState.ENABLED)
            .withNewTier(TierType.CONSUMPTION)
            .create();
    }

    @SuppressWarnings("unchecked")
    private static <T> Map<String, T> mapOf(Object... inputs) {
        Map<String, T> map = new HashMap<>();
        for (int i = 0; i < inputs.length; i += 2) {
            String key = (String) inputs[i];
            T value = (T) inputs[i + 1];
            map.put(key, value);
        }
        return map;
    }
}
