// 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) Go Code Generator. DO NOT EDIT.

package fake

import (
	"context"
	"errors"
	"fmt"
	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/purestorageblock/armpurestorageblock"
	"net/http"
	"net/url"
	"regexp"
)

// ReservationsServer is a fake server for instances of the armpurestorageblock.ReservationsClient type.
type ReservationsServer struct {
	// BeginCreate is the fake for method ReservationsClient.BeginCreate
	// HTTP status codes to indicate success: http.StatusOK, http.StatusCreated
	BeginCreate func(ctx context.Context, resourceGroupName string, reservationName string, resource armpurestorageblock.Reservation, options *armpurestorageblock.ReservationsClientBeginCreateOptions) (resp azfake.PollerResponder[armpurestorageblock.ReservationsClientCreateResponse], errResp azfake.ErrorResponder)

	// BeginDelete is the fake for method ReservationsClient.BeginDelete
	// HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent
	BeginDelete func(ctx context.Context, resourceGroupName string, reservationName string, options *armpurestorageblock.ReservationsClientBeginDeleteOptions) (resp azfake.PollerResponder[armpurestorageblock.ReservationsClientDeleteResponse], errResp azfake.ErrorResponder)

	// Get is the fake for method ReservationsClient.Get
	// HTTP status codes to indicate success: http.StatusOK
	Get func(ctx context.Context, resourceGroupName string, reservationName string, options *armpurestorageblock.ReservationsClientGetOptions) (resp azfake.Responder[armpurestorageblock.ReservationsClientGetResponse], errResp azfake.ErrorResponder)

	// GetBillingReport is the fake for method ReservationsClient.GetBillingReport
	// HTTP status codes to indicate success: http.StatusOK
	GetBillingReport func(ctx context.Context, resourceGroupName string, reservationName string, options *armpurestorageblock.ReservationsClientGetBillingReportOptions) (resp azfake.Responder[armpurestorageblock.ReservationsClientGetBillingReportResponse], errResp azfake.ErrorResponder)

	// GetBillingStatus is the fake for method ReservationsClient.GetBillingStatus
	// HTTP status codes to indicate success: http.StatusOK
	GetBillingStatus func(ctx context.Context, resourceGroupName string, reservationName string, options *armpurestorageblock.ReservationsClientGetBillingStatusOptions) (resp azfake.Responder[armpurestorageblock.ReservationsClientGetBillingStatusResponse], errResp azfake.ErrorResponder)

	// GetResourceLimits is the fake for method ReservationsClient.GetResourceLimits
	// HTTP status codes to indicate success: http.StatusOK
	GetResourceLimits func(ctx context.Context, resourceGroupName string, reservationName string, options *armpurestorageblock.ReservationsClientGetResourceLimitsOptions) (resp azfake.Responder[armpurestorageblock.ReservationsClientGetResourceLimitsResponse], errResp azfake.ErrorResponder)

	// NewListByResourceGroupPager is the fake for method ReservationsClient.NewListByResourceGroupPager
	// HTTP status codes to indicate success: http.StatusOK
	NewListByResourceGroupPager func(resourceGroupName string, options *armpurestorageblock.ReservationsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armpurestorageblock.ReservationsClientListByResourceGroupResponse])

	// NewListBySubscriptionPager is the fake for method ReservationsClient.NewListBySubscriptionPager
	// HTTP status codes to indicate success: http.StatusOK
	NewListBySubscriptionPager func(options *armpurestorageblock.ReservationsClientListBySubscriptionOptions) (resp azfake.PagerResponder[armpurestorageblock.ReservationsClientListBySubscriptionResponse])

	// BeginUpdate is the fake for method ReservationsClient.BeginUpdate
	// HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted
	BeginUpdate func(ctx context.Context, resourceGroupName string, reservationName string, properties armpurestorageblock.ReservationUpdate, options *armpurestorageblock.ReservationsClientBeginUpdateOptions) (resp azfake.PollerResponder[armpurestorageblock.ReservationsClientUpdateResponse], errResp azfake.ErrorResponder)
}

