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

package com.azure.resourcemanager.managednetworkfabric.generated;

import com.azure.resourcemanager.managednetworkfabric.models.ManagementNetworkConfiguration;
import com.azure.resourcemanager.managednetworkfabric.models.OptionAProperties;
import com.azure.resourcemanager.managednetworkfabric.models.OptionBPropertiesAutoGenerated;
import com.azure.resourcemanager.managednetworkfabric.models.PeeringOption;
import com.azure.resourcemanager.managednetworkfabric.models.TerminalServerConfiguration;
import com.azure.resourcemanager.managednetworkfabric.models.VpnConfigurationProperties;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/** Samples for NetworkFabrics Create. */
public final class NetworkFabricsCreateSamples {
    /*
     * x-ms-original-file: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/preview/2023-02-01-preview/examples/NetworkFabrics_Create_MaximumSet_Gen.json
     */
    /**
     * Sample code: NetworkFabrics_Create_MaximumSet_Gen.
     *
     * @param manager Entry point to ManagedNetworkFabricManager.
     */
    public static void networkFabricsCreateMaximumSetGen(
        com.azure.resourcemanager.managednetworkfabric.ManagedNetworkFabricManager manager) {
        manager
            .networkFabrics()
            .define("FabricName")
            .withRegion("eastuseuap")
            .withExistingResourceGroup("resourceGroupName")
            .withTags(mapOf("key6468", ""))
            .withNetworkFabricSku("M4-A400-A100-C16-aa")
            .withRackCount(4)
            .withServerCountPerRack(8)
            .withIpv4Prefix("10.18.0.0/19")
            .withIpv6Prefix("3FFE:FFFF:0:CD40::/59")
            .withFabricAsn(29249)
            .withNetworkFabricControllerId(
                "/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.ManagedNetworkFabric/networkFabricControllers/fabricControllerName")
            .withTerminalServerConfiguration(
                new TerminalServerConfiguration()
                    .withPrimaryIpv4Prefix("20.0.0.12/30")
                    .withPrimaryIpv6Prefix("3FFE:FFFF:0:CD30::a8/126")
                    .withSecondaryIpv4Prefix("20.0.0.13/30")
                    .withSecondaryIpv6Prefix("3FFE:FFFF:0:CD30::ac/126")
                    .withUsername("username")
                    .withPassword("fakeTokenPlaceholder")
                    .withSerialNumber("123456"))
            .withManagementNetworkConfiguration(
                new ManagementNetworkConfiguration()
                    .withInfrastructureVpnConfiguration(
                        new VpnConfigurationProperties()
                            .withPeeringOption(PeeringOption.OPTIONA)
                            .withOptionBProperties(
                                new OptionBPropertiesAutoGenerated()
                                    .withImportRouteTargets(Arrays.asList("65046:10039"))
                                    .withExportRouteTargets(Arrays.asList("65046:10039")))
                            .withOptionAProperties(
                                new OptionAProperties()
                                    .withPrimaryIpv4Prefix("20.0.0.12/30")
                                    .withPrimaryIpv6Prefix("3FFE:FFFF:0:CD30::a8/126")
                                    .withSecondaryIpv4Prefix("20.0.0.13/30")
                                    .withSecondaryIpv6Prefix("3FFE:FFFF:0:CD30::ac/126")
                                    .withMtu(5892)
                                    .withVlanId(2724)
                                    .withPeerAsn(42666)))
                    .withWorkloadVpnConfiguration(
                        new VpnConfigurationProperties()
                            .withPeeringOption(PeeringOption.OPTIONA)
                            .withOptionBProperties(
                                new OptionBPropertiesAutoGenerated()
                                    .withImportRouteTargets(Arrays.asList("65046:10050"))
                                    .withExportRouteTargets(Arrays.asList("65046:10050")))
                            .withOptionAProperties(
                                new OptionAProperties()
                                    .withPrimaryIpv4Prefix("10.0.0.14/30")
                                    .withPrimaryIpv6Prefix("2FFE:FFFF:0:CD30::a7/126")
                                    .withSecondaryIpv4Prefix("10.0.0.15/30")
                                    .withSecondaryIpv6Prefix("2FFE:FFFF:0:CD30::ac/126")
                                    .withMtu(5892)
                                    .withVlanId(2724)
                                    .withPeerAsn(42666))))
            .withAnnotation("annotationValue")
            .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;
    }
}
