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

package com.azure.resourcemanager.peering.generated;

import com.azure.core.management.SubResource;
import com.azure.resourcemanager.peering.models.BgpSession;
import com.azure.resourcemanager.peering.models.DirectConnection;
import com.azure.resourcemanager.peering.models.DirectPeeringType;
import com.azure.resourcemanager.peering.models.ExchangeConnection;
import com.azure.resourcemanager.peering.models.Kind;
import com.azure.resourcemanager.peering.models.PeeringPropertiesDirect;
import com.azure.resourcemanager.peering.models.PeeringPropertiesExchange;
import com.azure.resourcemanager.peering.models.PeeringSku;
import com.azure.resourcemanager.peering.models.SessionAddressProvider;
import java.util.Arrays;

/** Samples for Peerings CreateOrUpdate. */
public final class PeeringsCreateOrUpdateSamples {
    /*
     * x-ms-original-file: specification/peering/resource-manager/Microsoft.Peering/stable/2021-01-01/examples/CreatePeeringWithExchangeRouteServer.json
     */
    /**
     * Sample code: Create a peering with exchange route server.
     *
     * @param manager Entry point to PeeringManager.
     */
    public static void createAPeeringWithExchangeRouteServer(com.azure.resourcemanager.peering.PeeringManager manager) {
        manager
            .peerings()
            .define("peeringName")
            .withRegion("eastus")
            .withExistingResourceGroup("rgName")
            .withSku(new PeeringSku().withName("Premium_Direct_Free"))
            .withKind(Kind.DIRECT)
            .withDirect(
                new PeeringPropertiesDirect()
                    .withConnections(
                        Arrays
                            .asList(
                                new DirectConnection()
                                    .withBandwidthInMbps(10000)
                                    .withSessionAddressProvider(SessionAddressProvider.PEER)
                                    .withUseForPeeringService(true)
                                    .withPeeringDBFacilityId(99999)
                                    .withBgpSession(
                                        new BgpSession()
                                            .withSessionPrefixV4("192.168.0.0/24")
                                            .withMicrosoftSessionIPv4Address("192.168.0.123")
                                            .withPeerSessionIPv4Address("192.168.0.234")
                                            .withMaxPrefixesAdvertisedV4(1000)
                                            .withMaxPrefixesAdvertisedV6(100))
                                    .withConnectionIdentifier("5F4CB5C7-6B43-4444-9338-9ABC72606C16")))
                    .withPeerAsn(
                        new SubResource().withId("/subscriptions/subId/providers/Microsoft.Peering/peerAsns/myAsn1"))
                    .withDirectPeeringType(DirectPeeringType.IX_RS))
            .withPeeringLocation("peeringLocation0")
            .create();
    }

    /*
     * x-ms-original-file: specification/peering/resource-manager/Microsoft.Peering/stable/2021-01-01/examples/CreateExchangePeering.json
     */
    /**
     * Sample code: Create an exchange peering.
     *
     * @param manager Entry point to PeeringManager.
     */
    public static void createAnExchangePeering(com.azure.resourcemanager.peering.PeeringManager manager) {
        manager
            .peerings()
            .define("peeringName")
            .withRegion("eastus")
            .withExistingResourceGroup("rgName")
            .withSku(new PeeringSku().withName("Basic_Exchange_Free"))
            .withKind(Kind.EXCHANGE)
            .withExchange(
                new PeeringPropertiesExchange()
                    .withConnections(
                        Arrays
                            .asList(
                                new ExchangeConnection()
                                    .withPeeringDBFacilityId(99999)
                                    .withBgpSession(
                                        new BgpSession()
                                            .withPeerSessionIPv4Address("192.168.2.1")
                                            .withPeerSessionIPv6Address("fd00::1")
                                            .withMaxPrefixesAdvertisedV4(1000)
                                            .withMaxPrefixesAdvertisedV6(100)
                                            .withMd5AuthenticationKey("fakeTokenPlaceholder"))
                                    .withConnectionIdentifier("CE495334-0E94-4E51-8164-8116D6CD284D"),
                                new ExchangeConnection()
                                    .withPeeringDBFacilityId(99999)
                                    .withBgpSession(
                                        new BgpSession()
                                            .withPeerSessionIPv4Address("192.168.2.2")
                                            .withPeerSessionIPv6Address("fd00::2")
                                            .withMaxPrefixesAdvertisedV4(1000)
                                            .withMaxPrefixesAdvertisedV6(100)
                                            .withMd5AuthenticationKey("fakeTokenPlaceholder"))
                                    .withConnectionIdentifier("CDD8E673-CB07-47E6-84DE-3739F778762B")))
                    .withPeerAsn(
                        new SubResource().withId("/subscriptions/subId/providers/Microsoft.Peering/peerAsns/myAsn1")))
            .withPeeringLocation("peeringLocation0")
            .create();
    }

    /*
     * x-ms-original-file: specification/peering/resource-manager/Microsoft.Peering/stable/2021-01-01/examples/CreateDirectPeering.json
     */
    /**
     * Sample code: Create a direct peering.
     *
     * @param manager Entry point to PeeringManager.
     */
    public static void createADirectPeering(com.azure.resourcemanager.peering.PeeringManager manager) {
        manager
            .peerings()
            .define("peeringName")
            .withRegion("eastus")
            .withExistingResourceGroup("rgName")
            .withSku(new PeeringSku().withName("Basic_Direct_Free"))
            .withKind(Kind.DIRECT)
            .withDirect(
                new PeeringPropertiesDirect()
                    .withConnections(
                        Arrays
                            .asList(
                                new DirectConnection()
                                    .withBandwidthInMbps(10000)
                                    .withSessionAddressProvider(SessionAddressProvider.PEER)
                                    .withUseForPeeringService(false)
                                    .withPeeringDBFacilityId(99999)
                                    .withBgpSession(
                                        new BgpSession()
                                            .withSessionPrefixV4("192.168.0.0/31")
                                            .withSessionPrefixV6("fd00::0/127")
                                            .withMaxPrefixesAdvertisedV4(1000)
                                            .withMaxPrefixesAdvertisedV6(100)
                                            .withMd5AuthenticationKey("fakeTokenPlaceholder"))
                                    .withConnectionIdentifier("5F4CB5C7-6B43-4444-9338-9ABC72606C16"),
                                new DirectConnection()
                                    .withBandwidthInMbps(10000)
                                    .withSessionAddressProvider(SessionAddressProvider.MICROSOFT)
                                    .withUseForPeeringService(true)
                                    .withPeeringDBFacilityId(99999)
                                    .withConnectionIdentifier("8AB00818-D533-4504-A25A-03A17F61201C")))
                    .withPeerAsn(
                        new SubResource().withId("/subscriptions/subId/providers/Microsoft.Peering/peerAsns/myAsn1"))
                    .withDirectPeeringType(DirectPeeringType.EDGE))
            .withPeeringLocation("peeringLocation0")
            .create();
    }
}
