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 = "2018-07-01" 79 queryParameters := map[string]interface{}{ 80 "api-version": APIVersion, 81 } 82 83 expressRouteCircuitConnectionParameters.Etag = nil 84 preparer := autorest.CreatePreparer( 85 autorest.AsContentType("application/json; charset=utf-8"), 86 autorest.AsPut(), 87 autorest.WithBaseURL(client.BaseURI), 88 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}/connections/{connectionName}", pathParameters), 89 autorest.WithJSON(expressRouteCircuitConnectionParameters), 90 autorest.WithQueryParameters(queryParameters)) 91 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 92} 93 94// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 95// http.Response Body if it receives an error. 96func (client ExpressRouteCircuitConnectionsClient) CreateOrUpdateSender(req *http.Request) (future ExpressRouteCircuitConnectionsCreateOrUpdateFuture, err error) { 97 var resp *http.Response 98 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 99 if err != nil { 100 return 101 } 102 var azf azure.Future 103 azf, err = azure.NewFutureFromResponse(resp) 104 future.FutureAPI = &azf 105 future.Result = future.result 106 return 107} 108 109// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 110// closes the http.Response Body. 111func (client ExpressRouteCircuitConnectionsClient) CreateOrUpdateResponder(resp *http.Response) (result ExpressRouteCircuitConnection, err error) { 112 err = autorest.Respond( 113 resp, 114 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 115 autorest.ByUnmarshallingJSON(&result), 116 autorest.ByClosing()) 117 result.Response = autorest.Response{Response: resp} 118 return 119} 120 121// Delete deletes the specified Express Route Circuit Connection from the specified express route circuit. 122// Parameters: 123// resourceGroupName - the name of the resource group. 124// circuitName - the name of the express route circuit. 125// peeringName - the name of the peering. 126// connectionName - the name of the express route circuit connection. 127func (client ExpressRouteCircuitConnectionsClient) Delete(ctx context.Context, resourceGroupName string, circuitName string, peeringName string, connectionName string) (result ExpressRouteCircuitConnectionsDeleteFuture, err error) { 128 if tracing.IsEnabled() { 129 ctx = tracing.StartSpan(ctx, fqdn+"/ExpressRouteCircuitConnectionsClient.Delete") 130 defer func() { 131 sc := -1 132 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 133 sc = result.FutureAPI.Response().StatusCode 134 } 135 tracing.EndSpan(ctx, sc, err) 136 }() 137 } 138 req, err := client.DeletePreparer(ctx, resourceGroupName, circuitName, peeringName, connectionName) 139 if err != nil { 140 err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitConnectionsClient", "Delete", nil, "Failure preparing request") 141 return 142 } 143 144 result, err = client.DeleteSender(req) 145 if err != nil { 146 err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitConnectionsClient", "Delete", nil, "Failure sending request") 147 return 148 } 149 150 return 151} 152 153// DeletePreparer prepares the Delete request. 154func (client ExpressRouteCircuitConnectionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, circuitName string, peeringName string, connectionName string) (*http.Request, error) { 155 pathParameters := map[string]interface{}{ 156 "circuitName": autorest.Encode("path", circuitName), 157 "connectionName": autorest.Encode("path", connectionName), 158 "peeringName": autorest.Encode("path", peeringName), 159 "resourceGroupName": autorest.Encode("path", resourceGroupName), 160 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 161 } 162 163 const APIVersion = "2018-07-01" 164 queryParameters := map[string]interface{}{ 165 "api-version": APIVersion, 166 } 167 168 preparer := autorest.CreatePreparer( 169 autorest.AsDelete(), 170 autorest.WithBaseURL(client.BaseURI), 171 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}/connections/{connectionName}", pathParameters), 172 autorest.WithQueryParameters(queryParameters)) 173 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 174} 175 176// DeleteSender sends the Delete request. The method will close the 177// http.Response Body if it receives an error. 178func (client ExpressRouteCircuitConnectionsClient) DeleteSender(req *http.Request) (future ExpressRouteCircuitConnectionsDeleteFuture, err error) { 179 var resp *http.Response 180 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 181 if err != nil { 182 return 183 } 184 var azf azure.Future 185 azf, err = azure.NewFutureFromResponse(resp) 186 future.FutureAPI = &azf 187 future.Result = future.result 188 return 189} 190 191// DeleteResponder handles the response to the Delete request. The method always 192// closes the http.Response Body. 193func (client ExpressRouteCircuitConnectionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 194 err = autorest.Respond( 195 resp, 196 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 197 autorest.ByClosing()) 198 result.Response = resp 199 return 200} 201 202// Get gets the specified Express Route Circuit Connection from the specified express route circuit. 203// Parameters: 204// resourceGroupName - the name of the resource group. 205// circuitName - the name of the express route circuit. 206// peeringName - the name of the peering. 207// connectionName - the name of the express route circuit connection. 208func (client ExpressRouteCircuitConnectionsClient) Get(ctx context.Context, resourceGroupName string, circuitName string, peeringName string, connectionName string) (result ExpressRouteCircuitConnection, err error) { 209 if tracing.IsEnabled() { 210 ctx = tracing.StartSpan(ctx, fqdn+"/ExpressRouteCircuitConnectionsClient.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, circuitName, peeringName, connectionName) 220 if err != nil { 221 err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitConnectionsClient", "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.ExpressRouteCircuitConnectionsClient", "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.ExpressRouteCircuitConnectionsClient", "Get", resp, "Failure responding to request") 235 return 236 } 237 238 return 239} 240 241// GetPreparer prepares the Get request. 242func (client ExpressRouteCircuitConnectionsClient) GetPreparer(ctx context.Context, resourceGroupName string, circuitName string, peeringName string, connectionName string) (*http.Request, error) { 243 pathParameters := map[string]interface{}{ 244 "circuitName": autorest.Encode("path", circuitName), 245 "connectionName": autorest.Encode("path", connectionName), 246 "peeringName": autorest.Encode("path", peeringName), 247 "resourceGroupName": autorest.Encode("path", resourceGroupName), 248 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 249 } 250 251 const APIVersion = "2018-07-01" 252 queryParameters := map[string]interface{}{ 253 "api-version": APIVersion, 254 } 255 256 preparer := autorest.CreatePreparer( 257 autorest.AsGet(), 258 autorest.WithBaseURL(client.BaseURI), 259 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}/connections/{connectionName}", pathParameters), 260 autorest.WithQueryParameters(queryParameters)) 261 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 262} 263 264// GetSender sends the Get request. The method will close the 265// http.Response Body if it receives an error. 266func (client ExpressRouteCircuitConnectionsClient) GetSender(req *http.Request) (*http.Response, error) { 267 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 268} 269 270// GetResponder handles the response to the Get request. The method always 271// closes the http.Response Body. 272func (client ExpressRouteCircuitConnectionsClient) GetResponder(resp *http.Response) (result ExpressRouteCircuitConnection, err error) { 273 err = autorest.Respond( 274 resp, 275 azure.WithErrorUnlessStatusCode(http.StatusOK), 276 autorest.ByUnmarshallingJSON(&result), 277 autorest.ByClosing()) 278 result.Response = autorest.Response{Response: resp} 279 return 280} 281