github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6@v6.2.0/fake/loadbalancers_server.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 fake
    10  
    11  import (
    12  	"context"
    13  	"errors"
    14  	"fmt"
    15  	azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake"
    16  	"github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server"
    17  	"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
    18  	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
    19  	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6"
    20  	"net/http"
    21  	"net/url"
    22  	"reflect"
    23  	"regexp"
    24  )
    25  
    26  // LoadBalancersServer is a fake server for instances of the armnetwork.LoadBalancersClient type.
    27  type LoadBalancersServer struct {
    28  	// BeginCreateOrUpdate is the fake for method LoadBalancersClient.BeginCreateOrUpdate
    29  	// HTTP status codes to indicate success: http.StatusOK, http.StatusCreated
    30  	BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, loadBalancerName string, parameters armnetwork.LoadBalancer, options *armnetwork.LoadBalancersClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armnetwork.LoadBalancersClientCreateOrUpdateResponse], errResp azfake.ErrorResponder)
    31  
    32  	// BeginDelete is the fake for method LoadBalancersClient.BeginDelete
    33  	// HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent
    34  	BeginDelete func(ctx context.Context, resourceGroupName string, loadBalancerName string, options *armnetwork.LoadBalancersClientBeginDeleteOptions) (resp azfake.PollerResponder[armnetwork.LoadBalancersClientDeleteResponse], errResp azfake.ErrorResponder)
    35  
    36  	// Get is the fake for method LoadBalancersClient.Get
    37  	// HTTP status codes to indicate success: http.StatusOK
    38  	Get func(ctx context.Context, resourceGroupName string, loadBalancerName string, options *armnetwork.LoadBalancersClientGetOptions) (resp azfake.Responder[armnetwork.LoadBalancersClientGetResponse], errResp azfake.ErrorResponder)
    39  
    40  	// NewListPager is the fake for method LoadBalancersClient.NewListPager
    41  	// HTTP status codes to indicate success: http.StatusOK
    42  	NewListPager func(resourceGroupName string, options *armnetwork.LoadBalancersClientListOptions) (resp azfake.PagerResponder[armnetwork.LoadBalancersClientListResponse])
    43  
    44  	// NewListAllPager is the fake for method LoadBalancersClient.NewListAllPager
    45  	// HTTP status codes to indicate success: http.StatusOK
    46  	NewListAllPager func(options *armnetwork.LoadBalancersClientListAllOptions) (resp azfake.PagerResponder[armnetwork.LoadBalancersClientListAllResponse])
    47  
    48  	// BeginListInboundNatRulePortMappings is the fake for method LoadBalancersClient.BeginListInboundNatRulePortMappings
    49  	// HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted
    50  	BeginListInboundNatRulePortMappings func(ctx context.Context, groupName string, loadBalancerName string, backendPoolName string, parameters armnetwork.QueryInboundNatRulePortMappingRequest, options *armnetwork.LoadBalancersClientBeginListInboundNatRulePortMappingsOptions) (resp azfake.PollerResponder[armnetwork.LoadBalancersClientListInboundNatRulePortMappingsResponse], errResp azfake.ErrorResponder)
    51  
    52  	// MigrateToIPBased is the fake for method LoadBalancersClient.MigrateToIPBased
    53  	// HTTP status codes to indicate success: http.StatusOK
    54  	MigrateToIPBased func(ctx context.Context, groupName string, loadBalancerName string, options *armnetwork.LoadBalancersClientMigrateToIPBasedOptions) (resp azfake.Responder[armnetwork.LoadBalancersClientMigrateToIPBasedResponse], errResp azfake.ErrorResponder)
    55  
    56  	// BeginSwapPublicIPAddresses is the fake for method LoadBalancersClient.BeginSwapPublicIPAddresses
    57  	// HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted
    58  	BeginSwapPublicIPAddresses func(ctx context.Context, location string, parameters armnetwork.LoadBalancerVipSwapRequest, options *armnetwork.LoadBalancersClientBeginSwapPublicIPAddressesOptions) (resp azfake.PollerResponder[armnetwork.LoadBalancersClientSwapPublicIPAddressesResponse], errResp azfake.ErrorResponder)
    59  
    60  	// UpdateTags is the fake for method LoadBalancersClient.UpdateTags
    61  	// HTTP status codes to indicate success: http.StatusOK
    62  	UpdateTags func(ctx context.Context, resourceGroupName string, loadBalancerName string, parameters armnetwork.TagsObject, options *armnetwork.LoadBalancersClientUpdateTagsOptions) (resp azfake.Responder[armnetwork.LoadBalancersClientUpdateTagsResponse], errResp azfake.ErrorResponder)
    63  }
    64  
    65  // NewLoadBalancersServerTransport creates a new instance of LoadBalancersServerTransport with the provided implementation.
    66  // The returned LoadBalancersServerTransport instance is connected to an instance of armnetwork.LoadBalancersClient via the
    67  // azcore.ClientOptions.Transporter field in the client's constructor parameters.
    68  func NewLoadBalancersServerTransport(srv *LoadBalancersServer) *LoadBalancersServerTransport {
    69  	return &LoadBalancersServerTransport{
    70  		srv:                                 srv,
    71  		beginCreateOrUpdate:                 newTracker[azfake.PollerResponder[armnetwork.LoadBalancersClientCreateOrUpdateResponse]](),
    72  		beginDelete:                         newTracker[azfake.PollerResponder[armnetwork.LoadBalancersClientDeleteResponse]](),
    73  		newListPager:                        newTracker[azfake.PagerResponder[armnetwork.LoadBalancersClientListResponse]](),
    74  		newListAllPager:                     newTracker[azfake.PagerResponder[armnetwork.LoadBalancersClientListAllResponse]](),
    75  		beginListInboundNatRulePortMappings: newTracker[azfake.PollerResponder[armnetwork.LoadBalancersClientListInboundNatRulePortMappingsResponse]](),
    76  		beginSwapPublicIPAddresses:          newTracker[azfake.PollerResponder[armnetwork.LoadBalancersClientSwapPublicIPAddressesResponse]](),
    77  	}
    78  }
    79  
    80  // LoadBalancersServerTransport connects instances of armnetwork.LoadBalancersClient to instances of LoadBalancersServer.
    81  // Don't use this type directly, use NewLoadBalancersServerTransport instead.
    82  type LoadBalancersServerTransport struct {
    83  	srv                                 *LoadBalancersServer
    84  	beginCreateOrUpdate                 *tracker[azfake.PollerResponder[armnetwork.LoadBalancersClientCreateOrUpdateResponse]]
    85  	beginDelete                         *tracker[azfake.PollerResponder[armnetwork.LoadBalancersClientDeleteResponse]]
    86  	newListPager                        *tracker[azfake.PagerResponder[armnetwork.LoadBalancersClientListResponse]]
    87  	newListAllPager                     *tracker[azfake.PagerResponder[armnetwork.LoadBalancersClientListAllResponse]]
    88  	beginListInboundNatRulePortMappings *tracker[azfake.PollerResponder[armnetwork.LoadBalancersClientListInboundNatRulePortMappingsResponse]]
    89  	beginSwapPublicIPAddresses          *tracker[azfake.PollerResponder[armnetwork.LoadBalancersClientSwapPublicIPAddressesResponse]]
    90  }
    91  
    92  // Do implements the policy.Transporter interface for LoadBalancersServerTransport.
    93  func (l *LoadBalancersServerTransport) Do(req *http.Request) (*http.Response, error) {
    94  	rawMethod := req.Context().Value(runtime.CtxAPINameKey{})
    95  	method, ok := rawMethod.(string)
    96  	if !ok {
    97  		return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")}
    98  	}
    99  
   100  	var resp *http.Response
   101  	var err error
   102  
   103  	switch method {
   104  	case "LoadBalancersClient.BeginCreateOrUpdate":
   105  		resp, err = l.dispatchBeginCreateOrUpdate(req)
   106  	case "LoadBalancersClient.BeginDelete":
   107  		resp, err = l.dispatchBeginDelete(req)
   108  	case "LoadBalancersClient.Get":
   109  		resp, err = l.dispatchGet(req)
   110  	case "LoadBalancersClient.NewListPager":
   111  		resp, err = l.dispatchNewListPager(req)
   112  	case "LoadBalancersClient.NewListAllPager":
   113  		resp, err = l.dispatchNewListAllPager(req)
   114  	case "LoadBalancersClient.BeginListInboundNatRulePortMappings":
   115  		resp, err = l.dispatchBeginListInboundNatRulePortMappings(req)
   116  	case "LoadBalancersClient.MigrateToIPBased":
   117  		resp, err = l.dispatchMigrateToIPBased(req)
   118  	case "LoadBalancersClient.BeginSwapPublicIPAddresses":
   119  		resp, err = l.dispatchBeginSwapPublicIPAddresses(req)
   120  	case "LoadBalancersClient.UpdateTags":
   121  		resp, err = l.dispatchUpdateTags(req)
   122  	default:
   123  		err = fmt.Errorf("unhandled API %s", method)
   124  	}
   125  
   126  	if err != nil {
   127  		return nil, err
   128  	}
   129  
   130  	return resp, nil
   131  }
   132  
   133  func (l *LoadBalancersServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) {
   134  	if l.srv.BeginCreateOrUpdate == nil {
   135  		return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")}
   136  	}
   137  	beginCreateOrUpdate := l.beginCreateOrUpdate.get(req)
   138  	if beginCreateOrUpdate == nil {
   139  		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Network/loadBalancers/(?P<loadBalancerName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)`
   140  		regex := regexp.MustCompile(regexStr)
   141  		matches := regex.FindStringSubmatch(req.URL.EscapedPath())
   142  		if matches == nil || len(matches) < 3 {
   143  			return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
   144  		}
   145  		body, err := server.UnmarshalRequestAsJSON[armnetwork.LoadBalancer](req)
   146  		if err != nil {
   147  			return nil, err
   148  		}
   149  		resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
   150  		if err != nil {
   151  			return nil, err
   152  		}
   153  		loadBalancerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("loadBalancerName")])
   154  		if err != nil {
   155  			return nil, err
   156  		}
   157  		respr, errRespr := l.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, loadBalancerNameParam, body, nil)
   158  		if respErr := server.GetError(errRespr, req); respErr != nil {
   159  			return nil, respErr
   160  		}
   161  		beginCreateOrUpdate = &respr
   162  		l.beginCreateOrUpdate.add(req, beginCreateOrUpdate)
   163  	}
   164  
   165  	resp, err := server.PollerResponderNext(beginCreateOrUpdate, req)
   166  	if err != nil {
   167  		return nil, err
   168  	}
   169  
   170  	if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) {
   171  		l.beginCreateOrUpdate.remove(req)
   172  		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)}
   173  	}
   174  	if !server.PollerResponderMore(beginCreateOrUpdate) {
   175  		l.beginCreateOrUpdate.remove(req)
   176  	}
   177  
   178  	return resp, nil
   179  }
   180  
   181  func (l *LoadBalancersServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) {
   182  	if l.srv.BeginDelete == nil {
   183  		return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")}
   184  	}
   185  	beginDelete := l.beginDelete.get(req)
   186  	if beginDelete == nil {
   187  		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Network/loadBalancers/(?P<loadBalancerName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)`
   188  		regex := regexp.MustCompile(regexStr)
   189  		matches := regex.FindStringSubmatch(req.URL.EscapedPath())
   190  		if matches == nil || len(matches) < 3 {
   191  			return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
   192  		}
   193  		resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
   194  		if err != nil {
   195  			return nil, err
   196  		}
   197  		loadBalancerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("loadBalancerName")])
   198  		if err != nil {
   199  			return nil, err
   200  		}
   201  		respr, errRespr := l.srv.BeginDelete(req.Context(), resourceGroupNameParam, loadBalancerNameParam, nil)
   202  		if respErr := server.GetError(errRespr, req); respErr != nil {
   203  			return nil, respErr
   204  		}
   205  		beginDelete = &respr
   206  		l.beginDelete.add(req, beginDelete)
   207  	}
   208  
   209  	resp, err := server.PollerResponderNext(beginDelete, req)
   210  	if err != nil {
   211  		return nil, err
   212  	}
   213  
   214  	if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) {
   215  		l.beginDelete.remove(req)
   216  		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)}
   217  	}
   218  	if !server.PollerResponderMore(beginDelete) {
   219  		l.beginDelete.remove(req)
   220  	}
   221  
   222  	return resp, nil
   223  }
   224  
   225  func (l *LoadBalancersServerTransport) dispatchGet(req *http.Request) (*http.Response, error) {
   226  	if l.srv.Get == nil {
   227  		return nil, &nonRetriableError{errors.New("fake for method Get not implemented")}
   228  	}
   229  	const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Network/loadBalancers/(?P<loadBalancerName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)`
   230  	regex := regexp.MustCompile(regexStr)
   231  	matches := regex.FindStringSubmatch(req.URL.EscapedPath())
   232  	if matches == nil || len(matches) < 3 {
   233  		return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
   234  	}
   235  	qp := req.URL.Query()
   236  	resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
   237  	if err != nil {
   238  		return nil, err
   239  	}
   240  	loadBalancerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("loadBalancerName")])
   241  	if err != nil {
   242  		return nil, err
   243  	}
   244  	expandUnescaped, err := url.QueryUnescape(qp.Get("$expand"))
   245  	if err != nil {
   246  		return nil, err
   247  	}
   248  	expandParam := getOptional(expandUnescaped)
   249  	var options *armnetwork.LoadBalancersClientGetOptions
   250  	if expandParam != nil {
   251  		options = &armnetwork.LoadBalancersClientGetOptions{
   252  			Expand: expandParam,
   253  		}
   254  	}
   255  	respr, errRespr := l.srv.Get(req.Context(), resourceGroupNameParam, loadBalancerNameParam, options)
   256  	if respErr := server.GetError(errRespr, req); respErr != nil {
   257  		return nil, respErr
   258  	}
   259  	respContent := server.GetResponseContent(respr)
   260  	if !contains([]int{http.StatusOK}, respContent.HTTPStatus) {
   261  		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)}
   262  	}
   263  	resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).LoadBalancer, req)
   264  	if err != nil {
   265  		return nil, err
   266  	}
   267  	return resp, nil
   268  }
   269  
   270  func (l *LoadBalancersServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) {
   271  	if l.srv.NewListPager == nil {
   272  		return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")}
   273  	}
   274  	newListPager := l.newListPager.get(req)
   275  	if newListPager == nil {
   276  		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Network/loadBalancers`
   277  		regex := regexp.MustCompile(regexStr)
   278  		matches := regex.FindStringSubmatch(req.URL.EscapedPath())
   279  		if matches == nil || len(matches) < 2 {
   280  			return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
   281  		}
   282  		resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
   283  		if err != nil {
   284  			return nil, err
   285  		}
   286  		resp := l.srv.NewListPager(resourceGroupNameParam, nil)
   287  		newListPager = &resp
   288  		l.newListPager.add(req, newListPager)
   289  		server.PagerResponderInjectNextLinks(newListPager, req, func(page *armnetwork.LoadBalancersClientListResponse, createLink func() string) {
   290  			page.NextLink = to.Ptr(createLink())
   291  		})
   292  	}
   293  	resp, err := server.PagerResponderNext(newListPager, req)
   294  	if err != nil {
   295  		return nil, err
   296  	}
   297  	if !contains([]int{http.StatusOK}, resp.StatusCode) {
   298  		l.newListPager.remove(req)
   299  		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)}
   300  	}
   301  	if !server.PagerResponderMore(newListPager) {
   302  		l.newListPager.remove(req)
   303  	}
   304  	return resp, nil
   305  }
   306  
   307  func (l *LoadBalancersServerTransport) dispatchNewListAllPager(req *http.Request) (*http.Response, error) {
   308  	if l.srv.NewListAllPager == nil {
   309  		return nil, &nonRetriableError{errors.New("fake for method NewListAllPager not implemented")}
   310  	}
   311  	newListAllPager := l.newListAllPager.get(req)
   312  	if newListAllPager == nil {
   313  		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Network/loadBalancers`
   314  		regex := regexp.MustCompile(regexStr)
   315  		matches := regex.FindStringSubmatch(req.URL.EscapedPath())
   316  		if matches == nil || len(matches) < 1 {
   317  			return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
   318  		}
   319  		resp := l.srv.NewListAllPager(nil)
   320  		newListAllPager = &resp
   321  		l.newListAllPager.add(req, newListAllPager)
   322  		server.PagerResponderInjectNextLinks(newListAllPager, req, func(page *armnetwork.LoadBalancersClientListAllResponse, createLink func() string) {
   323  			page.NextLink = to.Ptr(createLink())
   324  		})
   325  	}
   326  	resp, err := server.PagerResponderNext(newListAllPager, req)
   327  	if err != nil {
   328  		return nil, err
   329  	}
   330  	if !contains([]int{http.StatusOK}, resp.StatusCode) {
   331  		l.newListAllPager.remove(req)
   332  		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)}
   333  	}
   334  	if !server.PagerResponderMore(newListAllPager) {
   335  		l.newListAllPager.remove(req)
   336  	}
   337  	return resp, nil
   338  }
   339  
   340  func (l *LoadBalancersServerTransport) dispatchBeginListInboundNatRulePortMappings(req *http.Request) (*http.Response, error) {
   341  	if l.srv.BeginListInboundNatRulePortMappings == nil {
   342  		return nil, &nonRetriableError{errors.New("fake for method BeginListInboundNatRulePortMappings not implemented")}
   343  	}
   344  	beginListInboundNatRulePortMappings := l.beginListInboundNatRulePortMappings.get(req)
   345  	if beginListInboundNatRulePortMappings == nil {
   346  		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<groupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Network/loadBalancers/(?P<loadBalancerName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backendAddressPools/(?P<backendPoolName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/queryInboundNatRulePortMapping`
   347  		regex := regexp.MustCompile(regexStr)
   348  		matches := regex.FindStringSubmatch(req.URL.EscapedPath())
   349  		if matches == nil || len(matches) < 4 {
   350  			return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
   351  		}
   352  		body, err := server.UnmarshalRequestAsJSON[armnetwork.QueryInboundNatRulePortMappingRequest](req)
   353  		if err != nil {
   354  			return nil, err
   355  		}
   356  		groupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("groupName")])
   357  		if err != nil {
   358  			return nil, err
   359  		}
   360  		loadBalancerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("loadBalancerName")])
   361  		if err != nil {
   362  			return nil, err
   363  		}
   364  		backendPoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("backendPoolName")])
   365  		if err != nil {
   366  			return nil, err
   367  		}
   368  		respr, errRespr := l.srv.BeginListInboundNatRulePortMappings(req.Context(), groupNameParam, loadBalancerNameParam, backendPoolNameParam, body, nil)
   369  		if respErr := server.GetError(errRespr, req); respErr != nil {
   370  			return nil, respErr
   371  		}
   372  		beginListInboundNatRulePortMappings = &respr
   373  		l.beginListInboundNatRulePortMappings.add(req, beginListInboundNatRulePortMappings)
   374  	}
   375  
   376  	resp, err := server.PollerResponderNext(beginListInboundNatRulePortMappings, req)
   377  	if err != nil {
   378  		return nil, err
   379  	}
   380  
   381  	if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) {
   382  		l.beginListInboundNatRulePortMappings.remove(req)
   383  		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)}
   384  	}
   385  	if !server.PollerResponderMore(beginListInboundNatRulePortMappings) {
   386  		l.beginListInboundNatRulePortMappings.remove(req)
   387  	}
   388  
   389  	return resp, nil
   390  }
   391  
   392  func (l *LoadBalancersServerTransport) dispatchMigrateToIPBased(req *http.Request) (*http.Response, error) {
   393  	if l.srv.MigrateToIPBased == nil {
   394  		return nil, &nonRetriableError{errors.New("fake for method MigrateToIPBased not implemented")}
   395  	}
   396  	const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<groupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Network/loadBalancers/(?P<loadBalancerName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/migrateToIpBased`
   397  	regex := regexp.MustCompile(regexStr)
   398  	matches := regex.FindStringSubmatch(req.URL.EscapedPath())
   399  	if matches == nil || len(matches) < 3 {
   400  		return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
   401  	}
   402  	body, err := server.UnmarshalRequestAsJSON[armnetwork.MigrateLoadBalancerToIPBasedRequest](req)
   403  	if err != nil {
   404  		return nil, err
   405  	}
   406  	groupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("groupName")])
   407  	if err != nil {
   408  		return nil, err
   409  	}
   410  	loadBalancerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("loadBalancerName")])
   411  	if err != nil {
   412  		return nil, err
   413  	}
   414  	var options *armnetwork.LoadBalancersClientMigrateToIPBasedOptions
   415  	if !reflect.ValueOf(body).IsZero() {
   416  		options = &armnetwork.LoadBalancersClientMigrateToIPBasedOptions{
   417  			Parameters: &body,
   418  		}
   419  	}
   420  	respr, errRespr := l.srv.MigrateToIPBased(req.Context(), groupNameParam, loadBalancerNameParam, options)
   421  	if respErr := server.GetError(errRespr, req); respErr != nil {
   422  		return nil, respErr
   423  	}
   424  	respContent := server.GetResponseContent(respr)
   425  	if !contains([]int{http.StatusOK}, respContent.HTTPStatus) {
   426  		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)}
   427  	}
   428  	resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).MigratedPools, req)
   429  	if err != nil {
   430  		return nil, err
   431  	}
   432  	return resp, nil
   433  }
   434  
   435  func (l *LoadBalancersServerTransport) dispatchBeginSwapPublicIPAddresses(req *http.Request) (*http.Response, error) {
   436  	if l.srv.BeginSwapPublicIPAddresses == nil {
   437  		return nil, &nonRetriableError{errors.New("fake for method BeginSwapPublicIPAddresses not implemented")}
   438  	}
   439  	beginSwapPublicIPAddresses := l.beginSwapPublicIPAddresses.get(req)
   440  	if beginSwapPublicIPAddresses == nil {
   441  		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Network/locations/(?P<location>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/setLoadBalancerFrontendPublicIpAddresses`
   442  		regex := regexp.MustCompile(regexStr)
   443  		matches := regex.FindStringSubmatch(req.URL.EscapedPath())
   444  		if matches == nil || len(matches) < 2 {
   445  			return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
   446  		}
   447  		body, err := server.UnmarshalRequestAsJSON[armnetwork.LoadBalancerVipSwapRequest](req)
   448  		if err != nil {
   449  			return nil, err
   450  		}
   451  		locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")])
   452  		if err != nil {
   453  			return nil, err
   454  		}
   455  		respr, errRespr := l.srv.BeginSwapPublicIPAddresses(req.Context(), locationParam, body, nil)
   456  		if respErr := server.GetError(errRespr, req); respErr != nil {
   457  			return nil, respErr
   458  		}
   459  		beginSwapPublicIPAddresses = &respr
   460  		l.beginSwapPublicIPAddresses.add(req, beginSwapPublicIPAddresses)
   461  	}
   462  
   463  	resp, err := server.PollerResponderNext(beginSwapPublicIPAddresses, req)
   464  	if err != nil {
   465  		return nil, err
   466  	}
   467  
   468  	if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) {
   469  		l.beginSwapPublicIPAddresses.remove(req)
   470  		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)}
   471  	}
   472  	if !server.PollerResponderMore(beginSwapPublicIPAddresses) {
   473  		l.beginSwapPublicIPAddresses.remove(req)
   474  	}
   475  
   476  	return resp, nil
   477  }
   478  
   479  func (l *LoadBalancersServerTransport) dispatchUpdateTags(req *http.Request) (*http.Response, error) {
   480  	if l.srv.UpdateTags == nil {
   481  		return nil, &nonRetriableError{errors.New("fake for method UpdateTags not implemented")}
   482  	}
   483  	const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Network/loadBalancers/(?P<loadBalancerName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)`
   484  	regex := regexp.MustCompile(regexStr)
   485  	matches := regex.FindStringSubmatch(req.URL.EscapedPath())
   486  	if matches == nil || len(matches) < 3 {
   487  		return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
   488  	}
   489  	body, err := server.UnmarshalRequestAsJSON[armnetwork.TagsObject](req)
   490  	if err != nil {
   491  		return nil, err
   492  	}
   493  	resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
   494  	if err != nil {
   495  		return nil, err
   496  	}
   497  	loadBalancerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("loadBalancerName")])
   498  	if err != nil {
   499  		return nil, err
   500  	}
   501  	respr, errRespr := l.srv.UpdateTags(req.Context(), resourceGroupNameParam, loadBalancerNameParam, body, nil)
   502  	if respErr := server.GetError(errRespr, req); respErr != nil {
   503  		return nil, respErr
   504  	}
   505  	respContent := server.GetResponseContent(respr)
   506  	if !contains([]int{http.StatusOK}, respContent.HTTPStatus) {
   507  		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)}
   508  	}
   509  	resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).LoadBalancer, req)
   510  	if err != nil {
   511  		return nil, err
   512  	}
   513  	return resp, nil
   514  }