github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6@v6.2.0/expressrouteports_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 // ExpressRoutePortsClient contains the methods for the ExpressRoutePorts group. 24 // Don't use this type directly, use NewExpressRoutePortsClient() instead. 25 type ExpressRoutePortsClient struct { 26 internal *arm.Client 27 subscriptionID string 28 } 29 30 // NewExpressRoutePortsClient creates a new instance of ExpressRoutePortsClient 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 NewExpressRoutePortsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ExpressRoutePortsClient, error) { 36 cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) 37 if err != nil { 38 return nil, err 39 } 40 client := &ExpressRoutePortsClient{ 41 subscriptionID: subscriptionID, 42 internal: cl, 43 } 44 return client, nil 45 } 46 47 // BeginCreateOrUpdate - Creates or updates the specified ExpressRoutePort resource. 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 // - expressRoutePortName - The name of the ExpressRoutePort resource. 53 // - parameters - Parameters supplied to the create ExpressRoutePort operation. 54 // - options - ExpressRoutePortsClientBeginCreateOrUpdateOptions contains the optional parameters for the ExpressRoutePortsClient.BeginCreateOrUpdate 55 // method. 56 func (client *ExpressRoutePortsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, expressRoutePortName string, parameters ExpressRoutePort, options *ExpressRoutePortsClientBeginCreateOrUpdateOptions) (*runtime.Poller[ExpressRoutePortsClientCreateOrUpdateResponse], error) { 57 if options == nil || options.ResumeToken == "" { 58 resp, err := client.createOrUpdate(ctx, resourceGroupName, expressRoutePortName, parameters, options) 59 if err != nil { 60 return nil, err 61 } 62 poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ExpressRoutePortsClientCreateOrUpdateResponse]{ 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[ExpressRoutePortsClientCreateOrUpdateResponse]{ 69 Tracer: client.internal.Tracer(), 70 }) 71 } 72 } 73 74 // CreateOrUpdate - Creates or updates the specified ExpressRoutePort resource. 75 // If the operation fails it returns an *azcore.ResponseError type. 76 // 77 // Generated from API version 2024-05-01 78 func (client *ExpressRoutePortsClient) createOrUpdate(ctx context.Context, resourceGroupName string, expressRoutePortName string, parameters ExpressRoutePort, options *ExpressRoutePortsClientBeginCreateOrUpdateOptions) (*http.Response, error) { 79 var err error 80 const operationName = "ExpressRoutePortsClient.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, expressRoutePortName, 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, http.StatusCreated) { 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 *ExpressRoutePortsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, expressRoutePortName string, parameters ExpressRoutePort, options *ExpressRoutePortsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { 101 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ExpressRoutePorts/{expressRoutePortName}" 102 if client.subscriptionID == "" { 103 return nil, errors.New("parameter client.subscriptionID cannot be empty") 104 } 105 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 106 if resourceGroupName == "" { 107 return nil, errors.New("parameter resourceGroupName cannot be empty") 108 } 109 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 110 if expressRoutePortName == "" { 111 return nil, errors.New("parameter expressRoutePortName cannot be empty") 112 } 113 urlPath = strings.ReplaceAll(urlPath, "{expressRoutePortName}", url.PathEscape(expressRoutePortName)) 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 // BeginDelete - Deletes the specified ExpressRoutePort resource. 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. 133 // - expressRoutePortName - The name of the ExpressRoutePort resource. 134 // - options - ExpressRoutePortsClientBeginDeleteOptions contains the optional parameters for the ExpressRoutePortsClient.BeginDelete 135 // method. 136 func (client *ExpressRoutePortsClient) BeginDelete(ctx context.Context, resourceGroupName string, expressRoutePortName string, options *ExpressRoutePortsClientBeginDeleteOptions) (*runtime.Poller[ExpressRoutePortsClientDeleteResponse], error) { 137 if options == nil || options.ResumeToken == "" { 138 resp, err := client.deleteOperation(ctx, resourceGroupName, expressRoutePortName, options) 139 if err != nil { 140 return nil, err 141 } 142 poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ExpressRoutePortsClientDeleteResponse]{ 143 FinalStateVia: runtime.FinalStateViaAzureAsyncOp, 144 Tracer: client.internal.Tracer(), 145 }) 146 return poller, err 147 } else { 148 return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ExpressRoutePortsClientDeleteResponse]{ 149 Tracer: client.internal.Tracer(), 150 }) 151 } 152 } 153 154 // Delete - Deletes the specified ExpressRoutePort resource. 155 // If the operation fails it returns an *azcore.ResponseError type. 156 // 157 // Generated from API version 2024-05-01 158 func (client *ExpressRoutePortsClient) deleteOperation(ctx context.Context, resourceGroupName string, expressRoutePortName string, options *ExpressRoutePortsClientBeginDeleteOptions) (*http.Response, error) { 159 var err error 160 const operationName = "ExpressRoutePortsClient.BeginDelete" 161 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 162 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 163 defer func() { endSpan(err) }() 164 req, err := client.deleteCreateRequest(ctx, resourceGroupName, expressRoutePortName, options) 165 if err != nil { 166 return nil, err 167 } 168 httpResp, err := client.internal.Pipeline().Do(req) 169 if err != nil { 170 return nil, err 171 } 172 if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { 173 err = runtime.NewResponseError(httpResp) 174 return nil, err 175 } 176 return httpResp, nil 177 } 178 179 // deleteCreateRequest creates the Delete request. 180 func (client *ExpressRoutePortsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, expressRoutePortName string, options *ExpressRoutePortsClientBeginDeleteOptions) (*policy.Request, error) { 181 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ExpressRoutePorts/{expressRoutePortName}" 182 if client.subscriptionID == "" { 183 return nil, errors.New("parameter client.subscriptionID cannot be empty") 184 } 185 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 186 if resourceGroupName == "" { 187 return nil, errors.New("parameter resourceGroupName cannot be empty") 188 } 189 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 190 if expressRoutePortName == "" { 191 return nil, errors.New("parameter expressRoutePortName cannot be empty") 192 } 193 urlPath = strings.ReplaceAll(urlPath, "{expressRoutePortName}", url.PathEscape(expressRoutePortName)) 194 req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 195 if err != nil { 196 return nil, err 197 } 198 reqQP := req.Raw().URL.Query() 199 reqQP.Set("api-version", "2024-05-01") 200 req.Raw().URL.RawQuery = reqQP.Encode() 201 req.Raw().Header["Accept"] = []string{"application/json"} 202 return req, nil 203 } 204 205 // GenerateLOA - Generate a letter of authorization for the requested ExpressRoutePort resource. 206 // If the operation fails it returns an *azcore.ResponseError type. 207 // 208 // Generated from API version 2024-05-01 209 // - resourceGroupName - The name of the resource group. 210 // - expressRoutePortName - The name of ExpressRoutePort. 211 // - request - Request parameters supplied to generate a letter of authorization. 212 // - options - ExpressRoutePortsClientGenerateLOAOptions contains the optional parameters for the ExpressRoutePortsClient.GenerateLOA 213 // method. 214 func (client *ExpressRoutePortsClient) GenerateLOA(ctx context.Context, resourceGroupName string, expressRoutePortName string, request GenerateExpressRoutePortsLOARequest, options *ExpressRoutePortsClientGenerateLOAOptions) (ExpressRoutePortsClientGenerateLOAResponse, error) { 215 var err error 216 const operationName = "ExpressRoutePortsClient.GenerateLOA" 217 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 218 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 219 defer func() { endSpan(err) }() 220 req, err := client.generateLOACreateRequest(ctx, resourceGroupName, expressRoutePortName, request, options) 221 if err != nil { 222 return ExpressRoutePortsClientGenerateLOAResponse{}, err 223 } 224 httpResp, err := client.internal.Pipeline().Do(req) 225 if err != nil { 226 return ExpressRoutePortsClientGenerateLOAResponse{}, err 227 } 228 if !runtime.HasStatusCode(httpResp, http.StatusOK) { 229 err = runtime.NewResponseError(httpResp) 230 return ExpressRoutePortsClientGenerateLOAResponse{}, err 231 } 232 resp, err := client.generateLOAHandleResponse(httpResp) 233 return resp, err 234 } 235 236 // generateLOACreateRequest creates the GenerateLOA request. 237 func (client *ExpressRoutePortsClient) generateLOACreateRequest(ctx context.Context, resourceGroupName string, expressRoutePortName string, request GenerateExpressRoutePortsLOARequest, options *ExpressRoutePortsClientGenerateLOAOptions) (*policy.Request, error) { 238 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRoutePorts/{expressRoutePortName}/generateLoa" 239 if client.subscriptionID == "" { 240 return nil, errors.New("parameter client.subscriptionID cannot be empty") 241 } 242 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 243 if resourceGroupName == "" { 244 return nil, errors.New("parameter resourceGroupName cannot be empty") 245 } 246 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 247 if expressRoutePortName == "" { 248 return nil, errors.New("parameter expressRoutePortName cannot be empty") 249 } 250 urlPath = strings.ReplaceAll(urlPath, "{expressRoutePortName}", url.PathEscape(expressRoutePortName)) 251 req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 252 if err != nil { 253 return nil, err 254 } 255 reqQP := req.Raw().URL.Query() 256 reqQP.Set("api-version", "2024-05-01") 257 req.Raw().URL.RawQuery = reqQP.Encode() 258 req.Raw().Header["Accept"] = []string{"application/json"} 259 if err := runtime.MarshalAsJSON(req, request); err != nil { 260 return nil, err 261 } 262 return req, nil 263 } 264 265 // generateLOAHandleResponse handles the GenerateLOA response. 266 func (client *ExpressRoutePortsClient) generateLOAHandleResponse(resp *http.Response) (ExpressRoutePortsClientGenerateLOAResponse, error) { 267 result := ExpressRoutePortsClientGenerateLOAResponse{} 268 if err := runtime.UnmarshalAsJSON(resp, &result.GenerateExpressRoutePortsLOAResult); err != nil { 269 return ExpressRoutePortsClientGenerateLOAResponse{}, err 270 } 271 return result, nil 272 } 273 274 // Get - Retrieves the requested ExpressRoutePort resource. 275 // If the operation fails it returns an *azcore.ResponseError type. 276 // 277 // Generated from API version 2024-05-01 278 // - resourceGroupName - The name of the resource group. 279 // - expressRoutePortName - The name of ExpressRoutePort. 280 // - options - ExpressRoutePortsClientGetOptions contains the optional parameters for the ExpressRoutePortsClient.Get method. 281 func (client *ExpressRoutePortsClient) Get(ctx context.Context, resourceGroupName string, expressRoutePortName string, options *ExpressRoutePortsClientGetOptions) (ExpressRoutePortsClientGetResponse, error) { 282 var err error 283 const operationName = "ExpressRoutePortsClient.Get" 284 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 285 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 286 defer func() { endSpan(err) }() 287 req, err := client.getCreateRequest(ctx, resourceGroupName, expressRoutePortName, options) 288 if err != nil { 289 return ExpressRoutePortsClientGetResponse{}, err 290 } 291 httpResp, err := client.internal.Pipeline().Do(req) 292 if err != nil { 293 return ExpressRoutePortsClientGetResponse{}, err 294 } 295 if !runtime.HasStatusCode(httpResp, http.StatusOK) { 296 err = runtime.NewResponseError(httpResp) 297 return ExpressRoutePortsClientGetResponse{}, err 298 } 299 resp, err := client.getHandleResponse(httpResp) 300 return resp, err 301 } 302 303 // getCreateRequest creates the Get request. 304 func (client *ExpressRoutePortsClient) getCreateRequest(ctx context.Context, resourceGroupName string, expressRoutePortName string, options *ExpressRoutePortsClientGetOptions) (*policy.Request, error) { 305 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ExpressRoutePorts/{expressRoutePortName}" 306 if client.subscriptionID == "" { 307 return nil, errors.New("parameter client.subscriptionID cannot be empty") 308 } 309 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 310 if resourceGroupName == "" { 311 return nil, errors.New("parameter resourceGroupName cannot be empty") 312 } 313 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 314 if expressRoutePortName == "" { 315 return nil, errors.New("parameter expressRoutePortName cannot be empty") 316 } 317 urlPath = strings.ReplaceAll(urlPath, "{expressRoutePortName}", url.PathEscape(expressRoutePortName)) 318 req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 319 if err != nil { 320 return nil, err 321 } 322 reqQP := req.Raw().URL.Query() 323 reqQP.Set("api-version", "2024-05-01") 324 req.Raw().URL.RawQuery = reqQP.Encode() 325 req.Raw().Header["Accept"] = []string{"application/json"} 326 return req, nil 327 } 328 329 // getHandleResponse handles the Get response. 330 func (client *ExpressRoutePortsClient) getHandleResponse(resp *http.Response) (ExpressRoutePortsClientGetResponse, error) { 331 result := ExpressRoutePortsClientGetResponse{} 332 if err := runtime.UnmarshalAsJSON(resp, &result.ExpressRoutePort); err != nil { 333 return ExpressRoutePortsClientGetResponse{}, err 334 } 335 return result, nil 336 } 337 338 // NewListPager - List all the ExpressRoutePort resources in the specified subscription. 339 // 340 // Generated from API version 2024-05-01 341 // - options - ExpressRoutePortsClientListOptions contains the optional parameters for the ExpressRoutePortsClient.NewListPager 342 // method. 343 func (client *ExpressRoutePortsClient) NewListPager(options *ExpressRoutePortsClientListOptions) *runtime.Pager[ExpressRoutePortsClientListResponse] { 344 return runtime.NewPager(runtime.PagingHandler[ExpressRoutePortsClientListResponse]{ 345 More: func(page ExpressRoutePortsClientListResponse) bool { 346 return page.NextLink != nil && len(*page.NextLink) > 0 347 }, 348 Fetcher: func(ctx context.Context, page *ExpressRoutePortsClientListResponse) (ExpressRoutePortsClientListResponse, error) { 349 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ExpressRoutePortsClient.NewListPager") 350 nextLink := "" 351 if page != nil { 352 nextLink = *page.NextLink 353 } 354 resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { 355 return client.listCreateRequest(ctx, options) 356 }, nil) 357 if err != nil { 358 return ExpressRoutePortsClientListResponse{}, err 359 } 360 return client.listHandleResponse(resp) 361 }, 362 Tracer: client.internal.Tracer(), 363 }) 364 } 365 366 // listCreateRequest creates the List request. 367 func (client *ExpressRoutePortsClient) listCreateRequest(ctx context.Context, options *ExpressRoutePortsClientListOptions) (*policy.Request, error) { 368 urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Network/ExpressRoutePorts" 369 if client.subscriptionID == "" { 370 return nil, errors.New("parameter client.subscriptionID cannot be empty") 371 } 372 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 373 req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 374 if err != nil { 375 return nil, err 376 } 377 reqQP := req.Raw().URL.Query() 378 reqQP.Set("api-version", "2024-05-01") 379 req.Raw().URL.RawQuery = reqQP.Encode() 380 req.Raw().Header["Accept"] = []string{"application/json"} 381 return req, nil 382 } 383 384 // listHandleResponse handles the List response. 385 func (client *ExpressRoutePortsClient) listHandleResponse(resp *http.Response) (ExpressRoutePortsClientListResponse, error) { 386 result := ExpressRoutePortsClientListResponse{} 387 if err := runtime.UnmarshalAsJSON(resp, &result.ExpressRoutePortListResult); err != nil { 388 return ExpressRoutePortsClientListResponse{}, err 389 } 390 return result, nil 391 } 392 393 // NewListByResourceGroupPager - List all the ExpressRoutePort resources in the specified resource group. 394 // 395 // Generated from API version 2024-05-01 396 // - resourceGroupName - The name of the resource group. 397 // - options - ExpressRoutePortsClientListByResourceGroupOptions contains the optional parameters for the ExpressRoutePortsClient.NewListByResourceGroupPager 398 // method. 399 func (client *ExpressRoutePortsClient) NewListByResourceGroupPager(resourceGroupName string, options *ExpressRoutePortsClientListByResourceGroupOptions) *runtime.Pager[ExpressRoutePortsClientListByResourceGroupResponse] { 400 return runtime.NewPager(runtime.PagingHandler[ExpressRoutePortsClientListByResourceGroupResponse]{ 401 More: func(page ExpressRoutePortsClientListByResourceGroupResponse) bool { 402 return page.NextLink != nil && len(*page.NextLink) > 0 403 }, 404 Fetcher: func(ctx context.Context, page *ExpressRoutePortsClientListByResourceGroupResponse) (ExpressRoutePortsClientListByResourceGroupResponse, error) { 405 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ExpressRoutePortsClient.NewListByResourceGroupPager") 406 nextLink := "" 407 if page != nil { 408 nextLink = *page.NextLink 409 } 410 resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { 411 return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) 412 }, nil) 413 if err != nil { 414 return ExpressRoutePortsClientListByResourceGroupResponse{}, err 415 } 416 return client.listByResourceGroupHandleResponse(resp) 417 }, 418 Tracer: client.internal.Tracer(), 419 }) 420 } 421 422 // listByResourceGroupCreateRequest creates the ListByResourceGroup request. 423 func (client *ExpressRoutePortsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ExpressRoutePortsClientListByResourceGroupOptions) (*policy.Request, error) { 424 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ExpressRoutePorts" 425 if client.subscriptionID == "" { 426 return nil, errors.New("parameter client.subscriptionID cannot be empty") 427 } 428 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 429 if resourceGroupName == "" { 430 return nil, errors.New("parameter resourceGroupName cannot be empty") 431 } 432 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 433 req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 434 if err != nil { 435 return nil, err 436 } 437 reqQP := req.Raw().URL.Query() 438 reqQP.Set("api-version", "2024-05-01") 439 req.Raw().URL.RawQuery = reqQP.Encode() 440 req.Raw().Header["Accept"] = []string{"application/json"} 441 return req, nil 442 } 443 444 // listByResourceGroupHandleResponse handles the ListByResourceGroup response. 445 func (client *ExpressRoutePortsClient) listByResourceGroupHandleResponse(resp *http.Response) (ExpressRoutePortsClientListByResourceGroupResponse, error) { 446 result := ExpressRoutePortsClientListByResourceGroupResponse{} 447 if err := runtime.UnmarshalAsJSON(resp, &result.ExpressRoutePortListResult); err != nil { 448 return ExpressRoutePortsClientListByResourceGroupResponse{}, err 449 } 450 return result, nil 451 } 452 453 // UpdateTags - Update ExpressRoutePort tags. 454 // If the operation fails it returns an *azcore.ResponseError type. 455 // 456 // Generated from API version 2024-05-01 457 // - resourceGroupName - The name of the resource group. 458 // - expressRoutePortName - The name of the ExpressRoutePort resource. 459 // - parameters - Parameters supplied to update ExpressRoutePort resource tags. 460 // - options - ExpressRoutePortsClientUpdateTagsOptions contains the optional parameters for the ExpressRoutePortsClient.UpdateTags 461 // method. 462 func (client *ExpressRoutePortsClient) UpdateTags(ctx context.Context, resourceGroupName string, expressRoutePortName string, parameters TagsObject, options *ExpressRoutePortsClientUpdateTagsOptions) (ExpressRoutePortsClientUpdateTagsResponse, error) { 463 var err error 464 const operationName = "ExpressRoutePortsClient.UpdateTags" 465 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 466 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 467 defer func() { endSpan(err) }() 468 req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, expressRoutePortName, parameters, options) 469 if err != nil { 470 return ExpressRoutePortsClientUpdateTagsResponse{}, err 471 } 472 httpResp, err := client.internal.Pipeline().Do(req) 473 if err != nil { 474 return ExpressRoutePortsClientUpdateTagsResponse{}, err 475 } 476 if !runtime.HasStatusCode(httpResp, http.StatusOK) { 477 err = runtime.NewResponseError(httpResp) 478 return ExpressRoutePortsClientUpdateTagsResponse{}, err 479 } 480 resp, err := client.updateTagsHandleResponse(httpResp) 481 return resp, err 482 } 483 484 // updateTagsCreateRequest creates the UpdateTags request. 485 func (client *ExpressRoutePortsClient) updateTagsCreateRequest(ctx context.Context, resourceGroupName string, expressRoutePortName string, parameters TagsObject, options *ExpressRoutePortsClientUpdateTagsOptions) (*policy.Request, error) { 486 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ExpressRoutePorts/{expressRoutePortName}" 487 if client.subscriptionID == "" { 488 return nil, errors.New("parameter client.subscriptionID cannot be empty") 489 } 490 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 491 if resourceGroupName == "" { 492 return nil, errors.New("parameter resourceGroupName cannot be empty") 493 } 494 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 495 if expressRoutePortName == "" { 496 return nil, errors.New("parameter expressRoutePortName cannot be empty") 497 } 498 urlPath = strings.ReplaceAll(urlPath, "{expressRoutePortName}", url.PathEscape(expressRoutePortName)) 499 req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 500 if err != nil { 501 return nil, err 502 } 503 reqQP := req.Raw().URL.Query() 504 reqQP.Set("api-version", "2024-05-01") 505 req.Raw().URL.RawQuery = reqQP.Encode() 506 req.Raw().Header["Accept"] = []string{"application/json"} 507 if err := runtime.MarshalAsJSON(req, parameters); err != nil { 508 return nil, err 509 } 510 return req, nil 511 } 512 513 // updateTagsHandleResponse handles the UpdateTags response. 514 func (client *ExpressRoutePortsClient) updateTagsHandleResponse(resp *http.Response) (ExpressRoutePortsClientUpdateTagsResponse, error) { 515 result := ExpressRoutePortsClientUpdateTagsResponse{} 516 if err := runtime.UnmarshalAsJSON(resp, &result.ExpressRoutePort); err != nil { 517 return ExpressRoutePortsClientUpdateTagsResponse{}, err 518 } 519 return result, nil 520 }