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

package com.azure.resourcemanager.logic.generated;

import com.azure.resourcemanager.logic.models.IntegrationServiceEnvironment;
import com.azure.resourcemanager.logic.models.IntegrationServiceEnvironmentSku;
import com.azure.resourcemanager.logic.models.IntegrationServiceEnvironmentSkuName;
import java.util.HashMap;
import java.util.Map;

/** Samples for IntegrationServiceEnvironments Update. */
public final class IntegrationServiceEnvironmentsUpdateSamples {
    /*
     * x-ms-original-file: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationServiceEnvironments_Patch.json
     */
    /**
     * Sample code: Patch an integration service environment.
     *
     * @param manager Entry point to LogicManager.
     */
    public static void patchAnIntegrationServiceEnvironment(com.azure.resourcemanager.logic.LogicManager manager) {
        IntegrationServiceEnvironment resource =
            manager
                .integrationServiceEnvironments()
                .getByResourceGroupWithResponse(
                    "testResourceGroup", "testIntegrationServiceEnvironment", com.azure.core.util.Context.NONE)
                .getValue();
        resource
            .update()
            .withTags(mapOf("tag1", "value1"))
            .withSku(
                new IntegrationServiceEnvironmentSku()
                    .withName(IntegrationServiceEnvironmentSkuName.DEVELOPER)
                    .withCapacity(0))
            .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;
    }
}
