github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6@v6.2.0/azurefirewalls_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  // AzureFirewallsClient contains the methods for the AzureFirewalls group.
    24  // Don't use this type directly, use NewAzureFirewallsClient() instead.
    25  type AzureFirewallsClient struct {
    26  	internal       *arm.Client
    27  	subscriptionID string
    28  }
    29  
    30  // NewAzureFirewallsClient creates a new instance of AzureFirewallsClient 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 NewAzureFirewallsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AzureFirewallsClient, error) {
    36  	cl, err := arm.NewClient(moduleName, moduleVersion, credential, options)
    37  	if err != nil {
    38  		return nil, err
    39  	}
    40  	client := &AzureFirewallsClient{
    41  		subscriptionID: subscriptionID,
    42  		internal:       cl,
    43  	}
    44  	return client, nil
    45  }
    46  
    47  // BeginCreateOrUpdate - Creates or updates the specified Azure Firewall.
    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  //   - azureFirewallName - The name of the Azure Firewall.
    53  //   - parameters - Parameters supplied to the create or update Azure Firewall operation.
    54  //   - options - AzureFirewallsClientBeginCreateOrUpdateOptions contains the optional parameters for the AzureFirewallsClient.BeginCreateOrUpdate
    55  //     method.
    56  func (client *AzureFirewallsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, azureFirewallName string, parameters AzureFirewall, options *AzureFirewallsClientBeginCreateOrUpdateOptions) (*runtime.Poller[AzureFirewallsClientCreateOrUpdateResponse], error) {
    57  	if options == nil || options.ResumeToken == "" {
    58  		resp, err := client.createOrUpdate(ctx, resourceGroupName, azureFirewallName, parameters, options)
    59  		if err != nil {
    60  			return nil, err
    61  		}
    62  		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AzureFirewallsClientCreateOrUpdateResponse]{
    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[AzureFirewallsClientCreateOrUpdateResponse]{
    69  			Tracer: client.internal.Tracer(),
    70  		})
    71  	}
    72  }
    73  
    74  // CreateOrUpdate - Creates or updates the specified Azure Firewall.
    75  // If the operation fails it returns an *azcore.ResponseError type.
    76  //
    77  // Generated from API version 2024-05-01
    78  func (client *AzureFirewallsClient) createOrUpdate(ctx context.Context, resourceGroupName string, azureFirewallName string, parameters AzureFirewall, options *AzureFirewallsClientBeginCreateOrUpdateOptions) (*http.Response, error) {
    79  	var err error
    80  	const operationName = "AzureFirewallsClient.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, azureFirewallName, 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 *AzureFirewallsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, azureFirewallName string, parameters AzureFirewall, options *AzureFirewallsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {
   101  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/azureFirewalls/{azureFirewallName}"
   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 azureFirewallName == "" {
   107  		return nil, errors.New("parameter azureFirewallName cannot be empty")
   108  	}
   109  	urlPath = strings.ReplaceAll(urlPath, "{azureFirewallName}", url.PathEscape(azureFirewallName))
   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 Azure Firewall.
   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  //   - azureFirewallName - The name of the Azure Firewall.
   134  //   - options - AzureFirewallsClientBeginDeleteOptions contains the optional parameters for the AzureFirewallsClient.BeginDelete
   135  //     method.
   136  func (client *AzureFirewallsClient) BeginDelete(ctx context.Context, resourceGroupName string, azureFirewallName string, options *AzureFirewallsClientBeginDeleteOptions) (*runtime.Poller[AzureFirewallsClientDeleteResponse], error) {
   137  	if options == nil || options.ResumeToken == "" {
   138  		resp, err := client.deleteOperation(ctx, resourceGroupName, azureFirewallName, options)
   139  		if err != nil {
   140  			return nil, err
   141  		}
   142  		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AzureFirewallsClientDeleteResponse]{
   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[AzureFirewallsClientDeleteResponse]{
   149  			Tracer: client.internal.Tracer(),
   150  		})
   151  	}
   152  }
   153  
   154  // Delete - Deletes the specified Azure Firewall.
   155  // If the operation fails it returns an *azcore.ResponseError type.
   156  //
   157  // Generated from API version 2024-05-01
   158  func (client *AzureFirewallsClient) deleteOperation(ctx context.Context, resourceGroupName string, azureFirewallName string, options *AzureFirewallsClientBeginDeleteOptions) (*http.Response, error) {
   159  	var err error
   160  	const operationName = "AzureFirewallsClient.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, azureFirewallName, 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 *AzureFirewallsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, azureFirewallName string, options *AzureFirewallsClientBeginDeleteOptions) (*policy.Request, error) {
   181  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/azureFirewalls/{azureFirewallName}"
   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 azureFirewallName == "" {
   187  		return nil, errors.New("parameter azureFirewallName cannot be empty")
   188  	}
   189  	urlPath = strings.ReplaceAll(urlPath, "{azureFirewallName}", url.PathEscape(azureFirewallName))
   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 Azure Firewall.
   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  //   - azureFirewallName - The name of the Azure Firewall.
   211  //   - options - AzureFirewallsClientGetOptions contains the optional parameters for the AzureFirewallsClient.Get method.
   212  func (client *AzureFirewallsClient) Get(ctx context.Context, resourceGroupName string, azureFirewallName string, options *AzureFirewallsClientGetOptions) (AzureFirewallsClientGetResponse, error) {
   213  	var err error
   214  	const operationName = "AzureFirewallsClient.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, azureFirewallName, options)
   219  	if err != nil {
   220  		return AzureFirewallsClientGetResponse{}, err
   221  	}
   222  	httpResp, err := client.internal.Pipeline().Do(req)
   223  	if err != nil {
   224  		return AzureFirewallsClientGetResponse{}, err
   225  	}
   226  	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
   227  		err = runtime.NewResponseError(httpResp)
   228  		return AzureFirewallsClientGetResponse{}, err
   229  	}
   230  	resp, err := client.getHandleResponse(httpResp)
   231  	return resp, err
   232  }
   233  
   234  // getCreateRequest creates the Get request.
   235  func (client *AzureFirewallsClient) getCreateRequest(ctx context.Context, resourceGroupName string, azureFirewallName string, options *AzureFirewallsClientGetOptions) (*policy.Request, error) {
   236  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/azureFirewalls/{azureFirewallName}"
   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 azureFirewallName == "" {
   242  		return nil, errors.New("parameter azureFirewallName cannot be empty")
   243  	}
   244  	urlPath = strings.ReplaceAll(urlPath, "{azureFirewallName}", url.PathEscape(azureFirewallName))
   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 *AzureFirewallsClient) getHandleResponse(resp *http.Response) (AzureFirewallsClientGetResponse, error) {
   262  	result := AzureFirewallsClientGetResponse{}
   263  	if err := runtime.UnmarshalAsJSON(resp, &result.AzureFirewall); err != nil {
   264  		return AzureFirewallsClientGetResponse{}, err
   265  	}
   266  	return result, nil
   267  }
   268  
   269  // NewListPager - Lists all Azure Firewalls in a resource group.
   270  //
   271  // Generated from API version 2024-05-01
   272  //   - resourceGroupName - The name of the resource group.
   273  //   - options - AzureFirewallsClientListOptions contains the optional parameters for the AzureFirewallsClient.NewListPager method.
   274  func (client *AzureFirewallsClient) NewListPager(resourceGroupName string, options *AzureFirewallsClientListOptions) *runtime.Pager[AzureFirewallsClientListResponse] {
   275  	return runtime.NewPager(runtime.PagingHandler[AzureFirewallsClientListResponse]{
   276  		More: func(page AzureFirewallsClientListResponse) bool {
   277  			return page.NextLink != nil && len(*page.NextLink) > 0
   278  		},
   279  		Fetcher: func(ctx context.Context, page *AzureFirewallsClientListResponse) (AzureFirewallsClientListResponse, error) {
   280  			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "AzureFirewallsClient.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, resourceGroupName, options)
   287  			}, nil)
   288  			if err != nil {
   289  				return AzureFirewallsClientListResponse{}, 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 *AzureFirewallsClient) listCreateRequest(ctx context.Context, resourceGroupName string, options *AzureFirewallsClientListOptions) (*policy.Request, error) {
   299  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/azureFirewalls"
   300  	if resourceGroupName == "" {
   301  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   302  	}
   303  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   304  	if client.subscriptionID == "" {
   305  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   306  	}
   307  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   308  	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   309  	if err != nil {
   310  		return nil, err
   311  	}
   312  	reqQP := req.Raw().URL.Query()
   313  	reqQP.Set("api-version", "2024-05-01")
   314  	req.Raw().URL.RawQuery = reqQP.Encode()
   315  	req.Raw().Header["Accept"] = []string{"application/json"}
   316  	return req, nil
   317  }
   318  
   319  // listHandleResponse handles the List response.
   320  func (client *AzureFirewallsClient) listHandleResponse(resp *http.Response) (AzureFirewallsClientListResponse, error) {
   321  	result := AzureFirewallsClientListResponse{}
   322  	if err := runtime.UnmarshalAsJSON(resp, &result.AzureFirewallListResult); err != nil {
   323  		return AzureFirewallsClientListResponse{}, err
   324  	}
   325  	return result, nil
   326  }
   327  
   328  // NewListAllPager - Gets all the Azure Firewalls in a subscription.
   329  //
   330  // Generated from API version 2024-05-01
   331  //   - options - AzureFirewallsClientListAllOptions contains the optional parameters for the AzureFirewallsClient.NewListAllPager
   332  //     method.
   333  func (client *AzureFirewallsClient) NewListAllPager(options *AzureFirewallsClientListAllOptions) *runtime.Pager[AzureFirewallsClientListAllResponse] {
   334  	return runtime.NewPager(runtime.PagingHandler[AzureFirewallsClientListAllResponse]{
   335  		More: func(page AzureFirewallsClientListAllResponse) bool {
   336  			return page.NextLink != nil && len(*page.NextLink) > 0
   337  		},
   338  		Fetcher: func(ctx context.Context, page *AzureFirewallsClientListAllResponse) (AzureFirewallsClientListAllResponse, error) {
   339  			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "AzureFirewallsClient.NewListAllPager")
   340  			nextLink := ""
   341  			if page != nil {
   342  				nextLink = *page.NextLink
   343  			}
   344  			resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) {
   345  				return client.listAllCreateRequest(ctx, options)
   346  			}, nil)
   347  			if err != nil {
   348  				return AzureFirewallsClientListAllResponse{}, err
   349  			}
   350  			return client.listAllHandleResponse(resp)
   351  		},
   352  		Tracer: client.internal.Tracer(),
   353  	})
   354  }
   355  
   356  // listAllCreateRequest creates the ListAll request.
   357  func (client *AzureFirewallsClient) listAllCreateRequest(ctx context.Context, options *AzureFirewallsClientListAllOptions) (*policy.Request, error) {
   358  	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Network/azureFirewalls"
   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  // listAllHandleResponse handles the ListAll response.
   375  func (client *AzureFirewallsClient) listAllHandleResponse(resp *http.Response) (AzureFirewallsClientListAllResponse, error) {
   376  	result := AzureFirewallsClientListAllResponse{}
   377  	if err := runtime.UnmarshalAsJSON(resp, &result.AzureFirewallListResult); err != nil {
   378  		return AzureFirewallsClientListAllResponse{}, err
   379  	}
   380  	return result, nil
   381  }
   382  
   383  // BeginListLearnedPrefixes - Retrieves a list of all IP prefixes that azure firewall has learned to not SNAT.
   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  //   - azureFirewallName - The name of the azure firewall.
   389  //   - options - AzureFirewallsClientBeginListLearnedPrefixesOptions contains the optional parameters for the AzureFirewallsClient.BeginListLearnedPrefixes
   390  //     method.
   391  func (client *AzureFirewallsClient) BeginListLearnedPrefixes(ctx context.Context, resourceGroupName string, azureFirewallName string, options *AzureFirewallsClientBeginListLearnedPrefixesOptions) (*runtime.Poller[AzureFirewallsClientListLearnedPrefixesResponse], error) {
   392  	if options == nil || options.ResumeToken == "" {
   393  		resp, err := client.listLearnedPrefixes(ctx, resourceGroupName, azureFirewallName, options)
   394  		if err != nil {
   395  			return nil, err
   396  		}
   397  		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AzureFirewallsClientListLearnedPrefixesResponse]{
   398  			FinalStateVia: runtime.FinalStateViaLocation,
   399  			Tracer:        client.internal.Tracer(),
   400  		})
   401  		return poller, err
   402  	} else {
   403  		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[AzureFirewallsClientListLearnedPrefixesResponse]{
   404  			Tracer: client.internal.Tracer(),
   405  		})
   406  	}
   407  }
   408  
   409  // ListLearnedPrefixes - Retrieves a list of all IP prefixes that azure firewall has learned to not SNAT.
   410  // If the operation fails it returns an *azcore.ResponseError type.
   411  //
   412  // Generated from API version 2024-05-01
   413  func (client *AzureFirewallsClient) listLearnedPrefixes(ctx context.Context, resourceGroupName string, azureFirewallName string, options *AzureFirewallsClientBeginListLearnedPrefixesOptions) (*http.Response, error) {
   414  	var err error
   415  	const operationName = "AzureFirewallsClient.BeginListLearnedPrefixes"
   416  	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
   417  	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
   418  	defer func() { endSpan(err) }()
   419  	req, err := client.listLearnedPrefixesCreateRequest(ctx, resourceGroupName, azureFirewallName, options)
   420  	if err != nil {
   421  		return nil, err
   422  	}
   423  	httpResp, err := client.internal.Pipeline().Do(req)
   424  	if err != nil {
   425  		return nil, err
   426  	}
   427  	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) {
   428  		err = runtime.NewResponseError(httpResp)
   429  		return nil, err
   430  	}
   431  	return httpResp, nil
   432  }
   433  
   434  // listLearnedPrefixesCreateRequest creates the ListLearnedPrefixes request.
   435  func (client *AzureFirewallsClient) listLearnedPrefixesCreateRequest(ctx context.Context, resourceGroupName string, azureFirewallName string, options *AzureFirewallsClientBeginListLearnedPrefixesOptions) (*policy.Request, error) {
   436  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/azureFirewalls/{azureFirewallName}/learnedIPPrefixes"
   437  	if resourceGroupName == "" {
   438  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   439  	}
   440  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   441  	if azureFirewallName == "" {
   442  		return nil, errors.New("parameter azureFirewallName cannot be empty")
   443  	}
   444  	urlPath = strings.ReplaceAll(urlPath, "{azureFirewallName}", url.PathEscape(azureFirewallName))
   445  	if client.subscriptionID == "" {
   446  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   447  	}
   448  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   449  	req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   450  	if err != nil {
   451  		return nil, err
   452  	}
   453  	reqQP := req.Raw().URL.Query()
   454  	reqQP.Set("api-version", "2024-05-01")
   455  	req.Raw().URL.RawQuery = reqQP.Encode()
   456  	req.Raw().Header["Accept"] = []string{"application/json"}
   457  	return req, nil
   458  }
   459  
   460  // BeginPacketCapture - Runs a packet capture on AzureFirewall.
   461  // If the operation fails it returns an *azcore.ResponseError type.
   462  //
   463  // Generated from API version 2024-05-01
   464  //   - resourceGroupName - The name of the resource group.
   465  //   - azureFirewallName - The name of the Azure Firewall.
   466  //   - parameters - Parameters supplied to run packet capture on azure firewall.
   467  //   - options - AzureFirewallsClientBeginPacketCaptureOptions contains the optional parameters for the AzureFirewallsClient.BeginPacketCapture
   468  //     method.
   469  func (client *AzureFirewallsClient) BeginPacketCapture(ctx context.Context, resourceGroupName string, azureFirewallName string, parameters FirewallPacketCaptureParameters, options *AzureFirewallsClientBeginPacketCaptureOptions) (*runtime.Poller[AzureFirewallsClientPacketCaptureResponse], error) {
   470  	if options == nil || options.ResumeToken == "" {
   471  		resp, err := client.packetCapture(ctx, resourceGroupName, azureFirewallName, parameters, options)
   472  		if err != nil {
   473  			return nil, err
   474  		}
   475  		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AzureFirewallsClientPacketCaptureResponse]{
   476  			FinalStateVia: runtime.FinalStateViaLocation,
   477  			Tracer:        client.internal.Tracer(),
   478  		})
   479  		return poller, err
   480  	} else {
   481  		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[AzureFirewallsClientPacketCaptureResponse]{
   482  			Tracer: client.internal.Tracer(),
   483  		})
   484  	}
   485  }
   486  
   487  // PacketCapture - Runs a packet capture on AzureFirewall.
   488  // If the operation fails it returns an *azcore.ResponseError type.
   489  //
   490  // Generated from API version 2024-05-01
   491  func (client *AzureFirewallsClient) packetCapture(ctx context.Context, resourceGroupName string, azureFirewallName string, parameters FirewallPacketCaptureParameters, options *AzureFirewallsClientBeginPacketCaptureOptions) (*http.Response, error) {
   492  	var err error
   493  	const operationName = "AzureFirewallsClient.BeginPacketCapture"
   494  	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
   495  	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
   496  	defer func() { endSpan(err) }()
   497  	req, err := client.packetCaptureCreateRequest(ctx, resourceGroupName, azureFirewallName, parameters, options)
   498  	if err != nil {
   499  		return nil, err
   500  	}
   501  	httpResp, err := client.internal.Pipeline().Do(req)
   502  	if err != nil {
   503  		return nil, err
   504  	}
   505  	if !runtime.HasStatusCode(httpResp, http.StatusAccepted) {
   506  		err = runtime.NewResponseError(httpResp)
   507  		return nil, err
   508  	}
   509  	return httpResp, nil
   510  }
   511  
   512  // packetCaptureCreateRequest creates the PacketCapture request.
   513  func (client *AzureFirewallsClient) packetCaptureCreateRequest(ctx context.Context, resourceGroupName string, azureFirewallName string, parameters FirewallPacketCaptureParameters, options *AzureFirewallsClientBeginPacketCaptureOptions) (*policy.Request, error) {
   514  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/azureFirewalls/{azureFirewallName}/packetCapture"
   515  	if resourceGroupName == "" {
   516  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   517  	}
   518  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   519  	if azureFirewallName == "" {
   520  		return nil, errors.New("parameter azureFirewallName cannot be empty")
   521  	}
   522  	urlPath = strings.ReplaceAll(urlPath, "{azureFirewallName}", url.PathEscape(azureFirewallName))
   523  	if client.subscriptionID == "" {
   524  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   525  	}
   526  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   527  	req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   528  	if err != nil {
   529  		return nil, err
   530  	}
   531  	reqQP := req.Raw().URL.Query()
   532  	reqQP.Set("api-version", "2024-05-01")
   533  	req.Raw().URL.RawQuery = reqQP.Encode()
   534  	req.Raw().Header["Accept"] = []string{"application/json"}
   535  	if err := runtime.MarshalAsJSON(req, parameters); err != nil {
   536  		return nil, err
   537  	}
   538  	return req, nil
   539  }
   540  
   541  // BeginUpdateTags - Updates tags of an Azure Firewall resource.
   542  // If the operation fails it returns an *azcore.ResponseError type.
   543  //
   544  // Generated from API version 2024-05-01
   545  //   - resourceGroupName - The name of the resource group.
   546  //   - azureFirewallName - The name of the Azure Firewall.
   547  //   - parameters - Parameters supplied to update azure firewall tags.
   548  //   - options - AzureFirewallsClientBeginUpdateTagsOptions contains the optional parameters for the AzureFirewallsClient.BeginUpdateTags
   549  //     method.
   550  func (client *AzureFirewallsClient) BeginUpdateTags(ctx context.Context, resourceGroupName string, azureFirewallName string, parameters TagsObject, options *AzureFirewallsClientBeginUpdateTagsOptions) (*runtime.Poller[AzureFirewallsClientUpdateTagsResponse], error) {
   551  	if options == nil || options.ResumeToken == "" {
   552  		resp, err := client.updateTags(ctx, resourceGroupName, azureFirewallName, parameters, options)
   553  		if err != nil {
   554  			return nil, err
   555  		}
   556  		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AzureFirewallsClientUpdateTagsResponse]{
   557  			FinalStateVia: runtime.FinalStateViaAzureAsyncOp,
   558  			Tracer:        client.internal.Tracer(),
   559  		})
   560  		return poller, err
   561  	} else {
   562  		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[AzureFirewallsClientUpdateTagsResponse]{
   563  			Tracer: client.internal.Tracer(),
   564  		})
   565  	}
   566  }
   567  
   568  // UpdateTags - Updates tags of an Azure Firewall resource.
   569  // If the operation fails it returns an *azcore.ResponseError type.
   570  //
   571  // Generated from API version 2024-05-01
   572  func (client *AzureFirewallsClient) updateTags(ctx context.Context, resourceGroupName string, azureFirewallName string, parameters TagsObject, options *AzureFirewallsClientBeginUpdateTagsOptions) (*http.Response, error) {
   573  	var err error
   574  	const operationName = "AzureFirewallsClient.BeginUpdateTags"
   575  	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
   576  	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
   577  	defer func() { endSpan(err) }()
   578  	req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, azureFirewallName, parameters, options)
   579  	if err != nil {
   580  		return nil, err
   581  	}
   582  	httpResp, err := client.internal.Pipeline().Do(req)
   583  	if err != nil {
   584  		return nil, err
   585  	}
   586  	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) {
   587  		err = runtime.NewResponseError(httpResp)
   588  		return nil, err
   589  	}
   590  	return httpResp, nil
   591  }
   592  
   593  // updateTagsCreateRequest creates the UpdateTags request.
   594  func (client *AzureFirewallsClient) updateTagsCreateRequest(ctx context.Context, resourceGroupName string, azureFirewallName string, parameters TagsObject, options *AzureFirewallsClientBeginUpdateTagsOptions) (*policy.Request, error) {
   595  	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/azureFirewalls/{azureFirewallName}"
   596  	if resourceGroupName == "" {
   597  		return nil, errors.New("parameter resourceGroupName cannot be empty")
   598  	}
   599  	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
   600  	if azureFirewallName == "" {
   601  		return nil, errors.New("parameter azureFirewallName cannot be empty")
   602  	}
   603  	urlPath = strings.ReplaceAll(urlPath, "{azureFirewallName}", url.PathEscape(azureFirewallName))
   604  	if client.subscriptionID == "" {
   605  		return nil, errors.New("parameter client.subscriptionID cannot be empty")
   606  	}
   607  	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
   608  	req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
   609  	if err != nil {
   610  		return nil, err
   611  	}
   612  	reqQP := req.Raw().URL.Query()
   613  	reqQP.Set("api-version", "2024-05-01")
   614  	req.Raw().URL.RawQuery = reqQP.Encode()
   615  	req.Raw().Header["Accept"] = []string{"application/json"}
   616  	if err := runtime.MarshalAsJSON(req, parameters); err != nil {
   617  		return nil, err
   618  	}
   619  	return req, nil
   620  }