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

package com.azure.resourcemanager.loganalytics.generated;

import com.azure.core.util.Context;
import com.azure.resourcemanager.loganalytics.models.LogAnalyticsQueryPack;
import java.util.HashMap;
import java.util.Map;

/** Samples for QueryPacks UpdateTags. */
public final class QueryPacksUpdateTagsSamples {
    /*
     * x-ms-original-file: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPacksUpdateTagsOnly.json
     */
    /**
     * Sample code: QueryPackUpdateTagsOnly.
     *
     * @param manager Entry point to LogAnalyticsManager.
     */
    public static void queryPackUpdateTagsOnly(com.azure.resourcemanager.loganalytics.LogAnalyticsManager manager) {
        LogAnalyticsQueryPack resource =
            manager
                .queryPacks()
                .getByResourceGroupWithResponse("my-resource-group", "my-querypack", Context.NONE)
                .getValue();
        resource.update().withTags(mapOf("Tag1", "Value1", "Tag2", "Value2")).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;
    }
}
