1package network 2 3// Copyright (c) Microsoft Corporation. All rights reserved. 4// Licensed under the MIT License. See License.txt in the project root for license information. 5// 6// Code generated by Microsoft (R) AutoRest Code Generator. 7// Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 9import ( 10 "context" 11 "github.com/Azure/go-autorest/autorest" 12 "github.com/Azure/go-autorest/autorest/azure" 13 "github.com/Azure/go-autorest/tracing" 14 "net/http" 15) 16 17// ExpressRouteCircuitConnectionsClient is the network Client 18type ExpressRouteCircuitConnectionsClient struct { 19 BaseClient 20} 21 22// NewExpressRouteCircuitConnectionsClient creates an instance of the ExpressRouteCircuitConnectionsClient client. 23func NewExpressRouteCircuitConnectionsClient(subscriptionID string) ExpressRouteCircuitConnectionsClient { 24 return NewExpressRouteCircuitConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) 25} 26 27// NewExpressRouteCircuitConnectionsClientWithBaseURI creates an instance of the ExpressRouteCircuitConnectionsClient 28// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI 29// (sovereign clouds, Azure stack). 30func NewExpressRouteCircuitConnectionsClientWithBaseURI(baseURI string, subscriptionID string) ExpressRouteCircuitConnectionsClient { 31 return ExpressRouteCircuitConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)} 32} 33 34// CreateOrUpdate creates or updates a Express Route Circuit Connection in the specified express route circuits. 35// Parameters: 36// resourceGroupName - the name of the resource group. 37// circuitName - the name of the express route circuit. 38// peeringName - the name of the peering. 39// connectionName - the name of the express route circuit connection. 40// expressRouteCircuitConnectionParameters - parameters supplied to the create or update express route circuit 41// connection operation. 42func (client ExpressRouteCircuitConnectionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, circuitName string, peeringName string, connectionName string, expressRouteCircuitConnectionParameters ExpressRouteCircuitConnection) (result ExpressRouteCircuitConnectionsCreateOrUpdateFuture, err error) { 43 if tracing.IsEnabled() { 44 ctx = tracing.StartSpan(ctx, fqdn+"/ExpressRouteCircuitConnectionsClient.CreateOrUpdate") 45 defer func() { 46 sc := -1 47 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 48 sc = result.FutureAPI.Response().StatusCode 49 } 50 tracing.EndSpan(ctx, sc, err) 51 }() 52 } 53 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, circuitName, peeringName, connectionName, expressRouteCircuitConnectionParameters) 54 if err != nil { 55 err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") 56 return 57 } 58 59 result, err = client.CreateOrUpdateSender(req) 60 if err != nil { 61 err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitConnectionsClient", "CreateOrUpdate", nil, "Failure sending request") 62 return 63 } 64 65 return 66} 67 68// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 69func (client ExpressRouteCircuitConnectionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, circuitName string, peeringName string, connectionName string, expressRouteCircuitConnectionParameters ExpressRouteCircuitConnection) (*http.Request, error) { 70 pathParameters := map[string]interface{}{ 71 "circuitName": autorest.Encode("path", circuitName), 72 "connectionName": autorest.Encode("path", connectionName), 73 "peeringName": autorest.Encode("path", peeringName), 74 "resourceGroupName": autorest.Encode("path", resourceGroupName), 75 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 76 } 77 78 const APIVersion = "2019-07-01" 79 queryParameters := map[string]interface{}{ 80 "api-version": APIVersion, 81 } 82 83 expressRouteCircuitConnectionParameters.Etag = nil 84 expressRouteCircuitConnectionParameters.Type = nil 85 preparer := autorest.CreatePreparer( 86 autorest.AsContentType("application/json; charset=utf-8"), 87 autorest.AsPut(), 88 autorest.WithBaseURL(client.BaseURI), 89 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}/connections/{connectionName}", pathParameters), 90 autorest.WithJSON(expressRouteCircuitConnectionParameters), 91 autorest.WithQueryParameters(queryParameters)) 92 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 93} 94 95// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 96// http.Response Body if it receives an error. 97func (client ExpressRouteCircuitConnectionsClient) CreateOrUpdateSender(req *http.Request) (future ExpressRouteCircuitConnectionsCreateOrUpdateFuture, err error) { 98 var resp *http.Response 99 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 100 if err != nil { 101 return 102 } 103 var azf azure.Future 104 azf, err = azure.NewFutureFromResponse(resp) 105 future.FutureAPI = &azf 106 future.Result = future.result 107 return 108} 109 110// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 111// closes the http.Response Body. 112func (client ExpressRouteCircuitConnectionsClient) CreateOrUpdateResponder(resp *http.Response) (result ExpressRouteCircuitConnection, err error) { 113 err = autorest.Respond( 114 resp, 115 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 116 autorest.ByUnmarshallingJSON(&result), 117 autorest.ByClosing()) 118 result.Response = autorest.Response{Response: resp} 119 return 120} 121 122// Delete deletes the specified Express Route Circuit Connection from the specified express route circuit. 123// Parameters: 124// resourceGroupName - the name of the resource group. 125// circuitName - the name of the express route circuit. 126// peeringName - the name of the peering. 127// connectionName - the name of the express route circuit connection. 128func (client ExpressRouteCircuitConnectionsClient) Delete(ctx context.Context, resourceGroupName string, circuitName string, peeringName string, connectionName string) (result ExpressRouteCircuitConnectionsDeleteFuture, err error) { 129 if tracing.IsEnabled() { 130 ctx = tracing.StartSpan(ctx, fqdn+"/ExpressRouteCircuitConnectionsClient.Delete") 131 defer func() { 132 sc := -1 133 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 134 sc = result.FutureAPI.Response().StatusCode 135 } 136 tracing.EndSpan(ctx, sc, err) 137 }() 138 } 139 req, err := client.DeletePreparer(ctx, resourceGroupName, circuitName, peeringName, connectionName) 140 if err != nil { 141 err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitConnectionsClient", "Delete", nil, "Failure preparing request") 142 return 143 } 144 145 result, err = client.DeleteSender(req) 146 if err != nil { 147 err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitConnectionsClient", "Delete", nil, "Failure sending request") 148 return 149 } 150 151 return 152} 153 154// DeletePreparer prepares the Delete request. 155func (client ExpressRouteCircuitConnectionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, circuitName string, peeringName string, connectionName string) (*http.Request, error) { 156 pathParameters := map[string]interface{}{ 157 "circuitName": autorest.Encode("path", circuitName), 158 "connectionName": autorest.Encode("path", connectionName), 159 "peeringName": autorest.Encode("path", peeringName), 160 "resourceGroupName": autorest.Encode("path", resourceGroupName), 161 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 162 } 163 164 const APIVersion = "2019-07-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/expressRouteCircuits/{circuitName}/peerings/{peeringName}/connections/{connectionName}", pathParameters), 173 autorest.WithQueryParameters(queryParameters)) 174 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 175} 176 177// DeleteSender sends the Delete request. The method will close the 178// http.Response Body if it receives an error. 179func (client ExpressRouteCircuitConnectionsClient) DeleteSender(req *http.Request) (future ExpressRouteCircuitConnectionsDeleteFuture, err error) { 180 var resp *http.Response 181 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 182 if err != nil { 183 return 184 } 185 var azf azure.Future 186 azf, err = azure.NewFutureFromResponse(resp) 187 future.FutureAPI = &azf 188 future.Result = future.result 189 return 190} 191 192// DeleteResponder handles the response to the Delete request. The method always 193// closes the http.Response Body. 194func (client ExpressRouteCircuitConnectionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 195 err = autorest.Respond( 196 resp, 197 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 198 autorest.ByClosing()) 199 result.Response = resp 200 return 201} 202 203// Get gets the specified Express Route Circuit Connection from the specified express route circuit. 204// Parameters: 205// resourceGroupName - the name of the resource group. 206// circuitName - the name of the express route circuit. 207// peeringName - the name of the peering. 208// connectionName - the name of the express route circuit connection. 209func (client ExpressRouteCircuitConnectionsClient) Get(ctx context.Context, resourceGroupName string, circuitName string, peeringName string, connectionName string) (result ExpressRouteCircuitConnection, err error) { 210 if tracing.IsEnabled() { 211 ctx = tracing.StartSpan(ctx, fqdn+"/ExpressRouteCircuitConnectionsClient.Get") 212 defer func() { 213 sc := -1 214 if result.Response.Response != nil { 215 sc = result.Response.Response.StatusCode 216 } 217 tracing.EndSpan(ctx, sc, err) 218 }() 219 } 220 req, err := client.GetPreparer(ctx, resourceGroupName, circuitName, peeringName, connectionName) 221 if err != nil { 222 err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitConnectionsClient", "Get", nil, "Failure preparing request") 223 return 224 } 225 226 resp, err := client.GetSender(req) 227 if err != nil { 228 result.Response = autorest.Response{Response: resp} 229 err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitConnectionsClient", "Get", resp, "Failure sending request") 230 return 231 } 232 233 result, err = client.GetResponder(resp) 234 if err != nil { 235 err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitConnectionsClient", "Get", resp, "Failure responding to request") 236 return 237 } 238 239 return 240} 241 242// GetPreparer prepares the Get request. 243func (client ExpressRouteCircuitConnectionsClient) GetPreparer(ctx context.Context, resourceGroupName string, circuitName string, peeringName string, connectionName string) (*http.Request, error) { 244 pathParameters := map[string]interface{}{ 245 "circuitName": autorest.Encode("path", circuitName), 246 "connectionName": autorest.Encode("path", connectionName), 247 "peeringName": autorest.Encode("path", peeringName), 248 "resourceGroupName": autorest.Encode("path", resourceGroupName), 249 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 250 } 251 252 const APIVersion = "2019-07-01" 253 queryParameters := map[string]interface{}{ 254 "api-version": APIVersion, 255 } 256 257 preparer := autorest.CreatePreparer( 258 autorest.AsGet(), 259 autorest.WithBaseURL(client.BaseURI), 260 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}/connections/{connectionName}", pathParameters), 261 autorest.WithQueryParameters(queryParameters)) 262 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 263} 264 265// GetSender sends the Get request. The method will close the 266// http.Response Body if it receives an error. 267func (client ExpressRouteCircuitConnectionsClient) GetSender(req *http.Request) (*http.Response, error) { 268 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 269} 270 271// GetResponder handles the response to the Get request. The method always 272// closes the http.Response Body. 273func (client ExpressRouteCircuitConnectionsClient) GetResponder(resp *http.Response) (result ExpressRouteCircuitConnection, err error) { 274 err = autorest.Respond( 275 resp, 276 azure.WithErrorUnlessStatusCode(http.StatusOK), 277 autorest.ByUnmarshallingJSON(&result), 278 autorest.ByClosing()) 279 result.Response = autorest.Response{Response: resp} 280 return 281} 282 283// List gets all global reach connections associated with a private peering in an express route circuit. 284// Parameters: 285// resourceGroupName - the name of the resource group. 286// circuitName - the name of the circuit. 287// peeringName - the name of the peering. 288func (client ExpressRouteCircuitConnectionsClient) List(ctx context.Context, resourceGroupName string, circuitName string, peeringName string) (result ExpressRouteCircuitConnectionListResultPage, err error) { 289 if tracing.IsEnabled() { 290 ctx = tracing.StartSpan(ctx, fqdn+"/ExpressRouteCircuitConnectionsClient.List") 291 defer func() { 292 sc := -1 293 if result.ercclr.Response.Response != nil { 294 sc = result.ercclr.Response.Response.StatusCode 295 } 296 tracing.EndSpan(ctx, sc, err) 297 }() 298 } 299 result.fn = client.listNextResults 300 req, err := client.ListPreparer(ctx, resourceGroupName, circuitName, peeringName) 301 if err != nil { 302 err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitConnectionsClient", "List", nil, "Failure preparing request") 303 return 304 } 305 306 resp, err := client.ListSender(req) 307 if err != nil { 308 result.ercclr.Response = autorest.Response{Response: resp} 309 err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitConnectionsClient", "List", resp, "Failure sending request") 310 return 311 } 312 313 result.ercclr, err = client.ListResponder(resp) 314 if err != nil { 315 err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitConnectionsClient", "List", resp, "Failure responding to request") 316 return 317 } 318 if result.ercclr.hasNextLink() && result.ercclr.IsEmpty() { 319 err = result.NextWithContext(ctx) 320 return 321 } 322 323 return 324} 325 326// ListPreparer prepares the List request. 327func (client ExpressRouteCircuitConnectionsClient) ListPreparer(ctx context.Context, resourceGroupName string, circuitName string, peeringName string) (*http.Request, error) { 328 pathParameters := map[string]interface{}{ 329 "circuitName": autorest.Encode("path", circuitName), 330 "peeringName": autorest.Encode("path", peeringName), 331 "resourceGroupName": autorest.Encode("path", resourceGroupName), 332 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 333 } 334 335 const APIVersion = "2019-07-01" 336 queryParameters := map[string]interface{}{ 337 "api-version": APIVersion, 338 } 339 340 preparer := autorest.CreatePreparer( 341 autorest.AsGet(), 342 autorest.WithBaseURL(client.BaseURI), 343 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}/connections", pathParameters), 344 autorest.WithQueryParameters(queryParameters)) 345 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 346} 347 348// ListSender sends the List request. The method will close the 349// http.Response Body if it receives an error. 350func (client ExpressRouteCircuitConnectionsClient) ListSender(req *http.Request) (*http.Response, error) { 351 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 352} 353 354// ListResponder handles the response to the List request. The method always 355// closes the http.Response Body. 356func (client ExpressRouteCircuitConnectionsClient) ListResponder(resp *http.Response) (result ExpressRouteCircuitConnectionListResult, err error) { 357 err = autorest.Respond( 358 resp, 359 azure.WithErrorUnlessStatusCode(http.StatusOK), 360 autorest.ByUnmarshallingJSON(&result), 361 autorest.ByClosing()) 362 result.Response = autorest.Response{Response: resp} 363 return 364} 365 366// listNextResults retrieves the next set of results, if any. 367func (client ExpressRouteCircuitConnectionsClient) listNextResults(ctx context.Context, lastResults ExpressRouteCircuitConnectionListResult) (result ExpressRouteCircuitConnectionListResult, err error) { 368 req, err := lastResults.expressRouteCircuitConnectionListResultPreparer(ctx) 369 if err != nil { 370 return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitConnectionsClient", "listNextResults", nil, "Failure preparing next results request") 371 } 372 if req == nil { 373 return 374 } 375 resp, err := client.ListSender(req) 376 if err != nil { 377 result.Response = autorest.Response{Response: resp} 378 return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitConnectionsClient", "listNextResults", resp, "Failure sending next results request") 379 } 380 result, err = client.ListResponder(resp) 381 if err != nil { 382 err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitConnectionsClient", "listNextResults", resp, "Failure responding to next results request") 383 } 384 return 385} 386 387// ListComplete enumerates all values, automatically crossing page boundaries as required. 388func (client ExpressRouteCircuitConnectionsClient) ListComplete(ctx context.Context, resourceGroupName string, circuitName string, peeringName string) (result ExpressRouteCircuitConnectionListResultIterator, err error) { 389 if tracing.IsEnabled() { 390 ctx = tracing.StartSpan(ctx, fqdn+"/ExpressRouteCircuitConnectionsClient.List") 391 defer func() { 392 sc := -1 393 if result.Response().Response.Response != nil { 394 sc = result.page.Response().Response.Response.StatusCode 395 } 396 tracing.EndSpan(ctx, sc, err) 397 }() 398 } 399 result.page, err = client.List(ctx, resourceGroupName, circuitName, peeringName) 400 return 401} 402