@@ -23,6 +23,7 @@ namespace Microsoft.WindowsAzure.Commands.ExpressRoute
23
23
using Microsoft . WindowsAzure . Management . ExpressRoute . Models ;
24
24
using System ;
25
25
using System . Collections . Generic ;
26
+ using System . ComponentModel ;
26
27
using System . Net ;
27
28
using Utilities . Common ;
28
29
using Microsoft . Azure . Common . Authentication . Models ;
@@ -61,14 +62,23 @@ public AzureBgpPeering GetAzureBGPPeering(string serviceKey, BgpPeeringAccessTyp
61
62
public AzureBgpPeering NewAzureBGPPeering ( string serviceKey , UInt32 peerAsn , string primaryPeerSubnet ,
62
63
string secondaryPeerSubnet , UInt32 vlanId , BgpPeeringAccessType accessType , string sharedKey = null )
63
64
{
64
- return Client . BorderGatewayProtocolPeerings . New ( serviceKey , accessType , new BorderGatewayProtocolPeeringNewParameters ( )
65
+ var result = Client . BorderGatewayProtocolPeerings . New ( serviceKey , accessType , new BorderGatewayProtocolPeeringNewParameters ( )
65
66
{
66
67
PeerAutonomousSystemNumber = peerAsn ,
67
68
PrimaryPeerSubnet = primaryPeerSubnet ,
68
69
SecondaryPeerSubnet = secondaryPeerSubnet ,
69
70
SharedKey = sharedKey ,
70
71
VirtualLanId = vlanId
71
- } ) . BgpPeering ;
72
+ } ) ;
73
+
74
+ if ( result . HttpStatusCode . Equals ( HttpStatusCode . OK ) )
75
+ {
76
+ return GetAzureBGPPeering ( serviceKey , accessType ) ;
77
+ }
78
+ else
79
+ {
80
+ throw new Exception ( result . Error . ToString ( ) ) ;
81
+ }
72
82
}
73
83
74
84
public bool RemoveAzureBGPPeering ( string serviceKey , BgpPeeringAccessType accessType )
@@ -81,15 +91,22 @@ public AzureBgpPeering UpdateAzureBGPPeering(string serviceKey,
81
91
BgpPeeringAccessType accessType , UInt32 peerAsn , string primaryPeerSubnet ,
82
92
string secondaryPeerSubnet , UInt32 vlanId , string sharedKey )
83
93
{
84
- return
85
- ( Client . BorderGatewayProtocolPeerings . Update ( serviceKey , accessType , new BorderGatewayProtocolPeeringUpdateParameters ( )
94
+ var result = Client . BorderGatewayProtocolPeerings . Update ( serviceKey , accessType , new BorderGatewayProtocolPeeringUpdateParameters ( )
86
95
{
87
96
PeerAutonomousSystemNumber = peerAsn ,
88
97
PrimaryPeerSubnet = primaryPeerSubnet ,
89
98
SecondaryPeerSubnet = secondaryPeerSubnet ,
90
99
SharedKey = sharedKey ,
91
100
VirtualLanId = vlanId ,
92
- } ) ) . BgpPeering ;
101
+ } ) ;
102
+ if ( result . HttpStatusCode . Equals ( HttpStatusCode . OK ) )
103
+ {
104
+ return GetAzureBGPPeering ( serviceKey , accessType ) ;
105
+ }
106
+ else
107
+ {
108
+ throw new Exception ( result . Error . ToString ( ) ) ;
109
+ }
93
110
}
94
111
95
112
public AzureDedicatedCircuit GetAzureDedicatedCircuit ( string serviceKey )
@@ -100,20 +117,46 @@ public AzureDedicatedCircuit GetAzureDedicatedCircuit(string serviceKey)
100
117
public AzureDedicatedCircuit NewAzureDedicatedCircuit ( string circuitName ,
101
118
UInt32 bandwidth , string location , string serviceProviderName )
102
119
{
103
- return ( Client . DedicatedCircuits . New ( new DedicatedCircuitNewParameters ( )
120
+ var result = Client . DedicatedCircuits . New ( new DedicatedCircuitNewParameters ( )
104
121
{
105
122
Bandwidth = bandwidth ,
106
123
CircuitName = circuitName ,
107
124
Location = location ,
108
125
ServiceProviderName = serviceProviderName
109
- } ) ) . DedicatedCircuit ;
126
+ } ) ;
127
+
128
+ if ( result . HttpStatusCode . Equals ( HttpStatusCode . OK ) )
129
+ {
130
+ return GetAzureDedicatedCircuit ( result . Data ) ;
131
+ }
132
+ else
133
+ {
134
+ throw new Exception ( result . Error . ToString ( ) ) ;
135
+ }
110
136
}
111
137
112
138
public IEnumerable < AzureDedicatedCircuit > ListAzureDedicatedCircuit ( )
113
139
{
114
140
return ( Client . DedicatedCircuits . List ( ) . DedicatedCircuits ) ;
115
141
}
116
142
143
+ public AzureDedicatedCircuit SetAzureDedicatedCircuitBandwidth ( string serviceKey , UInt32 bandwidth )
144
+ {
145
+ var result = Client . DedicatedCircuits . Update ( serviceKey , ( new DedicatedCircuitUpdateParameters ( )
146
+ {
147
+ Bandwidth = bandwidth
148
+ } ) ) ;
149
+
150
+ if ( result . HttpStatusCode . Equals ( HttpStatusCode . OK ) )
151
+ {
152
+ return GetAzureDedicatedCircuit ( serviceKey ) ;
153
+ }
154
+ else
155
+ {
156
+ throw new Exception ( result . Error . ToString ( ) ) ;
157
+ }
158
+ }
159
+
117
160
public bool RemoveAzureDedicatedCircuit ( string serviceKey )
118
161
{
119
162
var result = Client . DedicatedCircuits . Remove ( serviceKey ) ;
@@ -127,7 +170,15 @@ public AzureDedicatedCircuitLink GetAzureDedicatedCircuitLink(string serviceKey,
127
170
128
171
public AzureDedicatedCircuitLink NewAzureDedicatedCircuitLink ( string serviceKey , string vNetName )
129
172
{
130
- return ( Client . DedicatedCircuitLinks . New ( serviceKey , vNetName ) ) . DedicatedCircuitLink ;
173
+ var result = Client . DedicatedCircuitLinks . New ( serviceKey , vNetName ) ;
174
+ if ( result . HttpStatusCode . Equals ( HttpStatusCode . OK ) )
175
+ {
176
+ return GetAzureDedicatedCircuitLink ( serviceKey , vNetName ) ;
177
+ }
178
+ else
179
+ {
180
+ throw new Exception ( result . Error . ToString ( ) ) ;
181
+ }
131
182
}
132
183
133
184
public IEnumerable < AzureDedicatedCircuitLink > ListAzureDedicatedCircuitLink ( string serviceKey )
@@ -153,13 +204,31 @@ public AzureCrossConnection GetAzureCrossConnection(string serviceKey)
153
204
154
205
public AzureCrossConnection NewAzureCrossConnection ( string serviceKey )
155
206
{
156
- return ( Client . CrossConnections . New ( serviceKey ) ) . CrossConnection ;
207
+ var result = Client . CrossConnections . New ( serviceKey ) ;
208
+
209
+ if ( result . HttpStatusCode . Equals ( HttpStatusCode . OK ) )
210
+ {
211
+ return GetAzureCrossConnection ( serviceKey ) ;
212
+ }
213
+ else
214
+ {
215
+ throw new Exception ( result . Error . ToString ( ) ) ;
216
+ }
157
217
}
158
218
159
219
public AzureCrossConnection SetAzureCrossConnection ( string serviceKey ,
160
220
CrossConnectionUpdateParameters parameters )
161
221
{
162
- return ( Client . CrossConnections . Update ( serviceKey , parameters ) ) . CrossConnection ;
222
+ var result = Client . CrossConnections . Update ( serviceKey , parameters ) ;
223
+
224
+ if ( result . HttpStatusCode . Equals ( HttpStatusCode . OK ) )
225
+ {
226
+ return GetAzureCrossConnection ( serviceKey ) ;
227
+ }
228
+ else
229
+ {
230
+ throw new Exception ( result . Error . ToString ( ) ) ;
231
+ }
163
232
}
164
233
165
234
public IEnumerable < AzureCrossConnection > ListAzureCrossConnections ( )
0 commit comments