-
Notifications
You must be signed in to change notification settings - Fork 12
/
CreatePeeringWithExchangeRouteServer.go
103 lines (100 loc) · 4.46 KB
/
CreatePeeringWithExchangeRouteServer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package armpeering_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/peering/armpeering"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/peering/resource-manager/Microsoft.Peering/stable/2022-01-01/examples/CreatePeeringWithExchangeRouteServer.json
func ExamplePeeringsClient_CreateOrUpdate_createAPeeringWithExchangeRouteServer() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpeering.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewPeeringsClient().CreateOrUpdate(ctx, "rgName", "peeringName", armpeering.Peering{
Kind: to.Ptr(armpeering.KindDirect),
Location: to.Ptr("eastus"),
Properties: &armpeering.Properties{
Direct: &armpeering.PropertiesDirect{
Connections: []*armpeering.DirectConnection{
{
BandwidthInMbps: to.Ptr[int32](10000),
BgpSession: &armpeering.BgpSession{
MaxPrefixesAdvertisedV4: to.Ptr[int32](1000),
MaxPrefixesAdvertisedV6: to.Ptr[int32](100),
MicrosoftSessionIPv4Address: to.Ptr("192.168.0.123"),
PeerSessionIPv4Address: to.Ptr("192.168.0.234"),
SessionPrefixV4: to.Ptr("192.168.0.0/24"),
},
ConnectionIdentifier: to.Ptr("5F4CB5C7-6B43-4444-9338-9ABC72606C16"),
PeeringDBFacilityID: to.Ptr[int32](99999),
SessionAddressProvider: to.Ptr(armpeering.SessionAddressProviderPeer),
UseForPeeringService: to.Ptr(true),
}},
DirectPeeringType: to.Ptr(armpeering.DirectPeeringTypeIxRs),
PeerAsn: &armpeering.SubResource{
ID: to.Ptr("/subscriptions/subId/providers/Microsoft.Peering/peerAsns/myAsn1"),
},
},
PeeringLocation: to.Ptr("peeringLocation0"),
},
SKU: &armpeering.SKU{
Name: to.Ptr("Premium_Direct_Free"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Peering = armpeering.Peering{
// Name: to.Ptr("peeringName"),
// Type: to.Ptr("Microsoft.Peering/peerings"),
// ID: to.Ptr("/subscriptions/subId/resourceGroups/rgName/providers/Microsoft.Peering/peerings/peeringName"),
// Kind: to.Ptr(armpeering.KindDirect),
// Location: to.Ptr("eastus"),
// Properties: &armpeering.Properties{
// Direct: &armpeering.PropertiesDirect{
// Connections: []*armpeering.DirectConnection{
// {
// BandwidthInMbps: to.Ptr[int32](10000),
// BgpSession: &armpeering.BgpSession{
// MaxPrefixesAdvertisedV4: to.Ptr[int32](1000),
// MaxPrefixesAdvertisedV6: to.Ptr[int32](100),
// MicrosoftSessionIPv4Address: to.Ptr("192.168.0.123"),
// PeerSessionIPv4Address: to.Ptr("192.168.0.234"),
// SessionPrefixV4: to.Ptr("192.168.0.0/24"),
// SessionStateV4: to.Ptr(armpeering.SessionStateV4Established),
// SessionStateV6: to.Ptr(armpeering.SessionStateV6Established),
// },
// ConnectionIdentifier: to.Ptr("5F4CB5C7-6B43-4444-9338-9ABC72606C16"),
// ConnectionState: to.Ptr(armpeering.ConnectionStateActive),
// PeeringDBFacilityID: to.Ptr[int32](99999),
// ProvisionedBandwidthInMbps: to.Ptr[int32](10000),
// SessionAddressProvider: to.Ptr(armpeering.SessionAddressProviderPeer),
// UseForPeeringService: to.Ptr(true),
// }},
// DirectPeeringType: to.Ptr(armpeering.DirectPeeringTypeIxRs),
// PeerAsn: &armpeering.SubResource{
// ID: to.Ptr("/subscriptions/subId/providers/Microsoft.Peering/peerAsns/myAsn1"),
// },
// UseForPeeringService: to.Ptr(true),
// },
// PeeringLocation: to.Ptr("peeringLocation0"),
// ProvisioningState: to.Ptr(armpeering.ProvisioningStateSucceeded),
// },
// SKU: &armpeering.SKU{
// Name: to.Ptr("Premium_Direct_Free"),
// Family: to.Ptr(armpeering.FamilyDirect),
// Size: to.Ptr(armpeering.SizeFree),
// Tier: to.Ptr(armpeering.TierPremium),
// },
// }
}