// 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"
)

// StoragePoolsServer is a fake server for instances of the armpurestorageblock.StoragePoolsClient type.
type StoragePoolsServer struct {
	// BeginCreate is the fake for method StoragePoolsClient.BeginCreate
	// HTTP status codes to indicate success: http.StatusOK, http.StatusCreated
	BeginCreate func(ctx context.Context, resourceGroupName string, storagePoolName string, resource armpurestorageblock.StoragePool, options *armpurestorageblock.StoragePoolsClientBeginCreateOptions) (resp azfake.PollerResponder[armpurestorageblock.StoragePoolsClientCreateResponse], errResp azfake.ErrorResponder)

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

	// BeginDisableAvsConnection is the fake for method StoragePoolsClient.BeginDisableAvsConnection
	// HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent
	BeginDisableAvsConnection func(ctx context.Context, resourceGroupName string, storagePoolName string, options *armpurestorageblock.StoragePoolsClientBeginDisableAvsConnectionOptions) (resp azfake.PollerResponder[armpurestorageblock.StoragePoolsClientDisableAvsConnectionResponse], errResp azfake.ErrorResponder)

	// BeginEnableAvsConnection is the fake for method StoragePoolsClient.BeginEnableAvsConnection
	// HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent
	BeginEnableAvsConnection func(ctx context.Context, resourceGroupName string, storagePoolName string, properties armpurestorageblock.StoragePoolEnableAvsConnectionPost, options *armpurestorageblock.StoragePoolsClientBeginEnableAvsConnectionOptions) (resp azfake.PollerResponder[armpurestorageblock.StoragePoolsClientEnableAvsConnectionResponse], errResp azfake.ErrorResponder)

	// BeginFinalizeAvsConnection is the fake for method StoragePoolsClient.BeginFinalizeAvsConnection
	// HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent
	BeginFinalizeAvsConnection func(ctx context.Context, resourceGroupName string, storagePoolName string, properties armpurestorageblock.StoragePoolFinalizeAvsConnectionPost, options *armpurestorageblock.StoragePoolsClientBeginFinalizeAvsConnectionOptions) (resp azfake.PollerResponder[armpurestorageblock.StoragePoolsClientFinalizeAvsConnectionResponse], errResp azfake.ErrorResponder)

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

	// GetAvsConnection is the fake for method StoragePoolsClient.GetAvsConnection
	// HTTP status codes to indicate success: http.StatusOK
	GetAvsConnection func(ctx context.Context, resourceGroupName string, storagePoolName string, options *armpurestorageblock.StoragePoolsClientGetAvsConnectionOptions) (resp azfake.Responder[armpurestorageblock.StoragePoolsClientGetAvsConnectionResponse], errResp azfake.ErrorResponder)

	// GetAvsStatus is the fake for method StoragePoolsClient.GetAvsStatus
	// HTTP status codes to indicate success: http.StatusOK
	GetAvsStatus func(ctx context.Context, resourceGroupName string, storagePoolName string, options *armpurestorageblock.StoragePoolsClientGetAvsStatusOptions) (resp azfake.Responder[armpurestorageblock.StoragePoolsClientGetAvsStatusResponse], errResp azfake.ErrorResponder)

	// GetHealthStatus is the fake for method StoragePoolsClient.GetHealthStatus
	// HTTP status codes to indicate success: http.StatusOK
	GetHealthStatus func(ctx context.Context, resourceGroupName string, storagePoolName string, options *armpurestorageblock.StoragePoolsClientGetHealthStatusOptions) (resp azfake.Responder[armpurestorageblock.StoragePoolsClientGetHealthStatusResponse], errResp azfake.ErrorResponder)

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

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

	// BeginRepairAvsConnection is the fake for method StoragePoolsClient.BeginRepairAvsConnection
	// HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent
	BeginRepairAvsConnection func(ctx context.Context, resourceGroupName string, storagePoolName string, options *armpurestorageblock.StoragePoolsClientBeginRepairAvsConnectionOptions) (resp azfake.PollerResponder[armpurestorageblock.StoragePoolsClientRepairAvsConnectionResponse], errResp azfake.ErrorResponder)

	// BeginUpdate is the fake for method StoragePoolsClient.BeginUpdate
	// HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted
	BeginUpdate func(ctx context.Context, resourceGroupName string, storagePoolName string, properties armpurestorageblock.StoragePoolUpdate, options *armpurestorageblock.StoragePoolsClientBeginUpdateOptions) (resp azfake.PollerResponder[armpurestorageblock.StoragePoolsClientUpdateResponse], errResp azfake.ErrorResponder)
}

