github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6@v6.2.0/privatelinkservices_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  // PrivateLinkServicesClient contains the methods for the PrivateLinkServices group.
    24  // Don't use this type directly, use NewPrivateLinkServicesClient() instead.
    25  type PrivateLinkServicesClient struct {
    26  	internal       *arm.Client
    27  	subscriptionID string
    28  }
    29  
    30  // NewPrivateLinkServicesClient creates a new instance of PrivateLinkServicesClient 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 NewPrivateLinkServicesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateLinkServicesClient, error) {
    36  	cl, err := arm.NewClient(moduleName, moduleVersion, credential, options)
    37  	if err != nil {
    38  		return nil, err
    39  	}
    40  	client := &PrivateLinkServicesClient{
    41  		subscriptionID: subscriptionID,
    42  		internal:       cl,
    43  	}
    44  	return client, nil
    45  }
    46  
    47  // BeginCheckPrivateLinkServiceVisibility - Checks whether the subscription is visible to private link service.
    48  // If the operation fails it returns an *azcore.ResponseError type.
    49  //
    50  // Generated from API version 2024-05-01
    51  //   - location - The location of the domain name.
    52  //   - parameters - The request body of CheckPrivateLinkService API call.
    53  //   - options - PrivateLinkServicesClientBeginCheckPrivateLinkServiceVisibilityOptions contains the optional parameters for the
    54  //     PrivateLinkServicesClient.BeginCheckPrivateLinkServiceVisibility method.
    55  func (client *PrivateLinkServicesClient) BeginCheckPrivateLinkServiceVisibility(ctx context.Context, location string, parameters CheckPrivateLinkServiceVisibilityRequest, options *PrivateLinkServicesClientBeginCheckPrivateLinkServiceVisibilityOptions) (*runtime.Poller[PrivateLinkServicesClientCheckPrivateLinkServiceVisibilityResponse], error) {
    56  	if options == nil || options.ResumeToken == "" {
    57  		resp, err := client.checkPrivateLinkServiceVisibility(ctx, location, parameters, options)
    58  		if err != nil {
    59  			return nil, err
    60  		}
    61  		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PrivateLinkServicesClientCheckPrivateLinkServiceVisibilityResponse]{
    62  			FinalStateVia: runtime.FinalStateViaLocation,
    63  			Tracer:        client.internal.Tracer(),
    64  		})
    65  		return poller, err
    66  	} else {
    67  		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PrivateLinkServicesClientCheckPrivateLinkServiceVisibilityResponse]{
    68  			Tracer: client.internal.Tracer(),
    69  		})
    70  	}
    71  }
    72  
    73  // CheckPrivateLinkServiceVisibility - Checks whether the subscription is visible to private link service.
    74  // If the operation fails it returns an *azcore.ResponseError type.
    75  //
    76  // Generated from API version 2024-05-01
    77  func (client *PrivateLinkServicesClient) checkPrivateLinkServiceVisibility(ctx context.Context, location string, parameters CheckPrivateLinkServiceVisibilityRequest, options *PrivateLinkServicesClientBeginCheckPrivateLinkServiceVisibilityOptions) (*http.Response, error) {
    78  	var err error
    79  	const operationName = "PrivateLinkServicesClient.BeginCheckPrivateLinkServiceVisibility"
    80  	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
    81  	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
    82  	defer func() { endSpan(err) }()
    83  	req, err := client.checkPrivateLinkServiceVisibilityCreateRequest(ctx, location, parameters, options)
    84  	if err != nil {
    85  		return nil, err
    86  	}
    87  	httpResp, err := client.internal.Pipeline().Do(req)
    88  	if err != nil {
    89  		return nil, err
    90  	}
    91  	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) {
    92  		err = runtime.NewResponseError(httpResp)
    93  		return nil, err
    94  	}
    95  	return httpResp, nil
    96  }
    97  
    98  // checkPrivateLinkServiceVisibilityCreateRequest creates the CheckPrivateLinkServiceVisibility request.
    99  func (client *PrivateLinkServicesClient) checkPrivateLinkServiceVisibilityCreateRequest(ctx context.Context, location string, parameters CheckPrivateLinkServiceVisibilityRequest, options *PrivateLinkServicesClientBeginCheckPrivateLinkServiceVisibilityOptions) (*policy.Request, error) {
   100  	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/checkPrivateLinkServiceVisibility"
   101  	if location == "" {
   102  		return nil, errors.New("parameter location cannot be empty")
   103  	}
   104  	urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location))
   105  	if client.subscriptionID == "" {
   106  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   107  	}
   108  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   109  	req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   110  	if err != nil {
   111  		return nil, err
   112  	}
   113  	reqQP := req.Raw().URL.Query()
   114  	reqQP.Set("api-version", "2024-05-01")
   115  	req.Raw().URL.RawQuery = reqQP.Encode()
   116  	req.Raw().Header["Accept"] = []string{"application/json"}
   117  	if err := runtime.MarshalAsJSON(req, parameters); err != nil {
   118  		return nil, err
   119  	}
   120  	return req, nil
   121  }
   122  
   123  // BeginCheckPrivateLinkServiceVisibilityByResourceGroup - Checks whether the subscription is visible to private link service
   124  // in the specified resource group.
   125  // If the operation fails it returns an *azcore.ResponseError type.
   126  //
   127  // Generated from API version 2024-05-01
   128  //   - location - The location of the domain name.
   129  //   - resourceGroupName - The name of the resource group.
   130  //   - parameters - The request body of CheckPrivateLinkService API call.
   131  //   - options - PrivateLinkServicesClientBeginCheckPrivateLinkServiceVisibilityByResourceGroupOptions contains the optional parameters
   132  //     for the PrivateLinkServicesClient.BeginCheckPrivateLinkServiceVisibilityByResourceGroup method.
   133  func (client *PrivateLinkServicesClient) BeginCheckPrivateLinkServiceVisibilityByResourceGroup(ctx context.Context, location string, resourceGroupName string, parameters CheckPrivateLinkServiceVisibilityRequest, options *PrivateLinkServicesClientBeginCheckPrivateLinkServiceVisibilityByResourceGroupOptions) (*runtime.Poller[PrivateLinkServicesClientCheckPrivateLinkServiceVisibilityByResourceGroupResponse], error) {
   134  	if options == nil || options.ResumeToken == "" {
   135  		resp, err := client.checkPrivateLinkServiceVisibilityByResourceGroup(ctx, location, resourceGroupName, parameters, options)
   136  		if err != nil {
   137  			return nil, err
   138  		}
   139  		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PrivateLinkServicesClientCheckPrivateLinkServiceVisibilityByResourceGroupResponse]{
   140  			FinalStateVia: runtime.FinalStateViaLocation,
   141  			Tracer:        client.internal.Tracer(),
   142  		})
   143  		return poller, err
   144  	} else {
   145  		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PrivateLinkServicesClientCheckPrivateLinkServiceVisibilityByResourceGroupResponse]{
   146  			Tracer: client.internal.Tracer(),
   147  		})
   148  	}
   149  }
   150  
   151  // CheckPrivateLinkServiceVisibilityByResourceGroup - Checks whether the subscription is visible to private link service in
   152  // the specified resource group.
   153  // If the operation fails it returns an *azcore.ResponseError type.
   154  //
   155  // Generated from API version 2024-05-01
   156  func (client *PrivateLinkServicesClient) checkPrivateLinkServiceVisibilityByResourceGroup(ctx context.Context, location string, resourceGroupName string, parameters CheckPrivateLinkServiceVisibilityRequest, options *PrivateLinkServicesClientBeginCheckPrivateLinkServiceVisibilityByResourceGroupOptions) (*http.Response, error) {
   157  	var err error
   158  	const operationName = "PrivateLinkServicesClient.BeginCheckPrivateLinkServiceVisibilityByResourceGroup"
   159  	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
   160  	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
   161  	defer func() { endSpan(err) }()
   162  	req, err := client.checkPrivateLinkServiceVisibilityByResourceGroupCreateRequest(ctx, location, resourceGroupName, parameters, options)
   163  	if err != nil {
   164  		return nil, err
   165  	}
   166  	httpResp, err := client.internal.Pipeline().Do(req)
   167  	if err != nil {
   168  		return nil, err
   169  	}
   170  	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) {
   171  		err = runtime.NewResponseError(httpResp)
   172  		return nil, err
   173  	}
   174  	return httpResp, nil
   175  }
   176  
   177  // checkPrivateLinkServiceVisibilityByResourceGroupCreateRequest creates the CheckPrivateLinkServiceVisibilityByResourceGroup request.
   178  func (client *PrivateLinkServicesClient) checkPrivateLinkServiceVisibilityByResourceGroupCreateRequest(ctx context.Context, location string, resourceGroupName string, parameters CheckPrivateLinkServiceVisibilityRequest, options *PrivateLinkServicesClientBeginCheckPrivateLinkServiceVisibilityByResourceGroupOptions) (*policy.Request, error) {
   179  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/locations/{location}/checkPrivateLinkServiceVisibility"
   180  	if location == "" {
   181  		return nil, errors.New("parameter location cannot be empty")
   182  	}
   183  	urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location))
   184  	if resourceGroupName == "" {
   185  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   186  	}
   187  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   188  	if client.subscriptionID == "" {
   189  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   190  	}
   191  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   192  	req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   193  	if err != nil {
   194  		return nil, err
   195  	}
   196  	reqQP := req.Raw().URL.Query()
   197  	reqQP.Set("api-version", "2024-05-01")
   198  	req.Raw().URL.RawQuery = reqQP.Encode()
   199  	req.Raw().Header["Accept"] = []string{"application/json"}
   200  	if err := runtime.MarshalAsJSON(req, parameters); err != nil {
   201  		return nil, err
   202  	}
   203  	return req, nil
   204  }
   205  
   206  // BeginCreateOrUpdate - Creates or updates an private link service in the specified resource 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  //   - serviceName - The name of the private link service.
   212  //   - parameters - Parameters supplied to the create or update private link service operation.
   213  //   - options - PrivateLinkServicesClientBeginCreateOrUpdateOptions contains the optional parameters for the PrivateLinkServicesClient.BeginCreateOrUpdate
   214  //     method.
   215  func (client *PrivateLinkServicesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, parameters PrivateLinkService, options *PrivateLinkServicesClientBeginCreateOrUpdateOptions) (*runtime.Poller[PrivateLinkServicesClientCreateOrUpdateResponse], error) {
   216  	if options == nil || options.ResumeToken == "" {
   217  		resp, err := client.createOrUpdate(ctx, resourceGroupName, serviceName, parameters, options)
   218  		if err != nil {
   219  			return nil, err
   220  		}
   221  		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PrivateLinkServicesClientCreateOrUpdateResponse]{
   222  			FinalStateVia: runtime.FinalStateViaAzureAsyncOp,
   223  			Tracer:        client.internal.Tracer(),
   224  		})
   225  		return poller, err
   226  	} else {
   227  		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PrivateLinkServicesClientCreateOrUpdateResponse]{
   228  			Tracer: client.internal.Tracer(),
   229  		})
   230  	}
   231  }
   232  
   233  // CreateOrUpdate - Creates or updates an private link service in the specified resource group.
   234  // If the operation fails it returns an *azcore.ResponseError type.
   235  //
   236  // Generated from API version 2024-05-01
   237  func (client *PrivateLinkServicesClient) createOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, parameters PrivateLinkService, options *PrivateLinkServicesClientBeginCreateOrUpdateOptions) (*http.Response, error) {
   238  	var err error
   239  	const operationName = "PrivateLinkServicesClient.BeginCreateOrUpdate"
   240  	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
   241  	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
   242  	defer func() { endSpan(err) }()
   243  	req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, parameters, options)
   244  	if err != nil {
   245  		return nil, err
   246  	}
   247  	httpResp, err := client.internal.Pipeline().Do(req)
   248  	if err != nil {
   249  		return nil, err
   250  	}
   251  	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) {
   252  		err = runtime.NewResponseError(httpResp)
   253  		return nil, err
   254  	}
   255  	return httpResp, nil
   256  }
   257  
   258  // createOrUpdateCreateRequest creates the CreateOrUpdate request.
   259  func (client *PrivateLinkServicesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, parameters PrivateLinkService, options *PrivateLinkServicesClientBeginCreateOrUpdateOptions) (*policy.Request, error) {
   260  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateLinkServices/{serviceName}"
   261  	if resourceGroupName == "" {
   262  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   263  	}
   264  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   265  	if serviceName == "" {
   266  		return nil, errors.New("parameter serviceName cannot be empty")
   267  	}
   268  	urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName))
   269  	if client.subscriptionID == "" {
   270  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   271  	}
   272  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   273  	req, err := runtime.NewRequest(ctx, http.MethodPut, 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  	if err := runtime.MarshalAsJSON(req, parameters); err != nil {
   282  		return nil, err
   283  	}
   284  	return req, nil
   285  }
   286  
   287  // BeginDelete - Deletes the specified private link service.
   288  // If the operation fails it returns an *azcore.ResponseError type.
   289  //
   290  // Generated from API version 2024-05-01
   291  //   - resourceGroupName - The name of the resource group.
   292  //   - serviceName - The name of the private link service.
   293  //   - options - PrivateLinkServicesClientBeginDeleteOptions contains the optional parameters for the PrivateLinkServicesClient.BeginDelete
   294  //     method.
   295  func (client *PrivateLinkServicesClient) BeginDelete(ctx context.Context, resourceGroupName string, serviceName string, options *PrivateLinkServicesClientBeginDeleteOptions) (*runtime.Poller[PrivateLinkServicesClientDeleteResponse], error) {
   296  	if options == nil || options.ResumeToken == "" {
   297  		resp, err := client.deleteOperation(ctx, resourceGroupName, serviceName, options)
   298  		if err != nil {
   299  			return nil, err
   300  		}
   301  		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PrivateLinkServicesClientDeleteResponse]{
   302  			FinalStateVia: runtime.FinalStateViaLocation,
   303  			Tracer:        client.internal.Tracer(),
   304  		})
   305  		return poller, err
   306  	} else {
   307  		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PrivateLinkServicesClientDeleteResponse]{
   308  			Tracer: client.internal.Tracer(),
   309  		})
   310  	}
   311  }
   312  
   313  // Delete - Deletes the specified private link service.
   314  // If the operation fails it returns an *azcore.ResponseError type.
   315  //
   316  // Generated from API version 2024-05-01
   317  func (client *PrivateLinkServicesClient) deleteOperation(ctx context.Context, resourceGroupName string, serviceName string, options *PrivateLinkServicesClientBeginDeleteOptions) (*http.Response, error) {
   318  	var err error
   319  	const operationName = "PrivateLinkServicesClient.BeginDelete"
   320  	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
   321  	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
   322  	defer func() { endSpan(err) }()
   323  	req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, options)
   324  	if err != nil {
   325  		return nil, err
   326  	}
   327  	httpResp, err := client.internal.Pipeline().Do(req)
   328  	if err != nil {
   329  		return nil, err
   330  	}
   331  	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) {
   332  		err = runtime.NewResponseError(httpResp)
   333  		return nil, err
   334  	}
   335  	return httpResp, nil
   336  }
   337  
   338  // deleteCreateRequest creates the Delete request.
   339  func (client *PrivateLinkServicesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *PrivateLinkServicesClientBeginDeleteOptions) (*policy.Request, error) {
   340  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateLinkServices/{serviceName}"
   341  	if resourceGroupName == "" {
   342  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   343  	}
   344  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   345  	if serviceName == "" {
   346  		return nil, errors.New("parameter serviceName cannot be empty")
   347  	}
   348  	urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName))
   349  	if client.subscriptionID == "" {
   350  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   351  	}
   352  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   353  	req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   354  	if err != nil {
   355  		return nil, err
   356  	}
   357  	reqQP := req.Raw().URL.Query()
   358  	reqQP.Set("api-version", "2024-05-01")
   359  	req.Raw().URL.RawQuery = reqQP.Encode()
   360  	req.Raw().Header["Accept"] = []string{"application/json"}
   361  	return req, nil
   362  }
   363  
   364  // BeginDeletePrivateEndpointConnection - Delete private end point connection for a private link service in a subscription.
   365  // If the operation fails it returns an *azcore.ResponseError type.
   366  //
   367  // Generated from API version 2024-05-01
   368  //   - resourceGroupName - The name of the resource group.
   369  //   - serviceName - The name of the private link service.
   370  //   - peConnectionName - The name of the private end point connection.
   371  //   - options - PrivateLinkServicesClientBeginDeletePrivateEndpointConnectionOptions contains the optional parameters for the
   372  //     PrivateLinkServicesClient.BeginDeletePrivateEndpointConnection method.
   373  func (client *PrivateLinkServicesClient) BeginDeletePrivateEndpointConnection(ctx context.Context, resourceGroupName string, serviceName string, peConnectionName string, options *PrivateLinkServicesClientBeginDeletePrivateEndpointConnectionOptions) (*runtime.Poller[PrivateLinkServicesClientDeletePrivateEndpointConnectionResponse], error) {
   374  	if options == nil || options.ResumeToken == "" {
   375  		resp, err := client.deletePrivateEndpointConnection(ctx, resourceGroupName, serviceName, peConnectionName, options)
   376  		if err != nil {
   377  			return nil, err
   378  		}
   379  		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PrivateLinkServicesClientDeletePrivateEndpointConnectionResponse]{
   380  			FinalStateVia: runtime.FinalStateViaLocation,
   381  			Tracer:        client.internal.Tracer(),
   382  		})
   383  		return poller, err
   384  	} else {
   385  		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PrivateLinkServicesClientDeletePrivateEndpointConnectionResponse]{
   386  			Tracer: client.internal.Tracer(),
   387  		})
   388  	}
   389  }
   390  
   391  // DeletePrivateEndpointConnection - Delete private end point connection for a private link service in a subscription.
   392  // If the operation fails it returns an *azcore.ResponseError type.
   393  //
   394  // Generated from API version 2024-05-01
   395  func (client *PrivateLinkServicesClient) deletePrivateEndpointConnection(ctx context.Context, resourceGroupName string, serviceName string, peConnectionName string, options *PrivateLinkServicesClientBeginDeletePrivateEndpointConnectionOptions) (*http.Response, error) {
   396  	var err error
   397  	const operationName = "PrivateLinkServicesClient.BeginDeletePrivateEndpointConnection"
   398  	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
   399  	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
   400  	defer func() { endSpan(err) }()
   401  	req, err := client.deletePrivateEndpointConnectionCreateRequest(ctx, resourceGroupName, serviceName, peConnectionName, options)
   402  	if err != nil {
   403  		return nil, err
   404  	}
   405  	httpResp, err := client.internal.Pipeline().Do(req)
   406  	if err != nil {
   407  		return nil, err
   408  	}
   409  	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) {
   410  		err = runtime.NewResponseError(httpResp)
   411  		return nil, err
   412  	}
   413  	return httpResp, nil
   414  }
   415  
   416  // deletePrivateEndpointConnectionCreateRequest creates the DeletePrivateEndpointConnection request.
   417  func (client *PrivateLinkServicesClient) deletePrivateEndpointConnectionCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, peConnectionName string, options *PrivateLinkServicesClientBeginDeletePrivateEndpointConnectionOptions) (*policy.Request, error) {
   418  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateLinkServices/{serviceName}/privateEndpointConnections/{peConnectionName}"
   419  	if resourceGroupName == "" {
   420  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   421  	}
   422  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   423  	if serviceName == "" {
   424  		return nil, errors.New("parameter serviceName cannot be empty")
   425  	}
   426  	urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName))
   427  	if peConnectionName == "" {
   428  		return nil, errors.New("parameter peConnectionName cannot be empty")
   429  	}
   430  	urlPath = strings.ReplaceAll(urlPath, "{peConnectionName}", url.PathEscape(peConnectionName))
   431  	if client.subscriptionID == "" {
   432  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   433  	}
   434  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   435  	req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   436  	if err != nil {
   437  		return nil, err
   438  	}
   439  	reqQP := req.Raw().URL.Query()
   440  	reqQP.Set("api-version", "2024-05-01")
   441  	req.Raw().URL.RawQuery = reqQP.Encode()
   442  	req.Raw().Header["Accept"] = []string{"application/json"}
   443  	return req, nil
   444  }
   445  
   446  // Get - Gets the specified private link service by resource group.
   447  // If the operation fails it returns an *azcore.ResponseError type.
   448  //
   449  // Generated from API version 2024-05-01
   450  //   - resourceGroupName - The name of the resource group.
   451  //   - serviceName - The name of the private link service.
   452  //   - options - PrivateLinkServicesClientGetOptions contains the optional parameters for the PrivateLinkServicesClient.Get method.
   453  func (client *PrivateLinkServicesClient) Get(ctx context.Context, resourceGroupName string, serviceName string, options *PrivateLinkServicesClientGetOptions) (PrivateLinkServicesClientGetResponse, error) {
   454  	var err error
   455  	const operationName = "PrivateLinkServicesClient.Get"
   456  	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
   457  	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
   458  	defer func() { endSpan(err) }()
   459  	req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, options)
   460  	if err != nil {
   461  		return PrivateLinkServicesClientGetResponse{}, err
   462  	}
   463  	httpResp, err := client.internal.Pipeline().Do(req)
   464  	if err != nil {
   465  		return PrivateLinkServicesClientGetResponse{}, err
   466  	}
   467  	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
   468  		err = runtime.NewResponseError(httpResp)
   469  		return PrivateLinkServicesClientGetResponse{}, err
   470  	}
   471  	resp, err := client.getHandleResponse(httpResp)
   472  	return resp, err
   473  }
   474  
   475  // getCreateRequest creates the Get request.
   476  func (client *PrivateLinkServicesClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *PrivateLinkServicesClientGetOptions) (*policy.Request, error) {
   477  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateLinkServices/{serviceName}"
   478  	if resourceGroupName == "" {
   479  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   480  	}
   481  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   482  	if serviceName == "" {
   483  		return nil, errors.New("parameter serviceName cannot be empty")
   484  	}
   485  	urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName))
   486  	if client.subscriptionID == "" {
   487  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   488  	}
   489  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   490  	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   491  	if err != nil {
   492  		return nil, err
   493  	}
   494  	reqQP := req.Raw().URL.Query()
   495  	if options != nil && options.Expand != nil {
   496  		reqQP.Set("$expand", *options.Expand)
   497  	}
   498  	reqQP.Set("api-version", "2024-05-01")
   499  	req.Raw().URL.RawQuery = reqQP.Encode()
   500  	req.Raw().Header["Accept"] = []string{"application/json"}
   501  	return req, nil
   502  }
   503  
   504  // getHandleResponse handles the Get response.
   505  func (client *PrivateLinkServicesClient) getHandleResponse(resp *http.Response) (PrivateLinkServicesClientGetResponse, error) {
   506  	result := PrivateLinkServicesClientGetResponse{}
   507  	if err := runtime.UnmarshalAsJSON(resp, &result.PrivateLinkService); err != nil {
   508  		return PrivateLinkServicesClientGetResponse{}, err
   509  	}
   510  	return result, nil
   511  }
   512  
   513  // GetPrivateEndpointConnection - Get the specific private end point connection by specific private link service in the resource
   514  // group.
   515  // If the operation fails it returns an *azcore.ResponseError type.
   516  //
   517  // Generated from API version 2024-05-01
   518  //   - resourceGroupName - The name of the resource group.
   519  //   - serviceName - The name of the private link service.
   520  //   - peConnectionName - The name of the private end point connection.
   521  //   - options - PrivateLinkServicesClientGetPrivateEndpointConnectionOptions contains the optional parameters for the PrivateLinkServicesClient.GetPrivateEndpointConnection
   522  //     method.
   523  func (client *PrivateLinkServicesClient) GetPrivateEndpointConnection(ctx context.Context, resourceGroupName string, serviceName string, peConnectionName string, options *PrivateLinkServicesClientGetPrivateEndpointConnectionOptions) (PrivateLinkServicesClientGetPrivateEndpointConnectionResponse, error) {
   524  	var err error
   525  	const operationName = "PrivateLinkServicesClient.GetPrivateEndpointConnection"
   526  	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
   527  	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
   528  	defer func() { endSpan(err) }()
   529  	req, err := client.getPrivateEndpointConnectionCreateRequest(ctx, resourceGroupName, serviceName, peConnectionName, options)
   530  	if err != nil {
   531  		return PrivateLinkServicesClientGetPrivateEndpointConnectionResponse{}, err
   532  	}
   533  	httpResp, err := client.internal.Pipeline().Do(req)
   534  	if err != nil {
   535  		return PrivateLinkServicesClientGetPrivateEndpointConnectionResponse{}, err
   536  	}
   537  	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
   538  		err = runtime.NewResponseError(httpResp)
   539  		return PrivateLinkServicesClientGetPrivateEndpointConnectionResponse{}, err
   540  	}
   541  	resp, err := client.getPrivateEndpointConnectionHandleResponse(httpResp)
   542  	return resp, err
   543  }
   544  
   545  // getPrivateEndpointConnectionCreateRequest creates the GetPrivateEndpointConnection request.
   546  func (client *PrivateLinkServicesClient) getPrivateEndpointConnectionCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, peConnectionName string, options *PrivateLinkServicesClientGetPrivateEndpointConnectionOptions) (*policy.Request, error) {
   547  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateLinkServices/{serviceName}/privateEndpointConnections/{peConnectionName}"
   548  	if resourceGroupName == "" {
   549  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   550  	}
   551  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   552  	if serviceName == "" {
   553  		return nil, errors.New("parameter serviceName cannot be empty")
   554  	}
   555  	urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName))
   556  	if peConnectionName == "" {
   557  		return nil, errors.New("parameter peConnectionName cannot be empty")
   558  	}
   559  	urlPath = strings.ReplaceAll(urlPath, "{peConnectionName}", url.PathEscape(peConnectionName))
   560  	if client.subscriptionID == "" {
   561  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   562  	}
   563  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   564  	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   565  	if err != nil {
   566  		return nil, err
   567  	}
   568  	reqQP := req.Raw().URL.Query()
   569  	if options != nil && options.Expand != nil {
   570  		reqQP.Set("$expand", *options.Expand)
   571  	}
   572  	reqQP.Set("api-version", "2024-05-01")
   573  	req.Raw().URL.RawQuery = reqQP.Encode()
   574  	req.Raw().Header["Accept"] = []string{"application/json"}
   575  	return req, nil
   576  }
   577  
   578  // getPrivateEndpointConnectionHandleResponse handles the GetPrivateEndpointConnection response.
   579  func (client *PrivateLinkServicesClient) getPrivateEndpointConnectionHandleResponse(resp *http.Response) (PrivateLinkServicesClientGetPrivateEndpointConnectionResponse, error) {
   580  	result := PrivateLinkServicesClientGetPrivateEndpointConnectionResponse{}
   581  	if err := runtime.UnmarshalAsJSON(resp, &result.PrivateEndpointConnection); err != nil {
   582  		return PrivateLinkServicesClientGetPrivateEndpointConnectionResponse{}, err
   583  	}
   584  	return result, nil
   585  }
   586  
   587  // NewListPager - Gets all private link services in a resource group.
   588  //
   589  // Generated from API version 2024-05-01
   590  //   - resourceGroupName - The name of the resource group.
   591  //   - options - PrivateLinkServicesClientListOptions contains the optional parameters for the PrivateLinkServicesClient.NewListPager
   592  //     method.
   593  func (client *PrivateLinkServicesClient) NewListPager(resourceGroupName string, options *PrivateLinkServicesClientListOptions) *runtime.Pager[PrivateLinkServicesClientListResponse] {
   594  	return runtime.NewPager(runtime.PagingHandler[PrivateLinkServicesClientListResponse]{
   595  		More: func(page PrivateLinkServicesClientListResponse) bool {
   596  			return page.NextLink != nil && len(*page.NextLink) > 0
   597  		},
   598  		Fetcher: func(ctx context.Context, page *PrivateLinkServicesClientListResponse) (PrivateLinkServicesClientListResponse, error) {
   599  			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PrivateLinkServicesClient.NewListPager")
   600  			nextLink := ""
   601  			if page != nil {
   602  				nextLink = *page.NextLink
   603  			}
   604  			resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) {
   605  				return client.listCreateRequest(ctx, resourceGroupName, options)
   606  			}, nil)
   607  			if err != nil {
   608  				return PrivateLinkServicesClientListResponse{}, err
   609  			}
   610  			return client.listHandleResponse(resp)
   611  		},
   612  		Tracer: client.internal.Tracer(),
   613  	})
   614  }
   615  
   616  // listCreateRequest creates the List request.
   617  func (client *PrivateLinkServicesClient) listCreateRequest(ctx context.Context, resourceGroupName string, options *PrivateLinkServicesClientListOptions) (*policy.Request, error) {
   618  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateLinkServices"
   619  	if resourceGroupName == "" {
   620  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   621  	}
   622  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   623  	if client.subscriptionID == "" {
   624  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   625  	}
   626  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   627  	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   628  	if err != nil {
   629  		return nil, err
   630  	}
   631  	reqQP := req.Raw().URL.Query()
   632  	reqQP.Set("api-version", "2024-05-01")
   633  	req.Raw().URL.RawQuery = reqQP.Encode()
   634  	req.Raw().Header["Accept"] = []string{"application/json"}
   635  	return req, nil
   636  }
   637  
   638  // listHandleResponse handles the List response.
   639  func (client *PrivateLinkServicesClient) listHandleResponse(resp *http.Response) (PrivateLinkServicesClientListResponse, error) {
   640  	result := PrivateLinkServicesClientListResponse{}
   641  	if err := runtime.UnmarshalAsJSON(resp, &result.PrivateLinkServiceListResult); err != nil {
   642  		return PrivateLinkServicesClientListResponse{}, err
   643  	}
   644  	return result, nil
   645  }
   646  
   647  // NewListAutoApprovedPrivateLinkServicesPager - Returns all of the private link service ids that can be linked to a Private
   648  // Endpoint with auto approved in this subscription in this region.
   649  //
   650  // Generated from API version 2024-05-01
   651  //   - location - The location of the domain name.
   652  //   - options - PrivateLinkServicesClientListAutoApprovedPrivateLinkServicesOptions contains the optional parameters for the
   653  //     PrivateLinkServicesClient.NewListAutoApprovedPrivateLinkServicesPager method.
   654  func (client *PrivateLinkServicesClient) NewListAutoApprovedPrivateLinkServicesPager(location string, options *PrivateLinkServicesClientListAutoApprovedPrivateLinkServicesOptions) *runtime.Pager[PrivateLinkServicesClientListAutoApprovedPrivateLinkServicesResponse] {
   655  	return runtime.NewPager(runtime.PagingHandler[PrivateLinkServicesClientListAutoApprovedPrivateLinkServicesResponse]{
   656  		More: func(page PrivateLinkServicesClientListAutoApprovedPrivateLinkServicesResponse) bool {
   657  			return page.NextLink != nil && len(*page.NextLink) > 0
   658  		},
   659  		Fetcher: func(ctx context.Context, page *PrivateLinkServicesClientListAutoApprovedPrivateLinkServicesResponse) (PrivateLinkServicesClientListAutoApprovedPrivateLinkServicesResponse, error) {
   660  			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PrivateLinkServicesClient.NewListAutoApprovedPrivateLinkServicesPager")
   661  			nextLink := ""
   662  			if page != nil {
   663  				nextLink = *page.NextLink
   664  			}
   665  			resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) {
   666  				return client.listAutoApprovedPrivateLinkServicesCreateRequest(ctx, location, options)
   667  			}, nil)
   668  			if err != nil {
   669  				return PrivateLinkServicesClientListAutoApprovedPrivateLinkServicesResponse{}, err
   670  			}
   671  			return client.listAutoApprovedPrivateLinkServicesHandleResponse(resp)
   672  		},
   673  		Tracer: client.internal.Tracer(),
   674  	})
   675  }
   676  
   677  // listAutoApprovedPrivateLinkServicesCreateRequest creates the ListAutoApprovedPrivateLinkServices request.
   678  func (client *PrivateLinkServicesClient) listAutoApprovedPrivateLinkServicesCreateRequest(ctx context.Context, location string, options *PrivateLinkServicesClientListAutoApprovedPrivateLinkServicesOptions) (*policy.Request, error) {
   679  	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/autoApprovedPrivateLinkServices"
   680  	if location == "" {
   681  		return nil, errors.New("parameter location cannot be empty")
   682  	}
   683  	urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location))
   684  	if client.subscriptionID == "" {
   685  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   686  	}
   687  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   688  	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   689  	if err != nil {
   690  		return nil, err
   691  	}
   692  	reqQP := req.Raw().URL.Query()
   693  	reqQP.Set("api-version", "2024-05-01")
   694  	req.Raw().URL.RawQuery = reqQP.Encode()
   695  	req.Raw().Header["Accept"] = []string{"application/json"}
   696  	return req, nil
   697  }
   698  
   699  // listAutoApprovedPrivateLinkServicesHandleResponse handles the ListAutoApprovedPrivateLinkServices response.
   700  func (client *PrivateLinkServicesClient) listAutoApprovedPrivateLinkServicesHandleResponse(resp *http.Response) (PrivateLinkServicesClientListAutoApprovedPrivateLinkServicesResponse, error) {
   701  	result := PrivateLinkServicesClientListAutoApprovedPrivateLinkServicesResponse{}
   702  	if err := runtime.UnmarshalAsJSON(resp, &result.AutoApprovedPrivateLinkServicesResult); err != nil {
   703  		return PrivateLinkServicesClientListAutoApprovedPrivateLinkServicesResponse{}, err
   704  	}
   705  	return result, nil
   706  }
   707  
   708  // NewListAutoApprovedPrivateLinkServicesByResourceGroupPager - Returns all of the private link service ids that can be linked
   709  // to a Private Endpoint with auto approved in this subscription in this region.
   710  //
   711  // Generated from API version 2024-05-01
   712  //   - location - The location of the domain name.
   713  //   - resourceGroupName - The name of the resource group.
   714  //   - options - PrivateLinkServicesClientListAutoApprovedPrivateLinkServicesByResourceGroupOptions contains the optional parameters
   715  //     for the PrivateLinkServicesClient.NewListAutoApprovedPrivateLinkServicesByResourceGroupPager method.
   716  func (client *PrivateLinkServicesClient) NewListAutoApprovedPrivateLinkServicesByResourceGroupPager(location string, resourceGroupName string, options *PrivateLinkServicesClientListAutoApprovedPrivateLinkServicesByResourceGroupOptions) *runtime.Pager[PrivateLinkServicesClientListAutoApprovedPrivateLinkServicesByResourceGroupResponse] {
   717  	return runtime.NewPager(runtime.PagingHandler[PrivateLinkServicesClientListAutoApprovedPrivateLinkServicesByResourceGroupResponse]{
   718  		More: func(page PrivateLinkServicesClientListAutoApprovedPrivateLinkServicesByResourceGroupResponse) bool {
   719  			return page.NextLink != nil && len(*page.NextLink) > 0
   720  		},
   721  		Fetcher: func(ctx context.Context, page *PrivateLinkServicesClientListAutoApprovedPrivateLinkServicesByResourceGroupResponse) (PrivateLinkServicesClientListAutoApprovedPrivateLinkServicesByResourceGroupResponse, error) {
   722  			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PrivateLinkServicesClient.NewListAutoApprovedPrivateLinkServicesByResourceGroupPager")
   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.listAutoApprovedPrivateLinkServicesByResourceGroupCreateRequest(ctx, location, resourceGroupName, options)
   729  			}, nil)
   730  			if err != nil {
   731  				return PrivateLinkServicesClientListAutoApprovedPrivateLinkServicesByResourceGroupResponse{}, err
   732  			}
   733  			return client.listAutoApprovedPrivateLinkServicesByResourceGroupHandleResponse(resp)
   734  		},
   735  		Tracer: client.internal.Tracer(),
   736  	})
   737  }
   738  
   739  // listAutoApprovedPrivateLinkServicesByResourceGroupCreateRequest creates the ListAutoApprovedPrivateLinkServicesByResourceGroup request.
   740  func (client *PrivateLinkServicesClient) listAutoApprovedPrivateLinkServicesByResourceGroupCreateRequest(ctx context.Context, location string, resourceGroupName string, options *PrivateLinkServicesClientListAutoApprovedPrivateLinkServicesByResourceGroupOptions) (*policy.Request, error) {
   741  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/locations/{location}/autoApprovedPrivateLinkServices"
   742  	if location == "" {
   743  		return nil, errors.New("parameter location cannot be empty")
   744  	}
   745  	urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location))
   746  	if resourceGroupName == "" {
   747  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   748  	}
   749  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   750  	if client.subscriptionID == "" {
   751  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   752  	}
   753  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   754  	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   755  	if err != nil {
   756  		return nil, err
   757  	}
   758  	reqQP := req.Raw().URL.Query()
   759  	reqQP.Set("api-version", "2024-05-01")
   760  	req.Raw().URL.RawQuery = reqQP.Encode()
   761  	req.Raw().Header["Accept"] = []string{"application/json"}
   762  	return req, nil
   763  }
   764  
   765  // listAutoApprovedPrivateLinkServicesByResourceGroupHandleResponse handles the ListAutoApprovedPrivateLinkServicesByResourceGroup response.
   766  func (client *PrivateLinkServicesClient) listAutoApprovedPrivateLinkServicesByResourceGroupHandleResponse(resp *http.Response) (PrivateLinkServicesClientListAutoApprovedPrivateLinkServicesByResourceGroupResponse, error) {
   767  	result := PrivateLinkServicesClientListAutoApprovedPrivateLinkServicesByResourceGroupResponse{}
   768  	if err := runtime.UnmarshalAsJSON(resp, &result.AutoApprovedPrivateLinkServicesResult); err != nil {
   769  		return PrivateLinkServicesClientListAutoApprovedPrivateLinkServicesByResourceGroupResponse{}, err
   770  	}
   771  	return result, nil
   772  }
   773  
   774  // NewListBySubscriptionPager - Gets all private link service in a subscription.
   775  //
   776  // Generated from API version 2024-05-01
   777  //   - options - PrivateLinkServicesClientListBySubscriptionOptions contains the optional parameters for the PrivateLinkServicesClient.NewListBySubscriptionPager
   778  //     method.
   779  func (client *PrivateLinkServicesClient) NewListBySubscriptionPager(options *PrivateLinkServicesClientListBySubscriptionOptions) *runtime.Pager[PrivateLinkServicesClientListBySubscriptionResponse] {
   780  	return runtime.NewPager(runtime.PagingHandler[PrivateLinkServicesClientListBySubscriptionResponse]{
   781  		More: func(page PrivateLinkServicesClientListBySubscriptionResponse) bool {
   782  			return page.NextLink != nil && len(*page.NextLink) > 0
   783  		},
   784  		Fetcher: func(ctx context.Context, page *PrivateLinkServicesClientListBySubscriptionResponse) (PrivateLinkServicesClientListBySubscriptionResponse, error) {
   785  			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PrivateLinkServicesClient.NewListBySubscriptionPager")
   786  			nextLink := ""
   787  			if page != nil {
   788  				nextLink = *page.NextLink
   789  			}
   790  			resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) {
   791  				return client.listBySubscriptionCreateRequest(ctx, options)
   792  			}, nil)
   793  			if err != nil {
   794  				return PrivateLinkServicesClientListBySubscriptionResponse{}, err
   795  			}
   796  			return client.listBySubscriptionHandleResponse(resp)
   797  		},
   798  		Tracer: client.internal.Tracer(),
   799  	})
   800  }
   801  
   802  // listBySubscriptionCreateRequest creates the ListBySubscription request.
   803  func (client *PrivateLinkServicesClient) listBySubscriptionCreateRequest(ctx context.Context, options *PrivateLinkServicesClientListBySubscriptionOptions) (*policy.Request, error) {
   804  	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Network/privateLinkServices"
   805  	if client.subscriptionID == "" {
   806  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   807  	}
   808  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   809  	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   810  	if err != nil {
   811  		return nil, err
   812  	}
   813  	reqQP := req.Raw().URL.Query()
   814  	reqQP.Set("api-version", "2024-05-01")
   815  	req.Raw().URL.RawQuery = reqQP.Encode()
   816  	req.Raw().Header["Accept"] = []string{"application/json"}
   817  	return req, nil
   818  }
   819  
   820  // listBySubscriptionHandleResponse handles the ListBySubscription response.
   821  func (client *PrivateLinkServicesClient) listBySubscriptionHandleResponse(resp *http.Response) (PrivateLinkServicesClientListBySubscriptionResponse, error) {
   822  	result := PrivateLinkServicesClientListBySubscriptionResponse{}
   823  	if err := runtime.UnmarshalAsJSON(resp, &result.PrivateLinkServiceListResult); err != nil {
   824  		return PrivateLinkServicesClientListBySubscriptionResponse{}, err
   825  	}
   826  	return result, nil
   827  }
   828  
   829  // NewListPrivateEndpointConnectionsPager - Gets all private end point connections for a specific private link service.
   830  //
   831  // Generated from API version 2024-05-01
   832  //   - resourceGroupName - The name of the resource group.
   833  //   - serviceName - The name of the private link service.
   834  //   - options - PrivateLinkServicesClientListPrivateEndpointConnectionsOptions contains the optional parameters for the PrivateLinkServicesClient.NewListPrivateEndpointConnectionsPager
   835  //     method.
   836  func (client *PrivateLinkServicesClient) NewListPrivateEndpointConnectionsPager(resourceGroupName string, serviceName string, options *PrivateLinkServicesClientListPrivateEndpointConnectionsOptions) *runtime.Pager[PrivateLinkServicesClientListPrivateEndpointConnectionsResponse] {
   837  	return runtime.NewPager(runtime.PagingHandler[PrivateLinkServicesClientListPrivateEndpointConnectionsResponse]{
   838  		More: func(page PrivateLinkServicesClientListPrivateEndpointConnectionsResponse) bool {
   839  			return page.NextLink != nil && len(*page.NextLink) > 0
   840  		},
   841  		Fetcher: func(ctx context.Context, page *PrivateLinkServicesClientListPrivateEndpointConnectionsResponse) (PrivateLinkServicesClientListPrivateEndpointConnectionsResponse, error) {
   842  			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PrivateLinkServicesClient.NewListPrivateEndpointConnectionsPager")
   843  			nextLink := ""
   844  			if page != nil {
   845  				nextLink = *page.NextLink
   846  			}
   847  			resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) {
   848  				return client.listPrivateEndpointConnectionsCreateRequest(ctx, resourceGroupName, serviceName, options)
   849  			}, nil)
   850  			if err != nil {
   851  				return PrivateLinkServicesClientListPrivateEndpointConnectionsResponse{}, err
   852  			}
   853  			return client.listPrivateEndpointConnectionsHandleResponse(resp)
   854  		},
   855  		Tracer: client.internal.Tracer(),
   856  	})
   857  }
   858  
   859  // listPrivateEndpointConnectionsCreateRequest creates the ListPrivateEndpointConnections request.
   860  func (client *PrivateLinkServicesClient) listPrivateEndpointConnectionsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *PrivateLinkServicesClientListPrivateEndpointConnectionsOptions) (*policy.Request, error) {
   861  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateLinkServices/{serviceName}/privateEndpointConnections"
   862  	if resourceGroupName == "" {
   863  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   864  	}
   865  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   866  	if serviceName == "" {
   867  		return nil, errors.New("parameter serviceName cannot be empty")
   868  	}
   869  	urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName))
   870  	if client.subscriptionID == "" {
   871  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   872  	}
   873  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   874  	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   875  	if err != nil {
   876  		return nil, err
   877  	}
   878  	reqQP := req.Raw().URL.Query()
   879  	reqQP.Set("api-version", "2024-05-01")
   880  	req.Raw().URL.RawQuery = reqQP.Encode()
   881  	req.Raw().Header["Accept"] = []string{"application/json"}
   882  	return req, nil
   883  }
   884  
   885  // listPrivateEndpointConnectionsHandleResponse handles the ListPrivateEndpointConnections response.
   886  func (client *PrivateLinkServicesClient) listPrivateEndpointConnectionsHandleResponse(resp *http.Response) (PrivateLinkServicesClientListPrivateEndpointConnectionsResponse, error) {
   887  	result := PrivateLinkServicesClientListPrivateEndpointConnectionsResponse{}
   888  	if err := runtime.UnmarshalAsJSON(resp, &result.PrivateEndpointConnectionListResult); err != nil {
   889  		return PrivateLinkServicesClientListPrivateEndpointConnectionsResponse{}, err
   890  	}
   891  	return result, nil
   892  }
   893  
   894  // UpdatePrivateEndpointConnection - Approve or reject private end point connection for a private link service in a subscription.
   895  // If the operation fails it returns an *azcore.ResponseError type.
   896  //
   897  // Generated from API version 2024-05-01
   898  //   - resourceGroupName - The name of the resource group.
   899  //   - serviceName - The name of the private link service.
   900  //   - peConnectionName - The name of the private end point connection.
   901  //   - parameters - Parameters supplied to approve or reject the private end point connection.
   902  //   - options - PrivateLinkServicesClientUpdatePrivateEndpointConnectionOptions contains the optional parameters for the PrivateLinkServicesClient.UpdatePrivateEndpointConnection
   903  //     method.
   904  func (client *PrivateLinkServicesClient) UpdatePrivateEndpointConnection(ctx context.Context, resourceGroupName string, serviceName string, peConnectionName string, parameters PrivateEndpointConnection, options *PrivateLinkServicesClientUpdatePrivateEndpointConnectionOptions) (PrivateLinkServicesClientUpdatePrivateEndpointConnectionResponse, error) {
   905  	var err error
   906  	const operationName = "PrivateLinkServicesClient.UpdatePrivateEndpointConnection"
   907  	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
   908  	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
   909  	defer func() { endSpan(err) }()
   910  	req, err := client.updatePrivateEndpointConnectionCreateRequest(ctx, resourceGroupName, serviceName, peConnectionName, parameters, options)
   911  	if err != nil {
   912  		return PrivateLinkServicesClientUpdatePrivateEndpointConnectionResponse{}, err
   913  	}
   914  	httpResp, err := client.internal.Pipeline().Do(req)
   915  	if err != nil {
   916  		return PrivateLinkServicesClientUpdatePrivateEndpointConnectionResponse{}, err
   917  	}
   918  	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
   919  		err = runtime.NewResponseError(httpResp)
   920  		return PrivateLinkServicesClientUpdatePrivateEndpointConnectionResponse{}, err
   921  	}
   922  	resp, err := client.updatePrivateEndpointConnectionHandleResponse(httpResp)
   923  	return resp, err
   924  }
   925  
   926  // updatePrivateEndpointConnectionCreateRequest creates the UpdatePrivateEndpointConnection request.
   927  func (client *PrivateLinkServicesClient) updatePrivateEndpointConnectionCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, peConnectionName string, parameters PrivateEndpointConnection, options *PrivateLinkServicesClientUpdatePrivateEndpointConnectionOptions) (*policy.Request, error) {
   928  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateLinkServices/{serviceName}/privateEndpointConnections/{peConnectionName}"
   929  	if resourceGroupName == "" {
   930  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   931  	}
   932  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   933  	if serviceName == "" {
   934  		return nil, errors.New("parameter serviceName cannot be empty")
   935  	}
   936  	urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName))
   937  	if peConnectionName == "" {
   938  		return nil, errors.New("parameter peConnectionName cannot be empty")
   939  	}
   940  	urlPath = strings.ReplaceAll(urlPath, "{peConnectionName}", url.PathEscape(peConnectionName))
   941  	if client.subscriptionID == "" {
   942  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   943  	}
   944  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   945  	req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   946  	if err != nil {
   947  		return nil, err
   948  	}
   949  	reqQP := req.Raw().URL.Query()
   950  	reqQP.Set("api-version", "2024-05-01")
   951  	req.Raw().URL.RawQuery = reqQP.Encode()
   952  	req.Raw().Header["Accept"] = []string{"application/json"}
   953  	if err := runtime.MarshalAsJSON(req, parameters); err != nil {
   954  		return nil, err
   955  	}
   956  	return req, nil
   957  }
   958  
   959  // updatePrivateEndpointConnectionHandleResponse handles the UpdatePrivateEndpointConnection response.
   960  func (client *PrivateLinkServicesClient) updatePrivateEndpointConnectionHandleResponse(resp *http.Response) (PrivateLinkServicesClientUpdatePrivateEndpointConnectionResponse, error) {
   961  	result := PrivateLinkServicesClientUpdatePrivateEndpointConnectionResponse{}
   962  	if err := runtime.UnmarshalAsJSON(resp, &result.PrivateEndpointConnection); err != nil {
   963  		return PrivateLinkServicesClientUpdatePrivateEndpointConnectionResponse{}, err
   964  	}
   965  	return result, nil
   966  }