github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6@v6.2.0/vpnlinkconnections_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  // VPNLinkConnectionsClient contains the methods for the VPNLinkConnections group.
    24  // Don't use this type directly, use NewVPNLinkConnectionsClient() instead.
    25  type VPNLinkConnectionsClient struct {
    26  	internal       *arm.Client
    27  	subscriptionID string
    28  }
    29  
    30  // NewVPNLinkConnectionsClient creates a new instance of VPNLinkConnectionsClient 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 NewVPNLinkConnectionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VPNLinkConnectionsClient, error) {
    36  	cl, err := arm.NewClient(moduleName, moduleVersion, credential, options)
    37  	if err != nil {
    38  		return nil, err
    39  	}
    40  	client := &VPNLinkConnectionsClient{
    41  		subscriptionID: subscriptionID,
    42  		internal:       cl,
    43  	}
    44  	return client, nil
    45  }
    46  
    47  // NewGetAllSharedKeysPager - Lists all shared keys of VpnLink connection specified.
    48  //
    49  // Generated from API version 2024-05-01
    50  //   - resourceGroupName - The name of the resource group.
    51  //   - gatewayName - The name of the gateway.
    52  //   - connectionName - The name of the vpn connection.
    53  //   - linkConnectionName - The name of the vpn link connection.
    54  //   - options - VPNLinkConnectionsClientGetAllSharedKeysOptions contains the optional parameters for the VPNLinkConnectionsClient.NewGetAllSharedKeysPager
    55  //     method.
    56  func (client *VPNLinkConnectionsClient) NewGetAllSharedKeysPager(resourceGroupName string, gatewayName string, connectionName string, linkConnectionName string, options *VPNLinkConnectionsClientGetAllSharedKeysOptions) *runtime.Pager[VPNLinkConnectionsClientGetAllSharedKeysResponse] {
    57  	return runtime.NewPager(runtime.PagingHandler[VPNLinkConnectionsClientGetAllSharedKeysResponse]{
    58  		More: func(page VPNLinkConnectionsClientGetAllSharedKeysResponse) bool {
    59  			return page.NextLink != nil && len(*page.NextLink) > 0
    60  		},
    61  		Fetcher: func(ctx context.Context, page *VPNLinkConnectionsClientGetAllSharedKeysResponse) (VPNLinkConnectionsClientGetAllSharedKeysResponse, error) {
    62  			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "VPNLinkConnectionsClient.NewGetAllSharedKeysPager")
    63  			nextLink := ""
    64  			if page != nil {
    65  				nextLink = *page.NextLink
    66  			}
    67  			resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) {
    68  				return client.getAllSharedKeysCreateRequest(ctx, resourceGroupName, gatewayName, connectionName, linkConnectionName, options)
    69  			}, nil)
    70  			if err != nil {
    71  				return VPNLinkConnectionsClientGetAllSharedKeysResponse{}, err
    72  			}
    73  			return client.getAllSharedKeysHandleResponse(resp)
    74  		},
    75  		Tracer: client.internal.Tracer(),
    76  	})
    77  }
    78  
    79  // getAllSharedKeysCreateRequest creates the GetAllSharedKeys request.
    80  func (client *VPNLinkConnectionsClient) getAllSharedKeysCreateRequest(ctx context.Context, resourceGroupName string, gatewayName string, connectionName string, linkConnectionName string, options *VPNLinkConnectionsClientGetAllSharedKeysOptions) (*policy.Request, error) {
    81  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/vpnGateways/{gatewayName}/vpnConnections/{connectionName}/vpnLinkConnections/{linkConnectionName}/sharedKeys"
    82  	if client.subscriptionID == "" {
    83  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
    84  	}
    85  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
    86  	if resourceGroupName == "" {
    87  		return nil, errors.New("parameter resourceGroupName cannot be empty")
    88  	}
    89  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
    90  	if gatewayName == "" {
    91  		return nil, errors.New("parameter gatewayName cannot be empty")
    92  	}
    93  	urlPath = strings.ReplaceAll(urlPath, "{gatewayName}", url.PathEscape(gatewayName))
    94  	if connectionName == "" {
    95  		return nil, errors.New("parameter connectionName cannot be empty")
    96  	}
    97  	urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName))
    98  	if linkConnectionName == "" {
    99  		return nil, errors.New("parameter linkConnectionName cannot be empty")
   100  	}
   101  	urlPath = strings.ReplaceAll(urlPath, "{linkConnectionName}", url.PathEscape(linkConnectionName))
   102  	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   103  	if err != nil {
   104  		return nil, err
   105  	}
   106  	reqQP := req.Raw().URL.Query()
   107  	reqQP.Set("api-version", "2024-05-01")
   108  	req.Raw().URL.RawQuery = reqQP.Encode()
   109  	req.Raw().Header["Accept"] = []string{"application/json"}
   110  	return req, nil
   111  }
   112  
   113  // getAllSharedKeysHandleResponse handles the GetAllSharedKeys response.
   114  func (client *VPNLinkConnectionsClient) getAllSharedKeysHandleResponse(resp *http.Response) (VPNLinkConnectionsClientGetAllSharedKeysResponse, error) {
   115  	result := VPNLinkConnectionsClientGetAllSharedKeysResponse{}
   116  	if err := runtime.UnmarshalAsJSON(resp, &result.ConnectionSharedKeyResultList); err != nil {
   117  		return VPNLinkConnectionsClientGetAllSharedKeysResponse{}, err
   118  	}
   119  	return result, nil
   120  }
   121  
   122  // GetDefaultSharedKey - Gets the shared key of VpnLink connection specified.
   123  // If the operation fails it returns an *azcore.ResponseError type.
   124  //
   125  // Generated from API version 2024-05-01
   126  //   - resourceGroupName - The name of the resource group.
   127  //   - gatewayName - The name of the gateway.
   128  //   - connectionName - The name of the vpn connection.
   129  //   - linkConnectionName - The name of the vpn link connection.
   130  //   - options - VPNLinkConnectionsClientGetDefaultSharedKeyOptions contains the optional parameters for the VPNLinkConnectionsClient.GetDefaultSharedKey
   131  //     method.
   132  func (client *VPNLinkConnectionsClient) GetDefaultSharedKey(ctx context.Context, resourceGroupName string, gatewayName string, connectionName string, linkConnectionName string, options *VPNLinkConnectionsClientGetDefaultSharedKeyOptions) (VPNLinkConnectionsClientGetDefaultSharedKeyResponse, error) {
   133  	var err error
   134  	const operationName = "VPNLinkConnectionsClient.GetDefaultSharedKey"
   135  	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
   136  	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
   137  	defer func() { endSpan(err) }()
   138  	req, err := client.getDefaultSharedKeyCreateRequest(ctx, resourceGroupName, gatewayName, connectionName, linkConnectionName, options)
   139  	if err != nil {
   140  		return VPNLinkConnectionsClientGetDefaultSharedKeyResponse{}, err
   141  	}
   142  	httpResp, err := client.internal.Pipeline().Do(req)
   143  	if err != nil {
   144  		return VPNLinkConnectionsClientGetDefaultSharedKeyResponse{}, err
   145  	}
   146  	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
   147  		err = runtime.NewResponseError(httpResp)
   148  		return VPNLinkConnectionsClientGetDefaultSharedKeyResponse{}, err
   149  	}
   150  	resp, err := client.getDefaultSharedKeyHandleResponse(httpResp)
   151  	return resp, err
   152  }
   153  
   154  // getDefaultSharedKeyCreateRequest creates the GetDefaultSharedKey request.
   155  func (client *VPNLinkConnectionsClient) getDefaultSharedKeyCreateRequest(ctx context.Context, resourceGroupName string, gatewayName string, connectionName string, linkConnectionName string, options *VPNLinkConnectionsClientGetDefaultSharedKeyOptions) (*policy.Request, error) {
   156  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/vpnGateways/{gatewayName}/vpnConnections/{connectionName}/vpnLinkConnections/{linkConnectionName}/sharedKeys/default"
   157  	if client.subscriptionID == "" {
   158  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   159  	}
   160  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   161  	if resourceGroupName == "" {
   162  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   163  	}
   164  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   165  	if gatewayName == "" {
   166  		return nil, errors.New("parameter gatewayName cannot be empty")
   167  	}
   168  	urlPath = strings.ReplaceAll(urlPath, "{gatewayName}", url.PathEscape(gatewayName))
   169  	if connectionName == "" {
   170  		return nil, errors.New("parameter connectionName cannot be empty")
   171  	}
   172  	urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName))
   173  	if linkConnectionName == "" {
   174  		return nil, errors.New("parameter linkConnectionName cannot be empty")
   175  	}
   176  	urlPath = strings.ReplaceAll(urlPath, "{linkConnectionName}", url.PathEscape(linkConnectionName))
   177  	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   178  	if err != nil {
   179  		return nil, err
   180  	}
   181  	reqQP := req.Raw().URL.Query()
   182  	reqQP.Set("api-version", "2024-05-01")
   183  	req.Raw().URL.RawQuery = reqQP.Encode()
   184  	req.Raw().Header["Accept"] = []string{"application/json"}
   185  	return req, nil
   186  }
   187  
   188  // getDefaultSharedKeyHandleResponse handles the GetDefaultSharedKey response.
   189  func (client *VPNLinkConnectionsClient) getDefaultSharedKeyHandleResponse(resp *http.Response) (VPNLinkConnectionsClientGetDefaultSharedKeyResponse, error) {
   190  	result := VPNLinkConnectionsClientGetDefaultSharedKeyResponse{}
   191  	if err := runtime.UnmarshalAsJSON(resp, &result.ConnectionSharedKeyResult); err != nil {
   192  		return VPNLinkConnectionsClientGetDefaultSharedKeyResponse{}, err
   193  	}
   194  	return result, nil
   195  }
   196  
   197  // BeginGetIkeSas - Lists IKE Security Associations for Vpn Site Link Connection in the specified resource group.
   198  // If the operation fails it returns an *azcore.ResponseError type.
   199  //
   200  // Generated from API version 2024-05-01
   201  //   - resourceGroupName - The name of the resource group.
   202  //   - gatewayName - The name of the gateway.
   203  //   - connectionName - The name of the vpn connection.
   204  //   - linkConnectionName - The name of the vpn link connection.
   205  //   - options - VPNLinkConnectionsClientBeginGetIkeSasOptions contains the optional parameters for the VPNLinkConnectionsClient.BeginGetIkeSas
   206  //     method.
   207  func (client *VPNLinkConnectionsClient) BeginGetIkeSas(ctx context.Context, resourceGroupName string, gatewayName string, connectionName string, linkConnectionName string, options *VPNLinkConnectionsClientBeginGetIkeSasOptions) (*runtime.Poller[VPNLinkConnectionsClientGetIkeSasResponse], error) {
   208  	if options == nil || options.ResumeToken == "" {
   209  		resp, err := client.getIkeSas(ctx, resourceGroupName, gatewayName, connectionName, linkConnectionName, options)
   210  		if err != nil {
   211  			return nil, err
   212  		}
   213  		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VPNLinkConnectionsClientGetIkeSasResponse]{
   214  			FinalStateVia: runtime.FinalStateViaLocation,
   215  			Tracer:        client.internal.Tracer(),
   216  		})
   217  		return poller, err
   218  	} else {
   219  		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VPNLinkConnectionsClientGetIkeSasResponse]{
   220  			Tracer: client.internal.Tracer(),
   221  		})
   222  	}
   223  }
   224  
   225  // GetIkeSas - Lists IKE Security Associations for Vpn Site Link Connection in the specified resource group.
   226  // If the operation fails it returns an *azcore.ResponseError type.
   227  //
   228  // Generated from API version 2024-05-01
   229  func (client *VPNLinkConnectionsClient) getIkeSas(ctx context.Context, resourceGroupName string, gatewayName string, connectionName string, linkConnectionName string, options *VPNLinkConnectionsClientBeginGetIkeSasOptions) (*http.Response, error) {
   230  	var err error
   231  	const operationName = "VPNLinkConnectionsClient.BeginGetIkeSas"
   232  	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
   233  	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
   234  	defer func() { endSpan(err) }()
   235  	req, err := client.getIkeSasCreateRequest(ctx, resourceGroupName, gatewayName, connectionName, linkConnectionName, options)
   236  	if err != nil {
   237  		return nil, err
   238  	}
   239  	httpResp, err := client.internal.Pipeline().Do(req)
   240  	if err != nil {
   241  		return nil, err
   242  	}
   243  	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) {
   244  		err = runtime.NewResponseError(httpResp)
   245  		return nil, err
   246  	}
   247  	return httpResp, nil
   248  }
   249  
   250  // getIkeSasCreateRequest creates the GetIkeSas request.
   251  func (client *VPNLinkConnectionsClient) getIkeSasCreateRequest(ctx context.Context, resourceGroupName string, gatewayName string, connectionName string, linkConnectionName string, options *VPNLinkConnectionsClientBeginGetIkeSasOptions) (*policy.Request, error) {
   252  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/vpnGateways/{gatewayName}/vpnConnections/{connectionName}/vpnLinkConnections/{linkConnectionName}/getikesas"
   253  	if client.subscriptionID == "" {
   254  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   255  	}
   256  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   257  	if resourceGroupName == "" {
   258  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   259  	}
   260  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   261  	if gatewayName == "" {
   262  		return nil, errors.New("parameter gatewayName cannot be empty")
   263  	}
   264  	urlPath = strings.ReplaceAll(urlPath, "{gatewayName}", url.PathEscape(gatewayName))
   265  	if connectionName == "" {
   266  		return nil, errors.New("parameter connectionName cannot be empty")
   267  	}
   268  	urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName))
   269  	if linkConnectionName == "" {
   270  		return nil, errors.New("parameter linkConnectionName cannot be empty")
   271  	}
   272  	urlPath = strings.ReplaceAll(urlPath, "{linkConnectionName}", url.PathEscape(linkConnectionName))
   273  	req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   274  	if err != nil {
   275  		return nil, err
   276  	}
   277  	reqQP := req.Raw().URL.Query()
   278  	reqQP.Set("api-version", "2024-05-01")
   279  	req.Raw().URL.RawQuery = reqQP.Encode()
   280  	req.Raw().Header["Accept"] = []string{"application/json"}
   281  	return req, nil
   282  }
   283  
   284  // NewListByVPNConnectionPager - Retrieves all vpn site link connections for a particular virtual wan vpn gateway vpn connection.
   285  //
   286  // Generated from API version 2024-05-01
   287  //   - resourceGroupName - The resource group name of the vpn gateway.
   288  //   - gatewayName - The name of the gateway.
   289  //   - connectionName - The name of the vpn connection.
   290  //   - options - VPNLinkConnectionsClientListByVPNConnectionOptions contains the optional parameters for the VPNLinkConnectionsClient.NewListByVPNConnectionPager
   291  //     method.
   292  func (client *VPNLinkConnectionsClient) NewListByVPNConnectionPager(resourceGroupName string, gatewayName string, connectionName string, options *VPNLinkConnectionsClientListByVPNConnectionOptions) *runtime.Pager[VPNLinkConnectionsClientListByVPNConnectionResponse] {
   293  	return runtime.NewPager(runtime.PagingHandler[VPNLinkConnectionsClientListByVPNConnectionResponse]{
   294  		More: func(page VPNLinkConnectionsClientListByVPNConnectionResponse) bool {
   295  			return page.NextLink != nil && len(*page.NextLink) > 0
   296  		},
   297  		Fetcher: func(ctx context.Context, page *VPNLinkConnectionsClientListByVPNConnectionResponse) (VPNLinkConnectionsClientListByVPNConnectionResponse, error) {
   298  			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "VPNLinkConnectionsClient.NewListByVPNConnectionPager")
   299  			nextLink := ""
   300  			if page != nil {
   301  				nextLink = *page.NextLink
   302  			}
   303  			resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) {
   304  				return client.listByVPNConnectionCreateRequest(ctx, resourceGroupName, gatewayName, connectionName, options)
   305  			}, nil)
   306  			if err != nil {
   307  				return VPNLinkConnectionsClientListByVPNConnectionResponse{}, err
   308  			}
   309  			return client.listByVPNConnectionHandleResponse(resp)
   310  		},
   311  		Tracer: client.internal.Tracer(),
   312  	})
   313  }
   314  
   315  // listByVPNConnectionCreateRequest creates the ListByVPNConnection request.
   316  func (client *VPNLinkConnectionsClient) listByVPNConnectionCreateRequest(ctx context.Context, resourceGroupName string, gatewayName string, connectionName string, options *VPNLinkConnectionsClientListByVPNConnectionOptions) (*policy.Request, error) {
   317  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/vpnGateways/{gatewayName}/vpnConnections/{connectionName}/vpnLinkConnections"
   318  	if client.subscriptionID == "" {
   319  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   320  	}
   321  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   322  	if resourceGroupName == "" {
   323  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   324  	}
   325  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   326  	if gatewayName == "" {
   327  		return nil, errors.New("parameter gatewayName cannot be empty")
   328  	}
   329  	urlPath = strings.ReplaceAll(urlPath, "{gatewayName}", url.PathEscape(gatewayName))
   330  	if connectionName == "" {
   331  		return nil, errors.New("parameter connectionName cannot be empty")
   332  	}
   333  	urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName))
   334  	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   335  	if err != nil {
   336  		return nil, err
   337  	}
   338  	reqQP := req.Raw().URL.Query()
   339  	reqQP.Set("api-version", "2024-05-01")
   340  	req.Raw().URL.RawQuery = reqQP.Encode()
   341  	req.Raw().Header["Accept"] = []string{"application/json"}
   342  	return req, nil
   343  }
   344  
   345  // listByVPNConnectionHandleResponse handles the ListByVPNConnection response.
   346  func (client *VPNLinkConnectionsClient) listByVPNConnectionHandleResponse(resp *http.Response) (VPNLinkConnectionsClientListByVPNConnectionResponse, error) {
   347  	result := VPNLinkConnectionsClientListByVPNConnectionResponse{}
   348  	if err := runtime.UnmarshalAsJSON(resp, &result.ListVPNSiteLinkConnectionsResult); err != nil {
   349  		return VPNLinkConnectionsClientListByVPNConnectionResponse{}, err
   350  	}
   351  	return result, nil
   352  }
   353  
   354  // ListDefaultSharedKey - Gets the value of the shared key of VpnLink connection specified.
   355  // If the operation fails it returns an *azcore.ResponseError type.
   356  //
   357  // Generated from API version 2024-05-01
   358  //   - resourceGroupName - The name of the resource group.
   359  //   - gatewayName - The name of the gateway.
   360  //   - connectionName - The name of the vpn connection.
   361  //   - linkConnectionName - The name of the vpn link connection.
   362  //   - options - VPNLinkConnectionsClientListDefaultSharedKeyOptions contains the optional parameters for the VPNLinkConnectionsClient.ListDefaultSharedKey
   363  //     method.
   364  func (client *VPNLinkConnectionsClient) ListDefaultSharedKey(ctx context.Context, resourceGroupName string, gatewayName string, connectionName string, linkConnectionName string, options *VPNLinkConnectionsClientListDefaultSharedKeyOptions) (VPNLinkConnectionsClientListDefaultSharedKeyResponse, error) {
   365  	var err error
   366  	const operationName = "VPNLinkConnectionsClient.ListDefaultSharedKey"
   367  	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
   368  	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
   369  	defer func() { endSpan(err) }()
   370  	req, err := client.listDefaultSharedKeyCreateRequest(ctx, resourceGroupName, gatewayName, connectionName, linkConnectionName, options)
   371  	if err != nil {
   372  		return VPNLinkConnectionsClientListDefaultSharedKeyResponse{}, err
   373  	}
   374  	httpResp, err := client.internal.Pipeline().Do(req)
   375  	if err != nil {
   376  		return VPNLinkConnectionsClientListDefaultSharedKeyResponse{}, err
   377  	}
   378  	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
   379  		err = runtime.NewResponseError(httpResp)
   380  		return VPNLinkConnectionsClientListDefaultSharedKeyResponse{}, err
   381  	}
   382  	resp, err := client.listDefaultSharedKeyHandleResponse(httpResp)
   383  	return resp, err
   384  }
   385  
   386  // listDefaultSharedKeyCreateRequest creates the ListDefaultSharedKey request.
   387  func (client *VPNLinkConnectionsClient) listDefaultSharedKeyCreateRequest(ctx context.Context, resourceGroupName string, gatewayName string, connectionName string, linkConnectionName string, options *VPNLinkConnectionsClientListDefaultSharedKeyOptions) (*policy.Request, error) {
   388  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/vpnGateways/{gatewayName}/vpnConnections/{connectionName}/vpnLinkConnections/{linkConnectionName}/sharedKeys/default/listSharedKey"
   389  	if client.subscriptionID == "" {
   390  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   391  	}
   392  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   393  	if resourceGroupName == "" {
   394  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   395  	}
   396  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   397  	if gatewayName == "" {
   398  		return nil, errors.New("parameter gatewayName cannot be empty")
   399  	}
   400  	urlPath = strings.ReplaceAll(urlPath, "{gatewayName}", url.PathEscape(gatewayName))
   401  	if connectionName == "" {
   402  		return nil, errors.New("parameter connectionName cannot be empty")
   403  	}
   404  	urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName))
   405  	if linkConnectionName == "" {
   406  		return nil, errors.New("parameter linkConnectionName cannot be empty")
   407  	}
   408  	urlPath = strings.ReplaceAll(urlPath, "{linkConnectionName}", url.PathEscape(linkConnectionName))
   409  	req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   410  	if err != nil {
   411  		return nil, err
   412  	}
   413  	reqQP := req.Raw().URL.Query()
   414  	reqQP.Set("api-version", "2024-05-01")
   415  	req.Raw().URL.RawQuery = reqQP.Encode()
   416  	req.Raw().Header["Accept"] = []string{"application/json"}
   417  	return req, nil
   418  }
   419  
   420  // listDefaultSharedKeyHandleResponse handles the ListDefaultSharedKey response.
   421  func (client *VPNLinkConnectionsClient) listDefaultSharedKeyHandleResponse(resp *http.Response) (VPNLinkConnectionsClientListDefaultSharedKeyResponse, error) {
   422  	result := VPNLinkConnectionsClientListDefaultSharedKeyResponse{}
   423  	if err := runtime.UnmarshalAsJSON(resp, &result.ConnectionSharedKeyResult); err != nil {
   424  		return VPNLinkConnectionsClientListDefaultSharedKeyResponse{}, err
   425  	}
   426  	return result, nil
   427  }
   428  
   429  // BeginResetConnection - Resets the VpnLink connection specified.
   430  // If the operation fails it returns an *azcore.ResponseError type.
   431  //
   432  // Generated from API version 2024-05-01
   433  //   - resourceGroupName - The name of the resource group.
   434  //   - gatewayName - The name of the gateway.
   435  //   - connectionName - The name of the vpn connection.
   436  //   - linkConnectionName - The name of the vpn link connection.
   437  //   - options - VPNLinkConnectionsClientBeginResetConnectionOptions contains the optional parameters for the VPNLinkConnectionsClient.BeginResetConnection
   438  //     method.
   439  func (client *VPNLinkConnectionsClient) BeginResetConnection(ctx context.Context, resourceGroupName string, gatewayName string, connectionName string, linkConnectionName string, options *VPNLinkConnectionsClientBeginResetConnectionOptions) (*runtime.Poller[VPNLinkConnectionsClientResetConnectionResponse], error) {
   440  	if options == nil || options.ResumeToken == "" {
   441  		resp, err := client.resetConnection(ctx, resourceGroupName, gatewayName, connectionName, linkConnectionName, options)
   442  		if err != nil {
   443  			return nil, err
   444  		}
   445  		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VPNLinkConnectionsClientResetConnectionResponse]{
   446  			FinalStateVia: runtime.FinalStateViaLocation,
   447  			Tracer:        client.internal.Tracer(),
   448  		})
   449  		return poller, err
   450  	} else {
   451  		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VPNLinkConnectionsClientResetConnectionResponse]{
   452  			Tracer: client.internal.Tracer(),
   453  		})
   454  	}
   455  }
   456  
   457  // ResetConnection - Resets the VpnLink connection specified.
   458  // If the operation fails it returns an *azcore.ResponseError type.
   459  //
   460  // Generated from API version 2024-05-01
   461  func (client *VPNLinkConnectionsClient) resetConnection(ctx context.Context, resourceGroupName string, gatewayName string, connectionName string, linkConnectionName string, options *VPNLinkConnectionsClientBeginResetConnectionOptions) (*http.Response, error) {
   462  	var err error
   463  	const operationName = "VPNLinkConnectionsClient.BeginResetConnection"
   464  	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
   465  	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
   466  	defer func() { endSpan(err) }()
   467  	req, err := client.resetConnectionCreateRequest(ctx, resourceGroupName, gatewayName, connectionName, linkConnectionName, options)
   468  	if err != nil {
   469  		return nil, err
   470  	}
   471  	httpResp, err := client.internal.Pipeline().Do(req)
   472  	if err != nil {
   473  		return nil, err
   474  	}
   475  	if !runtime.HasStatusCode(httpResp, http.StatusAccepted) {
   476  		err = runtime.NewResponseError(httpResp)
   477  		return nil, err
   478  	}
   479  	return httpResp, nil
   480  }
   481  
   482  // resetConnectionCreateRequest creates the ResetConnection request.
   483  func (client *VPNLinkConnectionsClient) resetConnectionCreateRequest(ctx context.Context, resourceGroupName string, gatewayName string, connectionName string, linkConnectionName string, options *VPNLinkConnectionsClientBeginResetConnectionOptions) (*policy.Request, error) {
   484  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/vpnGateways/{gatewayName}/vpnConnections/{connectionName}/vpnLinkConnections/{linkConnectionName}/resetconnection"
   485  	if client.subscriptionID == "" {
   486  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   487  	}
   488  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   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 connectionName == "" {
   498  		return nil, errors.New("parameter connectionName cannot be empty")
   499  	}
   500  	urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName))
   501  	if linkConnectionName == "" {
   502  		return nil, errors.New("parameter linkConnectionName cannot be empty")
   503  	}
   504  	urlPath = strings.ReplaceAll(urlPath, "{linkConnectionName}", url.PathEscape(linkConnectionName))
   505  	req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   506  	if err != nil {
   507  		return nil, err
   508  	}
   509  	reqQP := req.Raw().URL.Query()
   510  	reqQP.Set("api-version", "2024-05-01")
   511  	req.Raw().URL.RawQuery = reqQP.Encode()
   512  	req.Raw().Header["Accept"] = []string{"application/json"}
   513  	return req, nil
   514  }
   515  
   516  // BeginSetOrInitDefaultSharedKey - Sets or auto generates the shared key based on the user input. If users give a shared
   517  // key value, it does the set operation. If key length is given, the operation creates a random key of the
   518  // pre-defined length.
   519  // If the operation fails it returns an *azcore.ResponseError type.
   520  //
   521  // Generated from API version 2024-05-01
   522  //   - resourceGroupName - The resource group name of the VpnGateway.
   523  //   - gatewayName - The name of the gateway.
   524  //   - connectionName - The name of the connection.
   525  //   - linkConnectionName - The name of the vpn link connection.
   526  //   - connectionSharedKeyParameters - Parameters supplied to set or auto generate the shared key for the vpn link connection.
   527  //   - options - VPNLinkConnectionsClientBeginSetOrInitDefaultSharedKeyOptions contains the optional parameters for the VPNLinkConnectionsClient.BeginSetOrInitDefaultSharedKey
   528  //     method.
   529  func (client *VPNLinkConnectionsClient) BeginSetOrInitDefaultSharedKey(ctx context.Context, resourceGroupName string, gatewayName string, connectionName string, linkConnectionName string, connectionSharedKeyParameters ConnectionSharedKeyResult, options *VPNLinkConnectionsClientBeginSetOrInitDefaultSharedKeyOptions) (*runtime.Poller[VPNLinkConnectionsClientSetOrInitDefaultSharedKeyResponse], error) {
   530  	if options == nil || options.ResumeToken == "" {
   531  		resp, err := client.setOrInitDefaultSharedKey(ctx, resourceGroupName, gatewayName, connectionName, linkConnectionName, connectionSharedKeyParameters, options)
   532  		if err != nil {
   533  			return nil, err
   534  		}
   535  		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VPNLinkConnectionsClientSetOrInitDefaultSharedKeyResponse]{
   536  			FinalStateVia: runtime.FinalStateViaAzureAsyncOp,
   537  			Tracer:        client.internal.Tracer(),
   538  		})
   539  		return poller, err
   540  	} else {
   541  		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VPNLinkConnectionsClientSetOrInitDefaultSharedKeyResponse]{
   542  			Tracer: client.internal.Tracer(),
   543  		})
   544  	}
   545  }
   546  
   547  // SetOrInitDefaultSharedKey - Sets or auto generates the shared key based on the user input. If users give a shared key value,
   548  // it does the set operation. If key length is given, the operation creates a random key of the
   549  // pre-defined length.
   550  // If the operation fails it returns an *azcore.ResponseError type.
   551  //
   552  // Generated from API version 2024-05-01
   553  func (client *VPNLinkConnectionsClient) setOrInitDefaultSharedKey(ctx context.Context, resourceGroupName string, gatewayName string, connectionName string, linkConnectionName string, connectionSharedKeyParameters ConnectionSharedKeyResult, options *VPNLinkConnectionsClientBeginSetOrInitDefaultSharedKeyOptions) (*http.Response, error) {
   554  	var err error
   555  	const operationName = "VPNLinkConnectionsClient.BeginSetOrInitDefaultSharedKey"
   556  	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
   557  	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
   558  	defer func() { endSpan(err) }()
   559  	req, err := client.setOrInitDefaultSharedKeyCreateRequest(ctx, resourceGroupName, gatewayName, connectionName, linkConnectionName, connectionSharedKeyParameters, options)
   560  	if err != nil {
   561  		return nil, err
   562  	}
   563  	httpResp, err := client.internal.Pipeline().Do(req)
   564  	if err != nil {
   565  		return nil, err
   566  	}
   567  	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) {
   568  		err = runtime.NewResponseError(httpResp)
   569  		return nil, err
   570  	}
   571  	return httpResp, nil
   572  }
   573  
   574  // setOrInitDefaultSharedKeyCreateRequest creates the SetOrInitDefaultSharedKey request.
   575  func (client *VPNLinkConnectionsClient) setOrInitDefaultSharedKeyCreateRequest(ctx context.Context, resourceGroupName string, gatewayName string, connectionName string, linkConnectionName string, connectionSharedKeyParameters ConnectionSharedKeyResult, options *VPNLinkConnectionsClientBeginSetOrInitDefaultSharedKeyOptions) (*policy.Request, error) {
   576  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/vpnGateways/{gatewayName}/vpnConnections/{connectionName}/vpnLinkConnections/{linkConnectionName}/sharedKeys/default"
   577  	if client.subscriptionID == "" {
   578  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   579  	}
   580  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   581  	if resourceGroupName == "" {
   582  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   583  	}
   584  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   585  	if gatewayName == "" {
   586  		return nil, errors.New("parameter gatewayName cannot be empty")
   587  	}
   588  	urlPath = strings.ReplaceAll(urlPath, "{gatewayName}", url.PathEscape(gatewayName))
   589  	if connectionName == "" {
   590  		return nil, errors.New("parameter connectionName cannot be empty")
   591  	}
   592  	urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName))
   593  	if linkConnectionName == "" {
   594  		return nil, errors.New("parameter linkConnectionName cannot be empty")
   595  	}
   596  	urlPath = strings.ReplaceAll(urlPath, "{linkConnectionName}", url.PathEscape(linkConnectionName))
   597  	req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   598  	if err != nil {
   599  		return nil, err
   600  	}
   601  	reqQP := req.Raw().URL.Query()
   602  	reqQP.Set("api-version", "2024-05-01")
   603  	req.Raw().URL.RawQuery = reqQP.Encode()
   604  	req.Raw().Header["Accept"] = []string{"application/json"}
   605  	if err := runtime.MarshalAsJSON(req, connectionSharedKeyParameters); err != nil {
   606  		return nil, err
   607  	}
   608  	return req, nil
   609  }