// 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.LogAnalyticsQueryPackQuerySearchProperties;
import com.azure.resourcemanager.loganalytics.models.LogAnalyticsQueryPackQuerySearchPropertiesRelated;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/** Samples for Queries Search. */
public final class QueriesSearchSamples {
    /*
     * x-ms-original-file: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPackQueriesSearch.json
     */
    /**
     * Sample code: QuerySearch.
     *
     * @param manager Entry point to LogAnalyticsManager.
     */
    public static void querySearch(com.azure.resourcemanager.loganalytics.LogAnalyticsManager manager) {
        manager
            .queries()
            .search(
                "my-resource-group",
                "my-querypack",
                new LogAnalyticsQueryPackQuerySearchProperties()
                    .withRelated(
                        new LogAnalyticsQueryPackQuerySearchPropertiesRelated()
                            .withCategories(Arrays.asList("other", "analytics")))
                    .withTags(mapOf("my-label", Arrays.asList("label1"))),
                3L,
                true,
                null,
                Context.NONE);
    }

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