//go:build go1.18
// +build go1.18

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.

package fake

import (
	"context"
	"errors"
	"fmt"
	"net/http"
	"net/url"
	"regexp"

	azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling"
)

// RoleDefinitionServer is a fake server for instances of the armbilling.RoleDefinitionClient type.
type RoleDefinitionServer struct {
	// GetByBillingAccount is the fake for method RoleDefinitionClient.GetByBillingAccount
	// HTTP status codes to indicate success: http.StatusOK
	GetByBillingAccount func(ctx context.Context, billingAccountName string, roleDefinitionName string, options *armbilling.RoleDefinitionClientGetByBillingAccountOptions) (resp azfake.Responder[armbilling.RoleDefinitionClientGetByBillingAccountResponse], errResp azfake.ErrorResponder)

	// GetByBillingProfile is the fake for method RoleDefinitionClient.GetByBillingProfile
	// HTTP status codes to indicate success: http.StatusOK
	GetByBillingProfile func(ctx context.Context, billingAccountName string, billingProfileName string, roleDefinitionName string, options *armbilling.RoleDefinitionClientGetByBillingProfileOptions) (resp azfake.Responder[armbilling.RoleDefinitionClientGetByBillingProfileResponse], errResp azfake.ErrorResponder)

	// GetByCustomer is the fake for method RoleDefinitionClient.GetByCustomer
	// HTTP status codes to indicate success: http.StatusOK
	GetByCustomer func(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, roleDefinitionName string, options *armbilling.RoleDefinitionClientGetByCustomerOptions) (resp azfake.Responder[armbilling.RoleDefinitionClientGetByCustomerResponse], errResp azfake.ErrorResponder)

	// GetByDepartment is the fake for method RoleDefinitionClient.GetByDepartment
	// HTTP status codes to indicate success: http.StatusOK
	GetByDepartment func(ctx context.Context, billingAccountName string, departmentName string, roleDefinitionName string, options *armbilling.RoleDefinitionClientGetByDepartmentOptions) (resp azfake.Responder[armbilling.RoleDefinitionClientGetByDepartmentResponse], errResp azfake.ErrorResponder)

	// GetByEnrollmentAccount is the fake for method RoleDefinitionClient.GetByEnrollmentAccount
	// HTTP status codes to indicate success: http.StatusOK
	GetByEnrollmentAccount func(ctx context.Context, billingAccountName string, enrollmentAccountName string, roleDefinitionName string, options *armbilling.RoleDefinitionClientGetByEnrollmentAccountOptions) (resp azfake.Responder[armbilling.RoleDefinitionClientGetByEnrollmentAccountResponse], errResp azfake.ErrorResponder)

	// GetByInvoiceSection is the fake for method RoleDefinitionClient.GetByInvoiceSection
	// HTTP status codes to indicate success: http.StatusOK
	GetByInvoiceSection func(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, roleDefinitionName string, options *armbilling.RoleDefinitionClientGetByInvoiceSectionOptions) (resp azfake.Responder[armbilling.RoleDefinitionClientGetByInvoiceSectionResponse], errResp azfake.ErrorResponder)

	// NewListByBillingAccountPager is the fake for method RoleDefinitionClient.NewListByBillingAccountPager
	// HTTP status codes to indicate success: http.StatusOK
	NewListByBillingAccountPager func(billingAccountName string, options *armbilling.RoleDefinitionClientListByBillingAccountOptions) (resp azfake.PagerResponder[armbilling.RoleDefinitionClientListByBillingAccountResponse])

	// NewListByBillingProfilePager is the fake for method RoleDefinitionClient.NewListByBillingProfilePager
	// HTTP status codes to indicate success: http.StatusOK
	NewListByBillingProfilePager func(billingAccountName string, billingProfileName string, options *armbilling.RoleDefinitionClientListByBillingProfileOptions) (resp azfake.PagerResponder[armbilling.RoleDefinitionClientListByBillingProfileResponse])

	// NewListByCustomerPager is the fake for method RoleDefinitionClient.NewListByCustomerPager
	// HTTP status codes to indicate success: http.StatusOK
	NewListByCustomerPager func(billingAccountName string, billingProfileName string, customerName string, options *armbilling.RoleDefinitionClientListByCustomerOptions) (resp azfake.PagerResponder[armbilling.RoleDefinitionClientListByCustomerResponse])

	// NewListByDepartmentPager is the fake for method RoleDefinitionClient.NewListByDepartmentPager
	// HTTP status codes to indicate success: http.StatusOK
	NewListByDepartmentPager func(billingAccountName string, departmentName string, options *armbilling.RoleDefinitionClientListByDepartmentOptions) (resp azfake.PagerResponder[armbilling.RoleDefinitionClientListByDepartmentResponse])

	// NewListByEnrollmentAccountPager is the fake for method RoleDefinitionClient.NewListByEnrollmentAccountPager
	// HTTP status codes to indicate success: http.StatusOK
	NewListByEnrollmentAccountPager func(billingAccountName string, enrollmentAccountName string, options *armbilling.RoleDefinitionClientListByEnrollmentAccountOptions) (resp azfake.PagerResponder[armbilling.RoleDefinitionClientListByEnrollmentAccountResponse])

	// NewListByInvoiceSectionPager is the fake for method RoleDefinitionClient.NewListByInvoiceSectionPager
	// HTTP status codes to indicate success: http.StatusOK
	NewListByInvoiceSectionPager func(billingAccountName string, billingProfileName string, invoiceSectionName string, options *armbilling.RoleDefinitionClientListByInvoiceSectionOptions) (resp azfake.PagerResponder[armbilling.RoleDefinitionClientListByInvoiceSectionResponse])
}