// NewStoragePoolsServerTransport creates a new instance of StoragePoolsServerTransport with the provided implementation.
// The returned StoragePoolsServerTransport instance is connected to an instance of armpurestorageblock.StoragePoolsClient via the
// azcore.ClientOptions.Transporter field in the client's constructor parameters.
func NewStoragePoolsServerTransport(srv *StoragePoolsServer) *StoragePoolsServerTransport {
	return &StoragePoolsServerTransport{
		srv:                         srv,
		beginCreate:                 newTracker[azfake.PollerResponder[armpurestorageblock.StoragePoolsClientCreateResponse]](),
		beginDelete:                 newTracker[azfake.PollerResponder[armpurestorageblock.StoragePoolsClientDeleteResponse]](),
		beginDisableAvsConnection:   newTracker[azfake.PollerResponder[armpurestorageblock.StoragePoolsClientDisableAvsConnectionResponse]](),
		beginEnableAvsConnection:    newTracker[azfake.PollerResponder[armpurestorageblock.StoragePoolsClientEnableAvsConnectionResponse]](),
		beginFinalizeAvsConnection:  newTracker[azfake.PollerResponder[armpurestorageblock.StoragePoolsClientFinalizeAvsConnectionResponse]](),
		newListByResourceGroupPager: newTracker[azfake.PagerResponder[armpurestorageblock.StoragePoolsClientListByResourceGroupResponse]](),
		newListBySubscriptionPager:  newTracker[azfake.PagerResponder[armpurestorageblock.StoragePoolsClientListBySubscriptionResponse]](),
		beginRepairAvsConnection:    newTracker[azfake.PollerResponder[armpurestorageblock.StoragePoolsClientRepairAvsConnectionResponse]](),
		beginUpdate:                 newTracker[azfake.PollerResponder[armpurestorageblock.StoragePoolsClientUpdateResponse]](),
	}
}

// StoragePoolsServerTransport connects instances of armpurestorageblock.StoragePoolsClient to instances of StoragePoolsServer.
// Don't use this type directly, use NewStoragePoolsServerTransport instead.
type StoragePoolsServerTransport struct {
	srv                         *StoragePoolsServer
	beginCreate                 *tracker[azfake.PollerResponder[armpurestorageblock.StoragePoolsClientCreateResponse]]
	beginDelete                 *tracker[azfake.PollerResponder[armpurestorageblock.StoragePoolsClientDeleteResponse]]
	beginDisableAvsConnection   *tracker[azfake.PollerResponder[armpurestorageblock.StoragePoolsClientDisableAvsConnectionResponse]]
	beginEnableAvsConnection    *tracker[azfake.PollerResponder[armpurestorageblock.StoragePoolsClientEnableAvsConnectionResponse]]
	beginFinalizeAvsConnection  *tracker[azfake.PollerResponder[armpurestorageblock.StoragePoolsClientFinalizeAvsConnectionResponse]]
	newListByResourceGroupPager *tracker[azfake.PagerResponder[armpurestorageblock.StoragePoolsClientListByResourceGroupResponse]]
	newListBySubscriptionPager  *tracker[azfake.PagerResponder[armpurestorageblock.StoragePoolsClientListBySubscriptionResponse]]
	beginRepairAvsConnection    *tracker[azfake.PollerResponder[armpurestorageblock.StoragePoolsClientRepairAvsConnectionResponse]]
	beginUpdate                 *tracker[azfake.PollerResponder[armpurestorageblock.StoragePoolsClientUpdateResponse]]
}

// Do implements the policy.Transporter interface for StoragePoolsServerTransport.
func (s *StoragePoolsServerTransport) 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 s.dispatchToMethodFake(req, method)
}