// NewReservationsServerTransport creates a new instance of ReservationsServerTransport with the provided implementation.
// The returned ReservationsServerTransport instance is connected to an instance of armpurestorageblock.ReservationsClient via the
// azcore.ClientOptions.Transporter field in the client's constructor parameters.
func NewReservationsServerTransport(srv *ReservationsServer) *ReservationsServerTransport {
	return &ReservationsServerTransport{
		srv:                         srv,
		beginCreate:                 newTracker[azfake.PollerResponder[armpurestorageblock.ReservationsClientCreateResponse]](),
		beginDelete:                 newTracker[azfake.PollerResponder[armpurestorageblock.ReservationsClientDeleteResponse]](),
		newListByResourceGroupPager: newTracker[azfake.PagerResponder[armpurestorageblock.ReservationsClientListByResourceGroupResponse]](),
		newListBySubscriptionPager:  newTracker[azfake.PagerResponder[armpurestorageblock.ReservationsClientListBySubscriptionResponse]](),
		beginUpdate:                 newTracker[azfake.PollerResponder[armpurestorageblock.ReservationsClientUpdateResponse]](),
	}
}

// ReservationsServerTransport connects instances of armpurestorageblock.ReservationsClient to instances of ReservationsServer.
// Don't use this type directly, use NewReservationsServerTransport instead.
type ReservationsServerTransport struct {
	srv                         *ReservationsServer
	beginCreate                 *tracker[azfake.PollerResponder[armpurestorageblock.ReservationsClientCreateResponse]]
	beginDelete                 *tracker[azfake.PollerResponder[armpurestorageblock.ReservationsClientDeleteResponse]]
	newListByResourceGroupPager *tracker[azfake.PagerResponder[armpurestorageblock.ReservationsClientListByResourceGroupResponse]]
	newListBySubscriptionPager  *tracker[azfake.PagerResponder[armpurestorageblock.ReservationsClientListBySubscriptionResponse]]
	beginUpdate                 *tracker[azfake.PollerResponder[armpurestorageblock.ReservationsClientUpdateResponse]]
}

// Do implements the policy.Transporter interface for ReservationsServerTransport.
func (r *ReservationsServerTransport) 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")}
	}

	return r.dispatchToMethodFake(req, method)
}

func (r *ReservationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) {
	resultChan := make(chan result)
	defer close(resultChan)

	go func() {
		var intercepted bool
		var res result
		if reservationsServerTransportInterceptor != nil {
			res.resp, res.err, intercepted = reservationsServerTransportInterceptor.Do(req)
		}
		if !intercepted {
			switch method {
			case "ReservationsClient.BeginCreate":
				res.resp, res.err = r.dispatchBeginCreate(req)
			case "ReservationsClient.BeginDelete":
				res.resp, res.err = r.dispatchBeginDelete(req)
			case "ReservationsClient.Get":
				res.resp, res.err = r.dispatchGet(req)
			case "ReservationsClient.GetBillingReport":
				res.resp, res.err = r.dispatchGetBillingReport(req)
			case "ReservationsClient.GetBillingStatus":
				res.resp, res.err = r.dispatchGetBillingStatus(req)
			case "ReservationsClient.GetResourceLimits":
				res.resp, res.err = r.dispatchGetResourceLimits(req)
			case "ReservationsClient.NewListByResourceGroupPager":
				res.resp, res.err = r.dispatchNewListByResourceGroupPager(req)
			case "ReservationsClient.NewListBySubscriptionPager":
				res.resp, res.err = r.dispatchNewListBySubscriptionPager(req)
			case "ReservationsClient.BeginUpdate":
				res.resp, res.err = r.dispatchBeginUpdate(req)
			default:
				res.err = fmt.Errorf("unhandled API %s", method)
			}

		}
		select {
		case resultChan <- res:
		case <-req.Context().Done():
		}
	}()

	select {
	case <-req.Context().Done():
		return nil, req.Context().Err()
	case res := <-resultChan:
		return res.resp, res.err
	}
}