// NewRoleDefinitionServerTransport creates a new instance of RoleDefinitionServerTransport with the provided implementation.
// The returned RoleDefinitionServerTransport instance is connected to an instance of armbilling.RoleDefinitionClient via the
// azcore.ClientOptions.Transporter field in the client's constructor parameters.
func NewRoleDefinitionServerTransport(srv *RoleDefinitionServer) *RoleDefinitionServerTransport {
	return &RoleDefinitionServerTransport{
		srv:                             srv,
		newListByBillingAccountPager:    newTracker[azfake.PagerResponder[armbilling.RoleDefinitionClientListByBillingAccountResponse]](),
		newListByBillingProfilePager:    newTracker[azfake.PagerResponder[armbilling.RoleDefinitionClientListByBillingProfileResponse]](),
		newListByCustomerPager:          newTracker[azfake.PagerResponder[armbilling.RoleDefinitionClientListByCustomerResponse]](),
		newListByDepartmentPager:        newTracker[azfake.PagerResponder[armbilling.RoleDefinitionClientListByDepartmentResponse]](),
		newListByEnrollmentAccountPager: newTracker[azfake.PagerResponder[armbilling.RoleDefinitionClientListByEnrollmentAccountResponse]](),
		newListByInvoiceSectionPager:    newTracker[azfake.PagerResponder[armbilling.RoleDefinitionClientListByInvoiceSectionResponse]](),
	}
}

// RoleDefinitionServerTransport connects instances of armbilling.RoleDefinitionClient to instances of RoleDefinitionServer.
// Don't use this type directly, use NewRoleDefinitionServerTransport instead.
type RoleDefinitionServerTransport struct {
	srv                             *RoleDefinitionServer
	newListByBillingAccountPager    *tracker[azfake.PagerResponder[armbilling.RoleDefinitionClientListByBillingAccountResponse]]
	newListByBillingProfilePager    *tracker[azfake.PagerResponder[armbilling.RoleDefinitionClientListByBillingProfileResponse]]
	newListByCustomerPager          *tracker[azfake.PagerResponder[armbilling.RoleDefinitionClientListByCustomerResponse]]
	newListByDepartmentPager        *tracker[azfake.PagerResponder[armbilling.RoleDefinitionClientListByDepartmentResponse]]
	newListByEnrollmentAccountPager *tracker[azfake.PagerResponder[armbilling.RoleDefinitionClientListByEnrollmentAccountResponse]]
	newListByInvoiceSectionPager    *tracker[azfake.PagerResponder[armbilling.RoleDefinitionClientListByInvoiceSectionResponse]]
}

