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