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

package com.azure.resourcemanager.azureadexternalidentities.generated;

import com.azure.core.util.Context;
import com.azure.resourcemanager.azureadexternalidentities.models.B2CResourceSku;
import com.azure.resourcemanager.azureadexternalidentities.models.B2CResourceSkuName;
import com.azure.resourcemanager.azureadexternalidentities.models.B2CTenantResource;
import com.azure.resourcemanager.azureadexternalidentities.models.B2CTenantResourcePropertiesBillingConfig;
import com.azure.resourcemanager.azureadexternalidentities.models.BillingType;
import java.util.HashMap;
import java.util.Map;

/** Samples for B2CTenants Update. */
public final class B2CTenantsUpdateSamples {
    /*
     * x-ms-original-file: specification/cpim/resource-manager/Microsoft.AzureActiveDirectory/stable/2021-04-01/examples/updateTenant.json
     */
    /**
     * Sample code: Update tenant.
     *
     * @param manager Entry point to ExternalIdentitiesConfigurationManager.
     */
    public static void updateTenant(
        com.azure.resourcemanager.azureadexternalidentities.ExternalIdentitiesConfigurationManager manager) {
        B2CTenantResource resource =
            manager
                .b2CTenants()
                .getByResourceGroupWithResponse("contosoResourceGroup", "contoso.onmicrosoft.com", Context.NONE)
                .getValue();
        resource
            .update()
            .withTags(mapOf("key", "value"))
            .withSku(new B2CResourceSku().withName(B2CResourceSkuName.PREMIUM_P1))
            .withBillingConfig(new B2CTenantResourcePropertiesBillingConfig().withBillingType(BillingType.MAU))
            .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;
    }
}