// Do implements the policy.Transporter interface for RoleDefinitionServerTransport.
func (r *RoleDefinitionServerTransport) Do(req *http.Request) (*http.Response, error) {
	rawMethod := req.Context().Value(runtime.CtxAPINameKey{})
	method, ok := rawMethod.(string)
	if !ok {
		return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")}
	}

	var resp *http.Response
	var err error

	switch method {
	case "RoleDefinitionClient.GetByBillingAccount":
		resp, err = r.dispatchGetByBillingAccount(req)
	case "RoleDefinitionClient.GetByBillingProfile":
		resp, err = r.dispatchGetByBillingProfile(req)
	case "RoleDefinitionClient.GetByCustomer":
		resp, err = r.dispatchGetByCustomer(req)
	case "RoleDefinitionClient.GetByDepartment":
		resp, err = r.dispatchGetByDepartment(req)
	case "RoleDefinitionClient.GetByEnrollmentAccount":
		resp, err = r.dispatchGetByEnrollmentAccount(req)
	case "RoleDefinitionClient.GetByInvoiceSection":
		resp, err = r.dispatchGetByInvoiceSection(req)
	case "RoleDefinitionClient.NewListByBillingAccountPager":
		resp, err = r.dispatchNewListByBillingAccountPager(req)
	case "RoleDefinitionClient.NewListByBillingProfilePager":
		resp, err = r.dispatchNewListByBillingProfilePager(req)
	case "RoleDefinitionClient.NewListByCustomerPager":
		resp, err = r.dispatchNewListByCustomerPager(req)
	case "RoleDefinitionClient.NewListByDepartmentPager":
		resp, err = r.dispatchNewListByDepartmentPager(req)
	case "RoleDefinitionClient.NewListByEnrollmentAccountPager":
		resp, err = r.dispatchNewListByEnrollmentAccountPager(req)
	case "RoleDefinitionClient.NewListByInvoiceSectionPager":
		resp, err = r.dispatchNewListByInvoiceSectionPager(req)
	default:
		err = fmt.Errorf("unhandled API %s", method)
	}

	if err != nil {
		return nil, err
	}

	return resp, nil
}

func (r *RoleDefinitionServerTransport) dispatchGetByBillingAccount(req *http.Request) (*http.Response, error) {
	if r.srv.GetByBillingAccount == nil {
		return nil, &nonRetriableError{errors.New("fake for method GetByBillingAccount not implemented")}
	}
	const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P<billingAccountName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions/(?P<roleDefinitionName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)`
	regex := regexp.MustCompile(regexStr)
	matches := regex.FindStringSubmatch(req.URL.EscapedPath())
	if matches == nil || len(matches) < 2 {
		return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
	}
	billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")])
	if err != nil {
		return nil, err
	}
	roleDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("roleDefinitionName")])
	if err != nil {
		return nil, err
	}
	respr, errRespr := r.srv.GetByBillingAccount(req.Context(), billingAccountNameParam, roleDefinitionNameParam, nil)
	if respErr := server.GetError(errRespr, req); respErr != nil {
		return nil, respErr
	}
	respContent := server.GetResponseContent(respr)
	if !contains([]int{http.StatusOK}, respContent.HTTPStatus) {
		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)}
	}
	resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RoleDefinition, req)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

func (r *RoleDefinitionServerTransport) dispatchGetByBillingProfile(req *http.Request) (*http.Response, error) {
	if r.srv.GetByBillingProfile == nil {
		return nil, &nonRetriableError{errors.New("fake for method GetByBillingProfile not implemented")}
	}
	const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P<billingAccountName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P<billingProfileName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions/(?P<roleDefinitionName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)`
	regex := regexp.MustCompile(regexStr)
	matches := regex.FindStringSubmatch(req.URL.EscapedPath())
	if matches == nil || len(matches) < 3 {
		return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
	}
	billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")])
	if err != nil {
		return nil, err
	}
	billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")])
	if err != nil {
		return nil, err
	}
	roleDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("roleDefinitionName")])
	if err != nil {
		return nil, err
	}
	respr, errRespr := r.srv.GetByBillingProfile(req.Context(), billingAccountNameParam, billingProfileNameParam, roleDefinitionNameParam, nil)
	if respErr := server.GetError(errRespr, req); respErr != nil {
		return nil, respErr
	}
	respContent := server.GetResponseContent(respr)
	if !contains([]int{http.StatusOK}, respContent.HTTPStatus) {
		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)}
	}
	resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RoleDefinition, req)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

