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

package com.azure.resourcemanager.networkcloud.generated;

import com.azure.resourcemanager.networkcloud.models.ManagedResourceGroupConfiguration;
import java.util.HashMap;
import java.util.Map;

/** Samples for ClusterManagers CreateOrUpdate. */
public final class ClusterManagersCreateOrUpdateSamples {
    /*
     * x-ms-original-file: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2023-05-01-preview/examples/ClusterManagers_Create.json
     */
    /**
     * Sample code: Create or update cluster manager.
     *
     * @param manager Entry point to NetworkCloudManager.
     */
    public static void createOrUpdateClusterManager(
        com.azure.resourcemanager.networkcloud.NetworkCloudManager manager) {
        manager
            .clusterManagers()
            .define("clusterManagerName")
            .withRegion("location")
            .withExistingResourceGroup("resourceGroupName")
            .withFabricControllerId(
                "/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedNetworkFabric/networkFabricControllers/fabricControllerName")
            .withTags(mapOf("key1", "myvalue1", "key2", "myvalue2"))
            .withAnalyticsWorkspaceId(
                "/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/microsoft.operationalInsights/workspaces/logAnalyticsWorkspaceName")
            .withManagedResourceGroupConfiguration(
                new ManagedResourceGroupConfiguration().withLocation("East US").withName("my-managed-rg"))
            .create();
    }

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