// Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.9, generator: @autorest/go@4.0.0-preview.74)
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
// Code generated by @autorest/go. DO NOT EDIT.

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/ARO-HCP/test/sdk/v20251223preview/resourcemanager/redhatopenshifthcp/armredhatopenshifthcp"
)

// HcpOpenShiftClustersServer is a fake server for instances of the armredhatopenshifthcp.HcpOpenShiftClustersClient type.
type HcpOpenShiftClustersServer struct {
	// BeginCreateOrUpdate is the fake for method HcpOpenShiftClustersClient.BeginCreateOrUpdate
	// HTTP status codes to indicate success: http.StatusOK, http.StatusCreated
	BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, hcpOpenShiftClusterName string, resource armredhatopenshifthcp.HcpOpenShiftCluster, options *armredhatopenshifthcp.HcpOpenShiftClustersClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armredhatopenshifthcp.HcpOpenShiftClustersClientCreateOrUpdateResponse], errResp azfake.ErrorResponder)

	// BeginDelete is the fake for method HcpOpenShiftClustersClient.BeginDelete
	// HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent
	BeginDelete func(ctx context.Context, resourceGroupName string, hcpOpenShiftClusterName string, options *armredhatopenshifthcp.HcpOpenShiftClustersClientBeginDeleteOptions) (resp azfake.PollerResponder[armredhatopenshifthcp.HcpOpenShiftClustersClientDeleteResponse], errResp azfake.ErrorResponder)

	// Get is the fake for method HcpOpenShiftClustersClient.Get
	// HTTP status codes to indicate success: http.StatusOK
	Get func(ctx context.Context, resourceGroupName string, hcpOpenShiftClusterName string, options *armredhatopenshifthcp.HcpOpenShiftClustersClientGetOptions) (resp azfake.Responder[armredhatopenshifthcp.HcpOpenShiftClustersClientGetResponse], errResp azfake.ErrorResponder)

	// NewListByResourceGroupPager is the fake for method HcpOpenShiftClustersClient.NewListByResourceGroupPager
	// HTTP status codes to indicate success: http.StatusOK
	NewListByResourceGroupPager func(resourceGroupName string, options *armredhatopenshifthcp.HcpOpenShiftClustersClientListByResourceGroupOptions) (resp azfake.PagerResponder[armredhatopenshifthcp.HcpOpenShiftClustersClientListByResourceGroupResponse])

	// NewListBySubscriptionPager is the fake for method HcpOpenShiftClustersClient.NewListBySubscriptionPager
	// HTTP status codes to indicate success: http.StatusOK
	NewListBySubscriptionPager func(options *armredhatopenshifthcp.HcpOpenShiftClustersClientListBySubscriptionOptions) (resp azfake.PagerResponder[armredhatopenshifthcp.HcpOpenShiftClustersClientListBySubscriptionResponse])

	// BeginRequestAdminCredential is the fake for method HcpOpenShiftClustersClient.BeginRequestAdminCredential
	// HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted
	BeginRequestAdminCredential func(ctx context.Context, resourceGroupName string, hcpOpenShiftClusterName string, options *armredhatopenshifthcp.HcpOpenShiftClustersClientBeginRequestAdminCredentialOptions) (resp azfake.PollerResponder[armredhatopenshifthcp.HcpOpenShiftClustersClientRequestAdminCredentialResponse], errResp azfake.ErrorResponder)

	// BeginRevokeCredentials is the fake for method HcpOpenShiftClustersClient.BeginRevokeCredentials
	// HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent
	BeginRevokeCredentials func(ctx context.Context, resourceGroupName string, hcpOpenShiftClusterName string, options *armredhatopenshifthcp.HcpOpenShiftClustersClientBeginRevokeCredentialsOptions) (resp azfake.PollerResponder[armredhatopenshifthcp.HcpOpenShiftClustersClientRevokeCredentialsResponse], errResp azfake.ErrorResponder)

	// BeginUpdate is the fake for method HcpOpenShiftClustersClient.BeginUpdate
	// HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted
	BeginUpdate func(ctx context.Context, resourceGroupName string, hcpOpenShiftClusterName string, properties armredhatopenshifthcp.HcpOpenShiftClusterUpdate, options *armredhatopenshifthcp.HcpOpenShiftClustersClientBeginUpdateOptions) (resp azfake.PollerResponder[armredhatopenshifthcp.HcpOpenShiftClustersClientUpdateResponse], errResp azfake.ErrorResponder)
}