func (r *RoleDefinitionServerTransport) dispatchGetByCustomer(req *http.Request) (*http.Response, error) {
	if r.srv.GetByCustomer == nil {
		return nil, &nonRetriableError{errors.New("fake for method GetByCustomer not implemented")}
	}
	const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P<billingAccountName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P<billingProfileName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P<customerName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions/(?P<roleDefinitionName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)`
	regex := regexp.MustCompile(regexStr)
	matches := regex.FindStringSubmatch(req.URL.EscapedPath())
	if matches == nil || len(matches) < 4 {
		return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
	}
	billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")])
	if err != nil {
		return nil, err
	}
	billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")])
	if err != nil {
		return nil, err
	}
	customerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("customerName")])
	if err != nil {
		return nil, err
	}
	roleDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("roleDefinitionName")])
	if err != nil {
		return nil, err
	}
	respr, errRespr := r.srv.GetByCustomer(req.Context(), billingAccountNameParam, billingProfileNameParam, customerNameParam, roleDefinitionNameParam, nil)
	if respErr := server.GetError(errRespr, req); respErr != nil {
		return nil, respErr
	}
	respContent := server.GetResponseContent(respr)
	if !contains([]int{http.StatusOK}, respContent.HTTPStatus) {
		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)}
	}
	resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RoleDefinition, req)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

func (r *RoleDefinitionServerTransport) dispatchGetByDepartment(req *http.Request) (*http.Response, error) {
	if r.srv.GetByDepartment == nil {
		return nil, &nonRetriableError{errors.New("fake for method GetByDepartment not implemented")}
	}
	const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P<billingAccountName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/departments/(?P<departmentName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions/(?P<roleDefinitionName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)`
	regex := regexp.MustCompile(regexStr)
	matches := regex.FindStringSubmatch(req.URL.EscapedPath())
	if matches == nil || len(matches) < 3 {
		return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
	}
	billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")])
	if err != nil {
		return nil, err
	}
	departmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("departmentName")])
	if err != nil {
		return nil, err
	}
	roleDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("roleDefinitionName")])
	if err != nil {
		return nil, err
	}
	respr, errRespr := r.srv.GetByDepartment(req.Context(), billingAccountNameParam, departmentNameParam, roleDefinitionNameParam, nil)
	if respErr := server.GetError(errRespr, req); respErr != nil {
		return nil, respErr
	}
	respContent := server.GetResponseContent(respr)
	if !contains([]int{http.StatusOK}, respContent.HTTPStatus) {
		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)}
	}
	resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RoleDefinition, req)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

