github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6@v6.2.0/customipprefixes_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  // CustomIPPrefixesClient contains the methods for the CustomIPPrefixes group.
    24  // Don't use this type directly, use NewCustomIPPrefixesClient() instead.
    25  type CustomIPPrefixesClient struct {
    26  	internal       *arm.Client
    27  	subscriptionID string
    28  }
    29  
    30  // NewCustomIPPrefixesClient creates a new instance of CustomIPPrefixesClient 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 NewCustomIPPrefixesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CustomIPPrefixesClient, error) {
    36  	cl, err := arm.NewClient(moduleName, moduleVersion, credential, options)
    37  	if err != nil {
    38  		return nil, err
    39  	}
    40  	client := &CustomIPPrefixesClient{
    41  		subscriptionID: subscriptionID,
    42  		internal:       cl,
    43  	}
    44  	return client, nil
    45  }
    46  
    47  // BeginCreateOrUpdate - Creates or updates a custom IP prefix.
    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  //   - customIPPrefixName - The name of the custom IP prefix.
    53  //   - parameters - Parameters supplied to the create or update custom IP prefix operation.
    54  //   - options - CustomIPPrefixesClientBeginCreateOrUpdateOptions contains the optional parameters for the CustomIPPrefixesClient.BeginCreateOrUpdate
    55  //     method.
    56  func (client *CustomIPPrefixesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, customIPPrefixName string, parameters CustomIPPrefix, options *CustomIPPrefixesClientBeginCreateOrUpdateOptions) (*runtime.Poller[CustomIPPrefixesClientCreateOrUpdateResponse], error) {
    57  	if options == nil || options.ResumeToken == "" {
    58  		resp, err := client.createOrUpdate(ctx, resourceGroupName, customIPPrefixName, parameters, options)
    59  		if err != nil {
    60  			return nil, err
    61  		}
    62  		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CustomIPPrefixesClientCreateOrUpdateResponse]{
    63  			FinalStateVia: runtime.FinalStateViaLocation,
    64  			Tracer:        client.internal.Tracer(),
    65  		})
    66  		return poller, err
    67  	} else {
    68  		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[CustomIPPrefixesClientCreateOrUpdateResponse]{
    69  			Tracer: client.internal.Tracer(),
    70  		})
    71  	}
    72  }
    73  
    74  // CreateOrUpdate - Creates or updates a custom IP prefix.
    75  // If the operation fails it returns an *azcore.ResponseError type.
    76  //
    77  // Generated from API version 2024-05-01
    78  func (client *CustomIPPrefixesClient) createOrUpdate(ctx context.Context, resourceGroupName string, customIPPrefixName string, parameters CustomIPPrefix, options *CustomIPPrefixesClientBeginCreateOrUpdateOptions) (*http.Response, error) {
    79  	var err error
    80  	const operationName = "CustomIPPrefixesClient.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, customIPPrefixName, 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 *CustomIPPrefixesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, customIPPrefixName string, parameters CustomIPPrefix, options *CustomIPPrefixesClientBeginCreateOrUpdateOptions) (*policy.Request, error) {
   101  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/customIpPrefixes/{customIpPrefixName}"
   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 customIPPrefixName == "" {
   107  		return nil, errors.New("parameter customIPPrefixName cannot be empty")
   108  	}
   109  	urlPath = strings.ReplaceAll(urlPath, "{customIpPrefixName}", url.PathEscape(customIPPrefixName))
   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 custom IP prefix.
   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  //   - customIPPrefixName - The name of the CustomIpPrefix.
   134  //   - options - CustomIPPrefixesClientBeginDeleteOptions contains the optional parameters for the CustomIPPrefixesClient.BeginDelete
   135  //     method.
   136  func (client *CustomIPPrefixesClient) BeginDelete(ctx context.Context, resourceGroupName string, customIPPrefixName string, options *CustomIPPrefixesClientBeginDeleteOptions) (*runtime.Poller[CustomIPPrefixesClientDeleteResponse], error) {
   137  	if options == nil || options.ResumeToken == "" {
   138  		resp, err := client.deleteOperation(ctx, resourceGroupName, customIPPrefixName, options)
   139  		if err != nil {
   140  			return nil, err
   141  		}
   142  		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CustomIPPrefixesClientDeleteResponse]{
   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[CustomIPPrefixesClientDeleteResponse]{
   149  			Tracer: client.internal.Tracer(),
   150  		})
   151  	}
   152  }
   153  
   154  // Delete - Deletes the specified custom IP prefix.
   155  // If the operation fails it returns an *azcore.ResponseError type.
   156  //
   157  // Generated from API version 2024-05-01
   158  func (client *CustomIPPrefixesClient) deleteOperation(ctx context.Context, resourceGroupName string, customIPPrefixName string, options *CustomIPPrefixesClientBeginDeleteOptions) (*http.Response, error) {
   159  	var err error
   160  	const operationName = "CustomIPPrefixesClient.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, customIPPrefixName, 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 *CustomIPPrefixesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, customIPPrefixName string, options *CustomIPPrefixesClientBeginDeleteOptions) (*policy.Request, error) {
   181  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/customIpPrefixes/{customIpPrefixName}"
   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 customIPPrefixName == "" {
   187  		return nil, errors.New("parameter customIPPrefixName cannot be empty")
   188  	}
   189  	urlPath = strings.ReplaceAll(urlPath, "{customIpPrefixName}", url.PathEscape(customIPPrefixName))
   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 custom IP prefix in a specified resource group.
   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  //   - customIPPrefixName - The name of the custom IP prefix.
   211  //   - options - CustomIPPrefixesClientGetOptions contains the optional parameters for the CustomIPPrefixesClient.Get method.
   212  func (client *CustomIPPrefixesClient) Get(ctx context.Context, resourceGroupName string, customIPPrefixName string, options *CustomIPPrefixesClientGetOptions) (CustomIPPrefixesClientGetResponse, error) {
   213  	var err error
   214  	const operationName = "CustomIPPrefixesClient.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, customIPPrefixName, options)
   219  	if err != nil {
   220  		return CustomIPPrefixesClientGetResponse{}, err
   221  	}
   222  	httpResp, err := client.internal.Pipeline().Do(req)
   223  	if err != nil {
   224  		return CustomIPPrefixesClientGetResponse{}, err
   225  	}
   226  	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
   227  		err = runtime.NewResponseError(httpResp)
   228  		return CustomIPPrefixesClientGetResponse{}, err
   229  	}
   230  	resp, err := client.getHandleResponse(httpResp)
   231  	return resp, err
   232  }
   233  
   234  // getCreateRequest creates the Get request.
   235  func (client *CustomIPPrefixesClient) getCreateRequest(ctx context.Context, resourceGroupName string, customIPPrefixName string, options *CustomIPPrefixesClientGetOptions) (*policy.Request, error) {
   236  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/customIpPrefixes/{customIpPrefixName}"
   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 customIPPrefixName == "" {
   242  		return nil, errors.New("parameter customIPPrefixName cannot be empty")
   243  	}
   244  	urlPath = strings.ReplaceAll(urlPath, "{customIpPrefixName}", url.PathEscape(customIPPrefixName))
   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  	if options != nil && options.Expand != nil {
   255  		reqQP.Set("$expand", *options.Expand)
   256  	}
   257  	reqQP.Set("api-version", "2024-05-01")
   258  	req.Raw().URL.RawQuery = reqQP.Encode()
   259  	req.Raw().Header["Accept"] = []string{"application/json"}
   260  	return req, nil
   261  }
   262  
   263  // getHandleResponse handles the Get response.
   264  func (client *CustomIPPrefixesClient) getHandleResponse(resp *http.Response) (CustomIPPrefixesClientGetResponse, error) {
   265  	result := CustomIPPrefixesClientGetResponse{}
   266  	if err := runtime.UnmarshalAsJSON(resp, &result.CustomIPPrefix); err != nil {
   267  		return CustomIPPrefixesClientGetResponse{}, err
   268  	}
   269  	return result, nil
   270  }
   271  
   272  // NewListPager - Gets all custom IP prefixes in a resource group.
   273  //
   274  // Generated from API version 2024-05-01
   275  //   - resourceGroupName - The name of the resource group.
   276  //   - options - CustomIPPrefixesClientListOptions contains the optional parameters for the CustomIPPrefixesClient.NewListPager
   277  //     method.
   278  func (client *CustomIPPrefixesClient) NewListPager(resourceGroupName string, options *CustomIPPrefixesClientListOptions) *runtime.Pager[CustomIPPrefixesClientListResponse] {
   279  	return runtime.NewPager(runtime.PagingHandler[CustomIPPrefixesClientListResponse]{
   280  		More: func(page CustomIPPrefixesClientListResponse) bool {
   281  			return page.NextLink != nil && len(*page.NextLink) > 0
   282  		},
   283  		Fetcher: func(ctx context.Context, page *CustomIPPrefixesClientListResponse) (CustomIPPrefixesClientListResponse, error) {
   284  			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "CustomIPPrefixesClient.NewListPager")
   285  			nextLink := ""
   286  			if page != nil {
   287  				nextLink = *page.NextLink
   288  			}
   289  			resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) {
   290  				return client.listCreateRequest(ctx, resourceGroupName, options)
   291  			}, nil)
   292  			if err != nil {
   293  				return CustomIPPrefixesClientListResponse{}, err
   294  			}
   295  			return client.listHandleResponse(resp)
   296  		},
   297  		Tracer: client.internal.Tracer(),
   298  	})
   299  }
   300  
   301  // listCreateRequest creates the List request.
   302  func (client *CustomIPPrefixesClient) listCreateRequest(ctx context.Context, resourceGroupName string, options *CustomIPPrefixesClientListOptions) (*policy.Request, error) {
   303  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/customIpPrefixes"
   304  	if resourceGroupName == "" {
   305  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   306  	}
   307  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   308  	if client.subscriptionID == "" {
   309  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   310  	}
   311  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   312  	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   313  	if err != nil {
   314  		return nil, err
   315  	}
   316  	reqQP := req.Raw().URL.Query()
   317  	reqQP.Set("api-version", "2024-05-01")
   318  	req.Raw().URL.RawQuery = reqQP.Encode()
   319  	req.Raw().Header["Accept"] = []string{"application/json"}
   320  	return req, nil
   321  }
   322  
   323  // listHandleResponse handles the List response.
   324  func (client *CustomIPPrefixesClient) listHandleResponse(resp *http.Response) (CustomIPPrefixesClientListResponse, error) {
   325  	result := CustomIPPrefixesClientListResponse{}
   326  	if err := runtime.UnmarshalAsJSON(resp, &result.CustomIPPrefixListResult); err != nil {
   327  		return CustomIPPrefixesClientListResponse{}, err
   328  	}
   329  	return result, nil
   330  }
   331  
   332  // NewListAllPager - Gets all the custom IP prefixes in a subscription.
   333  //
   334  // Generated from API version 2024-05-01
   335  //   - options - CustomIPPrefixesClientListAllOptions contains the optional parameters for the CustomIPPrefixesClient.NewListAllPager
   336  //     method.
   337  func (client *CustomIPPrefixesClient) NewListAllPager(options *CustomIPPrefixesClientListAllOptions) *runtime.Pager[CustomIPPrefixesClientListAllResponse] {
   338  	return runtime.NewPager(runtime.PagingHandler[CustomIPPrefixesClientListAllResponse]{
   339  		More: func(page CustomIPPrefixesClientListAllResponse) bool {
   340  			return page.NextLink != nil && len(*page.NextLink) > 0
   341  		},
   342  		Fetcher: func(ctx context.Context, page *CustomIPPrefixesClientListAllResponse) (CustomIPPrefixesClientListAllResponse, error) {
   343  			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "CustomIPPrefixesClient.NewListAllPager")
   344  			nextLink := ""
   345  			if page != nil {
   346  				nextLink = *page.NextLink
   347  			}
   348  			resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) {
   349  				return client.listAllCreateRequest(ctx, options)
   350  			}, nil)
   351  			if err != nil {
   352  				return CustomIPPrefixesClientListAllResponse{}, err
   353  			}
   354  			return client.listAllHandleResponse(resp)
   355  		},
   356  		Tracer: client.internal.Tracer(),
   357  	})
   358  }
   359  
   360  // listAllCreateRequest creates the ListAll request.
   361  func (client *CustomIPPrefixesClient) listAllCreateRequest(ctx context.Context, options *CustomIPPrefixesClientListAllOptions) (*policy.Request, error) {
   362  	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Network/customIpPrefixes"
   363  	if client.subscriptionID == "" {
   364  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   365  	}
   366  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   367  	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   368  	if err != nil {
   369  		return nil, err
   370  	}
   371  	reqQP := req.Raw().URL.Query()
   372  	reqQP.Set("api-version", "2024-05-01")
   373  	req.Raw().URL.RawQuery = reqQP.Encode()
   374  	req.Raw().Header["Accept"] = []string{"application/json"}
   375  	return req, nil
   376  }
   377  
   378  // listAllHandleResponse handles the ListAll response.
   379  func (client *CustomIPPrefixesClient) listAllHandleResponse(resp *http.Response) (CustomIPPrefixesClientListAllResponse, error) {
   380  	result := CustomIPPrefixesClientListAllResponse{}
   381  	if err := runtime.UnmarshalAsJSON(resp, &result.CustomIPPrefixListResult); err != nil {
   382  		return CustomIPPrefixesClientListAllResponse{}, err
   383  	}
   384  	return result, nil
   385  }
   386  
   387  // UpdateTags - Updates custom IP prefix tags.
   388  // If the operation fails it returns an *azcore.ResponseError type.
   389  //
   390  // Generated from API version 2024-05-01
   391  //   - resourceGroupName - The name of the resource group.
   392  //   - customIPPrefixName - The name of the custom IP prefix.
   393  //   - parameters - Parameters supplied to update custom IP prefix tags.
   394  //   - options - CustomIPPrefixesClientUpdateTagsOptions contains the optional parameters for the CustomIPPrefixesClient.UpdateTags
   395  //     method.
   396  func (client *CustomIPPrefixesClient) UpdateTags(ctx context.Context, resourceGroupName string, customIPPrefixName string, parameters TagsObject, options *CustomIPPrefixesClientUpdateTagsOptions) (CustomIPPrefixesClientUpdateTagsResponse, error) {
   397  	var err error
   398  	const operationName = "CustomIPPrefixesClient.UpdateTags"
   399  	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
   400  	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
   401  	defer func() { endSpan(err) }()
   402  	req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, customIPPrefixName, parameters, options)
   403  	if err != nil {
   404  		return CustomIPPrefixesClientUpdateTagsResponse{}, err
   405  	}
   406  	httpResp, err := client.internal.Pipeline().Do(req)
   407  	if err != nil {
   408  		return CustomIPPrefixesClientUpdateTagsResponse{}, err
   409  	}
   410  	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
   411  		err = runtime.NewResponseError(httpResp)
   412  		return CustomIPPrefixesClientUpdateTagsResponse{}, err
   413  	}
   414  	resp, err := client.updateTagsHandleResponse(httpResp)
   415  	return resp, err
   416  }
   417  
   418  // updateTagsCreateRequest creates the UpdateTags request.
   419  func (client *CustomIPPrefixesClient) updateTagsCreateRequest(ctx context.Context, resourceGroupName string, customIPPrefixName string, parameters TagsObject, options *CustomIPPrefixesClientUpdateTagsOptions) (*policy.Request, error) {
   420  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/customIpPrefixes/{customIpPrefixName}"
   421  	if resourceGroupName == "" {
   422  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   423  	}
   424  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   425  	if customIPPrefixName == "" {
   426  		return nil, errors.New("parameter customIPPrefixName cannot be empty")
   427  	}
   428  	urlPath = strings.ReplaceAll(urlPath, "{customIpPrefixName}", url.PathEscape(customIPPrefixName))
   429  	if client.subscriptionID == "" {
   430  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   431  	}
   432  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   433  	req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   434  	if err != nil {
   435  		return nil, err
   436  	}
   437  	reqQP := req.Raw().URL.Query()
   438  	reqQP.Set("api-version", "2024-05-01")
   439  	req.Raw().URL.RawQuery = reqQP.Encode()
   440  	req.Raw().Header["Accept"] = []string{"application/json"}
   441  	if err := runtime.MarshalAsJSON(req, parameters); err != nil {
   442  		return nil, err
   443  	}
   444  	return req, nil
   445  }
   446  
   447  // updateTagsHandleResponse handles the UpdateTags response.
   448  func (client *CustomIPPrefixesClient) updateTagsHandleResponse(resp *http.Response) (CustomIPPrefixesClientUpdateTagsResponse, error) {
   449  	result := CustomIPPrefixesClientUpdateTagsResponse{}
   450  	if err := runtime.UnmarshalAsJSON(resp, &result.CustomIPPrefix); err != nil {
   451  		return CustomIPPrefixesClientUpdateTagsResponse{}, err
   452  	}
   453  	return result, nil
   454  }