func (s *StoragePoolsServerTransport) 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 storagePoolsServerTransportInterceptor != nil {
			res.resp, res.err, intercepted = storagePoolsServerTransportInterceptor.Do(req)
		}
		if !intercepted {
			switch method {
			case "StoragePoolsClient.BeginCreate":
				res.resp, res.err = s.dispatchBeginCreate(req)
			case "StoragePoolsClient.BeginDelete":
				res.resp, res.err = s.dispatchBeginDelete(req)
			case "StoragePoolsClient.BeginDisableAvsConnection":
				res.resp, res.err = s.dispatchBeginDisableAvsConnection(req)
			case "StoragePoolsClient.BeginEnableAvsConnection":
				res.resp, res.err = s.dispatchBeginEnableAvsConnection(req)
			case "StoragePoolsClient.BeginFinalizeAvsConnection":
				res.resp, res.err = s.dispatchBeginFinalizeAvsConnection(req)
			case "StoragePoolsClient.Get":
				res.resp, res.err = s.dispatchGet(req)
			case "StoragePoolsClient.GetAvsConnection":
				res.resp, res.err = s.dispatchGetAvsConnection(req)
			case "StoragePoolsClient.GetAvsStatus":
				res.resp, res.err = s.dispatchGetAvsStatus(req)
			case "StoragePoolsClient.GetHealthStatus":
				res.resp, res.err = s.dispatchGetHealthStatus(req)
			case "StoragePoolsClient.NewListByResourceGroupPager":
				res.resp, res.err = s.dispatchNewListByResourceGroupPager(req)
			case "StoragePoolsClient.NewListBySubscriptionPager":
				res.resp, res.err = s.dispatchNewListBySubscriptionPager(req)
			case "StoragePoolsClient.BeginRepairAvsConnection":
				res.resp, res.err = s.dispatchBeginRepairAvsConnection(req)
			case "StoragePoolsClient.BeginUpdate":
				res.resp, res.err = s.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 (s *StoragePoolsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) {
	if s.srv.BeginCreate == nil {
		return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")}
	}
	beginCreate := s.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/storagePools/(?P<storagePoolName>[!#&$-;=?-\[\]_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.StoragePool](req)
		if err != nil {
			return nil, err
		}
		resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
		if err != nil {
			return nil, err
		}
		storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")])
		if err != nil {
			return nil, err
		}
		respr, errRespr := s.srv.BeginCreate(req.Context(), resourceGroupNameParam, storagePoolNameParam, body, nil)
		if respErr := server.GetError(errRespr, req); respErr != nil {
			return nil, respErr
		}
		beginCreate = &respr
		s.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) {
		s.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) {
		s.beginCreate.remove(req)
	}

	return resp, nil
}

func (s *StoragePoolsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) {
	if s.srv.BeginDelete == nil {
		return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")}
	}
	beginDelete := s.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/storagePools/(?P<storagePoolName>[!#&$-;=?-\[\]_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
		}
		storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")])
		if err != nil {
			return nil, err
		}
		respr, errRespr := s.srv.BeginDelete(req.Context(), resourceGroupNameParam, storagePoolNameParam, nil)
		if respErr := server.GetError(errRespr, req); respErr != nil {
			return nil, respErr
		}
		beginDelete = &respr
		s.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) {
		s.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) {
		s.beginDelete.remove(req)
	}

	return resp, nil
}

func (s *StoragePoolsServerTransport) dispatchBeginDisableAvsConnection(req *http.Request) (*http.Response, error) {
	if s.srv.BeginDisableAvsConnection == nil {
		return nil, &nonRetriableError{errors.New("fake for method BeginDisableAvsConnection not implemented")}
	}
	beginDisableAvsConnection := s.beginDisableAvsConnection.get(req)
	if beginDisableAvsConnection == nil {
		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P<storagePoolName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/disableAvsConnection`
		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
		}
		storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")])
		if err != nil {
			return nil, err
		}
		respr, errRespr := s.srv.BeginDisableAvsConnection(req.Context(), resourceGroupNameParam, storagePoolNameParam, nil)
		if respErr := server.GetError(errRespr, req); respErr != nil {
			return nil, respErr
		}
		beginDisableAvsConnection = &respr
		s.beginDisableAvsConnection.add(req, beginDisableAvsConnection)
	}

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

	if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) {
		s.beginDisableAvsConnection.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(beginDisableAvsConnection) {
		s.beginDisableAvsConnection.remove(req)
	}

	return resp, nil
}

func (s *StoragePoolsServerTransport) dispatchBeginEnableAvsConnection(req *http.Request) (*http.Response, error) {
	if s.srv.BeginEnableAvsConnection == nil {
		return nil, &nonRetriableError{errors.New("fake for method BeginEnableAvsConnection not implemented")}
	}
	beginEnableAvsConnection := s.beginEnableAvsConnection.get(req)
	if beginEnableAvsConnection == nil {
		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P<storagePoolName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enableAvsConnection`
		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.StoragePoolEnableAvsConnectionPost](req)
		if err != nil {
			return nil, err
		}
		resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
		if err != nil {
			return nil, err
		}
		storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")])
		if err != nil {
			return nil, err
		}
		respr, errRespr := s.srv.BeginEnableAvsConnection(req.Context(), resourceGroupNameParam, storagePoolNameParam, body, nil)
		if respErr := server.GetError(errRespr, req); respErr != nil {
			return nil, respErr
		}
		beginEnableAvsConnection = &respr
		s.beginEnableAvsConnection.add(req, beginEnableAvsConnection)
	}

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

	if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) {
		s.beginEnableAvsConnection.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(beginEnableAvsConnection) {
		s.beginEnableAvsConnection.remove(req)
	}

	return resp, nil
}

func (s *StoragePoolsServerTransport) dispatchBeginFinalizeAvsConnection(req *http.Request) (*http.Response, error) {
	if s.srv.BeginFinalizeAvsConnection == nil {
		return nil, &nonRetriableError{errors.New("fake for method BeginFinalizeAvsConnection not implemented")}
	}
	beginFinalizeAvsConnection := s.beginFinalizeAvsConnection.get(req)
	if beginFinalizeAvsConnection == nil {
		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P<storagePoolName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/finalizeAvsConnection`
		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.StoragePoolFinalizeAvsConnectionPost](req)
		if err != nil {
			return nil, err
		}
		resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
		if err != nil {
			return nil, err
		}
		storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")])
		if err != nil {
			return nil, err
		}
		respr, errRespr := s.srv.BeginFinalizeAvsConnection(req.Context(), resourceGroupNameParam, storagePoolNameParam, body, nil)
		if respErr := server.GetError(errRespr, req); respErr != nil {
			return nil, respErr
		}
		beginFinalizeAvsConnection = &respr
		s.beginFinalizeAvsConnection.add(req, beginFinalizeAvsConnection)
	}

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

	if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) {
		s.beginFinalizeAvsConnection.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(beginFinalizeAvsConnection) {
		s.beginFinalizeAvsConnection.remove(req)
	}

	return resp, nil
}

func (s *StoragePoolsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) {
	if s.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/storagePools/(?P<storagePoolName>[!#&$-;=?-\[\]_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
	}
	storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")])
	if err != nil {
		return nil, err
	}
	respr, errRespr := s.srv.Get(req.Context(), resourceGroupNameParam, storagePoolNameParam, 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).StoragePool, req)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

func (s *StoragePoolsServerTransport) dispatchGetAvsConnection(req *http.Request) (*http.Response, error) {
	if s.srv.GetAvsConnection == nil {
		return nil, &nonRetriableError{errors.New("fake for method GetAvsConnection not implemented")}
	}
	const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P<storagePoolName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/getAvsConnection`
	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
	}
	storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")])
	if err != nil {
		return nil, err
	}
	respr, errRespr := s.srv.GetAvsConnection(req.Context(), resourceGroupNameParam, storagePoolNameParam, 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).AvsConnection, req)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

func (s *StoragePoolsServerTransport) dispatchGetAvsStatus(req *http.Request) (*http.Response, error) {
	if s.srv.GetAvsStatus == nil {
		return nil, &nonRetriableError{errors.New("fake for method GetAvsStatus not implemented")}
	}
	const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P<storagePoolName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/getAvsStatus`
	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
	}
	storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")])
	if err != nil {
		return nil, err
	}
	respr, errRespr := s.srv.GetAvsStatus(req.Context(), resourceGroupNameParam, storagePoolNameParam, 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).AvsStatus, req)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

func (s *StoragePoolsServerTransport) dispatchGetHealthStatus(req *http.Request) (*http.Response, error) {
	if s.srv.GetHealthStatus == nil {
		return nil, &nonRetriableError{errors.New("fake for method GetHealthStatus not implemented")}
	}
	const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P<storagePoolName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/getHealthStatus`
	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
	}
	storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")])
	if err != nil {
		return nil, err
	}
	respr, errRespr := s.srv.GetHealthStatus(req.Context(), resourceGroupNameParam, storagePoolNameParam, 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).StoragePoolHealthInfo, req)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

func (s *StoragePoolsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) {
	if s.srv.NewListByResourceGroupPager == nil {
		return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")}
	}
	newListByResourceGroupPager := s.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/storagePools`
		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 := s.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil)
		newListByResourceGroupPager = &resp
		s.newListByResourceGroupPager.add(req, newListByResourceGroupPager)
		server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armpurestorageblock.StoragePoolsClientListByResourceGroupResponse, 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) {
		s.newListByResourceGroupPager.remove(req)
		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)}
	}
	if !server.PagerResponderMore(newListByResourceGroupPager) {
		s.newListByResourceGroupPager.remove(req)
	}
	return resp, nil
}

func (s *StoragePoolsServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) {
	if s.srv.NewListBySubscriptionPager == nil {
		return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")}
	}
	newListBySubscriptionPager := s.newListBySubscriptionPager.get(req)
	if newListBySubscriptionPager == nil {
		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools`
		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 := s.srv.NewListBySubscriptionPager(nil)
		newListBySubscriptionPager = &resp
		s.newListBySubscriptionPager.add(req, newListBySubscriptionPager)
		server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armpurestorageblock.StoragePoolsClientListBySubscriptionResponse, 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) {
		s.newListBySubscriptionPager.remove(req)
		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)}
	}
	if !server.PagerResponderMore(newListBySubscriptionPager) {
		s.newListBySubscriptionPager.remove(req)
	}
	return resp, nil
}

