// 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.DataLakeStoreAccount;
import com.azure.resourcemanager.datalakestore.models.FirewallAllowAzureIpsState;
import com.azure.resourcemanager.datalakestore.models.FirewallState;
import com.azure.resourcemanager.datalakestore.models.TierType;
import com.azure.resourcemanager.datalakestore.models.TrustedIdProviderState;
import com.azure.resourcemanager.datalakestore.models.UpdateEncryptionConfig;
import com.azure.resourcemanager.datalakestore.models.UpdateKeyVaultMetaInfo;
import java.util.HashMap;
import java.util.Map;

/** Samples for Accounts Update. */
public final class AccountsUpdateSamples {
    /*
     * x-ms-original-file: specification/datalake-store/resource-manager/Microsoft.DataLakeStore/stable/2016-11-01/examples/Accounts_Update.json
     */
    /**
     * Sample code: Updates the specified Data Lake Store account information.
     *
     * @param manager Entry point to DataLakeStoreManager.
     */
    public static void updatesTheSpecifiedDataLakeStoreAccountInformation(
        com.azure.resourcemanager.datalakestore.DataLakeStoreManager manager) {
        DataLakeStoreAccount resource =
            manager
                .accounts()
                .getByResourceGroupWithResponse("contosorg", "contosoadla", com.azure.core.util.Context.NONE)
                .getValue();
        resource
            .update()
            .withTags(mapOf("test_key", "test_value"))
            .withDefaultGroup("test_default_group")
            .withEncryptionConfig(
                new UpdateEncryptionConfig()
                    .withKeyVaultMetaInfo(
                        new UpdateKeyVaultMetaInfo().withEncryptionKeyVersion("fakeTokenPlaceholder")))
            .withFirewallState(FirewallState.ENABLED)
            .withFirewallAllowAzureIps(FirewallAllowAzureIpsState.ENABLED)
            .withTrustedIdProviderState(TrustedIdProviderState.ENABLED)
            .withNewTier(TierType.CONSUMPTION)
            .apply();
    }

    @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;
    }
}