func (r *RoleDefinitionServerTransport) dispatchGetByEnrollmentAccount(req *http.Request) (*http.Response, error) {
	if r.srv.GetByEnrollmentAccount == nil {
		return nil, &nonRetriableError{errors.New("fake for method GetByEnrollmentAccount not implemented")}
	}
	const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P<billingAccountName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enrollmentAccounts/(?P<enrollmentAccountName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions/(?P<roleDefinitionName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)`
	regex := regexp.MustCompile(regexStr)
	matches := regex.FindStringSubmatch(req.URL.EscapedPath())
	if matches == nil || len(matches) < 3 {
		return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
	}
	billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")])
	if err != nil {
		return nil, err
	}
	enrollmentAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("enrollmentAccountName")])
	if err != nil {
		return nil, err
	}
	roleDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("roleDefinitionName")])
	if err != nil {
		return nil, err
	}
	respr, errRespr := r.srv.GetByEnrollmentAccount(req.Context(), billingAccountNameParam, enrollmentAccountNameParam, roleDefinitionNameParam, nil)
	if respErr := server.GetError(errRespr, req); respErr != nil {
		return nil, respErr
	}
	respContent := server.GetResponseContent(respr)
	if !contains([]int{http.StatusOK}, respContent.HTTPStatus) {
		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)}
	}
	resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RoleDefinition, req)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

func (r *RoleDefinitionServerTransport) dispatchGetByInvoiceSection(req *http.Request) (*http.Response, error) {
	if r.srv.GetByInvoiceSection == nil {
		return nil, &nonRetriableError{errors.New("fake for method GetByInvoiceSection not implemented")}
	}
	const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P<billingAccountName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P<billingProfileName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoiceSections/(?P<invoiceSectionName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions/(?P<roleDefinitionName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)`
	regex := regexp.MustCompile(regexStr)
	matches := regex.FindStringSubmatch(req.URL.EscapedPath())
	if matches == nil || len(matches) < 4 {
		return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
	}
	billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")])
	if err != nil {
		return nil, err
	}
	billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")])
	if err != nil {
		return nil, err
	}
	invoiceSectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceSectionName")])
	if err != nil {
		return nil, err
	}
	roleDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("roleDefinitionName")])
	if err != nil {
		return nil, err
	}
	respr, errRespr := r.srv.GetByInvoiceSection(req.Context(), billingAccountNameParam, billingProfileNameParam, invoiceSectionNameParam, roleDefinitionNameParam, nil)
	if respErr := server.GetError(errRespr, req); respErr != nil {
		return nil, respErr
	}
	respContent := server.GetResponseContent(respr)
	if !contains([]int{http.StatusOK}, respContent.HTTPStatus) {
		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)}
	}
	resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RoleDefinition, req)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

func (r *RoleDefinitionServerTransport) dispatchNewListByBillingAccountPager(req *http.Request) (*http.Response, error) {
	if r.srv.NewListByBillingAccountPager == nil {
		return nil, &nonRetriableError{errors.New("fake for method NewListByBillingAccountPager not implemented")}
	}
	newListByBillingAccountPager := r.newListByBillingAccountPager.get(req)
	if newListByBillingAccountPager == nil {
		const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P<billingAccountName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions`
		regex := regexp.MustCompile(regexStr)
		matches := regex.FindStringSubmatch(req.URL.EscapedPath())
		if matches == nil || len(matches) < 1 {
			return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
		}
		billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")])
		if err != nil {
			return nil, err
		}
		resp := r.srv.NewListByBillingAccountPager(billingAccountNameParam, nil)
		newListByBillingAccountPager = &resp
		r.newListByBillingAccountPager.add(req, newListByBillingAccountPager)
		server.PagerResponderInjectNextLinks(newListByBillingAccountPager, req, func(page *armbilling.RoleDefinitionClientListByBillingAccountResponse, createLink func() string) {
			page.NextLink = to.Ptr(createLink())
		})
	}
	resp, err := server.PagerResponderNext(newListByBillingAccountPager, req)
	if err != nil {
		return nil, err
	}
	if !contains([]int{http.StatusOK}, resp.StatusCode) {
		r.newListByBillingAccountPager.remove(req)
		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)}
	}
	if !server.PagerResponderMore(newListByBillingAccountPager) {
		r.newListByBillingAccountPager.remove(req)
	}
	return resp, nil
}

func (r *RoleDefinitionServerTransport) dispatchNewListByBillingProfilePager(req *http.Request) (*http.Response, error) {
	if r.srv.NewListByBillingProfilePager == nil {
		return nil, &nonRetriableError{errors.New("fake for method NewListByBillingProfilePager not implemented")}
	}
	newListByBillingProfilePager := r.newListByBillingProfilePager.get(req)
	if newListByBillingProfilePager == nil {
		const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P<billingAccountName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P<billingProfileName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions`
		regex := regexp.MustCompile(regexStr)
		matches := regex.FindStringSubmatch(req.URL.EscapedPath())
		if matches == nil || len(matches) < 2 {
			return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
		}
		billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")])
		if err != nil {
			return nil, err
		}
		billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")])
		if err != nil {
			return nil, err
		}
		resp := r.srv.NewListByBillingProfilePager(billingAccountNameParam, billingProfileNameParam, nil)
		newListByBillingProfilePager = &resp
		r.newListByBillingProfilePager.add(req, newListByBillingProfilePager)
		server.PagerResponderInjectNextLinks(newListByBillingProfilePager, req, func(page *armbilling.RoleDefinitionClientListByBillingProfileResponse, createLink func() string) {
			page.NextLink = to.Ptr(createLink())
		})
	}
	resp, err := server.PagerResponderNext(newListByBillingProfilePager, req)
	if err != nil {
		return nil, err
	}
	if !contains([]int{http.StatusOK}, resp.StatusCode) {
		r.newListByBillingProfilePager.remove(req)
		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)}
	}
	if !server.PagerResponderMore(newListByBillingProfilePager) {
		r.newListByBillingProfilePager.remove(req)
	}
	return resp, nil
}

