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