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