func (r *RoleDefinitionServerTransport) dispatchNewListByCustomerPager(req *http.Request) (*http.Response, error) {
	if r.srv.NewListByCustomerPager == nil {
		return nil, &nonRetriableError{errors.New("fake for method NewListByCustomerPager not implemented")}
	}
	newListByCustomerPager := r.newListByCustomerPager.get(req)
	if newListByCustomerPager == nil {
		const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P<billingAccountName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P<billingProfileName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P<customerName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions`
		regex := regexp.MustCompile(regexStr)
		matches := regex.FindStringSubmatch(req.URL.EscapedPath())
		if matches == nil || len(matches) < 3 {
			return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
		}
		billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")])
		if err != nil {
			return nil, err
		}
		billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")])
		if err != nil {
			return nil, err
		}
		customerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("customerName")])
		if err != nil {
			return nil, err
		}
		resp := r.srv.NewListByCustomerPager(billingAccountNameParam, billingProfileNameParam, customerNameParam, nil)
		newListByCustomerPager = &resp
		r.newListByCustomerPager.add(req, newListByCustomerPager)
		server.PagerResponderInjectNextLinks(newListByCustomerPager, req, func(page *armbilling.RoleDefinitionClientListByCustomerResponse, createLink func() string) {
			page.NextLink = to.Ptr(createLink())
		})
	}
	resp, err := server.PagerResponderNext(newListByCustomerPager, req)
	if err != nil {
		return nil, err
	}
	if !contains([]int{http.StatusOK}, resp.StatusCode) {
		r.newListByCustomerPager.remove(req)
		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)}
	}
	if !server.PagerResponderMore(newListByCustomerPager) {
		r.newListByCustomerPager.remove(req)
	}
	return resp, nil
}

func (r *RoleDefinitionServerTransport) dispatchNewListByDepartmentPager(req *http.Request) (*http.Response, error) {
	if r.srv.NewListByDepartmentPager == nil {
		return nil, &nonRetriableError{errors.New("fake for method NewListByDepartmentPager not implemented")}
	}
	newListByDepartmentPager := r.newListByDepartmentPager.get(req)
	if newListByDepartmentPager == nil {
		const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P<billingAccountName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/departments/(?P<departmentName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions`
		regex := regexp.MustCompile(regexStr)
		matches := regex.FindStringSubmatch(req.URL.EscapedPath())
		if matches == nil || len(matches) < 2 {
			return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
		}
		billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")])
		if err != nil {
			return nil, err
		}
		departmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("departmentName")])
		if err != nil {
			return nil, err
		}
		resp := r.srv.NewListByDepartmentPager(billingAccountNameParam, departmentNameParam, nil)
		newListByDepartmentPager = &resp
		r.newListByDepartmentPager.add(req, newListByDepartmentPager)
		server.PagerResponderInjectNextLinks(newListByDepartmentPager, req, func(page *armbilling.RoleDefinitionClientListByDepartmentResponse, createLink func() string) {
			page.NextLink = to.Ptr(createLink())
		})
	}
	resp, err := server.PagerResponderNext(newListByDepartmentPager, req)
	if err != nil {
		return nil, err
	}
	if !contains([]int{http.StatusOK}, resp.StatusCode) {
		r.newListByDepartmentPager.remove(req)
		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)}
	}
	if !server.PagerResponderMore(newListByDepartmentPager) {
		r.newListByDepartmentPager.remove(req)
	}
	return resp, nil
}

