1 package network
2
3
4
5
6
7
8
9 import (
10 "context"
11 "github.com/Azure/go-autorest/autorest"
12 "github.com/Azure/go-autorest/autorest/azure"
13 "github.com/Azure/go-autorest/autorest/validation"
14 "github.com/Azure/go-autorest/tracing"
15 "net/http"
16 )
17
18
19 type ExpressRouteGatewaysClient struct {
20 BaseClient
21 }
22
23
24 func NewExpressRouteGatewaysClient(subscriptionID string) ExpressRouteGatewaysClient {
25 return NewExpressRouteGatewaysClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30
31 func NewExpressRouteGatewaysClientWithBaseURI(baseURI string, subscriptionID string) ExpressRouteGatewaysClient {
32 return ExpressRouteGatewaysClient{NewWithBaseURI(baseURI, subscriptionID)}
33 }
34
35
36
37
38
39
40 func (client ExpressRouteGatewaysClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, expressRouteGatewayName string, putExpressRouteGatewayParameters ExpressRouteGateway) (result ExpressRouteGatewaysCreateOrUpdateFuture, err error) {
41 if tracing.IsEnabled() {
42 ctx = tracing.StartSpan(ctx, fqdn+"/ExpressRouteGatewaysClient.CreateOrUpdate")
43 defer func() {
44 sc := -1
45 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
46 sc = result.FutureAPI.Response().StatusCode
47 }
48 tracing.EndSpan(ctx, sc, err)
49 }()
50 }
51 if err := validation.Validate([]validation.Validation{
52 {TargetValue: putExpressRouteGatewayParameters,
53 Constraints: []validation.Constraint{{Target: "putExpressRouteGatewayParameters.ExpressRouteGatewayProperties", Name: validation.Null, Rule: false,
54 Chain: []validation.Constraint{{Target: "putExpressRouteGatewayParameters.ExpressRouteGatewayProperties.VirtualHub", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
55 return result, validation.NewError("network.ExpressRouteGatewaysClient", "CreateOrUpdate", err.Error())
56 }
57
58 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, expressRouteGatewayName, putExpressRouteGatewayParameters)
59 if err != nil {
60 err = autorest.NewErrorWithError(err, "network.ExpressRouteGatewaysClient", "CreateOrUpdate", nil, "Failure preparing request")
61 return
62 }
63
64 result, err = client.CreateOrUpdateSender(req)
65 if err != nil {
66 err = autorest.NewErrorWithError(err, "network.ExpressRouteGatewaysClient", "CreateOrUpdate", result.Response(), "Failure sending request")
67 return
68 }
69
70 return
71 }
72
73
74 func (client ExpressRouteGatewaysClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, expressRouteGatewayName string, putExpressRouteGatewayParameters ExpressRouteGateway) (*http.Request, error) {
75 pathParameters := map[string]interface{}{
76 "expressRouteGatewayName": autorest.Encode("path", expressRouteGatewayName),
77 "resourceGroupName": autorest.Encode("path", resourceGroupName),
78 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
79 }
80
81 const APIVersion = "2022-05-01"
82 queryParameters := map[string]interface{}{
83 "api-version": APIVersion,
84 }
85
86 putExpressRouteGatewayParameters.Etag = nil
87 preparer := autorest.CreatePreparer(
88 autorest.AsContentType("application/json; charset=utf-8"),
89 autorest.AsPut(),
90 autorest.WithBaseURL(client.BaseURI),
91 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteGateways/{expressRouteGatewayName}", pathParameters),
92 autorest.WithJSON(putExpressRouteGatewayParameters),
93 autorest.WithQueryParameters(queryParameters))
94 return preparer.Prepare((&http.Request{}).WithContext(ctx))
95 }
96
97
98
99 func (client ExpressRouteGatewaysClient) CreateOrUpdateSender(req *http.Request) (future ExpressRouteGatewaysCreateOrUpdateFuture, err error) {
100 var resp *http.Response
101 future.FutureAPI = &azure.Future{}
102 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
103 if err != nil {
104 return
105 }
106 var azf azure.Future
107 azf, err = azure.NewFutureFromResponse(resp)
108 future.FutureAPI = &azf
109 future.Result = future.result
110 return
111 }
112
113
114
115 func (client ExpressRouteGatewaysClient) CreateOrUpdateResponder(resp *http.Response) (result ExpressRouteGateway, err error) {
116 err = autorest.Respond(
117 resp,
118 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
119 autorest.ByUnmarshallingJSON(&result),
120 autorest.ByClosing())
121 result.Response = autorest.Response{Response: resp}
122 return
123 }
124
125
126
127
128
129
130 func (client ExpressRouteGatewaysClient) Delete(ctx context.Context, resourceGroupName string, expressRouteGatewayName string) (result ExpressRouteGatewaysDeleteFuture, err error) {
131 if tracing.IsEnabled() {
132 ctx = tracing.StartSpan(ctx, fqdn+"/ExpressRouteGatewaysClient.Delete")
133 defer func() {
134 sc := -1
135 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
136 sc = result.FutureAPI.Response().StatusCode
137 }
138 tracing.EndSpan(ctx, sc, err)
139 }()
140 }
141 req, err := client.DeletePreparer(ctx, resourceGroupName, expressRouteGatewayName)
142 if err != nil {
143 err = autorest.NewErrorWithError(err, "network.ExpressRouteGatewaysClient", "Delete", nil, "Failure preparing request")
144 return
145 }
146
147 result, err = client.DeleteSender(req)
148 if err != nil {
149 err = autorest.NewErrorWithError(err, "network.ExpressRouteGatewaysClient", "Delete", result.Response(), "Failure sending request")
150 return
151 }
152
153 return
154 }
155
156
157 func (client ExpressRouteGatewaysClient) DeletePreparer(ctx context.Context, resourceGroupName string, expressRouteGatewayName string) (*http.Request, error) {
158 pathParameters := map[string]interface{}{
159 "expressRouteGatewayName": autorest.Encode("path", expressRouteGatewayName),
160 "resourceGroupName": autorest.Encode("path", resourceGroupName),
161 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
162 }
163
164 const APIVersion = "2022-05-01"
165 queryParameters := map[string]interface{}{
166 "api-version": APIVersion,
167 }
168
169 preparer := autorest.CreatePreparer(
170 autorest.AsDelete(),
171 autorest.WithBaseURL(client.BaseURI),
172 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteGateways/{expressRouteGatewayName}", pathParameters),
173 autorest.WithQueryParameters(queryParameters))
174 return preparer.Prepare((&http.Request{}).WithContext(ctx))
175 }
176
177
178
179 func (client ExpressRouteGatewaysClient) DeleteSender(req *http.Request) (future ExpressRouteGatewaysDeleteFuture, err error) {
180 var resp *http.Response
181 future.FutureAPI = &azure.Future{}
182 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
183 if err != nil {
184 return
185 }
186 var azf azure.Future
187 azf, err = azure.NewFutureFromResponse(resp)
188 future.FutureAPI = &azf
189 future.Result = future.result
190 return
191 }
192
193
194
195 func (client ExpressRouteGatewaysClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
196 err = autorest.Respond(
197 resp,
198 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
199 autorest.ByClosing())
200 result.Response = resp
201 return
202 }
203
204
205
206
207
208 func (client ExpressRouteGatewaysClient) Get(ctx context.Context, resourceGroupName string, expressRouteGatewayName string) (result ExpressRouteGateway, err error) {
209 if tracing.IsEnabled() {
210 ctx = tracing.StartSpan(ctx, fqdn+"/ExpressRouteGatewaysClient.Get")
211 defer func() {
212 sc := -1
213 if result.Response.Response != nil {
214 sc = result.Response.Response.StatusCode
215 }
216 tracing.EndSpan(ctx, sc, err)
217 }()
218 }
219 req, err := client.GetPreparer(ctx, resourceGroupName, expressRouteGatewayName)
220 if err != nil {
221 err = autorest.NewErrorWithError(err, "network.ExpressRouteGatewaysClient", "Get", nil, "Failure preparing request")
222 return
223 }
224
225 resp, err := client.GetSender(req)
226 if err != nil {
227 result.Response = autorest.Response{Response: resp}
228 err = autorest.NewErrorWithError(err, "network.ExpressRouteGatewaysClient", "Get", resp, "Failure sending request")
229 return
230 }
231
232 result, err = client.GetResponder(resp)
233 if err != nil {
234 err = autorest.NewErrorWithError(err, "network.ExpressRouteGatewaysClient", "Get", resp, "Failure responding to request")
235 return
236 }
237
238 return
239 }
240
241
242 func (client ExpressRouteGatewaysClient) GetPreparer(ctx context.Context, resourceGroupName string, expressRouteGatewayName string) (*http.Request, error) {
243 pathParameters := map[string]interface{}{
244 "expressRouteGatewayName": autorest.Encode("path", expressRouteGatewayName),
245 "resourceGroupName": autorest.Encode("path", resourceGroupName),
246 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
247 }
248
249 const APIVersion = "2022-05-01"
250 queryParameters := map[string]interface{}{
251 "api-version": APIVersion,
252 }
253
254 preparer := autorest.CreatePreparer(
255 autorest.AsGet(),
256 autorest.WithBaseURL(client.BaseURI),
257 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteGateways/{expressRouteGatewayName}", pathParameters),
258 autorest.WithQueryParameters(queryParameters))
259 return preparer.Prepare((&http.Request{}).WithContext(ctx))
260 }
261
262
263
264 func (client ExpressRouteGatewaysClient) GetSender(req *http.Request) (*http.Response, error) {
265 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
266 }
267
268
269
270 func (client ExpressRouteGatewaysClient) GetResponder(resp *http.Response) (result ExpressRouteGateway, err error) {
271 err = autorest.Respond(
272 resp,
273 azure.WithErrorUnlessStatusCode(http.StatusOK),
274 autorest.ByUnmarshallingJSON(&result),
275 autorest.ByClosing())
276 result.Response = autorest.Response{Response: resp}
277 return
278 }
279
280
281
282
283 func (client ExpressRouteGatewaysClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ExpressRouteGatewayList, err error) {
284 if tracing.IsEnabled() {
285 ctx = tracing.StartSpan(ctx, fqdn+"/ExpressRouteGatewaysClient.ListByResourceGroup")
286 defer func() {
287 sc := -1
288 if result.Response.Response != nil {
289 sc = result.Response.Response.StatusCode
290 }
291 tracing.EndSpan(ctx, sc, err)
292 }()
293 }
294 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
295 if err != nil {
296 err = autorest.NewErrorWithError(err, "network.ExpressRouteGatewaysClient", "ListByResourceGroup", nil, "Failure preparing request")
297 return
298 }
299
300 resp, err := client.ListByResourceGroupSender(req)
301 if err != nil {
302 result.Response = autorest.Response{Response: resp}
303 err = autorest.NewErrorWithError(err, "network.ExpressRouteGatewaysClient", "ListByResourceGroup", resp, "Failure sending request")
304 return
305 }
306
307 result, err = client.ListByResourceGroupResponder(resp)
308 if err != nil {
309 err = autorest.NewErrorWithError(err, "network.ExpressRouteGatewaysClient", "ListByResourceGroup", resp, "Failure responding to request")
310 return
311 }
312
313 return
314 }
315
316
317 func (client ExpressRouteGatewaysClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
318 pathParameters := map[string]interface{}{
319 "resourceGroupName": autorest.Encode("path", resourceGroupName),
320 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
321 }
322
323 const APIVersion = "2022-05-01"
324 queryParameters := map[string]interface{}{
325 "api-version": APIVersion,
326 }
327
328 preparer := autorest.CreatePreparer(
329 autorest.AsGet(),
330 autorest.WithBaseURL(client.BaseURI),
331 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteGateways", pathParameters),
332 autorest.WithQueryParameters(queryParameters))
333 return preparer.Prepare((&http.Request{}).WithContext(ctx))
334 }
335
336
337
338 func (client ExpressRouteGatewaysClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
339 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
340 }
341
342
343
344 func (client ExpressRouteGatewaysClient) ListByResourceGroupResponder(resp *http.Response) (result ExpressRouteGatewayList, err error) {
345 err = autorest.Respond(
346 resp,
347 azure.WithErrorUnlessStatusCode(http.StatusOK),
348 autorest.ByUnmarshallingJSON(&result),
349 autorest.ByClosing())
350 result.Response = autorest.Response{Response: resp}
351 return
352 }
353
354
355 func (client ExpressRouteGatewaysClient) ListBySubscription(ctx context.Context) (result ExpressRouteGatewayList, err error) {
356 if tracing.IsEnabled() {
357 ctx = tracing.StartSpan(ctx, fqdn+"/ExpressRouteGatewaysClient.ListBySubscription")
358 defer func() {
359 sc := -1
360 if result.Response.Response != nil {
361 sc = result.Response.Response.StatusCode
362 }
363 tracing.EndSpan(ctx, sc, err)
364 }()
365 }
366 req, err := client.ListBySubscriptionPreparer(ctx)
367 if err != nil {
368 err = autorest.NewErrorWithError(err, "network.ExpressRouteGatewaysClient", "ListBySubscription", nil, "Failure preparing request")
369 return
370 }
371
372 resp, err := client.ListBySubscriptionSender(req)
373 if err != nil {
374 result.Response = autorest.Response{Response: resp}
375 err = autorest.NewErrorWithError(err, "network.ExpressRouteGatewaysClient", "ListBySubscription", resp, "Failure sending request")
376 return
377 }
378
379 result, err = client.ListBySubscriptionResponder(resp)
380 if err != nil {
381 err = autorest.NewErrorWithError(err, "network.ExpressRouteGatewaysClient", "ListBySubscription", resp, "Failure responding to request")
382 return
383 }
384
385 return
386 }
387
388
389 func (client ExpressRouteGatewaysClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) {
390 pathParameters := map[string]interface{}{
391 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
392 }
393
394 const APIVersion = "2022-05-01"
395 queryParameters := map[string]interface{}{
396 "api-version": APIVersion,
397 }
398
399 preparer := autorest.CreatePreparer(
400 autorest.AsGet(),
401 autorest.WithBaseURL(client.BaseURI),
402 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/expressRouteGateways", pathParameters),
403 autorest.WithQueryParameters(queryParameters))
404 return preparer.Prepare((&http.Request{}).WithContext(ctx))
405 }
406
407
408
409 func (client ExpressRouteGatewaysClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) {
410 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
411 }
412
413
414
415 func (client ExpressRouteGatewaysClient) ListBySubscriptionResponder(resp *http.Response) (result ExpressRouteGatewayList, err error) {
416 err = autorest.Respond(
417 resp,
418 azure.WithErrorUnlessStatusCode(http.StatusOK),
419 autorest.ByUnmarshallingJSON(&result),
420 autorest.ByClosing())
421 result.Response = autorest.Response{Response: resp}
422 return
423 }
424
425
426
427
428
429
430 func (client ExpressRouteGatewaysClient) UpdateTags(ctx context.Context, resourceGroupName string, expressRouteGatewayName string, expressRouteGatewayParameters TagsObject) (result ExpressRouteGatewaysUpdateTagsFuture, err error) {
431 if tracing.IsEnabled() {
432 ctx = tracing.StartSpan(ctx, fqdn+"/ExpressRouteGatewaysClient.UpdateTags")
433 defer func() {
434 sc := -1
435 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
436 sc = result.FutureAPI.Response().StatusCode
437 }
438 tracing.EndSpan(ctx, sc, err)
439 }()
440 }
441 req, err := client.UpdateTagsPreparer(ctx, resourceGroupName, expressRouteGatewayName, expressRouteGatewayParameters)
442 if err != nil {
443 err = autorest.NewErrorWithError(err, "network.ExpressRouteGatewaysClient", "UpdateTags", nil, "Failure preparing request")
444 return
445 }
446
447 result, err = client.UpdateTagsSender(req)
448 if err != nil {
449 err = autorest.NewErrorWithError(err, "network.ExpressRouteGatewaysClient", "UpdateTags", result.Response(), "Failure sending request")
450 return
451 }
452
453 return
454 }
455
456
457 func (client ExpressRouteGatewaysClient) UpdateTagsPreparer(ctx context.Context, resourceGroupName string, expressRouteGatewayName string, expressRouteGatewayParameters TagsObject) (*http.Request, error) {
458 pathParameters := map[string]interface{}{
459 "expressRouteGatewayName": autorest.Encode("path", expressRouteGatewayName),
460 "resourceGroupName": autorest.Encode("path", resourceGroupName),
461 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
462 }
463
464 const APIVersion = "2022-05-01"
465 queryParameters := map[string]interface{}{
466 "api-version": APIVersion,
467 }
468
469 preparer := autorest.CreatePreparer(
470 autorest.AsContentType("application/json; charset=utf-8"),
471 autorest.AsPatch(),
472 autorest.WithBaseURL(client.BaseURI),
473 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteGateways/{expressRouteGatewayName}", pathParameters),
474 autorest.WithJSON(expressRouteGatewayParameters),
475 autorest.WithQueryParameters(queryParameters))
476 return preparer.Prepare((&http.Request{}).WithContext(ctx))
477 }
478
479
480
481 func (client ExpressRouteGatewaysClient) UpdateTagsSender(req *http.Request) (future ExpressRouteGatewaysUpdateTagsFuture, err error) {
482 var resp *http.Response
483 future.FutureAPI = &azure.Future{}
484 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
485 if err != nil {
486 return
487 }
488 var azf azure.Future
489 azf, err = azure.NewFutureFromResponse(resp)
490 future.FutureAPI = &azf
491 future.Result = future.result
492 return
493 }
494
495
496
497 func (client ExpressRouteGatewaysClient) UpdateTagsResponder(resp *http.Response) (result ExpressRouteGateway, err error) {
498 err = autorest.Respond(
499 resp,
500 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
501 autorest.ByUnmarshallingJSON(&result),
502 autorest.ByClosing())
503 result.Response = autorest.Response{Response: resp}
504 return
505 }
506
View as plain text