github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6@v6.2.0/p2svpngateways_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  // P2SVPNGatewaysClient contains the methods for the P2SVPNGateways group.
    24  // Don't use this type directly, use NewP2SVPNGatewaysClient() instead.
    25  type P2SVPNGatewaysClient struct {
    26  	internal       *arm.Client
    27  	subscriptionID string
    28  }
    29  
    30  // NewP2SVPNGatewaysClient creates a new instance of P2SVPNGatewaysClient 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 NewP2SVPNGatewaysClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*P2SVPNGatewaysClient, error) {
    36  	cl, err := arm.NewClient(moduleName, moduleVersion, credential, options)
    37  	if err != nil {
    38  		return nil, err
    39  	}
    40  	client := &P2SVPNGatewaysClient{
    41  		subscriptionID: subscriptionID,
    42  		internal:       cl,
    43  	}
    44  	return client, nil
    45  }
    46  
    47  // BeginCreateOrUpdate - Creates a virtual wan p2s vpn gateway if it doesn't exist else updates the existing gateway.
    48  // If the operation fails it returns an *azcore.ResponseError type.
    49  //
    50  // Generated from API version 2024-05-01
    51  //   - resourceGroupName - The resource group name of the P2SVpnGateway.
    52  //   - gatewayName - The name of the gateway.
    53  //   - p2SVPNGatewayParameters - Parameters supplied to create or Update a virtual wan p2s vpn gateway.
    54  //   - options - P2SVPNGatewaysClientBeginCreateOrUpdateOptions contains the optional parameters for the P2SVPNGatewaysClient.BeginCreateOrUpdate
    55  //     method.
    56  func (client *P2SVPNGatewaysClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, gatewayName string, p2SVPNGatewayParameters P2SVPNGateway, options *P2SVPNGatewaysClientBeginCreateOrUpdateOptions) (*runtime.Poller[P2SVPNGatewaysClientCreateOrUpdateResponse], error) {
    57  	if options == nil || options.ResumeToken == "" {
    58  		resp, err := client.createOrUpdate(ctx, resourceGroupName, gatewayName, p2SVPNGatewayParameters, options)
    59  		if err != nil {
    60  			return nil, err
    61  		}
    62  		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[P2SVPNGatewaysClientCreateOrUpdateResponse]{
    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[P2SVPNGatewaysClientCreateOrUpdateResponse]{
    69  			Tracer: client.internal.Tracer(),
    70  		})
    71  	}
    72  }
    73  
    74  // CreateOrUpdate - Creates a virtual wan p2s vpn gateway if it doesn't exist else updates the existing gateway.
    75  // If the operation fails it returns an *azcore.ResponseError type.
    76  //
    77  // Generated from API version 2024-05-01
    78  func (client *P2SVPNGatewaysClient) createOrUpdate(ctx context.Context, resourceGroupName string, gatewayName string, p2SVPNGatewayParameters P2SVPNGateway, options *P2SVPNGatewaysClientBeginCreateOrUpdateOptions) (*http.Response, error) {
    79  	var err error
    80  	const operationName = "P2SVPNGatewaysClient.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, gatewayName, p2SVPNGatewayParameters, 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 *P2SVPNGatewaysClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, gatewayName string, p2SVPNGatewayParameters P2SVPNGateway, options *P2SVPNGatewaysClientBeginCreateOrUpdateOptions) (*policy.Request, error) {
   101  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{gatewayName}"
   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 gatewayName == "" {
   111  		return nil, errors.New("parameter gatewayName cannot be empty")
   112  	}
   113  	urlPath = strings.ReplaceAll(urlPath, "{gatewayName}", url.PathEscape(gatewayName))
   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, p2SVPNGatewayParameters); err != nil {
   123  		return nil, err
   124  	}
   125  	return req, nil
   126  }
   127  
   128  // BeginDelete - Deletes a virtual wan p2s vpn gateway.
   129  // If the operation fails it returns an *azcore.ResponseError type.
   130  //
   131  // Generated from API version 2024-05-01
   132  //   - resourceGroupName - The resource group name of the P2SVpnGateway.
   133  //   - gatewayName - The name of the gateway.
   134  //   - options - P2SVPNGatewaysClientBeginDeleteOptions contains the optional parameters for the P2SVPNGatewaysClient.BeginDelete
   135  //     method.
   136  func (client *P2SVPNGatewaysClient) BeginDelete(ctx context.Context, resourceGroupName string, gatewayName string, options *P2SVPNGatewaysClientBeginDeleteOptions) (*runtime.Poller[P2SVPNGatewaysClientDeleteResponse], error) {
   137  	if options == nil || options.ResumeToken == "" {
   138  		resp, err := client.deleteOperation(ctx, resourceGroupName, gatewayName, options)
   139  		if err != nil {
   140  			return nil, err
   141  		}
   142  		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[P2SVPNGatewaysClientDeleteResponse]{
   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[P2SVPNGatewaysClientDeleteResponse]{
   149  			Tracer: client.internal.Tracer(),
   150  		})
   151  	}
   152  }
   153  
   154  // Delete - Deletes a virtual wan p2s vpn gateway.
   155  // If the operation fails it returns an *azcore.ResponseError type.
   156  //
   157  // Generated from API version 2024-05-01
   158  func (client *P2SVPNGatewaysClient) deleteOperation(ctx context.Context, resourceGroupName string, gatewayName string, options *P2SVPNGatewaysClientBeginDeleteOptions) (*http.Response, error) {
   159  	var err error
   160  	const operationName = "P2SVPNGatewaysClient.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, gatewayName, 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 *P2SVPNGatewaysClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, gatewayName string, options *P2SVPNGatewaysClientBeginDeleteOptions) (*policy.Request, error) {
   181  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{gatewayName}"
   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 gatewayName == "" {
   191  		return nil, errors.New("parameter gatewayName cannot be empty")
   192  	}
   193  	urlPath = strings.ReplaceAll(urlPath, "{gatewayName}", url.PathEscape(gatewayName))
   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  // BeginDisconnectP2SVPNConnections - Disconnect P2S vpn connections of the virtual wan P2SVpnGateway in the specified resource
   206  // group.
   207  // If the operation fails it returns an *azcore.ResponseError type.
   208  //
   209  // Generated from API version 2024-05-01
   210  //   - resourceGroupName - The name of the resource group.
   211  //   - p2SVPNGatewayName - The name of the P2S Vpn Gateway.
   212  //   - request - The parameters are supplied to disconnect p2s vpn connections.
   213  //   - options - P2SVPNGatewaysClientBeginDisconnectP2SVPNConnectionsOptions contains the optional parameters for the P2SVPNGatewaysClient.BeginDisconnectP2SVPNConnections
   214  //     method.
   215  func (client *P2SVPNGatewaysClient) BeginDisconnectP2SVPNConnections(ctx context.Context, resourceGroupName string, p2SVPNGatewayName string, request P2SVPNConnectionRequest, options *P2SVPNGatewaysClientBeginDisconnectP2SVPNConnectionsOptions) (*runtime.Poller[P2SVPNGatewaysClientDisconnectP2SVPNConnectionsResponse], error) {
   216  	if options == nil || options.ResumeToken == "" {
   217  		resp, err := client.disconnectP2SVPNConnections(ctx, resourceGroupName, p2SVPNGatewayName, request, options)
   218  		if err != nil {
   219  			return nil, err
   220  		}
   221  		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[P2SVPNGatewaysClientDisconnectP2SVPNConnectionsResponse]{
   222  			FinalStateVia: runtime.FinalStateViaLocation,
   223  			Tracer:        client.internal.Tracer(),
   224  		})
   225  		return poller, err
   226  	} else {
   227  		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[P2SVPNGatewaysClientDisconnectP2SVPNConnectionsResponse]{
   228  			Tracer: client.internal.Tracer(),
   229  		})
   230  	}
   231  }
   232  
   233  // DisconnectP2SVPNConnections - Disconnect P2S vpn connections of the virtual wan P2SVpnGateway in the specified resource
   234  // group.
   235  // If the operation fails it returns an *azcore.ResponseError type.
   236  //
   237  // Generated from API version 2024-05-01
   238  func (client *P2SVPNGatewaysClient) disconnectP2SVPNConnections(ctx context.Context, resourceGroupName string, p2SVPNGatewayName string, request P2SVPNConnectionRequest, options *P2SVPNGatewaysClientBeginDisconnectP2SVPNConnectionsOptions) (*http.Response, error) {
   239  	var err error
   240  	const operationName = "P2SVPNGatewaysClient.BeginDisconnectP2SVPNConnections"
   241  	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
   242  	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
   243  	defer func() { endSpan(err) }()
   244  	req, err := client.disconnectP2SVPNConnectionsCreateRequest(ctx, resourceGroupName, p2SVPNGatewayName, request, options)
   245  	if err != nil {
   246  		return nil, err
   247  	}
   248  	httpResp, err := client.internal.Pipeline().Do(req)
   249  	if err != nil {
   250  		return nil, err
   251  	}
   252  	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) {
   253  		err = runtime.NewResponseError(httpResp)
   254  		return nil, err
   255  	}
   256  	return httpResp, nil
   257  }
   258  
   259  // disconnectP2SVPNConnectionsCreateRequest creates the DisconnectP2SVPNConnections request.
   260  func (client *P2SVPNGatewaysClient) disconnectP2SVPNConnectionsCreateRequest(ctx context.Context, resourceGroupName string, p2SVPNGatewayName string, request P2SVPNConnectionRequest, options *P2SVPNGatewaysClientBeginDisconnectP2SVPNConnectionsOptions) (*policy.Request, error) {
   261  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{p2sVpnGatewayName}/disconnectP2sVpnConnections"
   262  	if client.subscriptionID == "" {
   263  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   264  	}
   265  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   266  	if resourceGroupName == "" {
   267  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   268  	}
   269  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   270  	if p2SVPNGatewayName == "" {
   271  		return nil, errors.New("parameter p2SVPNGatewayName cannot be empty")
   272  	}
   273  	urlPath = strings.ReplaceAll(urlPath, "{p2sVpnGatewayName}", url.PathEscape(p2SVPNGatewayName))
   274  	req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   275  	if err != nil {
   276  		return nil, err
   277  	}
   278  	reqQP := req.Raw().URL.Query()
   279  	reqQP.Set("api-version", "2024-05-01")
   280  	req.Raw().URL.RawQuery = reqQP.Encode()
   281  	req.Raw().Header["Accept"] = []string{"application/json"}
   282  	if err := runtime.MarshalAsJSON(req, request); err != nil {
   283  		return nil, err
   284  	}
   285  	return req, nil
   286  }
   287  
   288  // BeginGenerateVPNProfile - Generates VPN profile for P2S client of the P2SVpnGateway in the specified resource group.
   289  // If the operation fails it returns an *azcore.ResponseError type.
   290  //
   291  // Generated from API version 2024-05-01
   292  //   - resourceGroupName - The name of the resource group.
   293  //   - gatewayName - The name of the P2SVpnGateway.
   294  //   - parameters - Parameters supplied to the generate P2SVpnGateway VPN client package operation.
   295  //   - options - P2SVPNGatewaysClientBeginGenerateVPNProfileOptions contains the optional parameters for the P2SVPNGatewaysClient.BeginGenerateVPNProfile
   296  //     method.
   297  func (client *P2SVPNGatewaysClient) BeginGenerateVPNProfile(ctx context.Context, resourceGroupName string, gatewayName string, parameters P2SVPNProfileParameters, options *P2SVPNGatewaysClientBeginGenerateVPNProfileOptions) (*runtime.Poller[P2SVPNGatewaysClientGenerateVPNProfileResponse], error) {
   298  	if options == nil || options.ResumeToken == "" {
   299  		resp, err := client.generateVPNProfile(ctx, resourceGroupName, gatewayName, parameters, options)
   300  		if err != nil {
   301  			return nil, err
   302  		}
   303  		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[P2SVPNGatewaysClientGenerateVPNProfileResponse]{
   304  			FinalStateVia: runtime.FinalStateViaLocation,
   305  			Tracer:        client.internal.Tracer(),
   306  		})
   307  		return poller, err
   308  	} else {
   309  		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[P2SVPNGatewaysClientGenerateVPNProfileResponse]{
   310  			Tracer: client.internal.Tracer(),
   311  		})
   312  	}
   313  }
   314  
   315  // GenerateVPNProfile - Generates VPN profile for P2S client of the P2SVpnGateway in the specified resource group.
   316  // If the operation fails it returns an *azcore.ResponseError type.
   317  //
   318  // Generated from API version 2024-05-01
   319  func (client *P2SVPNGatewaysClient) generateVPNProfile(ctx context.Context, resourceGroupName string, gatewayName string, parameters P2SVPNProfileParameters, options *P2SVPNGatewaysClientBeginGenerateVPNProfileOptions) (*http.Response, error) {
   320  	var err error
   321  	const operationName = "P2SVPNGatewaysClient.BeginGenerateVPNProfile"
   322  	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
   323  	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
   324  	defer func() { endSpan(err) }()
   325  	req, err := client.generateVPNProfileCreateRequest(ctx, resourceGroupName, gatewayName, parameters, options)
   326  	if err != nil {
   327  		return nil, err
   328  	}
   329  	httpResp, err := client.internal.Pipeline().Do(req)
   330  	if err != nil {
   331  		return nil, err
   332  	}
   333  	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) {
   334  		err = runtime.NewResponseError(httpResp)
   335  		return nil, err
   336  	}
   337  	return httpResp, nil
   338  }
   339  
   340  // generateVPNProfileCreateRequest creates the GenerateVPNProfile request.
   341  func (client *P2SVPNGatewaysClient) generateVPNProfileCreateRequest(ctx context.Context, resourceGroupName string, gatewayName string, parameters P2SVPNProfileParameters, options *P2SVPNGatewaysClientBeginGenerateVPNProfileOptions) (*policy.Request, error) {
   342  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{gatewayName}/generatevpnprofile"
   343  	if resourceGroupName == "" {
   344  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   345  	}
   346  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   347  	if gatewayName == "" {
   348  		return nil, errors.New("parameter gatewayName cannot be empty")
   349  	}
   350  	urlPath = strings.ReplaceAll(urlPath, "{gatewayName}", url.PathEscape(gatewayName))
   351  	if client.subscriptionID == "" {
   352  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   353  	}
   354  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   355  	req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   356  	if err != nil {
   357  		return nil, err
   358  	}
   359  	reqQP := req.Raw().URL.Query()
   360  	reqQP.Set("api-version", "2024-05-01")
   361  	req.Raw().URL.RawQuery = reqQP.Encode()
   362  	req.Raw().Header["Accept"] = []string{"application/json"}
   363  	if err := runtime.MarshalAsJSON(req, parameters); err != nil {
   364  		return nil, err
   365  	}
   366  	return req, nil
   367  }
   368  
   369  // Get - Retrieves the details of a virtual wan p2s vpn gateway.
   370  // If the operation fails it returns an *azcore.ResponseError type.
   371  //
   372  // Generated from API version 2024-05-01
   373  //   - resourceGroupName - The resource group name of the P2SVpnGateway.
   374  //   - gatewayName - The name of the gateway.
   375  //   - options - P2SVPNGatewaysClientGetOptions contains the optional parameters for the P2SVPNGatewaysClient.Get method.
   376  func (client *P2SVPNGatewaysClient) Get(ctx context.Context, resourceGroupName string, gatewayName string, options *P2SVPNGatewaysClientGetOptions) (P2SVPNGatewaysClientGetResponse, error) {
   377  	var err error
   378  	const operationName = "P2SVPNGatewaysClient.Get"
   379  	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
   380  	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
   381  	defer func() { endSpan(err) }()
   382  	req, err := client.getCreateRequest(ctx, resourceGroupName, gatewayName, options)
   383  	if err != nil {
   384  		return P2SVPNGatewaysClientGetResponse{}, err
   385  	}
   386  	httpResp, err := client.internal.Pipeline().Do(req)
   387  	if err != nil {
   388  		return P2SVPNGatewaysClientGetResponse{}, err
   389  	}
   390  	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
   391  		err = runtime.NewResponseError(httpResp)
   392  		return P2SVPNGatewaysClientGetResponse{}, err
   393  	}
   394  	resp, err := client.getHandleResponse(httpResp)
   395  	return resp, err
   396  }
   397  
   398  // getCreateRequest creates the Get request.
   399  func (client *P2SVPNGatewaysClient) getCreateRequest(ctx context.Context, resourceGroupName string, gatewayName string, options *P2SVPNGatewaysClientGetOptions) (*policy.Request, error) {
   400  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{gatewayName}"
   401  	if client.subscriptionID == "" {
   402  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   403  	}
   404  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   405  	if resourceGroupName == "" {
   406  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   407  	}
   408  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   409  	if gatewayName == "" {
   410  		return nil, errors.New("parameter gatewayName cannot be empty")
   411  	}
   412  	urlPath = strings.ReplaceAll(urlPath, "{gatewayName}", url.PathEscape(gatewayName))
   413  	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   414  	if err != nil {
   415  		return nil, err
   416  	}
   417  	reqQP := req.Raw().URL.Query()
   418  	reqQP.Set("api-version", "2024-05-01")
   419  	req.Raw().URL.RawQuery = reqQP.Encode()
   420  	req.Raw().Header["Accept"] = []string{"application/json"}
   421  	return req, nil
   422  }
   423  
   424  // getHandleResponse handles the Get response.
   425  func (client *P2SVPNGatewaysClient) getHandleResponse(resp *http.Response) (P2SVPNGatewaysClientGetResponse, error) {
   426  	result := P2SVPNGatewaysClientGetResponse{}
   427  	if err := runtime.UnmarshalAsJSON(resp, &result.P2SVPNGateway); err != nil {
   428  		return P2SVPNGatewaysClientGetResponse{}, err
   429  	}
   430  	return result, nil
   431  }
   432  
   433  // BeginGetP2SVPNConnectionHealth - Gets the connection health of P2S clients of the virtual wan P2SVpnGateway in the specified
   434  // resource group.
   435  // If the operation fails it returns an *azcore.ResponseError type.
   436  //
   437  // Generated from API version 2024-05-01
   438  //   - resourceGroupName - The name of the resource group.
   439  //   - gatewayName - The name of the P2SVpnGateway.
   440  //   - options - P2SVPNGatewaysClientBeginGetP2SVPNConnectionHealthOptions contains the optional parameters for the P2SVPNGatewaysClient.BeginGetP2SVPNConnectionHealth
   441  //     method.
   442  func (client *P2SVPNGatewaysClient) BeginGetP2SVPNConnectionHealth(ctx context.Context, resourceGroupName string, gatewayName string, options *P2SVPNGatewaysClientBeginGetP2SVPNConnectionHealthOptions) (*runtime.Poller[P2SVPNGatewaysClientGetP2SVPNConnectionHealthResponse], error) {
   443  	if options == nil || options.ResumeToken == "" {
   444  		resp, err := client.getP2SVPNConnectionHealth(ctx, resourceGroupName, gatewayName, options)
   445  		if err != nil {
   446  			return nil, err
   447  		}
   448  		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[P2SVPNGatewaysClientGetP2SVPNConnectionHealthResponse]{
   449  			FinalStateVia: runtime.FinalStateViaLocation,
   450  			Tracer:        client.internal.Tracer(),
   451  		})
   452  		return poller, err
   453  	} else {
   454  		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[P2SVPNGatewaysClientGetP2SVPNConnectionHealthResponse]{
   455  			Tracer: client.internal.Tracer(),
   456  		})
   457  	}
   458  }
   459  
   460  // GetP2SVPNConnectionHealth - Gets the connection health of P2S clients of the virtual wan P2SVpnGateway in the specified
   461  // resource group.
   462  // If the operation fails it returns an *azcore.ResponseError type.
   463  //
   464  // Generated from API version 2024-05-01
   465  func (client *P2SVPNGatewaysClient) getP2SVPNConnectionHealth(ctx context.Context, resourceGroupName string, gatewayName string, options *P2SVPNGatewaysClientBeginGetP2SVPNConnectionHealthOptions) (*http.Response, error) {
   466  	var err error
   467  	const operationName = "P2SVPNGatewaysClient.BeginGetP2SVPNConnectionHealth"
   468  	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
   469  	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
   470  	defer func() { endSpan(err) }()
   471  	req, err := client.getP2SVPNConnectionHealthCreateRequest(ctx, resourceGroupName, gatewayName, options)
   472  	if err != nil {
   473  		return nil, err
   474  	}
   475  	httpResp, err := client.internal.Pipeline().Do(req)
   476  	if err != nil {
   477  		return nil, err
   478  	}
   479  	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) {
   480  		err = runtime.NewResponseError(httpResp)
   481  		return nil, err
   482  	}
   483  	return httpResp, nil
   484  }
   485  
   486  // getP2SVPNConnectionHealthCreateRequest creates the GetP2SVPNConnectionHealth request.
   487  func (client *P2SVPNGatewaysClient) getP2SVPNConnectionHealthCreateRequest(ctx context.Context, resourceGroupName string, gatewayName string, options *P2SVPNGatewaysClientBeginGetP2SVPNConnectionHealthOptions) (*policy.Request, error) {
   488  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{gatewayName}/getP2sVpnConnectionHealth"
   489  	if resourceGroupName == "" {
   490  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   491  	}
   492  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   493  	if gatewayName == "" {
   494  		return nil, errors.New("parameter gatewayName cannot be empty")
   495  	}
   496  	urlPath = strings.ReplaceAll(urlPath, "{gatewayName}", url.PathEscape(gatewayName))
   497  	if client.subscriptionID == "" {
   498  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   499  	}
   500  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   501  	req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   502  	if err != nil {
   503  		return nil, err
   504  	}
   505  	reqQP := req.Raw().URL.Query()
   506  	reqQP.Set("api-version", "2024-05-01")
   507  	req.Raw().URL.RawQuery = reqQP.Encode()
   508  	req.Raw().Header["Accept"] = []string{"application/json"}
   509  	return req, nil
   510  }
   511  
   512  // BeginGetP2SVPNConnectionHealthDetailed - Gets the sas url to get the connection health detail of P2S clients of the virtual
   513  // wan P2SVpnGateway in the specified resource group.
   514  // If the operation fails it returns an *azcore.ResponseError type.
   515  //
   516  // Generated from API version 2024-05-01
   517  //   - resourceGroupName - The name of the resource group.
   518  //   - gatewayName - The name of the P2SVpnGateway.
   519  //   - request - Request parameters supplied to get p2s vpn connections detailed health.
   520  //   - options - P2SVPNGatewaysClientBeginGetP2SVPNConnectionHealthDetailedOptions contains the optional parameters for the P2SVPNGatewaysClient.BeginGetP2SVPNConnectionHealthDetailed
   521  //     method.
   522  func (client *P2SVPNGatewaysClient) BeginGetP2SVPNConnectionHealthDetailed(ctx context.Context, resourceGroupName string, gatewayName string, request P2SVPNConnectionHealthRequest, options *P2SVPNGatewaysClientBeginGetP2SVPNConnectionHealthDetailedOptions) (*runtime.Poller[P2SVPNGatewaysClientGetP2SVPNConnectionHealthDetailedResponse], error) {
   523  	if options == nil || options.ResumeToken == "" {
   524  		resp, err := client.getP2SVPNConnectionHealthDetailed(ctx, resourceGroupName, gatewayName, request, options)
   525  		if err != nil {
   526  			return nil, err
   527  		}
   528  		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[P2SVPNGatewaysClientGetP2SVPNConnectionHealthDetailedResponse]{
   529  			FinalStateVia: runtime.FinalStateViaLocation,
   530  			Tracer:        client.internal.Tracer(),
   531  		})
   532  		return poller, err
   533  	} else {
   534  		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[P2SVPNGatewaysClientGetP2SVPNConnectionHealthDetailedResponse]{
   535  			Tracer: client.internal.Tracer(),
   536  		})
   537  	}
   538  }
   539  
   540  // GetP2SVPNConnectionHealthDetailed - Gets the sas url to get the connection health detail of P2S clients of the virtual
   541  // wan P2SVpnGateway in the specified resource group.
   542  // If the operation fails it returns an *azcore.ResponseError type.
   543  //
   544  // Generated from API version 2024-05-01
   545  func (client *P2SVPNGatewaysClient) getP2SVPNConnectionHealthDetailed(ctx context.Context, resourceGroupName string, gatewayName string, request P2SVPNConnectionHealthRequest, options *P2SVPNGatewaysClientBeginGetP2SVPNConnectionHealthDetailedOptions) (*http.Response, error) {
   546  	var err error
   547  	const operationName = "P2SVPNGatewaysClient.BeginGetP2SVPNConnectionHealthDetailed"
   548  	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
   549  	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
   550  	defer func() { endSpan(err) }()
   551  	req, err := client.getP2SVPNConnectionHealthDetailedCreateRequest(ctx, resourceGroupName, gatewayName, request, options)
   552  	if err != nil {
   553  		return nil, err
   554  	}
   555  	httpResp, err := client.internal.Pipeline().Do(req)
   556  	if err != nil {
   557  		return nil, err
   558  	}
   559  	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) {
   560  		err = runtime.NewResponseError(httpResp)
   561  		return nil, err
   562  	}
   563  	return httpResp, nil
   564  }
   565  
   566  // getP2SVPNConnectionHealthDetailedCreateRequest creates the GetP2SVPNConnectionHealthDetailed request.
   567  func (client *P2SVPNGatewaysClient) getP2SVPNConnectionHealthDetailedCreateRequest(ctx context.Context, resourceGroupName string, gatewayName string, request P2SVPNConnectionHealthRequest, options *P2SVPNGatewaysClientBeginGetP2SVPNConnectionHealthDetailedOptions) (*policy.Request, error) {
   568  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{gatewayName}/getP2sVpnConnectionHealthDetailed"
   569  	if client.subscriptionID == "" {
   570  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   571  	}
   572  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   573  	if resourceGroupName == "" {
   574  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   575  	}
   576  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   577  	if gatewayName == "" {
   578  		return nil, errors.New("parameter gatewayName cannot be empty")
   579  	}
   580  	urlPath = strings.ReplaceAll(urlPath, "{gatewayName}", url.PathEscape(gatewayName))
   581  	req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   582  	if err != nil {
   583  		return nil, err
   584  	}
   585  	reqQP := req.Raw().URL.Query()
   586  	reqQP.Set("api-version", "2024-05-01")
   587  	req.Raw().URL.RawQuery = reqQP.Encode()
   588  	req.Raw().Header["Accept"] = []string{"application/json"}
   589  	if err := runtime.MarshalAsJSON(req, request); err != nil {
   590  		return nil, err
   591  	}
   592  	return req, nil
   593  }
   594  
   595  // NewListPager - Lists all the P2SVpnGateways in a subscription.
   596  //
   597  // Generated from API version 2024-05-01
   598  //   - options - P2SVPNGatewaysClientListOptions contains the optional parameters for the P2SVPNGatewaysClient.NewListPager method.
   599  func (client *P2SVPNGatewaysClient) NewListPager(options *P2SVPNGatewaysClientListOptions) *runtime.Pager[P2SVPNGatewaysClientListResponse] {
   600  	return runtime.NewPager(runtime.PagingHandler[P2SVPNGatewaysClientListResponse]{
   601  		More: func(page P2SVPNGatewaysClientListResponse) bool {
   602  			return page.NextLink != nil && len(*page.NextLink) > 0
   603  		},
   604  		Fetcher: func(ctx context.Context, page *P2SVPNGatewaysClientListResponse) (P2SVPNGatewaysClientListResponse, error) {
   605  			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "P2SVPNGatewaysClient.NewListPager")
   606  			nextLink := ""
   607  			if page != nil {
   608  				nextLink = *page.NextLink
   609  			}
   610  			resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) {
   611  				return client.listCreateRequest(ctx, options)
   612  			}, nil)
   613  			if err != nil {
   614  				return P2SVPNGatewaysClientListResponse{}, err
   615  			}
   616  			return client.listHandleResponse(resp)
   617  		},
   618  		Tracer: client.internal.Tracer(),
   619  	})
   620  }
   621  
   622  // listCreateRequest creates the List request.
   623  func (client *P2SVPNGatewaysClient) listCreateRequest(ctx context.Context, options *P2SVPNGatewaysClientListOptions) (*policy.Request, error) {
   624  	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Network/p2svpnGateways"
   625  	if client.subscriptionID == "" {
   626  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   627  	}
   628  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   629  	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   630  	if err != nil {
   631  		return nil, err
   632  	}
   633  	reqQP := req.Raw().URL.Query()
   634  	reqQP.Set("api-version", "2024-05-01")
   635  	req.Raw().URL.RawQuery = reqQP.Encode()
   636  	req.Raw().Header["Accept"] = []string{"application/json"}
   637  	return req, nil
   638  }
   639  
   640  // listHandleResponse handles the List response.
   641  func (client *P2SVPNGatewaysClient) listHandleResponse(resp *http.Response) (P2SVPNGatewaysClientListResponse, error) {
   642  	result := P2SVPNGatewaysClientListResponse{}
   643  	if err := runtime.UnmarshalAsJSON(resp, &result.ListP2SVPNGatewaysResult); err != nil {
   644  		return P2SVPNGatewaysClientListResponse{}, err
   645  	}
   646  	return result, nil
   647  }
   648  
   649  // NewListByResourceGroupPager - Lists all the P2SVpnGateways in a resource group.
   650  //
   651  // Generated from API version 2024-05-01
   652  //   - resourceGroupName - The resource group name of the P2SVpnGateway.
   653  //   - options - P2SVPNGatewaysClientListByResourceGroupOptions contains the optional parameters for the P2SVPNGatewaysClient.NewListByResourceGroupPager
   654  //     method.
   655  func (client *P2SVPNGatewaysClient) NewListByResourceGroupPager(resourceGroupName string, options *P2SVPNGatewaysClientListByResourceGroupOptions) *runtime.Pager[P2SVPNGatewaysClientListByResourceGroupResponse] {
   656  	return runtime.NewPager(runtime.PagingHandler[P2SVPNGatewaysClientListByResourceGroupResponse]{
   657  		More: func(page P2SVPNGatewaysClientListByResourceGroupResponse) bool {
   658  			return page.NextLink != nil && len(*page.NextLink) > 0
   659  		},
   660  		Fetcher: func(ctx context.Context, page *P2SVPNGatewaysClientListByResourceGroupResponse) (P2SVPNGatewaysClientListByResourceGroupResponse, error) {
   661  			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "P2SVPNGatewaysClient.NewListByResourceGroupPager")
   662  			nextLink := ""
   663  			if page != nil {
   664  				nextLink = *page.NextLink
   665  			}
   666  			resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) {
   667  				return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options)
   668  			}, nil)
   669  			if err != nil {
   670  				return P2SVPNGatewaysClientListByResourceGroupResponse{}, err
   671  			}
   672  			return client.listByResourceGroupHandleResponse(resp)
   673  		},
   674  		Tracer: client.internal.Tracer(),
   675  	})
   676  }
   677  
   678  // listByResourceGroupCreateRequest creates the ListByResourceGroup request.
   679  func (client *P2SVPNGatewaysClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *P2SVPNGatewaysClientListByResourceGroupOptions) (*policy.Request, error) {
   680  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways"
   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  	if resourceGroupName == "" {
   686  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   687  	}
   688  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   689  	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   690  	if err != nil {
   691  		return nil, err
   692  	}
   693  	reqQP := req.Raw().URL.Query()
   694  	reqQP.Set("api-version", "2024-05-01")
   695  	req.Raw().URL.RawQuery = reqQP.Encode()
   696  	req.Raw().Header["Accept"] = []string{"application/json"}
   697  	return req, nil
   698  }
   699  
   700  // listByResourceGroupHandleResponse handles the ListByResourceGroup response.
   701  func (client *P2SVPNGatewaysClient) listByResourceGroupHandleResponse(resp *http.Response) (P2SVPNGatewaysClientListByResourceGroupResponse, error) {
   702  	result := P2SVPNGatewaysClientListByResourceGroupResponse{}
   703  	if err := runtime.UnmarshalAsJSON(resp, &result.ListP2SVPNGatewaysResult); err != nil {
   704  		return P2SVPNGatewaysClientListByResourceGroupResponse{}, err
   705  	}
   706  	return result, nil
   707  }
   708  
   709  // BeginReset - Resets the primary of the p2s vpn gateway in the specified resource group.
   710  // If the operation fails it returns an *azcore.ResponseError type.
   711  //
   712  // Generated from API version 2024-05-01
   713  //   - resourceGroupName - The resource group name of the P2SVpnGateway.
   714  //   - gatewayName - The name of the gateway.
   715  //   - options - P2SVPNGatewaysClientBeginResetOptions contains the optional parameters for the P2SVPNGatewaysClient.BeginReset
   716  //     method.
   717  func (client *P2SVPNGatewaysClient) BeginReset(ctx context.Context, resourceGroupName string, gatewayName string, options *P2SVPNGatewaysClientBeginResetOptions) (*runtime.Poller[P2SVPNGatewaysClientResetResponse], error) {
   718  	if options == nil || options.ResumeToken == "" {
   719  		resp, err := client.reset(ctx, resourceGroupName, gatewayName, options)
   720  		if err != nil {
   721  			return nil, err
   722  		}
   723  		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[P2SVPNGatewaysClientResetResponse]{
   724  			FinalStateVia: runtime.FinalStateViaLocation,
   725  			Tracer:        client.internal.Tracer(),
   726  		})
   727  		return poller, err
   728  	} else {
   729  		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[P2SVPNGatewaysClientResetResponse]{
   730  			Tracer: client.internal.Tracer(),
   731  		})
   732  	}
   733  }
   734  
   735  // Reset - Resets the primary of the p2s vpn gateway in the specified resource group.
   736  // If the operation fails it returns an *azcore.ResponseError type.
   737  //
   738  // Generated from API version 2024-05-01
   739  func (client *P2SVPNGatewaysClient) reset(ctx context.Context, resourceGroupName string, gatewayName string, options *P2SVPNGatewaysClientBeginResetOptions) (*http.Response, error) {
   740  	var err error
   741  	const operationName = "P2SVPNGatewaysClient.BeginReset"
   742  	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
   743  	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
   744  	defer func() { endSpan(err) }()
   745  	req, err := client.resetCreateRequest(ctx, resourceGroupName, gatewayName, options)
   746  	if err != nil {
   747  		return nil, err
   748  	}
   749  	httpResp, err := client.internal.Pipeline().Do(req)
   750  	if err != nil {
   751  		return nil, err
   752  	}
   753  	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) {
   754  		err = runtime.NewResponseError(httpResp)
   755  		return nil, err
   756  	}
   757  	return httpResp, nil
   758  }
   759  
   760  // resetCreateRequest creates the Reset request.
   761  func (client *P2SVPNGatewaysClient) resetCreateRequest(ctx context.Context, resourceGroupName string, gatewayName string, options *P2SVPNGatewaysClientBeginResetOptions) (*policy.Request, error) {
   762  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{gatewayName}/reset"
   763  	if resourceGroupName == "" {
   764  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   765  	}
   766  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   767  	if gatewayName == "" {
   768  		return nil, errors.New("parameter gatewayName cannot be empty")
   769  	}
   770  	urlPath = strings.ReplaceAll(urlPath, "{gatewayName}", url.PathEscape(gatewayName))
   771  	if client.subscriptionID == "" {
   772  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   773  	}
   774  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   775  	req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   776  	if err != nil {
   777  		return nil, err
   778  	}
   779  	reqQP := req.Raw().URL.Query()
   780  	reqQP.Set("api-version", "2024-05-01")
   781  	req.Raw().URL.RawQuery = reqQP.Encode()
   782  	req.Raw().Header["Accept"] = []string{"application/json"}
   783  	return req, nil
   784  }
   785  
   786  // BeginUpdateTags - Updates virtual wan p2s vpn gateway tags.
   787  // If the operation fails it returns an *azcore.ResponseError type.
   788  //
   789  // Generated from API version 2024-05-01
   790  //   - resourceGroupName - The resource group name of the P2SVpnGateway.
   791  //   - gatewayName - The name of the gateway.
   792  //   - p2SVPNGatewayParameters - Parameters supplied to update a virtual wan p2s vpn gateway tags.
   793  //   - options - P2SVPNGatewaysClientBeginUpdateTagsOptions contains the optional parameters for the P2SVPNGatewaysClient.BeginUpdateTags
   794  //     method.
   795  func (client *P2SVPNGatewaysClient) BeginUpdateTags(ctx context.Context, resourceGroupName string, gatewayName string, p2SVPNGatewayParameters TagsObject, options *P2SVPNGatewaysClientBeginUpdateTagsOptions) (*runtime.Poller[P2SVPNGatewaysClientUpdateTagsResponse], error) {
   796  	if options == nil || options.ResumeToken == "" {
   797  		resp, err := client.updateTags(ctx, resourceGroupName, gatewayName, p2SVPNGatewayParameters, options)
   798  		if err != nil {
   799  			return nil, err
   800  		}
   801  		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[P2SVPNGatewaysClientUpdateTagsResponse]{
   802  			FinalStateVia: runtime.FinalStateViaAzureAsyncOp,
   803  			Tracer:        client.internal.Tracer(),
   804  		})
   805  		return poller, err
   806  	} else {
   807  		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[P2SVPNGatewaysClientUpdateTagsResponse]{
   808  			Tracer: client.internal.Tracer(),
   809  		})
   810  	}
   811  }
   812  
   813  // UpdateTags - Updates virtual wan p2s vpn gateway tags.
   814  // If the operation fails it returns an *azcore.ResponseError type.
   815  //
   816  // Generated from API version 2024-05-01
   817  func (client *P2SVPNGatewaysClient) updateTags(ctx context.Context, resourceGroupName string, gatewayName string, p2SVPNGatewayParameters TagsObject, options *P2SVPNGatewaysClientBeginUpdateTagsOptions) (*http.Response, error) {
   818  	var err error
   819  	const operationName = "P2SVPNGatewaysClient.BeginUpdateTags"
   820  	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
   821  	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
   822  	defer func() { endSpan(err) }()
   823  	req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, gatewayName, p2SVPNGatewayParameters, options)
   824  	if err != nil {
   825  		return nil, err
   826  	}
   827  	httpResp, err := client.internal.Pipeline().Do(req)
   828  	if err != nil {
   829  		return nil, err
   830  	}
   831  	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) {
   832  		err = runtime.NewResponseError(httpResp)
   833  		return nil, err
   834  	}
   835  	return httpResp, nil
   836  }
   837  
   838  // updateTagsCreateRequest creates the UpdateTags request.
   839  func (client *P2SVPNGatewaysClient) updateTagsCreateRequest(ctx context.Context, resourceGroupName string, gatewayName string, p2SVPNGatewayParameters TagsObject, options *P2SVPNGatewaysClientBeginUpdateTagsOptions) (*policy.Request, error) {
   840  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{gatewayName}"
   841  	if client.subscriptionID == "" {
   842  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   843  	}
   844  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   845  	if resourceGroupName == "" {
   846  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   847  	}
   848  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   849  	if gatewayName == "" {
   850  		return nil, errors.New("parameter gatewayName cannot be empty")
   851  	}
   852  	urlPath = strings.ReplaceAll(urlPath, "{gatewayName}", url.PathEscape(gatewayName))
   853  	req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   854  	if err != nil {
   855  		return nil, err
   856  	}
   857  	reqQP := req.Raw().URL.Query()
   858  	reqQP.Set("api-version", "2024-05-01")
   859  	req.Raw().URL.RawQuery = reqQP.Encode()
   860  	req.Raw().Header["Accept"] = []string{"application/json"}
   861  	if err := runtime.MarshalAsJSON(req, p2SVPNGatewayParameters); err != nil {
   862  		return nil, err
   863  	}
   864  	return req, nil
   865  }