github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6@v6.2.0/publicipaddresses_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 // PublicIPAddressesClient contains the methods for the PublicIPAddresses group. 24 // Don't use this type directly, use NewPublicIPAddressesClient() instead. 25 type PublicIPAddressesClient struct { 26 internal *arm.Client 27 subscriptionID string 28 } 29 30 // NewPublicIPAddressesClient creates a new instance of PublicIPAddressesClient 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 NewPublicIPAddressesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PublicIPAddressesClient, error) { 36 cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) 37 if err != nil { 38 return nil, err 39 } 40 client := &PublicIPAddressesClient{ 41 subscriptionID: subscriptionID, 42 internal: cl, 43 } 44 return client, nil 45 } 46 47 // BeginCreateOrUpdate - Creates or updates a static or dynamic public IP address. 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 // - publicIPAddressName - The name of the public IP address. 53 // - parameters - Parameters supplied to the create or update public IP address operation. 54 // - options - PublicIPAddressesClientBeginCreateOrUpdateOptions contains the optional parameters for the PublicIPAddressesClient.BeginCreateOrUpdate 55 // method. 56 func (client *PublicIPAddressesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, publicIPAddressName string, parameters PublicIPAddress, options *PublicIPAddressesClientBeginCreateOrUpdateOptions) (*runtime.Poller[PublicIPAddressesClientCreateOrUpdateResponse], error) { 57 if options == nil || options.ResumeToken == "" { 58 resp, err := client.createOrUpdate(ctx, resourceGroupName, publicIPAddressName, parameters, options) 59 if err != nil { 60 return nil, err 61 } 62 poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PublicIPAddressesClientCreateOrUpdateResponse]{ 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[PublicIPAddressesClientCreateOrUpdateResponse]{ 69 Tracer: client.internal.Tracer(), 70 }) 71 } 72 } 73 74 // CreateOrUpdate - Creates or updates a static or dynamic public IP address. 75 // If the operation fails it returns an *azcore.ResponseError type. 76 // 77 // Generated from API version 2024-05-01 78 func (client *PublicIPAddressesClient) createOrUpdate(ctx context.Context, resourceGroupName string, publicIPAddressName string, parameters PublicIPAddress, options *PublicIPAddressesClientBeginCreateOrUpdateOptions) (*http.Response, error) { 79 var err error 80 const operationName = "PublicIPAddressesClient.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, publicIPAddressName, 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 *PublicIPAddressesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, publicIPAddressName string, parameters PublicIPAddress, options *PublicIPAddressesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { 101 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName}" 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 publicIPAddressName == "" { 107 return nil, errors.New("parameter publicIPAddressName cannot be empty") 108 } 109 urlPath = strings.ReplaceAll(urlPath, "{publicIpAddressName}", url.PathEscape(publicIPAddressName)) 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 // BeginDdosProtectionStatus - Gets the Ddos Protection Status of a Public IP Address 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 // - publicIPAddressName - The name of the public IP address. 134 // - options - PublicIPAddressesClientBeginDdosProtectionStatusOptions contains the optional parameters for the PublicIPAddressesClient.BeginDdosProtectionStatus 135 // method. 136 func (client *PublicIPAddressesClient) BeginDdosProtectionStatus(ctx context.Context, resourceGroupName string, publicIPAddressName string, options *PublicIPAddressesClientBeginDdosProtectionStatusOptions) (*runtime.Poller[PublicIPAddressesClientDdosProtectionStatusResponse], error) { 137 if options == nil || options.ResumeToken == "" { 138 resp, err := client.ddosProtectionStatus(ctx, resourceGroupName, publicIPAddressName, options) 139 if err != nil { 140 return nil, err 141 } 142 poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PublicIPAddressesClientDdosProtectionStatusResponse]{ 143 FinalStateVia: runtime.FinalStateViaLocation, 144 Tracer: client.internal.Tracer(), 145 }) 146 return poller, err 147 } else { 148 return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PublicIPAddressesClientDdosProtectionStatusResponse]{ 149 Tracer: client.internal.Tracer(), 150 }) 151 } 152 } 153 154 // DdosProtectionStatus - Gets the Ddos Protection Status of a Public IP Address 155 // If the operation fails it returns an *azcore.ResponseError type. 156 // 157 // Generated from API version 2024-05-01 158 func (client *PublicIPAddressesClient) ddosProtectionStatus(ctx context.Context, resourceGroupName string, publicIPAddressName string, options *PublicIPAddressesClientBeginDdosProtectionStatusOptions) (*http.Response, error) { 159 var err error 160 const operationName = "PublicIPAddressesClient.BeginDdosProtectionStatus" 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.ddosProtectionStatusCreateRequest(ctx, resourceGroupName, publicIPAddressName, 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) { 173 err = runtime.NewResponseError(httpResp) 174 return nil, err 175 } 176 return httpResp, nil 177 } 178 179 // ddosProtectionStatusCreateRequest creates the DdosProtectionStatus request. 180 func (client *PublicIPAddressesClient) ddosProtectionStatusCreateRequest(ctx context.Context, resourceGroupName string, publicIPAddressName string, options *PublicIPAddressesClientBeginDdosProtectionStatusOptions) (*policy.Request, error) { 181 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName}/ddosProtectionStatus" 182 if resourceGroupName == "" { 183 return nil, errors.New("parameter resourceGroupName cannot be empty") 184 } 185 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 186 if publicIPAddressName == "" { 187 return nil, errors.New("parameter publicIPAddressName cannot be empty") 188 } 189 urlPath = strings.ReplaceAll(urlPath, "{publicIpAddressName}", url.PathEscape(publicIPAddressName)) 190 if client.subscriptionID == "" { 191 return nil, errors.New("parameter client.subscriptionID cannot be empty") 192 } 193 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 194 req, err := runtime.NewRequest(ctx, http.MethodPost, 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 // BeginDelete - Deletes the specified public IP address. 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 // - publicIPAddressName - The name of the public IP address. 211 // - options - PublicIPAddressesClientBeginDeleteOptions contains the optional parameters for the PublicIPAddressesClient.BeginDelete 212 // method. 213 func (client *PublicIPAddressesClient) BeginDelete(ctx context.Context, resourceGroupName string, publicIPAddressName string, options *PublicIPAddressesClientBeginDeleteOptions) (*runtime.Poller[PublicIPAddressesClientDeleteResponse], error) { 214 if options == nil || options.ResumeToken == "" { 215 resp, err := client.deleteOperation(ctx, resourceGroupName, publicIPAddressName, options) 216 if err != nil { 217 return nil, err 218 } 219 poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PublicIPAddressesClientDeleteResponse]{ 220 FinalStateVia: runtime.FinalStateViaLocation, 221 Tracer: client.internal.Tracer(), 222 }) 223 return poller, err 224 } else { 225 return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PublicIPAddressesClientDeleteResponse]{ 226 Tracer: client.internal.Tracer(), 227 }) 228 } 229 } 230 231 // Delete - Deletes the specified public IP address. 232 // If the operation fails it returns an *azcore.ResponseError type. 233 // 234 // Generated from API version 2024-05-01 235 func (client *PublicIPAddressesClient) deleteOperation(ctx context.Context, resourceGroupName string, publicIPAddressName string, options *PublicIPAddressesClientBeginDeleteOptions) (*http.Response, error) { 236 var err error 237 const operationName = "PublicIPAddressesClient.BeginDelete" 238 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 239 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 240 defer func() { endSpan(err) }() 241 req, err := client.deleteCreateRequest(ctx, resourceGroupName, publicIPAddressName, options) 242 if err != nil { 243 return nil, err 244 } 245 httpResp, err := client.internal.Pipeline().Do(req) 246 if err != nil { 247 return nil, err 248 } 249 if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { 250 err = runtime.NewResponseError(httpResp) 251 return nil, err 252 } 253 return httpResp, nil 254 } 255 256 // deleteCreateRequest creates the Delete request. 257 func (client *PublicIPAddressesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, publicIPAddressName string, options *PublicIPAddressesClientBeginDeleteOptions) (*policy.Request, error) { 258 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName}" 259 if resourceGroupName == "" { 260 return nil, errors.New("parameter resourceGroupName cannot be empty") 261 } 262 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 263 if publicIPAddressName == "" { 264 return nil, errors.New("parameter publicIPAddressName cannot be empty") 265 } 266 urlPath = strings.ReplaceAll(urlPath, "{publicIpAddressName}", url.PathEscape(publicIPAddressName)) 267 if client.subscriptionID == "" { 268 return nil, errors.New("parameter client.subscriptionID cannot be empty") 269 } 270 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 271 req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 272 if err != nil { 273 return nil, err 274 } 275 reqQP := req.Raw().URL.Query() 276 reqQP.Set("api-version", "2024-05-01") 277 req.Raw().URL.RawQuery = reqQP.Encode() 278 req.Raw().Header["Accept"] = []string{"application/json"} 279 return req, nil 280 } 281 282 // Get - Gets the specified public IP address in a specified resource group. 283 // If the operation fails it returns an *azcore.ResponseError type. 284 // 285 // Generated from API version 2024-05-01 286 // - resourceGroupName - The name of the resource group. 287 // - publicIPAddressName - The name of the public IP address. 288 // - options - PublicIPAddressesClientGetOptions contains the optional parameters for the PublicIPAddressesClient.Get method. 289 func (client *PublicIPAddressesClient) Get(ctx context.Context, resourceGroupName string, publicIPAddressName string, options *PublicIPAddressesClientGetOptions) (PublicIPAddressesClientGetResponse, error) { 290 var err error 291 const operationName = "PublicIPAddressesClient.Get" 292 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 293 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 294 defer func() { endSpan(err) }() 295 req, err := client.getCreateRequest(ctx, resourceGroupName, publicIPAddressName, options) 296 if err != nil { 297 return PublicIPAddressesClientGetResponse{}, err 298 } 299 httpResp, err := client.internal.Pipeline().Do(req) 300 if err != nil { 301 return PublicIPAddressesClientGetResponse{}, err 302 } 303 if !runtime.HasStatusCode(httpResp, http.StatusOK) { 304 err = runtime.NewResponseError(httpResp) 305 return PublicIPAddressesClientGetResponse{}, err 306 } 307 resp, err := client.getHandleResponse(httpResp) 308 return resp, err 309 } 310 311 // getCreateRequest creates the Get request. 312 func (client *PublicIPAddressesClient) getCreateRequest(ctx context.Context, resourceGroupName string, publicIPAddressName string, options *PublicIPAddressesClientGetOptions) (*policy.Request, error) { 313 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName}" 314 if resourceGroupName == "" { 315 return nil, errors.New("parameter resourceGroupName cannot be empty") 316 } 317 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 318 if publicIPAddressName == "" { 319 return nil, errors.New("parameter publicIPAddressName cannot be empty") 320 } 321 urlPath = strings.ReplaceAll(urlPath, "{publicIpAddressName}", url.PathEscape(publicIPAddressName)) 322 if client.subscriptionID == "" { 323 return nil, errors.New("parameter client.subscriptionID cannot be empty") 324 } 325 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 326 req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 327 if err != nil { 328 return nil, err 329 } 330 reqQP := req.Raw().URL.Query() 331 if options != nil && options.Expand != nil { 332 reqQP.Set("$expand", *options.Expand) 333 } 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 // getHandleResponse handles the Get response. 341 func (client *PublicIPAddressesClient) getHandleResponse(resp *http.Response) (PublicIPAddressesClientGetResponse, error) { 342 result := PublicIPAddressesClientGetResponse{} 343 if err := runtime.UnmarshalAsJSON(resp, &result.PublicIPAddress); err != nil { 344 return PublicIPAddressesClientGetResponse{}, err 345 } 346 return result, nil 347 } 348 349 // GetCloudServicePublicIPAddress - Get the specified public IP address in a cloud service. 350 // If the operation fails it returns an *azcore.ResponseError type. 351 // 352 // Generated from API version 2024-05-01 353 // - resourceGroupName - The name of the resource group. 354 // - cloudServiceName - The name of the cloud service. 355 // - roleInstanceName - The role instance name. 356 // - networkInterfaceName - The name of the network interface. 357 // - ipConfigurationName - The name of the IP configuration. 358 // - publicIPAddressName - The name of the public IP Address. 359 // - options - PublicIPAddressesClientGetCloudServicePublicIPAddressOptions contains the optional parameters for the PublicIPAddressesClient.GetCloudServicePublicIPAddress 360 // method. 361 func (client *PublicIPAddressesClient) GetCloudServicePublicIPAddress(ctx context.Context, resourceGroupName string, cloudServiceName string, roleInstanceName string, networkInterfaceName string, ipConfigurationName string, publicIPAddressName string, options *PublicIPAddressesClientGetCloudServicePublicIPAddressOptions) (PublicIPAddressesClientGetCloudServicePublicIPAddressResponse, error) { 362 var err error 363 const operationName = "PublicIPAddressesClient.GetCloudServicePublicIPAddress" 364 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 365 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 366 defer func() { endSpan(err) }() 367 req, err := client.getCloudServicePublicIPAddressCreateRequest(ctx, resourceGroupName, cloudServiceName, roleInstanceName, networkInterfaceName, ipConfigurationName, publicIPAddressName, options) 368 if err != nil { 369 return PublicIPAddressesClientGetCloudServicePublicIPAddressResponse{}, err 370 } 371 httpResp, err := client.internal.Pipeline().Do(req) 372 if err != nil { 373 return PublicIPAddressesClientGetCloudServicePublicIPAddressResponse{}, err 374 } 375 if !runtime.HasStatusCode(httpResp, http.StatusOK) { 376 err = runtime.NewResponseError(httpResp) 377 return PublicIPAddressesClientGetCloudServicePublicIPAddressResponse{}, err 378 } 379 resp, err := client.getCloudServicePublicIPAddressHandleResponse(httpResp) 380 return resp, err 381 } 382 383 // getCloudServicePublicIPAddressCreateRequest creates the GetCloudServicePublicIPAddress request. 384 func (client *PublicIPAddressesClient) getCloudServicePublicIPAddressCreateRequest(ctx context.Context, resourceGroupName string, cloudServiceName string, roleInstanceName string, networkInterfaceName string, ipConfigurationName string, publicIPAddressName string, options *PublicIPAddressesClientGetCloudServicePublicIPAddressOptions) (*policy.Request, error) { 385 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/networkInterfaces/{networkInterfaceName}/ipconfigurations/{ipConfigurationName}/publicipaddresses/{publicIpAddressName}" 386 if resourceGroupName == "" { 387 return nil, errors.New("parameter resourceGroupName cannot be empty") 388 } 389 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 390 if cloudServiceName == "" { 391 return nil, errors.New("parameter cloudServiceName cannot be empty") 392 } 393 urlPath = strings.ReplaceAll(urlPath, "{cloudServiceName}", url.PathEscape(cloudServiceName)) 394 if roleInstanceName == "" { 395 return nil, errors.New("parameter roleInstanceName cannot be empty") 396 } 397 urlPath = strings.ReplaceAll(urlPath, "{roleInstanceName}", url.PathEscape(roleInstanceName)) 398 if networkInterfaceName == "" { 399 return nil, errors.New("parameter networkInterfaceName cannot be empty") 400 } 401 urlPath = strings.ReplaceAll(urlPath, "{networkInterfaceName}", url.PathEscape(networkInterfaceName)) 402 if ipConfigurationName == "" { 403 return nil, errors.New("parameter ipConfigurationName cannot be empty") 404 } 405 urlPath = strings.ReplaceAll(urlPath, "{ipConfigurationName}", url.PathEscape(ipConfigurationName)) 406 if publicIPAddressName == "" { 407 return nil, errors.New("parameter publicIPAddressName cannot be empty") 408 } 409 urlPath = strings.ReplaceAll(urlPath, "{publicIpAddressName}", url.PathEscape(publicIPAddressName)) 410 if client.subscriptionID == "" { 411 return nil, errors.New("parameter client.subscriptionID cannot be empty") 412 } 413 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 414 req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 415 if err != nil { 416 return nil, err 417 } 418 reqQP := req.Raw().URL.Query() 419 if options != nil && options.Expand != nil { 420 reqQP.Set("$expand", *options.Expand) 421 } 422 reqQP.Set("api-version", "2024-05-01") 423 req.Raw().URL.RawQuery = reqQP.Encode() 424 req.Raw().Header["Accept"] = []string{"application/json"} 425 return req, nil 426 } 427 428 // getCloudServicePublicIPAddressHandleResponse handles the GetCloudServicePublicIPAddress response. 429 func (client *PublicIPAddressesClient) getCloudServicePublicIPAddressHandleResponse(resp *http.Response) (PublicIPAddressesClientGetCloudServicePublicIPAddressResponse, error) { 430 result := PublicIPAddressesClientGetCloudServicePublicIPAddressResponse{} 431 if err := runtime.UnmarshalAsJSON(resp, &result.PublicIPAddress); err != nil { 432 return PublicIPAddressesClientGetCloudServicePublicIPAddressResponse{}, err 433 } 434 return result, nil 435 } 436 437 // GetVirtualMachineScaleSetPublicIPAddress - Get the specified public IP address in a virtual machine scale set. 438 // If the operation fails it returns an *azcore.ResponseError type. 439 // 440 // Generated from API version 2018-10-01 441 // - resourceGroupName - The name of the resource group. 442 // - virtualMachineScaleSetName - The name of the virtual machine scale set. 443 // - virtualmachineIndex - The virtual machine index. 444 // - networkInterfaceName - The name of the network interface. 445 // - ipConfigurationName - The name of the IP configuration. 446 // - publicIPAddressName - The name of the public IP Address. 447 // - options - PublicIPAddressesClientGetVirtualMachineScaleSetPublicIPAddressOptions contains the optional parameters for the 448 // PublicIPAddressesClient.GetVirtualMachineScaleSetPublicIPAddress method. 449 func (client *PublicIPAddressesClient) GetVirtualMachineScaleSetPublicIPAddress(ctx context.Context, resourceGroupName string, virtualMachineScaleSetName string, virtualmachineIndex string, networkInterfaceName string, ipConfigurationName string, publicIPAddressName string, options *PublicIPAddressesClientGetVirtualMachineScaleSetPublicIPAddressOptions) (PublicIPAddressesClientGetVirtualMachineScaleSetPublicIPAddressResponse, error) { 450 var err error 451 const operationName = "PublicIPAddressesClient.GetVirtualMachineScaleSetPublicIPAddress" 452 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 453 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 454 defer func() { endSpan(err) }() 455 req, err := client.getVirtualMachineScaleSetPublicIPAddressCreateRequest(ctx, resourceGroupName, virtualMachineScaleSetName, virtualmachineIndex, networkInterfaceName, ipConfigurationName, publicIPAddressName, options) 456 if err != nil { 457 return PublicIPAddressesClientGetVirtualMachineScaleSetPublicIPAddressResponse{}, err 458 } 459 httpResp, err := client.internal.Pipeline().Do(req) 460 if err != nil { 461 return PublicIPAddressesClientGetVirtualMachineScaleSetPublicIPAddressResponse{}, err 462 } 463 if !runtime.HasStatusCode(httpResp, http.StatusOK) { 464 err = runtime.NewResponseError(httpResp) 465 return PublicIPAddressesClientGetVirtualMachineScaleSetPublicIPAddressResponse{}, err 466 } 467 resp, err := client.getVirtualMachineScaleSetPublicIPAddressHandleResponse(httpResp) 468 return resp, err 469 } 470 471 // getVirtualMachineScaleSetPublicIPAddressCreateRequest creates the GetVirtualMachineScaleSetPublicIPAddress request. 472 func (client *PublicIPAddressesClient) getVirtualMachineScaleSetPublicIPAddressCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineScaleSetName string, virtualmachineIndex string, networkInterfaceName string, ipConfigurationName string, publicIPAddressName string, options *PublicIPAddressesClientGetVirtualMachineScaleSetPublicIPAddressOptions) (*policy.Request, error) { 473 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines/{virtualmachineIndex}/networkInterfaces/{networkInterfaceName}/ipconfigurations/{ipConfigurationName}/publicipaddresses/{publicIpAddressName}" 474 if resourceGroupName == "" { 475 return nil, errors.New("parameter resourceGroupName cannot be empty") 476 } 477 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 478 if virtualMachineScaleSetName == "" { 479 return nil, errors.New("parameter virtualMachineScaleSetName cannot be empty") 480 } 481 urlPath = strings.ReplaceAll(urlPath, "{virtualMachineScaleSetName}", url.PathEscape(virtualMachineScaleSetName)) 482 if virtualmachineIndex == "" { 483 return nil, errors.New("parameter virtualmachineIndex cannot be empty") 484 } 485 urlPath = strings.ReplaceAll(urlPath, "{virtualmachineIndex}", url.PathEscape(virtualmachineIndex)) 486 if networkInterfaceName == "" { 487 return nil, errors.New("parameter networkInterfaceName cannot be empty") 488 } 489 urlPath = strings.ReplaceAll(urlPath, "{networkInterfaceName}", url.PathEscape(networkInterfaceName)) 490 if ipConfigurationName == "" { 491 return nil, errors.New("parameter ipConfigurationName cannot be empty") 492 } 493 urlPath = strings.ReplaceAll(urlPath, "{ipConfigurationName}", url.PathEscape(ipConfigurationName)) 494 if publicIPAddressName == "" { 495 return nil, errors.New("parameter publicIPAddressName cannot be empty") 496 } 497 urlPath = strings.ReplaceAll(urlPath, "{publicIpAddressName}", url.PathEscape(publicIPAddressName)) 498 if client.subscriptionID == "" { 499 return nil, errors.New("parameter client.subscriptionID cannot be empty") 500 } 501 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 502 req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 503 if err != nil { 504 return nil, err 505 } 506 reqQP := req.Raw().URL.Query() 507 if options != nil && options.Expand != nil { 508 reqQP.Set("$expand", *options.Expand) 509 } 510 reqQP.Set("api-version", "2018-10-01") 511 req.Raw().URL.RawQuery = reqQP.Encode() 512 req.Raw().Header["Accept"] = []string{"application/json"} 513 return req, nil 514 } 515 516 // getVirtualMachineScaleSetPublicIPAddressHandleResponse handles the GetVirtualMachineScaleSetPublicIPAddress response. 517 func (client *PublicIPAddressesClient) getVirtualMachineScaleSetPublicIPAddressHandleResponse(resp *http.Response) (PublicIPAddressesClientGetVirtualMachineScaleSetPublicIPAddressResponse, error) { 518 result := PublicIPAddressesClientGetVirtualMachineScaleSetPublicIPAddressResponse{} 519 if err := runtime.UnmarshalAsJSON(resp, &result.PublicIPAddress); err != nil { 520 return PublicIPAddressesClientGetVirtualMachineScaleSetPublicIPAddressResponse{}, err 521 } 522 return result, nil 523 } 524 525 // NewListPager - Gets all public IP addresses in a resource group. 526 // 527 // Generated from API version 2024-05-01 528 // - resourceGroupName - The name of the resource group. 529 // - options - PublicIPAddressesClientListOptions contains the optional parameters for the PublicIPAddressesClient.NewListPager 530 // method. 531 func (client *PublicIPAddressesClient) NewListPager(resourceGroupName string, options *PublicIPAddressesClientListOptions) *runtime.Pager[PublicIPAddressesClientListResponse] { 532 return runtime.NewPager(runtime.PagingHandler[PublicIPAddressesClientListResponse]{ 533 More: func(page PublicIPAddressesClientListResponse) bool { 534 return page.NextLink != nil && len(*page.NextLink) > 0 535 }, 536 Fetcher: func(ctx context.Context, page *PublicIPAddressesClientListResponse) (PublicIPAddressesClientListResponse, error) { 537 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PublicIPAddressesClient.NewListPager") 538 nextLink := "" 539 if page != nil { 540 nextLink = *page.NextLink 541 } 542 resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { 543 return client.listCreateRequest(ctx, resourceGroupName, options) 544 }, nil) 545 if err != nil { 546 return PublicIPAddressesClientListResponse{}, err 547 } 548 return client.listHandleResponse(resp) 549 }, 550 Tracer: client.internal.Tracer(), 551 }) 552 } 553 554 // listCreateRequest creates the List request. 555 func (client *PublicIPAddressesClient) listCreateRequest(ctx context.Context, resourceGroupName string, options *PublicIPAddressesClientListOptions) (*policy.Request, error) { 556 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses" 557 if resourceGroupName == "" { 558 return nil, errors.New("parameter resourceGroupName cannot be empty") 559 } 560 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 561 if client.subscriptionID == "" { 562 return nil, errors.New("parameter client.subscriptionID cannot be empty") 563 } 564 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 565 req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 566 if err != nil { 567 return nil, err 568 } 569 reqQP := req.Raw().URL.Query() 570 reqQP.Set("api-version", "2024-05-01") 571 req.Raw().URL.RawQuery = reqQP.Encode() 572 req.Raw().Header["Accept"] = []string{"application/json"} 573 return req, nil 574 } 575 576 // listHandleResponse handles the List response. 577 func (client *PublicIPAddressesClient) listHandleResponse(resp *http.Response) (PublicIPAddressesClientListResponse, error) { 578 result := PublicIPAddressesClientListResponse{} 579 if err := runtime.UnmarshalAsJSON(resp, &result.PublicIPAddressListResult); err != nil { 580 return PublicIPAddressesClientListResponse{}, err 581 } 582 return result, nil 583 } 584 585 // NewListAllPager - Gets all the public IP addresses in a subscription. 586 // 587 // Generated from API version 2024-05-01 588 // - options - PublicIPAddressesClientListAllOptions contains the optional parameters for the PublicIPAddressesClient.NewListAllPager 589 // method. 590 func (client *PublicIPAddressesClient) NewListAllPager(options *PublicIPAddressesClientListAllOptions) *runtime.Pager[PublicIPAddressesClientListAllResponse] { 591 return runtime.NewPager(runtime.PagingHandler[PublicIPAddressesClientListAllResponse]{ 592 More: func(page PublicIPAddressesClientListAllResponse) bool { 593 return page.NextLink != nil && len(*page.NextLink) > 0 594 }, 595 Fetcher: func(ctx context.Context, page *PublicIPAddressesClientListAllResponse) (PublicIPAddressesClientListAllResponse, error) { 596 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PublicIPAddressesClient.NewListAllPager") 597 nextLink := "" 598 if page != nil { 599 nextLink = *page.NextLink 600 } 601 resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { 602 return client.listAllCreateRequest(ctx, options) 603 }, nil) 604 if err != nil { 605 return PublicIPAddressesClientListAllResponse{}, err 606 } 607 return client.listAllHandleResponse(resp) 608 }, 609 Tracer: client.internal.Tracer(), 610 }) 611 } 612 613 // listAllCreateRequest creates the ListAll request. 614 func (client *PublicIPAddressesClient) listAllCreateRequest(ctx context.Context, options *PublicIPAddressesClientListAllOptions) (*policy.Request, error) { 615 urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Network/publicIPAddresses" 616 if client.subscriptionID == "" { 617 return nil, errors.New("parameter client.subscriptionID cannot be empty") 618 } 619 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 620 req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 621 if err != nil { 622 return nil, err 623 } 624 reqQP := req.Raw().URL.Query() 625 reqQP.Set("api-version", "2024-05-01") 626 req.Raw().URL.RawQuery = reqQP.Encode() 627 req.Raw().Header["Accept"] = []string{"application/json"} 628 return req, nil 629 } 630 631 // listAllHandleResponse handles the ListAll response. 632 func (client *PublicIPAddressesClient) listAllHandleResponse(resp *http.Response) (PublicIPAddressesClientListAllResponse, error) { 633 result := PublicIPAddressesClientListAllResponse{} 634 if err := runtime.UnmarshalAsJSON(resp, &result.PublicIPAddressListResult); err != nil { 635 return PublicIPAddressesClientListAllResponse{}, err 636 } 637 return result, nil 638 } 639 640 // NewListCloudServicePublicIPAddressesPager - Gets information about all public IP addresses on a cloud service level. 641 // 642 // Generated from API version 2024-05-01 643 // - resourceGroupName - The name of the resource group. 644 // - cloudServiceName - The name of the cloud service. 645 // - options - PublicIPAddressesClientListCloudServicePublicIPAddressesOptions contains the optional parameters for the PublicIPAddressesClient.NewListCloudServicePublicIPAddressesPager 646 // method. 647 func (client *PublicIPAddressesClient) NewListCloudServicePublicIPAddressesPager(resourceGroupName string, cloudServiceName string, options *PublicIPAddressesClientListCloudServicePublicIPAddressesOptions) *runtime.Pager[PublicIPAddressesClientListCloudServicePublicIPAddressesResponse] { 648 return runtime.NewPager(runtime.PagingHandler[PublicIPAddressesClientListCloudServicePublicIPAddressesResponse]{ 649 More: func(page PublicIPAddressesClientListCloudServicePublicIPAddressesResponse) bool { 650 return page.NextLink != nil && len(*page.NextLink) > 0 651 }, 652 Fetcher: func(ctx context.Context, page *PublicIPAddressesClientListCloudServicePublicIPAddressesResponse) (PublicIPAddressesClientListCloudServicePublicIPAddressesResponse, error) { 653 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PublicIPAddressesClient.NewListCloudServicePublicIPAddressesPager") 654 nextLink := "" 655 if page != nil { 656 nextLink = *page.NextLink 657 } 658 resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { 659 return client.listCloudServicePublicIPAddressesCreateRequest(ctx, resourceGroupName, cloudServiceName, options) 660 }, nil) 661 if err != nil { 662 return PublicIPAddressesClientListCloudServicePublicIPAddressesResponse{}, err 663 } 664 return client.listCloudServicePublicIPAddressesHandleResponse(resp) 665 }, 666 Tracer: client.internal.Tracer(), 667 }) 668 } 669 670 // listCloudServicePublicIPAddressesCreateRequest creates the ListCloudServicePublicIPAddresses request. 671 func (client *PublicIPAddressesClient) listCloudServicePublicIPAddressesCreateRequest(ctx context.Context, resourceGroupName string, cloudServiceName string, options *PublicIPAddressesClientListCloudServicePublicIPAddressesOptions) (*policy.Request, error) { 672 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/publicipaddresses" 673 if resourceGroupName == "" { 674 return nil, errors.New("parameter resourceGroupName cannot be empty") 675 } 676 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 677 if cloudServiceName == "" { 678 return nil, errors.New("parameter cloudServiceName cannot be empty") 679 } 680 urlPath = strings.ReplaceAll(urlPath, "{cloudServiceName}", url.PathEscape(cloudServiceName)) 681 if client.subscriptionID == "" { 682 return nil, errors.New("parameter client.subscriptionID cannot be empty") 683 } 684 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 685 req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 686 if err != nil { 687 return nil, err 688 } 689 reqQP := req.Raw().URL.Query() 690 reqQP.Set("api-version", "2024-05-01") 691 req.Raw().URL.RawQuery = reqQP.Encode() 692 req.Raw().Header["Accept"] = []string{"application/json"} 693 return req, nil 694 } 695 696 // listCloudServicePublicIPAddressesHandleResponse handles the ListCloudServicePublicIPAddresses response. 697 func (client *PublicIPAddressesClient) listCloudServicePublicIPAddressesHandleResponse(resp *http.Response) (PublicIPAddressesClientListCloudServicePublicIPAddressesResponse, error) { 698 result := PublicIPAddressesClientListCloudServicePublicIPAddressesResponse{} 699 if err := runtime.UnmarshalAsJSON(resp, &result.PublicIPAddressListResult); err != nil { 700 return PublicIPAddressesClientListCloudServicePublicIPAddressesResponse{}, err 701 } 702 return result, nil 703 } 704 705 // NewListCloudServiceRoleInstancePublicIPAddressesPager - Gets information about all public IP addresses in a role instance 706 // IP configuration in a cloud service. 707 // 708 // Generated from API version 2024-05-01 709 // - resourceGroupName - The name of the resource group. 710 // - cloudServiceName - The name of the cloud service. 711 // - roleInstanceName - The name of role instance. 712 // - networkInterfaceName - The network interface name. 713 // - ipConfigurationName - The IP configuration name. 714 // - options - PublicIPAddressesClientListCloudServiceRoleInstancePublicIPAddressesOptions contains the optional parameters 715 // for the PublicIPAddressesClient.NewListCloudServiceRoleInstancePublicIPAddressesPager method. 716 func (client *PublicIPAddressesClient) NewListCloudServiceRoleInstancePublicIPAddressesPager(resourceGroupName string, cloudServiceName string, roleInstanceName string, networkInterfaceName string, ipConfigurationName string, options *PublicIPAddressesClientListCloudServiceRoleInstancePublicIPAddressesOptions) *runtime.Pager[PublicIPAddressesClientListCloudServiceRoleInstancePublicIPAddressesResponse] { 717 return runtime.NewPager(runtime.PagingHandler[PublicIPAddressesClientListCloudServiceRoleInstancePublicIPAddressesResponse]{ 718 More: func(page PublicIPAddressesClientListCloudServiceRoleInstancePublicIPAddressesResponse) bool { 719 return page.NextLink != nil && len(*page.NextLink) > 0 720 }, 721 Fetcher: func(ctx context.Context, page *PublicIPAddressesClientListCloudServiceRoleInstancePublicIPAddressesResponse) (PublicIPAddressesClientListCloudServiceRoleInstancePublicIPAddressesResponse, error) { 722 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PublicIPAddressesClient.NewListCloudServiceRoleInstancePublicIPAddressesPager") 723 nextLink := "" 724 if page != nil { 725 nextLink = *page.NextLink 726 } 727 resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { 728 return client.listCloudServiceRoleInstancePublicIPAddressesCreateRequest(ctx, resourceGroupName, cloudServiceName, roleInstanceName, networkInterfaceName, ipConfigurationName, options) 729 }, nil) 730 if err != nil { 731 return PublicIPAddressesClientListCloudServiceRoleInstancePublicIPAddressesResponse{}, err 732 } 733 return client.listCloudServiceRoleInstancePublicIPAddressesHandleResponse(resp) 734 }, 735 Tracer: client.internal.Tracer(), 736 }) 737 } 738 739 // listCloudServiceRoleInstancePublicIPAddressesCreateRequest creates the ListCloudServiceRoleInstancePublicIPAddresses request. 740 func (client *PublicIPAddressesClient) listCloudServiceRoleInstancePublicIPAddressesCreateRequest(ctx context.Context, resourceGroupName string, cloudServiceName string, roleInstanceName string, networkInterfaceName string, ipConfigurationName string, options *PublicIPAddressesClientListCloudServiceRoleInstancePublicIPAddressesOptions) (*policy.Request, error) { 741 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/networkInterfaces/{networkInterfaceName}/ipconfigurations/{ipConfigurationName}/publicipaddresses" 742 if resourceGroupName == "" { 743 return nil, errors.New("parameter resourceGroupName cannot be empty") 744 } 745 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 746 if cloudServiceName == "" { 747 return nil, errors.New("parameter cloudServiceName cannot be empty") 748 } 749 urlPath = strings.ReplaceAll(urlPath, "{cloudServiceName}", url.PathEscape(cloudServiceName)) 750 if roleInstanceName == "" { 751 return nil, errors.New("parameter roleInstanceName cannot be empty") 752 } 753 urlPath = strings.ReplaceAll(urlPath, "{roleInstanceName}", url.PathEscape(roleInstanceName)) 754 if networkInterfaceName == "" { 755 return nil, errors.New("parameter networkInterfaceName cannot be empty") 756 } 757 urlPath = strings.ReplaceAll(urlPath, "{networkInterfaceName}", url.PathEscape(networkInterfaceName)) 758 if ipConfigurationName == "" { 759 return nil, errors.New("parameter ipConfigurationName cannot be empty") 760 } 761 urlPath = strings.ReplaceAll(urlPath, "{ipConfigurationName}", url.PathEscape(ipConfigurationName)) 762 if client.subscriptionID == "" { 763 return nil, errors.New("parameter client.subscriptionID cannot be empty") 764 } 765 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 766 req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 767 if err != nil { 768 return nil, err 769 } 770 reqQP := req.Raw().URL.Query() 771 reqQP.Set("api-version", "2024-05-01") 772 req.Raw().URL.RawQuery = reqQP.Encode() 773 req.Raw().Header["Accept"] = []string{"application/json"} 774 return req, nil 775 } 776 777 // listCloudServiceRoleInstancePublicIPAddressesHandleResponse handles the ListCloudServiceRoleInstancePublicIPAddresses response. 778 func (client *PublicIPAddressesClient) listCloudServiceRoleInstancePublicIPAddressesHandleResponse(resp *http.Response) (PublicIPAddressesClientListCloudServiceRoleInstancePublicIPAddressesResponse, error) { 779 result := PublicIPAddressesClientListCloudServiceRoleInstancePublicIPAddressesResponse{} 780 if err := runtime.UnmarshalAsJSON(resp, &result.PublicIPAddressListResult); err != nil { 781 return PublicIPAddressesClientListCloudServiceRoleInstancePublicIPAddressesResponse{}, err 782 } 783 return result, nil 784 } 785 786 // NewListVirtualMachineScaleSetPublicIPAddressesPager - Gets information about all public IP addresses on a virtual machine 787 // scale set level. 788 // 789 // Generated from API version 2018-10-01 790 // - resourceGroupName - The name of the resource group. 791 // - virtualMachineScaleSetName - The name of the virtual machine scale set. 792 // - options - PublicIPAddressesClientListVirtualMachineScaleSetPublicIPAddressesOptions contains the optional parameters for 793 // the PublicIPAddressesClient.NewListVirtualMachineScaleSetPublicIPAddressesPager method. 794 func (client *PublicIPAddressesClient) NewListVirtualMachineScaleSetPublicIPAddressesPager(resourceGroupName string, virtualMachineScaleSetName string, options *PublicIPAddressesClientListVirtualMachineScaleSetPublicIPAddressesOptions) *runtime.Pager[PublicIPAddressesClientListVirtualMachineScaleSetPublicIPAddressesResponse] { 795 return runtime.NewPager(runtime.PagingHandler[PublicIPAddressesClientListVirtualMachineScaleSetPublicIPAddressesResponse]{ 796 More: func(page PublicIPAddressesClientListVirtualMachineScaleSetPublicIPAddressesResponse) bool { 797 return page.NextLink != nil && len(*page.NextLink) > 0 798 }, 799 Fetcher: func(ctx context.Context, page *PublicIPAddressesClientListVirtualMachineScaleSetPublicIPAddressesResponse) (PublicIPAddressesClientListVirtualMachineScaleSetPublicIPAddressesResponse, error) { 800 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PublicIPAddressesClient.NewListVirtualMachineScaleSetPublicIPAddressesPager") 801 nextLink := "" 802 if page != nil { 803 nextLink = *page.NextLink 804 } 805 resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { 806 return client.listVirtualMachineScaleSetPublicIPAddressesCreateRequest(ctx, resourceGroupName, virtualMachineScaleSetName, options) 807 }, nil) 808 if err != nil { 809 return PublicIPAddressesClientListVirtualMachineScaleSetPublicIPAddressesResponse{}, err 810 } 811 return client.listVirtualMachineScaleSetPublicIPAddressesHandleResponse(resp) 812 }, 813 Tracer: client.internal.Tracer(), 814 }) 815 } 816 817 // listVirtualMachineScaleSetPublicIPAddressesCreateRequest creates the ListVirtualMachineScaleSetPublicIPAddresses request. 818 func (client *PublicIPAddressesClient) listVirtualMachineScaleSetPublicIPAddressesCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineScaleSetName string, options *PublicIPAddressesClientListVirtualMachineScaleSetPublicIPAddressesOptions) (*policy.Request, error) { 819 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/publicipaddresses" 820 if resourceGroupName == "" { 821 return nil, errors.New("parameter resourceGroupName cannot be empty") 822 } 823 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 824 if virtualMachineScaleSetName == "" { 825 return nil, errors.New("parameter virtualMachineScaleSetName cannot be empty") 826 } 827 urlPath = strings.ReplaceAll(urlPath, "{virtualMachineScaleSetName}", url.PathEscape(virtualMachineScaleSetName)) 828 if client.subscriptionID == "" { 829 return nil, errors.New("parameter client.subscriptionID cannot be empty") 830 } 831 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 832 req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 833 if err != nil { 834 return nil, err 835 } 836 reqQP := req.Raw().URL.Query() 837 reqQP.Set("api-version", "2018-10-01") 838 req.Raw().URL.RawQuery = reqQP.Encode() 839 req.Raw().Header["Accept"] = []string{"application/json"} 840 return req, nil 841 } 842 843 // listVirtualMachineScaleSetPublicIPAddressesHandleResponse handles the ListVirtualMachineScaleSetPublicIPAddresses response. 844 func (client *PublicIPAddressesClient) listVirtualMachineScaleSetPublicIPAddressesHandleResponse(resp *http.Response) (PublicIPAddressesClientListVirtualMachineScaleSetPublicIPAddressesResponse, error) { 845 result := PublicIPAddressesClientListVirtualMachineScaleSetPublicIPAddressesResponse{} 846 if err := runtime.UnmarshalAsJSON(resp, &result.PublicIPAddressListResult); err != nil { 847 return PublicIPAddressesClientListVirtualMachineScaleSetPublicIPAddressesResponse{}, err 848 } 849 return result, nil 850 } 851 852 // NewListVirtualMachineScaleSetVMPublicIPAddressesPager - Gets information about all public IP addresses in a virtual machine 853 // IP configuration in a virtual machine scale set. 854 // 855 // Generated from API version 2018-10-01 856 // - resourceGroupName - The name of the resource group. 857 // - virtualMachineScaleSetName - The name of the virtual machine scale set. 858 // - virtualmachineIndex - The virtual machine index. 859 // - networkInterfaceName - The network interface name. 860 // - ipConfigurationName - The IP configuration name. 861 // - options - PublicIPAddressesClientListVirtualMachineScaleSetVMPublicIPAddressesOptions contains the optional parameters 862 // for the PublicIPAddressesClient.NewListVirtualMachineScaleSetVMPublicIPAddressesPager method. 863 func (client *PublicIPAddressesClient) NewListVirtualMachineScaleSetVMPublicIPAddressesPager(resourceGroupName string, virtualMachineScaleSetName string, virtualmachineIndex string, networkInterfaceName string, ipConfigurationName string, options *PublicIPAddressesClientListVirtualMachineScaleSetVMPublicIPAddressesOptions) *runtime.Pager[PublicIPAddressesClientListVirtualMachineScaleSetVMPublicIPAddressesResponse] { 864 return runtime.NewPager(runtime.PagingHandler[PublicIPAddressesClientListVirtualMachineScaleSetVMPublicIPAddressesResponse]{ 865 More: func(page PublicIPAddressesClientListVirtualMachineScaleSetVMPublicIPAddressesResponse) bool { 866 return page.NextLink != nil && len(*page.NextLink) > 0 867 }, 868 Fetcher: func(ctx context.Context, page *PublicIPAddressesClientListVirtualMachineScaleSetVMPublicIPAddressesResponse) (PublicIPAddressesClientListVirtualMachineScaleSetVMPublicIPAddressesResponse, error) { 869 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PublicIPAddressesClient.NewListVirtualMachineScaleSetVMPublicIPAddressesPager") 870 nextLink := "" 871 if page != nil { 872 nextLink = *page.NextLink 873 } 874 resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { 875 return client.listVirtualMachineScaleSetVMPublicIPAddressesCreateRequest(ctx, resourceGroupName, virtualMachineScaleSetName, virtualmachineIndex, networkInterfaceName, ipConfigurationName, options) 876 }, nil) 877 if err != nil { 878 return PublicIPAddressesClientListVirtualMachineScaleSetVMPublicIPAddressesResponse{}, err 879 } 880 return client.listVirtualMachineScaleSetVMPublicIPAddressesHandleResponse(resp) 881 }, 882 Tracer: client.internal.Tracer(), 883 }) 884 } 885 886 // listVirtualMachineScaleSetVMPublicIPAddressesCreateRequest creates the ListVirtualMachineScaleSetVMPublicIPAddresses request. 887 func (client *PublicIPAddressesClient) listVirtualMachineScaleSetVMPublicIPAddressesCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineScaleSetName string, virtualmachineIndex string, networkInterfaceName string, ipConfigurationName string, options *PublicIPAddressesClientListVirtualMachineScaleSetVMPublicIPAddressesOptions) (*policy.Request, error) { 888 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines/{virtualmachineIndex}/networkInterfaces/{networkInterfaceName}/ipconfigurations/{ipConfigurationName}/publicipaddresses" 889 if resourceGroupName == "" { 890 return nil, errors.New("parameter resourceGroupName cannot be empty") 891 } 892 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 893 if virtualMachineScaleSetName == "" { 894 return nil, errors.New("parameter virtualMachineScaleSetName cannot be empty") 895 } 896 urlPath = strings.ReplaceAll(urlPath, "{virtualMachineScaleSetName}", url.PathEscape(virtualMachineScaleSetName)) 897 if virtualmachineIndex == "" { 898 return nil, errors.New("parameter virtualmachineIndex cannot be empty") 899 } 900 urlPath = strings.ReplaceAll(urlPath, "{virtualmachineIndex}", url.PathEscape(virtualmachineIndex)) 901 if networkInterfaceName == "" { 902 return nil, errors.New("parameter networkInterfaceName cannot be empty") 903 } 904 urlPath = strings.ReplaceAll(urlPath, "{networkInterfaceName}", url.PathEscape(networkInterfaceName)) 905 if ipConfigurationName == "" { 906 return nil, errors.New("parameter ipConfigurationName cannot be empty") 907 } 908 urlPath = strings.ReplaceAll(urlPath, "{ipConfigurationName}", url.PathEscape(ipConfigurationName)) 909 if client.subscriptionID == "" { 910 return nil, errors.New("parameter client.subscriptionID cannot be empty") 911 } 912 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 913 req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 914 if err != nil { 915 return nil, err 916 } 917 reqQP := req.Raw().URL.Query() 918 reqQP.Set("api-version", "2018-10-01") 919 req.Raw().URL.RawQuery = reqQP.Encode() 920 req.Raw().Header["Accept"] = []string{"application/json"} 921 return req, nil 922 } 923 924 // listVirtualMachineScaleSetVMPublicIPAddressesHandleResponse handles the ListVirtualMachineScaleSetVMPublicIPAddresses response. 925 func (client *PublicIPAddressesClient) listVirtualMachineScaleSetVMPublicIPAddressesHandleResponse(resp *http.Response) (PublicIPAddressesClientListVirtualMachineScaleSetVMPublicIPAddressesResponse, error) { 926 result := PublicIPAddressesClientListVirtualMachineScaleSetVMPublicIPAddressesResponse{} 927 if err := runtime.UnmarshalAsJSON(resp, &result.PublicIPAddressListResult); err != nil { 928 return PublicIPAddressesClientListVirtualMachineScaleSetVMPublicIPAddressesResponse{}, err 929 } 930 return result, nil 931 } 932 933 // UpdateTags - Updates public IP address tags. 934 // If the operation fails it returns an *azcore.ResponseError type. 935 // 936 // Generated from API version 2024-05-01 937 // - resourceGroupName - The name of the resource group. 938 // - publicIPAddressName - The name of the public IP address. 939 // - parameters - Parameters supplied to update public IP address tags. 940 // - options - PublicIPAddressesClientUpdateTagsOptions contains the optional parameters for the PublicIPAddressesClient.UpdateTags 941 // method. 942 func (client *PublicIPAddressesClient) UpdateTags(ctx context.Context, resourceGroupName string, publicIPAddressName string, parameters TagsObject, options *PublicIPAddressesClientUpdateTagsOptions) (PublicIPAddressesClientUpdateTagsResponse, error) { 943 var err error 944 const operationName = "PublicIPAddressesClient.UpdateTags" 945 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 946 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 947 defer func() { endSpan(err) }() 948 req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, publicIPAddressName, parameters, options) 949 if err != nil { 950 return PublicIPAddressesClientUpdateTagsResponse{}, err 951 } 952 httpResp, err := client.internal.Pipeline().Do(req) 953 if err != nil { 954 return PublicIPAddressesClientUpdateTagsResponse{}, err 955 } 956 if !runtime.HasStatusCode(httpResp, http.StatusOK) { 957 err = runtime.NewResponseError(httpResp) 958 return PublicIPAddressesClientUpdateTagsResponse{}, err 959 } 960 resp, err := client.updateTagsHandleResponse(httpResp) 961 return resp, err 962 } 963 964 // updateTagsCreateRequest creates the UpdateTags request. 965 func (client *PublicIPAddressesClient) updateTagsCreateRequest(ctx context.Context, resourceGroupName string, publicIPAddressName string, parameters TagsObject, options *PublicIPAddressesClientUpdateTagsOptions) (*policy.Request, error) { 966 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName}" 967 if resourceGroupName == "" { 968 return nil, errors.New("parameter resourceGroupName cannot be empty") 969 } 970 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 971 if publicIPAddressName == "" { 972 return nil, errors.New("parameter publicIPAddressName cannot be empty") 973 } 974 urlPath = strings.ReplaceAll(urlPath, "{publicIpAddressName}", url.PathEscape(publicIPAddressName)) 975 if client.subscriptionID == "" { 976 return nil, errors.New("parameter client.subscriptionID cannot be empty") 977 } 978 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 979 req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 980 if err != nil { 981 return nil, err 982 } 983 reqQP := req.Raw().URL.Query() 984 reqQP.Set("api-version", "2024-05-01") 985 req.Raw().URL.RawQuery = reqQP.Encode() 986 req.Raw().Header["Accept"] = []string{"application/json"} 987 if err := runtime.MarshalAsJSON(req, parameters); err != nil { 988 return nil, err 989 } 990 return req, nil 991 } 992 993 // updateTagsHandleResponse handles the UpdateTags response. 994 func (client *PublicIPAddressesClient) updateTagsHandleResponse(resp *http.Response) (PublicIPAddressesClientUpdateTagsResponse, error) { 995 result := PublicIPAddressesClientUpdateTagsResponse{} 996 if err := runtime.UnmarshalAsJSON(resp, &result.PublicIPAddress); err != nil { 997 return PublicIPAddressesClientUpdateTagsResponse{}, err 998 } 999 return result, nil 1000 }