// NewHcpOpenShiftClustersServerTransport creates a new instance of HcpOpenShiftClustersServerTransport with the provided implementation.
// The returned HcpOpenShiftClustersServerTransport instance is connected to an instance of armredhatopenshifthcp.HcpOpenShiftClustersClient via the
// azcore.ClientOptions.Transporter field in the client's constructor parameters.
func NewHcpOpenShiftClustersServerTransport(srv *HcpOpenShiftClustersServer) *HcpOpenShiftClustersServerTransport {
	return &HcpOpenShiftClustersServerTransport{
		srv:                         srv,
		beginCreateOrUpdate:         newTracker[azfake.PollerResponder[armredhatopenshifthcp.HcpOpenShiftClustersClientCreateOrUpdateResponse]](),
		beginDelete:                 newTracker[azfake.PollerResponder[armredhatopenshifthcp.HcpOpenShiftClustersClientDeleteResponse]](),
		newListByResourceGroupPager: newTracker[azfake.PagerResponder[armredhatopenshifthcp.HcpOpenShiftClustersClientListByResourceGroupResponse]](),
		newListBySubscriptionPager:  newTracker[azfake.PagerResponder[armredhatopenshifthcp.HcpOpenShiftClustersClientListBySubscriptionResponse]](),
		beginRequestAdminCredential: newTracker[azfake.PollerResponder[armredhatopenshifthcp.HcpOpenShiftClustersClientRequestAdminCredentialResponse]](),
		beginRevokeCredentials:      newTracker[azfake.PollerResponder[armredhatopenshifthcp.HcpOpenShiftClustersClientRevokeCredentialsResponse]](),
		beginUpdate:                 newTracker[azfake.PollerResponder[armredhatopenshifthcp.HcpOpenShiftClustersClientUpdateResponse]](),
	}
}

// HcpOpenShiftClustersServerTransport connects instances of armredhatopenshifthcp.HcpOpenShiftClustersClient to instances of HcpOpenShiftClustersServer.
// Don't use this type directly, use NewHcpOpenShiftClustersServerTransport instead.
type HcpOpenShiftClustersServerTransport struct {
	srv                         *HcpOpenShiftClustersServer
	beginCreateOrUpdate         *tracker[azfake.PollerResponder[armredhatopenshifthcp.HcpOpenShiftClustersClientCreateOrUpdateResponse]]
	beginDelete                 *tracker[azfake.PollerResponder[armredhatopenshifthcp.HcpOpenShiftClustersClientDeleteResponse]]
	newListByResourceGroupPager *tracker[azfake.PagerResponder[armredhatopenshifthcp.HcpOpenShiftClustersClientListByResourceGroupResponse]]
	newListBySubscriptionPager  *tracker[azfake.PagerResponder[armredhatopenshifthcp.HcpOpenShiftClustersClientListBySubscriptionResponse]]
	beginRequestAdminCredential *tracker[azfake.PollerResponder[armredhatopenshifthcp.HcpOpenShiftClustersClientRequestAdminCredentialResponse]]
	beginRevokeCredentials      *tracker[azfake.PollerResponder[armredhatopenshifthcp.HcpOpenShiftClustersClientRevokeCredentialsResponse]]
	beginUpdate                 *tracker[azfake.PollerResponder[armredhatopenshifthcp.HcpOpenShiftClustersClientUpdateResponse]]
}

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