func (r *RoleDefinitionServerTransport) dispatchNewListByEnrollmentAccountPager(req *http.Request) (*http.Response, error) {
	if r.srv.NewListByEnrollmentAccountPager == nil {
		return nil, &nonRetriableError{errors.New("fake for method NewListByEnrollmentAccountPager not implemented")}
	}
	newListByEnrollmentAccountPager := r.newListByEnrollmentAccountPager.get(req)
	if newListByEnrollmentAccountPager == nil {
		const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P<billingAccountName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enrollmentAccounts/(?P<enrollmentAccountName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions`
		regex := regexp.MustCompile(regexStr)
		matches := regex.FindStringSubmatch(req.URL.EscapedPath())
		if matches == nil || len(matches) < 2 {
			return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
		}
		billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")])
		if err != nil {
			return nil, err
		}
		enrollmentAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("enrollmentAccountName")])
		if err != nil {
			return nil, err
		}
		resp := r.srv.NewListByEnrollmentAccountPager(billingAccountNameParam, enrollmentAccountNameParam, nil)
		newListByEnrollmentAccountPager = &resp
		r.newListByEnrollmentAccountPager.add(req, newListByEnrollmentAccountPager)
		server.PagerResponderInjectNextLinks(newListByEnrollmentAccountPager, req, func(page *armbilling.RoleDefinitionClientListByEnrollmentAccountResponse, createLink func() string) {
			page.NextLink = to.Ptr(createLink())
		})
	}
	resp, err := server.PagerResponderNext(newListByEnrollmentAccountPager, req)
	if err != nil {
		return nil, err
	}
	if !contains([]int{http.StatusOK}, resp.StatusCode) {
		r.newListByEnrollmentAccountPager.remove(req)
		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)}
	}
	if !server.PagerResponderMore(newListByEnrollmentAccountPager) {
		r.newListByEnrollmentAccountPager.remove(req)
	}
	return resp, nil
}

func (r *RoleDefinitionServerTransport) dispatchNewListByInvoiceSectionPager(req *http.Request) (*http.Response, error) {
	if r.srv.NewListByInvoiceSectionPager == nil {
		return nil, &nonRetriableError{errors.New("fake for method NewListByInvoiceSectionPager not implemented")}
	}
	newListByInvoiceSectionPager := r.newListByInvoiceSectionPager.get(req)
	if newListByInvoiceSectionPager == nil {
		const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P<billingAccountName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P<billingProfileName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoiceSections/(?P<invoiceSectionName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions`
		regex := regexp.MustCompile(regexStr)
		matches := regex.FindStringSubmatch(req.URL.EscapedPath())
		if matches == nil || len(matches) < 3 {
			return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
		}
		billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")])
		if err != nil {
			return nil, err
		}
		billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")])
		if err != nil {
			return nil, err
		}
		invoiceSectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceSectionName")])
		if err != nil {
			return nil, err
		}
		resp := r.srv.NewListByInvoiceSectionPager(billingAccountNameParam, billingProfileNameParam, invoiceSectionNameParam, nil)
		newListByInvoiceSectionPager = &resp
		r.newListByInvoiceSectionPager.add(req, newListByInvoiceSectionPager)
		server.PagerResponderInjectNextLinks(newListByInvoiceSectionPager, req, func(page *armbilling.RoleDefinitionClientListByInvoiceSectionResponse, createLink func() string) {
			page.NextLink = to.Ptr(createLink())
		})
	}
	resp, err := server.PagerResponderNext(newListByInvoiceSectionPager, req)
	if err != nil {
		return nil, err
	}
	if !contains([]int{http.StatusOK}, resp.StatusCode) {
		r.newListByInvoiceSectionPager.remove(req)
		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)}
	}
	if !server.PagerResponderMore(newListByInvoiceSectionPager) {
		r.newListByInvoiceSectionPager.remove(req)
	}
	return resp, nil
}
