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

package com.azure.resourcemanager.customerinsights.generated;

import com.azure.resourcemanager.customerinsights.models.CardinalityTypes;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/** Samples for Relationships CreateOrUpdate. */
public final class RelationshipsCreateOrUpdateSamples {
    /*
     * x-ms-original-file: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RelationshipsCreateOrUpdate.json
     */
    /**
     * Sample code: Relationships_CreateOrUpdate.
     *
     * @param manager Entry point to CustomerInsightsManager.
     */
    public static void relationshipsCreateOrUpdate(
        com.azure.resourcemanager.customerinsights.CustomerInsightsManager manager) {
        manager
            .relationships()
            .define("SomeRelationship")
            .withExistingHub("TestHubRG", "sdkTestHub")
            .withCardinality(CardinalityTypes.ONE_TO_ONE)
            .withDisplayName(mapOf("en-us", "Relationship DisplayName"))
            .withDescription(mapOf("en-us", "Relationship Description"))
            .withFields(Arrays.asList())
            .withProfileType("testProfile2326994")
            .withRelatedProfileType("testProfile2326994")
            .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;
    }
}