func (h *HcpOpenShiftClustersServerTransport) 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 hcpOpenShiftClustersServerTransportInterceptor != nil {
			res.resp, res.err, intercepted = hcpOpenShiftClustersServerTransportInterceptor.Do(req)
		}
		if !intercepted {
			switch method {
			case "HcpOpenShiftClustersClient.BeginCreateOrUpdate":
				res.resp, res.err = h.dispatchBeginCreateOrUpdate(req)
			case "HcpOpenShiftClustersClient.BeginDelete":
				res.resp, res.err = h.dispatchBeginDelete(req)
			case "HcpOpenShiftClustersClient.Get":
				res.resp, res.err = h.dispatchGet(req)
			case "HcpOpenShiftClustersClient.NewListByResourceGroupPager":
				res.resp, res.err = h.dispatchNewListByResourceGroupPager(req)
			case "HcpOpenShiftClustersClient.NewListBySubscriptionPager":
				res.resp, res.err = h.dispatchNewListBySubscriptionPager(req)
			case "HcpOpenShiftClustersClient.BeginRequestAdminCredential":
				res.resp, res.err = h.dispatchBeginRequestAdminCredential(req)
			case "HcpOpenShiftClustersClient.BeginRevokeCredentials":
				res.resp, res.err = h.dispatchBeginRevokeCredentials(req)
			case "HcpOpenShiftClustersClient.BeginUpdate":
				res.resp, res.err = h.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 (h *HcpOpenShiftClustersServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) {
	if h.srv.BeginCreateOrUpdate == nil {
		return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")}
	}
	beginCreateOrUpdate := h.beginCreateOrUpdate.get(req)
	if beginCreateOrUpdate == nil {
		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.RedHatOpenShift/hcpOpenShiftClusters/(?P<hcpOpenShiftClusterName>[!#&$-;=?-\[\]_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[armredhatopenshifthcp.HcpOpenShiftCluster](req)
		if err != nil {
			return nil, err
		}
		resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
		if err != nil {
			return nil, err
		}
		hcpOpenShiftClusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("hcpOpenShiftClusterName")])
		if err != nil {
			return nil, err
		}
		respr, errRespr := h.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, hcpOpenShiftClusterNameParam, body, nil)
		if respErr := server.GetError(errRespr, req); respErr != nil {
			return nil, respErr
		}
		beginCreateOrUpdate = &respr
		h.beginCreateOrUpdate.add(req, beginCreateOrUpdate)
	}

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

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

	return resp, nil
}

func (h *HcpOpenShiftClustersServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) {
	if h.srv.BeginDelete == nil {
		return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")}
	}
	beginDelete := h.beginDelete.get(req)
	if beginDelete == nil {
		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.RedHatOpenShift/hcpOpenShiftClusters/(?P<hcpOpenShiftClusterName>[!#&$-;=?-\[\]_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
		}
		hcpOpenShiftClusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("hcpOpenShiftClusterName")])
		if err != nil {
			return nil, err
		}
		respr, errRespr := h.srv.BeginDelete(req.Context(), resourceGroupNameParam, hcpOpenShiftClusterNameParam, nil)
		if respErr := server.GetError(errRespr, req); respErr != nil {
			return nil, respErr
		}
		beginDelete = &respr
		h.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) {
		h.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) {
		h.beginDelete.remove(req)
	}

	return resp, nil
}

func (h *HcpOpenShiftClustersServerTransport) dispatchGet(req *http.Request) (*http.Response, error) {
	if h.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/Microsoft\.RedHatOpenShift/hcpOpenShiftClusters/(?P<hcpOpenShiftClusterName>[!#&$-;=?-\[\]_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
	}
	hcpOpenShiftClusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("hcpOpenShiftClusterName")])
	if err != nil {
		return nil, err
	}
	respr, errRespr := h.srv.Get(req.Context(), resourceGroupNameParam, hcpOpenShiftClusterNameParam, 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).HcpOpenShiftCluster, req)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

func (h *HcpOpenShiftClustersServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) {
	if h.srv.NewListByResourceGroupPager == nil {
		return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")}
	}
	newListByResourceGroupPager := h.newListByResourceGroupPager.get(req)
	if newListByResourceGroupPager == nil {
		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.RedHatOpenShift/hcpOpenShiftClusters`
		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 := h.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil)
		newListByResourceGroupPager = &resp
		h.newListByResourceGroupPager.add(req, newListByResourceGroupPager)
		server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armredhatopenshifthcp.HcpOpenShiftClustersClientListByResourceGroupResponse, 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) {
		h.newListByResourceGroupPager.remove(req)
		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)}
	}
	if !server.PagerResponderMore(newListByResourceGroupPager) {
		h.newListByResourceGroupPager.remove(req)
	}
	return resp, nil
}

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

func (h *HcpOpenShiftClustersServerTransport) dispatchBeginRequestAdminCredential(req *http.Request) (*http.Response, error) {
	if h.srv.BeginRequestAdminCredential == nil {
		return nil, &nonRetriableError{errors.New("fake for method BeginRequestAdminCredential not implemented")}
	}
	beginRequestAdminCredential := h.beginRequestAdminCredential.get(req)
	if beginRequestAdminCredential == nil {
		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.RedHatOpenShift/hcpOpenShiftClusters/(?P<hcpOpenShiftClusterName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/requestAdminCredential`
		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
		}
		hcpOpenShiftClusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("hcpOpenShiftClusterName")])
		if err != nil {
			return nil, err
		}
		respr, errRespr := h.srv.BeginRequestAdminCredential(req.Context(), resourceGroupNameParam, hcpOpenShiftClusterNameParam, nil)
		if respErr := server.GetError(errRespr, req); respErr != nil {
			return nil, respErr
		}
		beginRequestAdminCredential = &respr
		h.beginRequestAdminCredential.add(req, beginRequestAdminCredential)
	}

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

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

	return resp, nil
}

func (h *HcpOpenShiftClustersServerTransport) dispatchBeginRevokeCredentials(req *http.Request) (*http.Response, error) {
	if h.srv.BeginRevokeCredentials == nil {
		return nil, &nonRetriableError{errors.New("fake for method BeginRevokeCredentials not implemented")}
	}
	beginRevokeCredentials := h.beginRevokeCredentials.get(req)
	if beginRevokeCredentials == nil {
		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.RedHatOpenShift/hcpOpenShiftClusters/(?P<hcpOpenShiftClusterName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/revokeCredentials`
		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
		}
		hcpOpenShiftClusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("hcpOpenShiftClusterName")])
		if err != nil {
			return nil, err
		}
		respr, errRespr := h.srv.BeginRevokeCredentials(req.Context(), resourceGroupNameParam, hcpOpenShiftClusterNameParam, nil)
		if respErr := server.GetError(errRespr, req); respErr != nil {
			return nil, respErr
		}
		beginRevokeCredentials = &respr
		h.beginRevokeCredentials.add(req, beginRevokeCredentials)
	}

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

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

	return resp, nil
}

func (h *HcpOpenShiftClustersServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) {
	if h.srv.BeginUpdate == nil {
		return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")}
	}
	beginUpdate := h.beginUpdate.get(req)
	if beginUpdate == nil {
		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.RedHatOpenShift/hcpOpenShiftClusters/(?P<hcpOpenShiftClusterName>[!#&$-;=?-\[\]_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[armredhatopenshifthcp.HcpOpenShiftClusterUpdate](req)
		if err != nil {
			return nil, err
		}
		resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
		if err != nil {
			return nil, err
		}
		hcpOpenShiftClusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("hcpOpenShiftClusterName")])
		if err != nil {
			return nil, err
		}
		respr, errRespr := h.srv.BeginUpdate(req.Context(), resourceGroupNameParam, hcpOpenShiftClusterNameParam, body, nil)
		if respErr := server.GetError(errRespr, req); respErr != nil {
			return nil, respErr
		}
		beginUpdate = &respr
		h.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) {
		h.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) {
		h.beginUpdate.remove(req)
	}

	return resp, nil
}

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