func (r *ReservationsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) {
	if r.srv.BeginCreate == nil {
		return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")}
	}
	beginCreate := r.beginCreate.get(req)
	if beginCreate == nil {
		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/reservations/(?P<reservationName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)`
		regex := regexp.MustCompile(regexStr)
		matches := regex.FindStringSubmatch(req.URL.EscapedPath())
		if len(matches) < 4 {
			return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
		}
		body, err := server.UnmarshalRequestAsJSON[armpurestorageblock.Reservation](req)
		if err != nil {
			return nil, err
		}
		resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
		if err != nil {
			return nil, err
		}
		reservationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reservationName")])
		if err != nil {
			return nil, err
		}
		respr, errRespr := r.srv.BeginCreate(req.Context(), resourceGroupNameParam, reservationNameParam, body, nil)
		if respErr := server.GetError(errRespr, req); respErr != nil {
			return nil, respErr
		}
		beginCreate = &respr
		r.beginCreate.add(req, beginCreate)
	}

	resp, err := server.PollerResponderNext(beginCreate, req)
	if err != nil {
		return nil, err
	}

	if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) {
		r.beginCreate.remove(req)
		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)}
	}
	if !server.PollerResponderMore(beginCreate) {
		r.beginCreate.remove(req)
	}

	return resp, nil
}

func (r *ReservationsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) {
	if r.srv.BeginDelete == nil {
		return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")}
	}
	beginDelete := r.beginDelete.get(req)
	if beginDelete == nil {
		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/reservations/(?P<reservationName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)`
		regex := regexp.MustCompile(regexStr)
		matches := regex.FindStringSubmatch(req.URL.EscapedPath())
		if len(matches) < 4 {
			return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
		}
		resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
		if err != nil {
			return nil, err
		}
		reservationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reservationName")])
		if err != nil {
			return nil, err
		}
		respr, errRespr := r.srv.BeginDelete(req.Context(), resourceGroupNameParam, reservationNameParam, nil)
		if respErr := server.GetError(errRespr, req); respErr != nil {
			return nil, respErr
		}
		beginDelete = &respr
		r.beginDelete.add(req, beginDelete)
	}

	resp, err := server.PollerResponderNext(beginDelete, req)
	if err != nil {
		return nil, err
	}

	if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) {
		r.beginDelete.remove(req)
		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)}
	}
	if !server.PollerResponderMore(beginDelete) {
		r.beginDelete.remove(req)
	}

	return resp, nil
}

func (r *ReservationsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) {
	if r.srv.Get == nil {
		return nil, &nonRetriableError{errors.New("fake for method Get not implemented")}
	}
	const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/reservations/(?P<reservationName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)`
	regex := regexp.MustCompile(regexStr)
	matches := regex.FindStringSubmatch(req.URL.EscapedPath())
	if len(matches) < 4 {
		return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
	}
	resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
	if err != nil {
		return nil, err
	}
	reservationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reservationName")])
	if err != nil {
		return nil, err
	}
	respr, errRespr := r.srv.Get(req.Context(), resourceGroupNameParam, reservationNameParam, 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).Reservation, req)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

func (r *ReservationsServerTransport) dispatchGetBillingReport(req *http.Request) (*http.Response, error) {
	if r.srv.GetBillingReport == nil {
		return nil, &nonRetriableError{errors.New("fake for method GetBillingReport not implemented")}
	}
	const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/reservations/(?P<reservationName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/getBillingReport`
	regex := regexp.MustCompile(regexStr)
	matches := regex.FindStringSubmatch(req.URL.EscapedPath())
	if len(matches) < 4 {
		return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
	}
	resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
	if err != nil {
		return nil, err
	}
	reservationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reservationName")])
	if err != nil {
		return nil, err
	}
	respr, errRespr := r.srv.GetBillingReport(req.Context(), resourceGroupNameParam, reservationNameParam, 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).ReservationBillingUsageReport, req)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

