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

package com.azure.resourcemanager.applicationinsights.generated;

import com.azure.core.util.Context;
import com.azure.resourcemanager.applicationinsights.models.ApplicationInsightsComponent;
import java.util.HashMap;
import java.util.Map;

/** Samples for Components UpdateTags. */
public final class ComponentsUpdateTagsSamples {
    /*
     * x-ms-original-file: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-02-02/examples/ComponentsUpdateTagsOnly.json
     */
    /**
     * Sample code: ComponentUpdateTagsOnly.
     *
     * @param manager Entry point to ApplicationInsightsManager.
     */
    public static void componentUpdateTagsOnly(
        com.azure.resourcemanager.applicationinsights.ApplicationInsightsManager manager) {
        ApplicationInsightsComponent resource =
            manager
                .components()
                .getByResourceGroupWithResponse("my-resource-group", "my-component", Context.NONE)
                .getValue();
        resource
            .update()
            .withTags(
                mapOf(
                    "ApplicationGatewayType",
                    "Internal-Only",
                    "BillingEntity",
                    "Self",
                    "Color",
                    "AzureBlue",
                    "CustomField_01",
                    "Custom text in some random field named randomly",
                    "NodeType",
                    "Edge"))
            .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;
    }
}
