github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6@v6.2.0/expressroutegateways_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 // ExpressRouteGatewaysClient contains the methods for the ExpressRouteGateways group. 24 // Don't use this type directly, use NewExpressRouteGatewaysClient() instead. 25 type ExpressRouteGatewaysClient struct { 26 internal *arm.Client 27 subscriptionID string 28 } 29 30 // NewExpressRouteGatewaysClient creates a new instance of ExpressRouteGatewaysClient 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 NewExpressRouteGatewaysClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ExpressRouteGatewaysClient, error) { 36 cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) 37 if err != nil { 38 return nil, err 39 } 40 client := &ExpressRouteGatewaysClient{ 41 subscriptionID: subscriptionID, 42 internal: cl, 43 } 44 return client, nil 45 } 46 47 // BeginCreateOrUpdate - Creates or updates a ExpressRoute gateway in a specified resource group. 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 // - expressRouteGatewayName - The name of the ExpressRoute gateway. 53 // - putExpressRouteGatewayParameters - Parameters required in an ExpressRoute gateway PUT operation. 54 // - options - ExpressRouteGatewaysClientBeginCreateOrUpdateOptions contains the optional parameters for the ExpressRouteGatewaysClient.BeginCreateOrUpdate 55 // method. 56 func (client *ExpressRouteGatewaysClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, expressRouteGatewayName string, putExpressRouteGatewayParameters ExpressRouteGateway, options *ExpressRouteGatewaysClientBeginCreateOrUpdateOptions) (*runtime.Poller[ExpressRouteGatewaysClientCreateOrUpdateResponse], error) { 57 if options == nil || options.ResumeToken == "" { 58 resp, err := client.createOrUpdate(ctx, resourceGroupName, expressRouteGatewayName, putExpressRouteGatewayParameters, options) 59 if err != nil { 60 return nil, err 61 } 62 poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ExpressRouteGatewaysClientCreateOrUpdateResponse]{ 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[ExpressRouteGatewaysClientCreateOrUpdateResponse]{ 69 Tracer: client.internal.Tracer(), 70 }) 71 } 72 } 73 74 // CreateOrUpdate - Creates or updates a ExpressRoute gateway in a specified resource group. 75 // If the operation fails it returns an *azcore.ResponseError type. 76 // 77 // Generated from API version 2024-05-01 78 func (client *ExpressRouteGatewaysClient) createOrUpdate(ctx context.Context, resourceGroupName string, expressRouteGatewayName string, putExpressRouteGatewayParameters ExpressRouteGateway, options *ExpressRouteGatewaysClientBeginCreateOrUpdateOptions) (*http.Response, error) { 79 var err error 80 const operationName = "ExpressRouteGatewaysClient.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, expressRouteGatewayName, putExpressRouteGatewayParameters, 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 *ExpressRouteGatewaysClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, expressRouteGatewayName string, putExpressRouteGatewayParameters ExpressRouteGateway, options *ExpressRouteGatewaysClientBeginCreateOrUpdateOptions) (*policy.Request, error) { 101 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteGateways/{expressRouteGatewayName}" 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 expressRouteGatewayName == "" { 107 return nil, errors.New("parameter expressRouteGatewayName cannot be empty") 108 } 109 urlPath = strings.ReplaceAll(urlPath, "{expressRouteGatewayName}", url.PathEscape(expressRouteGatewayName)) 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, putExpressRouteGatewayParameters); err != nil { 123 return nil, err 124 } 125 return req, nil 126 } 127 128 // BeginDelete - Deletes the specified ExpressRoute gateway in a resource group. An ExpressRoute gateway resource can only 129 // be deleted when there are no connection subresources. 130 // If the operation fails it returns an *azcore.ResponseError type. 131 // 132 // Generated from API version 2024-05-01 133 // - resourceGroupName - The name of the resource group. 134 // - expressRouteGatewayName - The name of the ExpressRoute gateway. 135 // - options - ExpressRouteGatewaysClientBeginDeleteOptions contains the optional parameters for the ExpressRouteGatewaysClient.BeginDelete 136 // method. 137 func (client *ExpressRouteGatewaysClient) BeginDelete(ctx context.Context, resourceGroupName string, expressRouteGatewayName string, options *ExpressRouteGatewaysClientBeginDeleteOptions) (*runtime.Poller[ExpressRouteGatewaysClientDeleteResponse], error) { 138 if options == nil || options.ResumeToken == "" { 139 resp, err := client.deleteOperation(ctx, resourceGroupName, expressRouteGatewayName, options) 140 if err != nil { 141 return nil, err 142 } 143 poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ExpressRouteGatewaysClientDeleteResponse]{ 144 FinalStateVia: runtime.FinalStateViaLocation, 145 Tracer: client.internal.Tracer(), 146 }) 147 return poller, err 148 } else { 149 return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ExpressRouteGatewaysClientDeleteResponse]{ 150 Tracer: client.internal.Tracer(), 151 }) 152 } 153 } 154 155 // Delete - Deletes the specified ExpressRoute gateway in a resource group. An ExpressRoute gateway resource can only be deleted 156 // when there are no connection subresources. 157 // If the operation fails it returns an *azcore.ResponseError type. 158 // 159 // Generated from API version 2024-05-01 160 func (client *ExpressRouteGatewaysClient) deleteOperation(ctx context.Context, resourceGroupName string, expressRouteGatewayName string, options *ExpressRouteGatewaysClientBeginDeleteOptions) (*http.Response, error) { 161 var err error 162 const operationName = "ExpressRouteGatewaysClient.BeginDelete" 163 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 164 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 165 defer func() { endSpan(err) }() 166 req, err := client.deleteCreateRequest(ctx, resourceGroupName, expressRouteGatewayName, options) 167 if err != nil { 168 return nil, err 169 } 170 httpResp, err := client.internal.Pipeline().Do(req) 171 if err != nil { 172 return nil, err 173 } 174 if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { 175 err = runtime.NewResponseError(httpResp) 176 return nil, err 177 } 178 return httpResp, nil 179 } 180 181 // deleteCreateRequest creates the Delete request. 182 func (client *ExpressRouteGatewaysClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, expressRouteGatewayName string, options *ExpressRouteGatewaysClientBeginDeleteOptions) (*policy.Request, error) { 183 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteGateways/{expressRouteGatewayName}" 184 if resourceGroupName == "" { 185 return nil, errors.New("parameter resourceGroupName cannot be empty") 186 } 187 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 188 if expressRouteGatewayName == "" { 189 return nil, errors.New("parameter expressRouteGatewayName cannot be empty") 190 } 191 urlPath = strings.ReplaceAll(urlPath, "{expressRouteGatewayName}", url.PathEscape(expressRouteGatewayName)) 192 if client.subscriptionID == "" { 193 return nil, errors.New("parameter client.subscriptionID cannot be empty") 194 } 195 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 196 req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 197 if err != nil { 198 return nil, err 199 } 200 reqQP := req.Raw().URL.Query() 201 reqQP.Set("api-version", "2024-05-01") 202 req.Raw().URL.RawQuery = reqQP.Encode() 203 req.Raw().Header["Accept"] = []string{"application/json"} 204 return req, nil 205 } 206 207 // Get - Fetches the details of a ExpressRoute gateway in a resource group. 208 // If the operation fails it returns an *azcore.ResponseError type. 209 // 210 // Generated from API version 2024-05-01 211 // - resourceGroupName - The name of the resource group. 212 // - expressRouteGatewayName - The name of the ExpressRoute gateway. 213 // - options - ExpressRouteGatewaysClientGetOptions contains the optional parameters for the ExpressRouteGatewaysClient.Get 214 // method. 215 func (client *ExpressRouteGatewaysClient) Get(ctx context.Context, resourceGroupName string, expressRouteGatewayName string, options *ExpressRouteGatewaysClientGetOptions) (ExpressRouteGatewaysClientGetResponse, error) { 216 var err error 217 const operationName = "ExpressRouteGatewaysClient.Get" 218 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 219 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 220 defer func() { endSpan(err) }() 221 req, err := client.getCreateRequest(ctx, resourceGroupName, expressRouteGatewayName, options) 222 if err != nil { 223 return ExpressRouteGatewaysClientGetResponse{}, err 224 } 225 httpResp, err := client.internal.Pipeline().Do(req) 226 if err != nil { 227 return ExpressRouteGatewaysClientGetResponse{}, err 228 } 229 if !runtime.HasStatusCode(httpResp, http.StatusOK) { 230 err = runtime.NewResponseError(httpResp) 231 return ExpressRouteGatewaysClientGetResponse{}, err 232 } 233 resp, err := client.getHandleResponse(httpResp) 234 return resp, err 235 } 236 237 // getCreateRequest creates the Get request. 238 func (client *ExpressRouteGatewaysClient) getCreateRequest(ctx context.Context, resourceGroupName string, expressRouteGatewayName string, options *ExpressRouteGatewaysClientGetOptions) (*policy.Request, error) { 239 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteGateways/{expressRouteGatewayName}" 240 if resourceGroupName == "" { 241 return nil, errors.New("parameter resourceGroupName cannot be empty") 242 } 243 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 244 if expressRouteGatewayName == "" { 245 return nil, errors.New("parameter expressRouteGatewayName cannot be empty") 246 } 247 urlPath = strings.ReplaceAll(urlPath, "{expressRouteGatewayName}", url.PathEscape(expressRouteGatewayName)) 248 if client.subscriptionID == "" { 249 return nil, errors.New("parameter client.subscriptionID cannot be empty") 250 } 251 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 252 req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 253 if err != nil { 254 return nil, err 255 } 256 reqQP := req.Raw().URL.Query() 257 reqQP.Set("api-version", "2024-05-01") 258 req.Raw().URL.RawQuery = reqQP.Encode() 259 req.Raw().Header["Accept"] = []string{"application/json"} 260 return req, nil 261 } 262 263 // getHandleResponse handles the Get response. 264 func (client *ExpressRouteGatewaysClient) getHandleResponse(resp *http.Response) (ExpressRouteGatewaysClientGetResponse, error) { 265 result := ExpressRouteGatewaysClientGetResponse{} 266 if err := runtime.UnmarshalAsJSON(resp, &result.ExpressRouteGateway); err != nil { 267 return ExpressRouteGatewaysClientGetResponse{}, err 268 } 269 return result, nil 270 } 271 272 // ListByResourceGroup - Lists ExpressRoute gateways in a given resource group. 273 // If the operation fails it returns an *azcore.ResponseError type. 274 // 275 // Generated from API version 2024-05-01 276 // - resourceGroupName - The name of the resource group. 277 // - options - ExpressRouteGatewaysClientListByResourceGroupOptions contains the optional parameters for the ExpressRouteGatewaysClient.ListByResourceGroup 278 // method. 279 func (client *ExpressRouteGatewaysClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, options *ExpressRouteGatewaysClientListByResourceGroupOptions) (ExpressRouteGatewaysClientListByResourceGroupResponse, error) { 280 var err error 281 const operationName = "ExpressRouteGatewaysClient.ListByResourceGroup" 282 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 283 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 284 defer func() { endSpan(err) }() 285 req, err := client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) 286 if err != nil { 287 return ExpressRouteGatewaysClientListByResourceGroupResponse{}, err 288 } 289 httpResp, err := client.internal.Pipeline().Do(req) 290 if err != nil { 291 return ExpressRouteGatewaysClientListByResourceGroupResponse{}, err 292 } 293 if !runtime.HasStatusCode(httpResp, http.StatusOK) { 294 err = runtime.NewResponseError(httpResp) 295 return ExpressRouteGatewaysClientListByResourceGroupResponse{}, err 296 } 297 resp, err := client.listByResourceGroupHandleResponse(httpResp) 298 return resp, err 299 } 300 301 // listByResourceGroupCreateRequest creates the ListByResourceGroup request. 302 func (client *ExpressRouteGatewaysClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ExpressRouteGatewaysClientListByResourceGroupOptions) (*policy.Request, error) { 303 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteGateways" 304 if resourceGroupName == "" { 305 return nil, errors.New("parameter resourceGroupName cannot be empty") 306 } 307 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 308 if client.subscriptionID == "" { 309 return nil, errors.New("parameter client.subscriptionID cannot be empty") 310 } 311 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 312 req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 313 if err != nil { 314 return nil, err 315 } 316 reqQP := req.Raw().URL.Query() 317 reqQP.Set("api-version", "2024-05-01") 318 req.Raw().URL.RawQuery = reqQP.Encode() 319 req.Raw().Header["Accept"] = []string{"application/json"} 320 return req, nil 321 } 322 323 // listByResourceGroupHandleResponse handles the ListByResourceGroup response. 324 func (client *ExpressRouteGatewaysClient) listByResourceGroupHandleResponse(resp *http.Response) (ExpressRouteGatewaysClientListByResourceGroupResponse, error) { 325 result := ExpressRouteGatewaysClientListByResourceGroupResponse{} 326 if err := runtime.UnmarshalAsJSON(resp, &result.ExpressRouteGatewayList); err != nil { 327 return ExpressRouteGatewaysClientListByResourceGroupResponse{}, err 328 } 329 return result, nil 330 } 331 332 // ListBySubscription - Lists ExpressRoute gateways under a given subscription. 333 // If the operation fails it returns an *azcore.ResponseError type. 334 // 335 // Generated from API version 2024-05-01 336 // - options - ExpressRouteGatewaysClientListBySubscriptionOptions contains the optional parameters for the ExpressRouteGatewaysClient.ListBySubscription 337 // method. 338 func (client *ExpressRouteGatewaysClient) ListBySubscription(ctx context.Context, options *ExpressRouteGatewaysClientListBySubscriptionOptions) (ExpressRouteGatewaysClientListBySubscriptionResponse, error) { 339 var err error 340 const operationName = "ExpressRouteGatewaysClient.ListBySubscription" 341 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 342 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 343 defer func() { endSpan(err) }() 344 req, err := client.listBySubscriptionCreateRequest(ctx, options) 345 if err != nil { 346 return ExpressRouteGatewaysClientListBySubscriptionResponse{}, err 347 } 348 httpResp, err := client.internal.Pipeline().Do(req) 349 if err != nil { 350 return ExpressRouteGatewaysClientListBySubscriptionResponse{}, err 351 } 352 if !runtime.HasStatusCode(httpResp, http.StatusOK) { 353 err = runtime.NewResponseError(httpResp) 354 return ExpressRouteGatewaysClientListBySubscriptionResponse{}, err 355 } 356 resp, err := client.listBySubscriptionHandleResponse(httpResp) 357 return resp, err 358 } 359 360 // listBySubscriptionCreateRequest creates the ListBySubscription request. 361 func (client *ExpressRouteGatewaysClient) listBySubscriptionCreateRequest(ctx context.Context, options *ExpressRouteGatewaysClientListBySubscriptionOptions) (*policy.Request, error) { 362 urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Network/expressRouteGateways" 363 if client.subscriptionID == "" { 364 return nil, errors.New("parameter client.subscriptionID cannot be empty") 365 } 366 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 367 req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 368 if err != nil { 369 return nil, err 370 } 371 reqQP := req.Raw().URL.Query() 372 reqQP.Set("api-version", "2024-05-01") 373 req.Raw().URL.RawQuery = reqQP.Encode() 374 req.Raw().Header["Accept"] = []string{"application/json"} 375 return req, nil 376 } 377 378 // listBySubscriptionHandleResponse handles the ListBySubscription response. 379 func (client *ExpressRouteGatewaysClient) listBySubscriptionHandleResponse(resp *http.Response) (ExpressRouteGatewaysClientListBySubscriptionResponse, error) { 380 result := ExpressRouteGatewaysClientListBySubscriptionResponse{} 381 if err := runtime.UnmarshalAsJSON(resp, &result.ExpressRouteGatewayList); err != nil { 382 return ExpressRouteGatewaysClientListBySubscriptionResponse{}, err 383 } 384 return result, nil 385 } 386 387 // BeginUpdateTags - Updates express route gateway tags. 388 // If the operation fails it returns an *azcore.ResponseError type. 389 // 390 // Generated from API version 2024-05-01 391 // - resourceGroupName - The resource group name of the ExpressRouteGateway. 392 // - expressRouteGatewayName - The name of the gateway. 393 // - expressRouteGatewayParameters - Parameters supplied to update a virtual wan express route gateway tags. 394 // - options - ExpressRouteGatewaysClientBeginUpdateTagsOptions contains the optional parameters for the ExpressRouteGatewaysClient.BeginUpdateTags 395 // method. 396 func (client *ExpressRouteGatewaysClient) BeginUpdateTags(ctx context.Context, resourceGroupName string, expressRouteGatewayName string, expressRouteGatewayParameters TagsObject, options *ExpressRouteGatewaysClientBeginUpdateTagsOptions) (*runtime.Poller[ExpressRouteGatewaysClientUpdateTagsResponse], error) { 397 if options == nil || options.ResumeToken == "" { 398 resp, err := client.updateTags(ctx, resourceGroupName, expressRouteGatewayName, expressRouteGatewayParameters, options) 399 if err != nil { 400 return nil, err 401 } 402 poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ExpressRouteGatewaysClientUpdateTagsResponse]{ 403 FinalStateVia: runtime.FinalStateViaAzureAsyncOp, 404 Tracer: client.internal.Tracer(), 405 }) 406 return poller, err 407 } else { 408 return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ExpressRouteGatewaysClientUpdateTagsResponse]{ 409 Tracer: client.internal.Tracer(), 410 }) 411 } 412 } 413 414 // UpdateTags - Updates express route gateway tags. 415 // If the operation fails it returns an *azcore.ResponseError type. 416 // 417 // Generated from API version 2024-05-01 418 func (client *ExpressRouteGatewaysClient) updateTags(ctx context.Context, resourceGroupName string, expressRouteGatewayName string, expressRouteGatewayParameters TagsObject, options *ExpressRouteGatewaysClientBeginUpdateTagsOptions) (*http.Response, error) { 419 var err error 420 const operationName = "ExpressRouteGatewaysClient.BeginUpdateTags" 421 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 422 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 423 defer func() { endSpan(err) }() 424 req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, expressRouteGatewayName, expressRouteGatewayParameters, options) 425 if err != nil { 426 return nil, err 427 } 428 httpResp, err := client.internal.Pipeline().Do(req) 429 if err != nil { 430 return nil, err 431 } 432 if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { 433 err = runtime.NewResponseError(httpResp) 434 return nil, err 435 } 436 return httpResp, nil 437 } 438 439 // updateTagsCreateRequest creates the UpdateTags request. 440 func (client *ExpressRouteGatewaysClient) updateTagsCreateRequest(ctx context.Context, resourceGroupName string, expressRouteGatewayName string, expressRouteGatewayParameters TagsObject, options *ExpressRouteGatewaysClientBeginUpdateTagsOptions) (*policy.Request, error) { 441 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteGateways/{expressRouteGatewayName}" 442 if client.subscriptionID == "" { 443 return nil, errors.New("parameter client.subscriptionID cannot be empty") 444 } 445 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 446 if resourceGroupName == "" { 447 return nil, errors.New("parameter resourceGroupName cannot be empty") 448 } 449 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 450 if expressRouteGatewayName == "" { 451 return nil, errors.New("parameter expressRouteGatewayName cannot be empty") 452 } 453 urlPath = strings.ReplaceAll(urlPath, "{expressRouteGatewayName}", url.PathEscape(expressRouteGatewayName)) 454 req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 455 if err != nil { 456 return nil, err 457 } 458 reqQP := req.Raw().URL.Query() 459 reqQP.Set("api-version", "2024-05-01") 460 req.Raw().URL.RawQuery = reqQP.Encode() 461 req.Raw().Header["Accept"] = []string{"application/json"} 462 if err := runtime.MarshalAsJSON(req, expressRouteGatewayParameters); err != nil { 463 return nil, err 464 } 465 return req, nil 466 }