func (r *ReservationsServerTransport) dispatchGetBillingStatus(req *http.Request) (*http.Response, error) {
	if r.srv.GetBillingStatus == nil {
		return nil, &nonRetriableError{errors.New("fake for method GetBillingStatus not implemented")}
	}
	const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/reservations/(?P<reservationName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/getBillingStatus`
	regex := regexp.MustCompile(regexStr)
	matches := regex.FindStringSubmatch(req.URL.EscapedPath())
	if len(matches) < 4 {
		return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
	}
	resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
	if err != nil {
		return nil, err
	}
	reservationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reservationName")])
	if err != nil {
		return nil, err
	}
	respr, errRespr := r.srv.GetBillingStatus(req.Context(), resourceGroupNameParam, reservationNameParam, 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).ReservationBillingStatus, req)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

func (r *ReservationsServerTransport) dispatchGetResourceLimits(req *http.Request) (*http.Response, error) {
	if r.srv.GetResourceLimits == nil {
		return nil, &nonRetriableError{errors.New("fake for method GetResourceLimits not implemented")}
	}
	const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/reservations/(?P<reservationName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/getResourceLimits`
	regex := regexp.MustCompile(regexStr)
	matches := regex.FindStringSubmatch(req.URL.EscapedPath())
	if len(matches) < 4 {
		return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
	}
	resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
	if err != nil {
		return nil, err
	}
	reservationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reservationName")])
	if err != nil {
		return nil, err
	}
	respr, errRespr := r.srv.GetResourceLimits(req.Context(), resourceGroupNameParam, reservationNameParam, 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).LimitDetails, req)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

func (r *ReservationsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) {
	if r.srv.NewListByResourceGroupPager == nil {
		return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")}
	}
	newListByResourceGroupPager := r.newListByResourceGroupPager.get(req)
	if newListByResourceGroupPager == nil {
		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/reservations`
		regex := regexp.MustCompile(regexStr)
		matches := regex.FindStringSubmatch(req.URL.EscapedPath())
		if len(matches) < 3 {
			return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
		}
		resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
		if err != nil {
			return nil, err
		}
		resp := r.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil)
		newListByResourceGroupPager = &resp
		r.newListByResourceGroupPager.add(req, newListByResourceGroupPager)
		server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armpurestorageblock.ReservationsClientListByResourceGroupResponse, createLink func() string) {
			page.NextLink = to.Ptr(createLink())
		})
	}
	resp, err := server.PagerResponderNext(newListByResourceGroupPager, req)
	if err != nil {
		return nil, err
	}
	if !contains([]int{http.StatusOK}, resp.StatusCode) {
		r.newListByResourceGroupPager.remove(req)
		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)}
	}
	if !server.PagerResponderMore(newListByResourceGroupPager) {
		r.newListByResourceGroupPager.remove(req)
	}
	return resp, nil
}

func (r *ReservationsServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) {
	if r.srv.NewListBySubscriptionPager == nil {
		return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")}
	}
	newListBySubscriptionPager := r.newListBySubscriptionPager.get(req)
	if newListBySubscriptionPager == nil {
		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/reservations`
		regex := regexp.MustCompile(regexStr)
		matches := regex.FindStringSubmatch(req.URL.EscapedPath())
		if len(matches) < 2 {
			return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
		}
		resp := r.srv.NewListBySubscriptionPager(nil)
		newListBySubscriptionPager = &resp
		r.newListBySubscriptionPager.add(req, newListBySubscriptionPager)
		server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armpurestorageblock.ReservationsClientListBySubscriptionResponse, createLink func() string) {
			page.NextLink = to.Ptr(createLink())
		})
	}
	resp, err := server.PagerResponderNext(newListBySubscriptionPager, req)
	if err != nil {
		return nil, err
	}
	if !contains([]int{http.StatusOK}, resp.StatusCode) {
		r.newListBySubscriptionPager.remove(req)
		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)}
	}
	if !server.PagerResponderMore(newListBySubscriptionPager) {
		r.newListBySubscriptionPager.remove(req)
	}
	return resp, nil
}

func (r *ReservationsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) {
	if r.srv.BeginUpdate == nil {
		return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")}
	}
	beginUpdate := r.beginUpdate.get(req)
	if beginUpdate == nil {
		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/reservations/(?P<reservationName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)`
		regex := regexp.MustCompile(regexStr)
		matches := regex.FindStringSubmatch(req.URL.EscapedPath())
		if len(matches) < 4 {
			return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
		}
		body, err := server.UnmarshalRequestAsJSON[armpurestorageblock.ReservationUpdate](req)
		if err != nil {
			return nil, err
		}
		resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
		if err != nil {
			return nil, err
		}
		reservationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reservationName")])
		if err != nil {
			return nil, err
		}
		respr, errRespr := r.srv.BeginUpdate(req.Context(), resourceGroupNameParam, reservationNameParam, body, nil)
		if respErr := server.GetError(errRespr, req); respErr != nil {
			return nil, respErr
		}
		beginUpdate = &respr
		r.beginUpdate.add(req, beginUpdate)
	}

	resp, err := server.PollerResponderNext(beginUpdate, req)
	if err != nil {
		return nil, err
	}

	if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) {
		r.beginUpdate.remove(req)
		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)}
	}
	if !server.PollerResponderMore(beginUpdate) {
		r.beginUpdate.remove(req)
	}

	return resp, nil
}

// set this to conditionally intercept incoming requests to ReservationsServerTransport
var reservationsServerTransportInterceptor interface {
	// Do returns true if the server transport should use the returned response/error
	Do(*http.Request) (*http.Response, error, bool)
}
