// 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.core.management.serializer.SerializerFactory;
import com.azure.core.util.serializer.SerializerEncoding;
import com.azure.resourcemanager.logic.fluent.models.WorkflowInner;
import com.azure.resourcemanager.logic.models.ResourceReference;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/** Samples for Workflows ValidateByLocation. */
public final class WorkflowsValidateByLocationSamples {
    /*
     * x-ms-original-file: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/Workflows_ValidateByLocation.json
     */
    /**
     * Sample code: Validate a workflow.
     *
     * @param manager Entry point to LogicManager.
     */
    public static void validateAWorkflow(com.azure.resourcemanager.logic.LogicManager manager) throws IOException {
        manager
            .workflows()
            .validateByLocationWithResponse(
                "test-resource-group",
                "brazilsouth",
                "test-workflow",
                new WorkflowInner()
                    .withLocation("brazilsouth")
                    .withTags(mapOf())
                    .withIntegrationAccount(
                        new ResourceReference()
                            .withId(
                                "/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/test-resource-group/providers/Microsoft.Logic/integrationAccounts/test-integration-account"))
                    .withDefinition(
                        SerializerFactory
                            .createDefaultManagementSerializerAdapter()
                            .deserialize(
                                "{\"$schema\":\"https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#\",\"actions\":{},\"contentVersion\":\"1.0.0.0\",\"outputs\":{},\"parameters\":{},\"triggers\":{}}",
                                Object.class,
                                SerializerEncoding.JSON)),
                com.azure.core.util.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;
    }
}
