github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6@v6.2.0/expressroutecrossconnections_client.go (about) 1 //go:build go1.18 2 // +build go1.18 3 4 // Copyright (c) Microsoft Corporation. All rights reserved. 5 // Licensed under the MIT License. See License.txt in the project root for license information. 6 // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. 7 // Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 9 package armnetwork 10 11 import ( 12 "context" 13 "errors" 14 "github.com/Azure/azure-sdk-for-go/sdk/azcore" 15 "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" 16 "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" 17 "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" 18 "net/http" 19 "net/url" 20 "strings" 21 ) 22 23 // ExpressRouteCrossConnectionsClient contains the methods for the ExpressRouteCrossConnections group. 24 // Don't use this type directly, use NewExpressRouteCrossConnectionsClient() instead. 25 type ExpressRouteCrossConnectionsClient struct { 26 internal *arm.Client 27 subscriptionID string 28 } 29 30 // NewExpressRouteCrossConnectionsClient creates a new instance of ExpressRouteCrossConnectionsClient with the specified values. 31 // - subscriptionID - The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription 32 // ID forms part of the URI for every service call. 33 // - credential - used to authorize requests. Usually a credential from azidentity. 34 // - options - pass nil to accept the default values. 35 func NewExpressRouteCrossConnectionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ExpressRouteCrossConnectionsClient, error) { 36 cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) 37 if err != nil { 38 return nil, err 39 } 40 client := &ExpressRouteCrossConnectionsClient{ 41 subscriptionID: subscriptionID, 42 internal: cl, 43 } 44 return client, nil 45 } 46 47 // BeginCreateOrUpdate - Update the specified ExpressRouteCrossConnection. 48 // If the operation fails it returns an *azcore.ResponseError type. 49 // 50 // Generated from API version 2024-05-01 51 // - resourceGroupName - The name of the resource group. 52 // - crossConnectionName - The name of the ExpressRouteCrossConnection. 53 // - parameters - Parameters supplied to the update express route crossConnection operation. 54 // - options - ExpressRouteCrossConnectionsClientBeginCreateOrUpdateOptions contains the optional parameters for the ExpressRouteCrossConnectionsClient.BeginCreateOrUpdate 55 // method. 56 func (client *ExpressRouteCrossConnectionsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, crossConnectionName string, parameters ExpressRouteCrossConnection, options *ExpressRouteCrossConnectionsClientBeginCreateOrUpdateOptions) (*runtime.Poller[ExpressRouteCrossConnectionsClientCreateOrUpdateResponse], error) { 57 if options == nil || options.ResumeToken == "" { 58 resp, err := client.createOrUpdate(ctx, resourceGroupName, crossConnectionName, parameters, options) 59 if err != nil { 60 return nil, err 61 } 62 poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ExpressRouteCrossConnectionsClientCreateOrUpdateResponse]{ 63 FinalStateVia: runtime.FinalStateViaAzureAsyncOp, 64 Tracer: client.internal.Tracer(), 65 }) 66 return poller, err 67 } else { 68 return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ExpressRouteCrossConnectionsClientCreateOrUpdateResponse]{ 69 Tracer: client.internal.Tracer(), 70 }) 71 } 72 } 73 74 // CreateOrUpdate - Update the specified ExpressRouteCrossConnection. 75 // If the operation fails it returns an *azcore.ResponseError type. 76 // 77 // Generated from API version 2024-05-01 78 func (client *ExpressRouteCrossConnectionsClient) createOrUpdate(ctx context.Context, resourceGroupName string, crossConnectionName string, parameters ExpressRouteCrossConnection, options *ExpressRouteCrossConnectionsClientBeginCreateOrUpdateOptions) (*http.Response, error) { 79 var err error 80 const operationName = "ExpressRouteCrossConnectionsClient.BeginCreateOrUpdate" 81 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 82 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 83 defer func() { endSpan(err) }() 84 req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, crossConnectionName, parameters, options) 85 if err != nil { 86 return nil, err 87 } 88 httpResp, err := client.internal.Pipeline().Do(req) 89 if err != nil { 90 return nil, err 91 } 92 if !runtime.HasStatusCode(httpResp, http.StatusOK) { 93 err = runtime.NewResponseError(httpResp) 94 return nil, err 95 } 96 return httpResp, nil 97 } 98 99 // createOrUpdateCreateRequest creates the CreateOrUpdate request. 100 func (client *ExpressRouteCrossConnectionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, crossConnectionName string, parameters ExpressRouteCrossConnection, options *ExpressRouteCrossConnectionsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { 101 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCrossConnections/{crossConnectionName}" 102 if resourceGroupName == "" { 103 return nil, errors.New("parameter resourceGroupName cannot be empty") 104 } 105 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 106 if crossConnectionName == "" { 107 return nil, errors.New("parameter crossConnectionName cannot be empty") 108 } 109 urlPath = strings.ReplaceAll(urlPath, "{crossConnectionName}", url.PathEscape(crossConnectionName)) 110 if client.subscriptionID == "" { 111 return nil, errors.New("parameter client.subscriptionID cannot be empty") 112 } 113 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 114 req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 115 if err != nil { 116 return nil, err 117 } 118 reqQP := req.Raw().URL.Query() 119 reqQP.Set("api-version", "2024-05-01") 120 req.Raw().URL.RawQuery = reqQP.Encode() 121 req.Raw().Header["Accept"] = []string{"application/json"} 122 if err := runtime.MarshalAsJSON(req, parameters); err != nil { 123 return nil, err 124 } 125 return req, nil 126 } 127 128 // Get - Gets details about the specified ExpressRouteCrossConnection. 129 // If the operation fails it returns an *azcore.ResponseError type. 130 // 131 // Generated from API version 2024-05-01 132 // - resourceGroupName - The name of the resource group (peering location of the circuit). 133 // - crossConnectionName - The name of the ExpressRouteCrossConnection (service key of the circuit). 134 // - options - ExpressRouteCrossConnectionsClientGetOptions contains the optional parameters for the ExpressRouteCrossConnectionsClient.Get 135 // method. 136 func (client *ExpressRouteCrossConnectionsClient) Get(ctx context.Context, resourceGroupName string, crossConnectionName string, options *ExpressRouteCrossConnectionsClientGetOptions) (ExpressRouteCrossConnectionsClientGetResponse, error) { 137 var err error 138 const operationName = "ExpressRouteCrossConnectionsClient.Get" 139 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 140 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 141 defer func() { endSpan(err) }() 142 req, err := client.getCreateRequest(ctx, resourceGroupName, crossConnectionName, options) 143 if err != nil { 144 return ExpressRouteCrossConnectionsClientGetResponse{}, err 145 } 146 httpResp, err := client.internal.Pipeline().Do(req) 147 if err != nil { 148 return ExpressRouteCrossConnectionsClientGetResponse{}, err 149 } 150 if !runtime.HasStatusCode(httpResp, http.StatusOK) { 151 err = runtime.NewResponseError(httpResp) 152 return ExpressRouteCrossConnectionsClientGetResponse{}, err 153 } 154 resp, err := client.getHandleResponse(httpResp) 155 return resp, err 156 } 157 158 // getCreateRequest creates the Get request. 159 func (client *ExpressRouteCrossConnectionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, crossConnectionName string, options *ExpressRouteCrossConnectionsClientGetOptions) (*policy.Request, error) { 160 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCrossConnections/{crossConnectionName}" 161 if resourceGroupName == "" { 162 return nil, errors.New("parameter resourceGroupName cannot be empty") 163 } 164 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 165 if crossConnectionName == "" { 166 return nil, errors.New("parameter crossConnectionName cannot be empty") 167 } 168 urlPath = strings.ReplaceAll(urlPath, "{crossConnectionName}", url.PathEscape(crossConnectionName)) 169 if client.subscriptionID == "" { 170 return nil, errors.New("parameter client.subscriptionID cannot be empty") 171 } 172 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 173 req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 174 if err != nil { 175 return nil, err 176 } 177 reqQP := req.Raw().URL.Query() 178 reqQP.Set("api-version", "2024-05-01") 179 req.Raw().URL.RawQuery = reqQP.Encode() 180 req.Raw().Header["Accept"] = []string{"application/json"} 181 return req, nil 182 } 183 184 // getHandleResponse handles the Get response. 185 func (client *ExpressRouteCrossConnectionsClient) getHandleResponse(resp *http.Response) (ExpressRouteCrossConnectionsClientGetResponse, error) { 186 result := ExpressRouteCrossConnectionsClientGetResponse{} 187 if err := runtime.UnmarshalAsJSON(resp, &result.ExpressRouteCrossConnection); err != nil { 188 return ExpressRouteCrossConnectionsClientGetResponse{}, err 189 } 190 return result, nil 191 } 192 193 // NewListPager - Retrieves all the ExpressRouteCrossConnections in a subscription. 194 // 195 // Generated from API version 2024-05-01 196 // - options - ExpressRouteCrossConnectionsClientListOptions contains the optional parameters for the ExpressRouteCrossConnectionsClient.NewListPager 197 // method. 198 func (client *ExpressRouteCrossConnectionsClient) NewListPager(options *ExpressRouteCrossConnectionsClientListOptions) *runtime.Pager[ExpressRouteCrossConnectionsClientListResponse] { 199 return runtime.NewPager(runtime.PagingHandler[ExpressRouteCrossConnectionsClientListResponse]{ 200 More: func(page ExpressRouteCrossConnectionsClientListResponse) bool { 201 return page.NextLink != nil && len(*page.NextLink) > 0 202 }, 203 Fetcher: func(ctx context.Context, page *ExpressRouteCrossConnectionsClientListResponse) (ExpressRouteCrossConnectionsClientListResponse, error) { 204 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ExpressRouteCrossConnectionsClient.NewListPager") 205 nextLink := "" 206 if page != nil { 207 nextLink = *page.NextLink 208 } 209 resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { 210 return client.listCreateRequest(ctx, options) 211 }, nil) 212 if err != nil { 213 return ExpressRouteCrossConnectionsClientListResponse{}, err 214 } 215 return client.listHandleResponse(resp) 216 }, 217 Tracer: client.internal.Tracer(), 218 }) 219 } 220 221 // listCreateRequest creates the List request. 222 func (client *ExpressRouteCrossConnectionsClient) listCreateRequest(ctx context.Context, options *ExpressRouteCrossConnectionsClientListOptions) (*policy.Request, error) { 223 urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Network/expressRouteCrossConnections" 224 if client.subscriptionID == "" { 225 return nil, errors.New("parameter client.subscriptionID cannot be empty") 226 } 227 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 228 req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 229 if err != nil { 230 return nil, err 231 } 232 reqQP := req.Raw().URL.Query() 233 if options != nil && options.Filter != nil { 234 reqQP.Set("$filter", *options.Filter) 235 } 236 reqQP.Set("api-version", "2024-05-01") 237 req.Raw().URL.RawQuery = reqQP.Encode() 238 req.Raw().Header["Accept"] = []string{"application/json"} 239 return req, nil 240 } 241 242 // listHandleResponse handles the List response. 243 func (client *ExpressRouteCrossConnectionsClient) listHandleResponse(resp *http.Response) (ExpressRouteCrossConnectionsClientListResponse, error) { 244 result := ExpressRouteCrossConnectionsClientListResponse{} 245 if err := runtime.UnmarshalAsJSON(resp, &result.ExpressRouteCrossConnectionListResult); err != nil { 246 return ExpressRouteCrossConnectionsClientListResponse{}, err 247 } 248 return result, nil 249 } 250 251 // BeginListArpTable - Gets the currently advertised ARP table associated with the express route cross connection in a resource 252 // group. 253 // If the operation fails it returns an *azcore.ResponseError type. 254 // 255 // Generated from API version 2024-05-01 256 // - resourceGroupName - The name of the resource group. 257 // - crossConnectionName - The name of the ExpressRouteCrossConnection. 258 // - peeringName - The name of the peering. 259 // - devicePath - The path of the device. 260 // - options - ExpressRouteCrossConnectionsClientBeginListArpTableOptions contains the optional parameters for the ExpressRouteCrossConnectionsClient.BeginListArpTable 261 // method. 262 func (client *ExpressRouteCrossConnectionsClient) BeginListArpTable(ctx context.Context, resourceGroupName string, crossConnectionName string, peeringName string, devicePath string, options *ExpressRouteCrossConnectionsClientBeginListArpTableOptions) (*runtime.Poller[ExpressRouteCrossConnectionsClientListArpTableResponse], error) { 263 if options == nil || options.ResumeToken == "" { 264 resp, err := client.listArpTable(ctx, resourceGroupName, crossConnectionName, peeringName, devicePath, options) 265 if err != nil { 266 return nil, err 267 } 268 poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ExpressRouteCrossConnectionsClientListArpTableResponse]{ 269 FinalStateVia: runtime.FinalStateViaLocation, 270 Tracer: client.internal.Tracer(), 271 }) 272 return poller, err 273 } else { 274 return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ExpressRouteCrossConnectionsClientListArpTableResponse]{ 275 Tracer: client.internal.Tracer(), 276 }) 277 } 278 } 279 280 // ListArpTable - Gets the currently advertised ARP table associated with the express route cross connection in a resource 281 // group. 282 // If the operation fails it returns an *azcore.ResponseError type. 283 // 284 // Generated from API version 2024-05-01 285 func (client *ExpressRouteCrossConnectionsClient) listArpTable(ctx context.Context, resourceGroupName string, crossConnectionName string, peeringName string, devicePath string, options *ExpressRouteCrossConnectionsClientBeginListArpTableOptions) (*http.Response, error) { 286 var err error 287 const operationName = "ExpressRouteCrossConnectionsClient.BeginListArpTable" 288 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 289 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 290 defer func() { endSpan(err) }() 291 req, err := client.listArpTableCreateRequest(ctx, resourceGroupName, crossConnectionName, peeringName, devicePath, options) 292 if err != nil { 293 return nil, err 294 } 295 httpResp, err := client.internal.Pipeline().Do(req) 296 if err != nil { 297 return nil, err 298 } 299 if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { 300 err = runtime.NewResponseError(httpResp) 301 return nil, err 302 } 303 return httpResp, nil 304 } 305 306 // listArpTableCreateRequest creates the ListArpTable request. 307 func (client *ExpressRouteCrossConnectionsClient) listArpTableCreateRequest(ctx context.Context, resourceGroupName string, crossConnectionName string, peeringName string, devicePath string, options *ExpressRouteCrossConnectionsClientBeginListArpTableOptions) (*policy.Request, error) { 308 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCrossConnections/{crossConnectionName}/peerings/{peeringName}/arpTables/{devicePath}" 309 if resourceGroupName == "" { 310 return nil, errors.New("parameter resourceGroupName cannot be empty") 311 } 312 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 313 if crossConnectionName == "" { 314 return nil, errors.New("parameter crossConnectionName cannot be empty") 315 } 316 urlPath = strings.ReplaceAll(urlPath, "{crossConnectionName}", url.PathEscape(crossConnectionName)) 317 if peeringName == "" { 318 return nil, errors.New("parameter peeringName cannot be empty") 319 } 320 urlPath = strings.ReplaceAll(urlPath, "{peeringName}", url.PathEscape(peeringName)) 321 if devicePath == "" { 322 return nil, errors.New("parameter devicePath cannot be empty") 323 } 324 urlPath = strings.ReplaceAll(urlPath, "{devicePath}", url.PathEscape(devicePath)) 325 if client.subscriptionID == "" { 326 return nil, errors.New("parameter client.subscriptionID cannot be empty") 327 } 328 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 329 req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 330 if err != nil { 331 return nil, err 332 } 333 reqQP := req.Raw().URL.Query() 334 reqQP.Set("api-version", "2024-05-01") 335 req.Raw().URL.RawQuery = reqQP.Encode() 336 req.Raw().Header["Accept"] = []string{"application/json"} 337 return req, nil 338 } 339 340 // NewListByResourceGroupPager - Retrieves all the ExpressRouteCrossConnections in a resource group. 341 // 342 // Generated from API version 2024-05-01 343 // - resourceGroupName - The name of the resource group. 344 // - options - ExpressRouteCrossConnectionsClientListByResourceGroupOptions contains the optional parameters for the ExpressRouteCrossConnectionsClient.NewListByResourceGroupPager 345 // method. 346 func (client *ExpressRouteCrossConnectionsClient) NewListByResourceGroupPager(resourceGroupName string, options *ExpressRouteCrossConnectionsClientListByResourceGroupOptions) *runtime.Pager[ExpressRouteCrossConnectionsClientListByResourceGroupResponse] { 347 return runtime.NewPager(runtime.PagingHandler[ExpressRouteCrossConnectionsClientListByResourceGroupResponse]{ 348 More: func(page ExpressRouteCrossConnectionsClientListByResourceGroupResponse) bool { 349 return page.NextLink != nil && len(*page.NextLink) > 0 350 }, 351 Fetcher: func(ctx context.Context, page *ExpressRouteCrossConnectionsClientListByResourceGroupResponse) (ExpressRouteCrossConnectionsClientListByResourceGroupResponse, error) { 352 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ExpressRouteCrossConnectionsClient.NewListByResourceGroupPager") 353 nextLink := "" 354 if page != nil { 355 nextLink = *page.NextLink 356 } 357 resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { 358 return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) 359 }, nil) 360 if err != nil { 361 return ExpressRouteCrossConnectionsClientListByResourceGroupResponse{}, err 362 } 363 return client.listByResourceGroupHandleResponse(resp) 364 }, 365 Tracer: client.internal.Tracer(), 366 }) 367 } 368 369 // listByResourceGroupCreateRequest creates the ListByResourceGroup request. 370 func (client *ExpressRouteCrossConnectionsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ExpressRouteCrossConnectionsClientListByResourceGroupOptions) (*policy.Request, error) { 371 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCrossConnections" 372 if resourceGroupName == "" { 373 return nil, errors.New("parameter resourceGroupName cannot be empty") 374 } 375 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 376 if client.subscriptionID == "" { 377 return nil, errors.New("parameter client.subscriptionID cannot be empty") 378 } 379 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 380 req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 381 if err != nil { 382 return nil, err 383 } 384 reqQP := req.Raw().URL.Query() 385 reqQP.Set("api-version", "2024-05-01") 386 req.Raw().URL.RawQuery = reqQP.Encode() 387 req.Raw().Header["Accept"] = []string{"application/json"} 388 return req, nil 389 } 390 391 // listByResourceGroupHandleResponse handles the ListByResourceGroup response. 392 func (client *ExpressRouteCrossConnectionsClient) listByResourceGroupHandleResponse(resp *http.Response) (ExpressRouteCrossConnectionsClientListByResourceGroupResponse, error) { 393 result := ExpressRouteCrossConnectionsClientListByResourceGroupResponse{} 394 if err := runtime.UnmarshalAsJSON(resp, &result.ExpressRouteCrossConnectionListResult); err != nil { 395 return ExpressRouteCrossConnectionsClientListByResourceGroupResponse{}, err 396 } 397 return result, nil 398 } 399 400 // BeginListRoutesTable - Gets the currently advertised routes table associated with the express route cross connection in 401 // a resource group. 402 // If the operation fails it returns an *azcore.ResponseError type. 403 // 404 // Generated from API version 2024-05-01 405 // - resourceGroupName - The name of the resource group. 406 // - crossConnectionName - The name of the ExpressRouteCrossConnection. 407 // - peeringName - The name of the peering. 408 // - devicePath - The path of the device. 409 // - options - ExpressRouteCrossConnectionsClientBeginListRoutesTableOptions contains the optional parameters for the ExpressRouteCrossConnectionsClient.BeginListRoutesTable 410 // method. 411 func (client *ExpressRouteCrossConnectionsClient) BeginListRoutesTable(ctx context.Context, resourceGroupName string, crossConnectionName string, peeringName string, devicePath string, options *ExpressRouteCrossConnectionsClientBeginListRoutesTableOptions) (*runtime.Poller[ExpressRouteCrossConnectionsClientListRoutesTableResponse], error) { 412 if options == nil || options.ResumeToken == "" { 413 resp, err := client.listRoutesTable(ctx, resourceGroupName, crossConnectionName, peeringName, devicePath, options) 414 if err != nil { 415 return nil, err 416 } 417 poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ExpressRouteCrossConnectionsClientListRoutesTableResponse]{ 418 FinalStateVia: runtime.FinalStateViaLocation, 419 Tracer: client.internal.Tracer(), 420 }) 421 return poller, err 422 } else { 423 return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ExpressRouteCrossConnectionsClientListRoutesTableResponse]{ 424 Tracer: client.internal.Tracer(), 425 }) 426 } 427 } 428 429 // ListRoutesTable - Gets the currently advertised routes table associated with the express route cross connection in a resource 430 // group. 431 // If the operation fails it returns an *azcore.ResponseError type. 432 // 433 // Generated from API version 2024-05-01 434 func (client *ExpressRouteCrossConnectionsClient) listRoutesTable(ctx context.Context, resourceGroupName string, crossConnectionName string, peeringName string, devicePath string, options *ExpressRouteCrossConnectionsClientBeginListRoutesTableOptions) (*http.Response, error) { 435 var err error 436 const operationName = "ExpressRouteCrossConnectionsClient.BeginListRoutesTable" 437 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 438 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 439 defer func() { endSpan(err) }() 440 req, err := client.listRoutesTableCreateRequest(ctx, resourceGroupName, crossConnectionName, peeringName, devicePath, options) 441 if err != nil { 442 return nil, err 443 } 444 httpResp, err := client.internal.Pipeline().Do(req) 445 if err != nil { 446 return nil, err 447 } 448 if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { 449 err = runtime.NewResponseError(httpResp) 450 return nil, err 451 } 452 return httpResp, nil 453 } 454 455 // listRoutesTableCreateRequest creates the ListRoutesTable request. 456 func (client *ExpressRouteCrossConnectionsClient) listRoutesTableCreateRequest(ctx context.Context, resourceGroupName string, crossConnectionName string, peeringName string, devicePath string, options *ExpressRouteCrossConnectionsClientBeginListRoutesTableOptions) (*policy.Request, error) { 457 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCrossConnections/{crossConnectionName}/peerings/{peeringName}/routeTables/{devicePath}" 458 if resourceGroupName == "" { 459 return nil, errors.New("parameter resourceGroupName cannot be empty") 460 } 461 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 462 if crossConnectionName == "" { 463 return nil, errors.New("parameter crossConnectionName cannot be empty") 464 } 465 urlPath = strings.ReplaceAll(urlPath, "{crossConnectionName}", url.PathEscape(crossConnectionName)) 466 if peeringName == "" { 467 return nil, errors.New("parameter peeringName cannot be empty") 468 } 469 urlPath = strings.ReplaceAll(urlPath, "{peeringName}", url.PathEscape(peeringName)) 470 if devicePath == "" { 471 return nil, errors.New("parameter devicePath cannot be empty") 472 } 473 urlPath = strings.ReplaceAll(urlPath, "{devicePath}", url.PathEscape(devicePath)) 474 if client.subscriptionID == "" { 475 return nil, errors.New("parameter client.subscriptionID cannot be empty") 476 } 477 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 478 req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 479 if err != nil { 480 return nil, err 481 } 482 reqQP := req.Raw().URL.Query() 483 reqQP.Set("api-version", "2024-05-01") 484 req.Raw().URL.RawQuery = reqQP.Encode() 485 req.Raw().Header["Accept"] = []string{"application/json"} 486 return req, nil 487 } 488 489 // BeginListRoutesTableSummary - Gets the route table summary associated with the express route cross connection in a resource 490 // group. 491 // If the operation fails it returns an *azcore.ResponseError type. 492 // 493 // Generated from API version 2024-05-01 494 // - resourceGroupName - The name of the resource group. 495 // - crossConnectionName - The name of the ExpressRouteCrossConnection. 496 // - peeringName - The name of the peering. 497 // - devicePath - The path of the device. 498 // - options - ExpressRouteCrossConnectionsClientBeginListRoutesTableSummaryOptions contains the optional parameters for the 499 // ExpressRouteCrossConnectionsClient.BeginListRoutesTableSummary method. 500 func (client *ExpressRouteCrossConnectionsClient) BeginListRoutesTableSummary(ctx context.Context, resourceGroupName string, crossConnectionName string, peeringName string, devicePath string, options *ExpressRouteCrossConnectionsClientBeginListRoutesTableSummaryOptions) (*runtime.Poller[ExpressRouteCrossConnectionsClientListRoutesTableSummaryResponse], error) { 501 if options == nil || options.ResumeToken == "" { 502 resp, err := client.listRoutesTableSummary(ctx, resourceGroupName, crossConnectionName, peeringName, devicePath, options) 503 if err != nil { 504 return nil, err 505 } 506 poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ExpressRouteCrossConnectionsClientListRoutesTableSummaryResponse]{ 507 FinalStateVia: runtime.FinalStateViaLocation, 508 Tracer: client.internal.Tracer(), 509 }) 510 return poller, err 511 } else { 512 return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ExpressRouteCrossConnectionsClientListRoutesTableSummaryResponse]{ 513 Tracer: client.internal.Tracer(), 514 }) 515 } 516 } 517 518 // ListRoutesTableSummary - Gets the route table summary associated with the express route cross connection in a resource 519 // group. 520 // If the operation fails it returns an *azcore.ResponseError type. 521 // 522 // Generated from API version 2024-05-01 523 func (client *ExpressRouteCrossConnectionsClient) listRoutesTableSummary(ctx context.Context, resourceGroupName string, crossConnectionName string, peeringName string, devicePath string, options *ExpressRouteCrossConnectionsClientBeginListRoutesTableSummaryOptions) (*http.Response, error) { 524 var err error 525 const operationName = "ExpressRouteCrossConnectionsClient.BeginListRoutesTableSummary" 526 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 527 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 528 defer func() { endSpan(err) }() 529 req, err := client.listRoutesTableSummaryCreateRequest(ctx, resourceGroupName, crossConnectionName, peeringName, devicePath, options) 530 if err != nil { 531 return nil, err 532 } 533 httpResp, err := client.internal.Pipeline().Do(req) 534 if err != nil { 535 return nil, err 536 } 537 if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { 538 err = runtime.NewResponseError(httpResp) 539 return nil, err 540 } 541 return httpResp, nil 542 } 543 544 // listRoutesTableSummaryCreateRequest creates the ListRoutesTableSummary request. 545 func (client *ExpressRouteCrossConnectionsClient) listRoutesTableSummaryCreateRequest(ctx context.Context, resourceGroupName string, crossConnectionName string, peeringName string, devicePath string, options *ExpressRouteCrossConnectionsClientBeginListRoutesTableSummaryOptions) (*policy.Request, error) { 546 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCrossConnections/{crossConnectionName}/peerings/{peeringName}/routeTablesSummary/{devicePath}" 547 if resourceGroupName == "" { 548 return nil, errors.New("parameter resourceGroupName cannot be empty") 549 } 550 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 551 if crossConnectionName == "" { 552 return nil, errors.New("parameter crossConnectionName cannot be empty") 553 } 554 urlPath = strings.ReplaceAll(urlPath, "{crossConnectionName}", url.PathEscape(crossConnectionName)) 555 if peeringName == "" { 556 return nil, errors.New("parameter peeringName cannot be empty") 557 } 558 urlPath = strings.ReplaceAll(urlPath, "{peeringName}", url.PathEscape(peeringName)) 559 if devicePath == "" { 560 return nil, errors.New("parameter devicePath cannot be empty") 561 } 562 urlPath = strings.ReplaceAll(urlPath, "{devicePath}", url.PathEscape(devicePath)) 563 if client.subscriptionID == "" { 564 return nil, errors.New("parameter client.subscriptionID cannot be empty") 565 } 566 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 567 req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 568 if err != nil { 569 return nil, err 570 } 571 reqQP := req.Raw().URL.Query() 572 reqQP.Set("api-version", "2024-05-01") 573 req.Raw().URL.RawQuery = reqQP.Encode() 574 req.Raw().Header["Accept"] = []string{"application/json"} 575 return req, nil 576 } 577 578 // UpdateTags - Updates an express route cross connection tags. 579 // If the operation fails it returns an *azcore.ResponseError type. 580 // 581 // Generated from API version 2024-05-01 582 // - resourceGroupName - The name of the resource group. 583 // - crossConnectionName - The name of the cross connection. 584 // - crossConnectionParameters - Parameters supplied to update express route cross connection tags. 585 // - options - ExpressRouteCrossConnectionsClientUpdateTagsOptions contains the optional parameters for the ExpressRouteCrossConnectionsClient.UpdateTags 586 // method. 587 func (client *ExpressRouteCrossConnectionsClient) UpdateTags(ctx context.Context, resourceGroupName string, crossConnectionName string, crossConnectionParameters TagsObject, options *ExpressRouteCrossConnectionsClientUpdateTagsOptions) (ExpressRouteCrossConnectionsClientUpdateTagsResponse, error) { 588 var err error 589 const operationName = "ExpressRouteCrossConnectionsClient.UpdateTags" 590 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 591 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 592 defer func() { endSpan(err) }() 593 req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, crossConnectionName, crossConnectionParameters, options) 594 if err != nil { 595 return ExpressRouteCrossConnectionsClientUpdateTagsResponse{}, err 596 } 597 httpResp, err := client.internal.Pipeline().Do(req) 598 if err != nil { 599 return ExpressRouteCrossConnectionsClientUpdateTagsResponse{}, err 600 } 601 if !runtime.HasStatusCode(httpResp, http.StatusOK) { 602 err = runtime.NewResponseError(httpResp) 603 return ExpressRouteCrossConnectionsClientUpdateTagsResponse{}, err 604 } 605 resp, err := client.updateTagsHandleResponse(httpResp) 606 return resp, err 607 } 608 609 // updateTagsCreateRequest creates the UpdateTags request. 610 func (client *ExpressRouteCrossConnectionsClient) updateTagsCreateRequest(ctx context.Context, resourceGroupName string, crossConnectionName string, crossConnectionParameters TagsObject, options *ExpressRouteCrossConnectionsClientUpdateTagsOptions) (*policy.Request, error) { 611 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCrossConnections/{crossConnectionName}" 612 if resourceGroupName == "" { 613 return nil, errors.New("parameter resourceGroupName cannot be empty") 614 } 615 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 616 if crossConnectionName == "" { 617 return nil, errors.New("parameter crossConnectionName cannot be empty") 618 } 619 urlPath = strings.ReplaceAll(urlPath, "{crossConnectionName}", url.PathEscape(crossConnectionName)) 620 if client.subscriptionID == "" { 621 return nil, errors.New("parameter client.subscriptionID cannot be empty") 622 } 623 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 624 req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 625 if err != nil { 626 return nil, err 627 } 628 reqQP := req.Raw().URL.Query() 629 reqQP.Set("api-version", "2024-05-01") 630 req.Raw().URL.RawQuery = reqQP.Encode() 631 req.Raw().Header["Accept"] = []string{"application/json"} 632 if err := runtime.MarshalAsJSON(req, crossConnectionParameters); err != nil { 633 return nil, err 634 } 635 return req, nil 636 } 637 638 // updateTagsHandleResponse handles the UpdateTags response. 639 func (client *ExpressRouteCrossConnectionsClient) updateTagsHandleResponse(resp *http.Response) (ExpressRouteCrossConnectionsClientUpdateTagsResponse, error) { 640 result := ExpressRouteCrossConnectionsClientUpdateTagsResponse{} 641 if err := runtime.UnmarshalAsJSON(resp, &result.ExpressRouteCrossConnection); err != nil { 642 return ExpressRouteCrossConnectionsClientUpdateTagsResponse{}, err 643 } 644 return result, nil 645 }