func (s *StoragePoolsServerTransport) dispatchBeginRepairAvsConnection(req *http.Request) (*http.Response, error) {
	if s.srv.BeginRepairAvsConnection == nil {
		return nil, &nonRetriableError{errors.New("fake for method BeginRepairAvsConnection not implemented")}
	}
	beginRepairAvsConnection := s.beginRepairAvsConnection.get(req)
	if beginRepairAvsConnection == nil {
		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P<storagePoolName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/repairAvsConnection`
		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
		}
		storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")])
		if err != nil {
			return nil, err
		}
		respr, errRespr := s.srv.BeginRepairAvsConnection(req.Context(), resourceGroupNameParam, storagePoolNameParam, nil)
		if respErr := server.GetError(errRespr, req); respErr != nil {
			return nil, respErr
		}
		beginRepairAvsConnection = &respr
		s.beginRepairAvsConnection.add(req, beginRepairAvsConnection)
	}

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

	if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) {
		s.beginRepairAvsConnection.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(beginRepairAvsConnection) {
		s.beginRepairAvsConnection.remove(req)
	}

	return resp, nil
}

func (s *StoragePoolsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) {
	if s.srv.BeginUpdate == nil {
		return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")}
	}
	beginUpdate := s.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/storagePools/(?P<storagePoolName>[!#&$-;=?-\[\]_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.StoragePoolUpdate](req)
		if err != nil {
			return nil, err
		}
		resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
		if err != nil {
			return nil, err
		}
		storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")])
		if err != nil {
			return nil, err
		}
		respr, errRespr := s.srv.BeginUpdate(req.Context(), resourceGroupNameParam, storagePoolNameParam, body, nil)
		if respErr := server.GetError(errRespr, req); respErr != nil {
			return nil, respErr
		}
		beginUpdate = &respr
		s.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) {
		s.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) {
		s.beginUpdate.remove(req)
	}

	return resp, nil
}

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