// 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"
	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/informaticadatamgmt/arminformaticadatamgmt"
	"net/http"
	"net/url"
	"regexp"
)

// ServerlessRuntimesServer is a fake server for instances of the arminformaticadatamgmt.ServerlessRuntimesClient type.
type ServerlessRuntimesServer struct {
	// CheckDependencies is the fake for method ServerlessRuntimesClient.CheckDependencies
	// HTTP status codes to indicate success: http.StatusOK
	CheckDependencies func(ctx context.Context, resourceGroupName string, organizationName string, serverlessRuntimeName string, options *arminformaticadatamgmt.ServerlessRuntimesClientCheckDependenciesOptions) (resp azfake.Responder[arminformaticadatamgmt.ServerlessRuntimesClientCheckDependenciesResponse], errResp azfake.ErrorResponder)

	// BeginCreateOrUpdate is the fake for method ServerlessRuntimesClient.BeginCreateOrUpdate
	// HTTP status codes to indicate success: http.StatusOK, http.StatusCreated
	BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, organizationName string, serverlessRuntimeName string, resource arminformaticadatamgmt.InformaticaServerlessRuntimeResource, options *arminformaticadatamgmt.ServerlessRuntimesClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[arminformaticadatamgmt.ServerlessRuntimesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder)

	// BeginDelete is the fake for method ServerlessRuntimesClient.BeginDelete
	// HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent
	BeginDelete func(ctx context.Context, resourceGroupName string, organizationName string, serverlessRuntimeName string, options *arminformaticadatamgmt.ServerlessRuntimesClientBeginDeleteOptions) (resp azfake.PollerResponder[arminformaticadatamgmt.ServerlessRuntimesClientDeleteResponse], errResp azfake.ErrorResponder)

	// Get is the fake for method ServerlessRuntimesClient.Get
	// HTTP status codes to indicate success: http.StatusOK
	Get func(ctx context.Context, resourceGroupName string, organizationName string, serverlessRuntimeName string, options *arminformaticadatamgmt.ServerlessRuntimesClientGetOptions) (resp azfake.Responder[arminformaticadatamgmt.ServerlessRuntimesClientGetResponse], errResp azfake.ErrorResponder)

	// NewListByInformaticaOrganizationResourcePager is the fake for method ServerlessRuntimesClient.NewListByInformaticaOrganizationResourcePager
	// HTTP status codes to indicate success: http.StatusOK
	NewListByInformaticaOrganizationResourcePager func(resourceGroupName string, organizationName string, options *arminformaticadatamgmt.ServerlessRuntimesClientListByInformaticaOrganizationResourceOptions) (resp azfake.PagerResponder[arminformaticadatamgmt.ServerlessRuntimesClientListByInformaticaOrganizationResourceResponse])

	// ServerlessResourceByID is the fake for method ServerlessRuntimesClient.ServerlessResourceByID
	// HTTP status codes to indicate success: http.StatusOK
	ServerlessResourceByID func(ctx context.Context, resourceGroupName string, organizationName string, serverlessRuntimeName string, options *arminformaticadatamgmt.ServerlessRuntimesClientServerlessResourceByIDOptions) (resp azfake.Responder[arminformaticadatamgmt.ServerlessRuntimesClientServerlessResourceByIDResponse], errResp azfake.ErrorResponder)

	// StartFailedServerlessRuntime is the fake for method ServerlessRuntimesClient.StartFailedServerlessRuntime
	// HTTP status codes to indicate success: http.StatusNoContent
	StartFailedServerlessRuntime func(ctx context.Context, resourceGroupName string, organizationName string, serverlessRuntimeName string, options *arminformaticadatamgmt.ServerlessRuntimesClientStartFailedServerlessRuntimeOptions) (resp azfake.Responder[arminformaticadatamgmt.ServerlessRuntimesClientStartFailedServerlessRuntimeResponse], errResp azfake.ErrorResponder)

	// Update is the fake for method ServerlessRuntimesClient.Update
	// HTTP status codes to indicate success: http.StatusOK
	Update func(ctx context.Context, resourceGroupName string, organizationName string, serverlessRuntimeName string, properties arminformaticadatamgmt.InformaticaServerlessRuntimeResourceUpdate, options *arminformaticadatamgmt.ServerlessRuntimesClientUpdateOptions) (resp azfake.Responder[arminformaticadatamgmt.ServerlessRuntimesClientUpdateResponse], errResp azfake.ErrorResponder)
}

// NewServerlessRuntimesServerTransport creates a new instance of ServerlessRuntimesServerTransport with the provided implementation.
// The returned ServerlessRuntimesServerTransport instance is connected to an instance of arminformaticadatamgmt.ServerlessRuntimesClient via the
// azcore.ClientOptions.Transporter field in the client's constructor parameters.
func NewServerlessRuntimesServerTransport(srv *ServerlessRuntimesServer) *ServerlessRuntimesServerTransport {
	return &ServerlessRuntimesServerTransport{
		srv:                 srv,
		beginCreateOrUpdate: newTracker[azfake.PollerResponder[arminformaticadatamgmt.ServerlessRuntimesClientCreateOrUpdateResponse]](),
		beginDelete:         newTracker[azfake.PollerResponder[arminformaticadatamgmt.ServerlessRuntimesClientDeleteResponse]](),
		newListByInformaticaOrganizationResourcePager: newTracker[azfake.PagerResponder[arminformaticadatamgmt.ServerlessRuntimesClientListByInformaticaOrganizationResourceResponse]](),
	}
}

// ServerlessRuntimesServerTransport connects instances of arminformaticadatamgmt.ServerlessRuntimesClient to instances of ServerlessRuntimesServer.
// Don't use this type directly, use NewServerlessRuntimesServerTransport instead.
type ServerlessRuntimesServerTransport struct {
	srv                                           *ServerlessRuntimesServer
	beginCreateOrUpdate                           *tracker[azfake.PollerResponder[arminformaticadatamgmt.ServerlessRuntimesClientCreateOrUpdateResponse]]
	beginDelete                                   *tracker[azfake.PollerResponder[arminformaticadatamgmt.ServerlessRuntimesClientDeleteResponse]]
	newListByInformaticaOrganizationResourcePager *tracker[azfake.PagerResponder[arminformaticadatamgmt.ServerlessRuntimesClientListByInformaticaOrganizationResourceResponse]]
}

// Do implements the policy.Transporter interface for ServerlessRuntimesServerTransport.
func (s *ServerlessRuntimesServerTransport) 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 "ServerlessRuntimesClient.CheckDependencies":
		resp, err = s.dispatchCheckDependencies(req)
	case "ServerlessRuntimesClient.BeginCreateOrUpdate":
		resp, err = s.dispatchBeginCreateOrUpdate(req)
	case "ServerlessRuntimesClient.BeginDelete":
		resp, err = s.dispatchBeginDelete(req)
	case "ServerlessRuntimesClient.Get":
		resp, err = s.dispatchGet(req)
	case "ServerlessRuntimesClient.NewListByInformaticaOrganizationResourcePager":
		resp, err = s.dispatchNewListByInformaticaOrganizationResourcePager(req)
	case "ServerlessRuntimesClient.ServerlessResourceByID":
		resp, err = s.dispatchServerlessResourceByID(req)
	case "ServerlessRuntimesClient.StartFailedServerlessRuntime":
		resp, err = s.dispatchStartFailedServerlessRuntime(req)
	case "ServerlessRuntimesClient.Update":
		resp, err = s.dispatchUpdate(req)
	default:
		err = fmt.Errorf("unhandled API %s", method)
	}

	if err != nil {
		return nil, err
	}

	return resp, nil
}

func (s *ServerlessRuntimesServerTransport) dispatchCheckDependencies(req *http.Request) (*http.Response, error) {
	if s.srv.CheckDependencies == nil {
		return nil, &nonRetriableError{errors.New("fake for method CheckDependencies not implemented")}
	}
	const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Informatica\.DataManagement/organizations/(?P<organizationName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/serverlessRuntimes/(?P<serverlessRuntimeName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/checkDependencies`
	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)
	}
	resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
	if err != nil {
		return nil, err
	}
	organizationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("organizationName")])
	if err != nil {
		return nil, err
	}
	serverlessRuntimeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serverlessRuntimeName")])
	if err != nil {
		return nil, err
	}
	respr, errRespr := s.srv.CheckDependencies(req.Context(), resourceGroupNameParam, organizationNameParam, serverlessRuntimeNameParam, 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).CheckDependenciesResponse, req)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

func (s *ServerlessRuntimesServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) {
	if s.srv.BeginCreateOrUpdate == nil {
		return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")}
	}
	beginCreateOrUpdate := s.beginCreateOrUpdate.get(req)
	if beginCreateOrUpdate == nil {
		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Informatica\.DataManagement/organizations/(?P<organizationName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/serverlessRuntimes/(?P<serverlessRuntimeName>[!#&$-;=?-\[\]_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)
		}
		body, err := server.UnmarshalRequestAsJSON[arminformaticadatamgmt.InformaticaServerlessRuntimeResource](req)
		if err != nil {
			return nil, err
		}
		resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
		if err != nil {
			return nil, err
		}
		organizationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("organizationName")])
		if err != nil {
			return nil, err
		}
		serverlessRuntimeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serverlessRuntimeName")])
		if err != nil {
			return nil, err
		}
		respr, errRespr := s.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, organizationNameParam, serverlessRuntimeNameParam, body, nil)
		if respErr := server.GetError(errRespr, req); respErr != nil {
			return nil, respErr
		}
		beginCreateOrUpdate = &respr
		s.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) {
		s.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) {
		s.beginCreateOrUpdate.remove(req)
	}

	return resp, nil
}

func (s *ServerlessRuntimesServerTransport) 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/Informatica\.DataManagement/organizations/(?P<organizationName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/serverlessRuntimes/(?P<serverlessRuntimeName>[!#&$-;=?-\[\]_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)
		}
		resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
		if err != nil {
			return nil, err
		}
		organizationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("organizationName")])
		if err != nil {
			return nil, err
		}
		serverlessRuntimeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serverlessRuntimeName")])
		if err != nil {
			return nil, err
		}
		respr, errRespr := s.srv.BeginDelete(req.Context(), resourceGroupNameParam, organizationNameParam, serverlessRuntimeNameParam, 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.StatusAccepted, http.StatusNoContent}, resp.StatusCode) {
		s.beginDelete.remove(req)
		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)}
	}
	if !server.PollerResponderMore(beginDelete) {
		s.beginDelete.remove(req)
	}

	return resp, nil
}

func (s *ServerlessRuntimesServerTransport) 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/Informatica\.DataManagement/organizations/(?P<organizationName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/serverlessRuntimes/(?P<serverlessRuntimeName>[!#&$-;=?-\[\]_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)
	}
	resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
	if err != nil {
		return nil, err
	}
	organizationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("organizationName")])
	if err != nil {
		return nil, err
	}
	serverlessRuntimeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serverlessRuntimeName")])
	if err != nil {
		return nil, err
	}
	respr, errRespr := s.srv.Get(req.Context(), resourceGroupNameParam, organizationNameParam, serverlessRuntimeNameParam, 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).InformaticaServerlessRuntimeResource, req)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

func (s *ServerlessRuntimesServerTransport) dispatchNewListByInformaticaOrganizationResourcePager(req *http.Request) (*http.Response, error) {
	if s.srv.NewListByInformaticaOrganizationResourcePager == nil {
		return nil, &nonRetriableError{errors.New("fake for method NewListByInformaticaOrganizationResourcePager not implemented")}
	}
	newListByInformaticaOrganizationResourcePager := s.newListByInformaticaOrganizationResourcePager.get(req)
	if newListByInformaticaOrganizationResourcePager == nil {
		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Informatica\.DataManagement/organizations/(?P<organizationName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/serverlessRuntimes`
		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)
		}
		resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
		if err != nil {
			return nil, err
		}
		organizationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("organizationName")])
		if err != nil {
			return nil, err
		}
		resp := s.srv.NewListByInformaticaOrganizationResourcePager(resourceGroupNameParam, organizationNameParam, nil)
		newListByInformaticaOrganizationResourcePager = &resp
		s.newListByInformaticaOrganizationResourcePager.add(req, newListByInformaticaOrganizationResourcePager)
		server.PagerResponderInjectNextLinks(newListByInformaticaOrganizationResourcePager, req, func(page *arminformaticadatamgmt.ServerlessRuntimesClientListByInformaticaOrganizationResourceResponse, createLink func() string) {
			page.NextLink = to.Ptr(createLink())
		})
	}
	resp, err := server.PagerResponderNext(newListByInformaticaOrganizationResourcePager, req)
	if err != nil {
		return nil, err
	}
	if !contains([]int{http.StatusOK}, resp.StatusCode) {
		s.newListByInformaticaOrganizationResourcePager.remove(req)
		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)}
	}
	if !server.PagerResponderMore(newListByInformaticaOrganizationResourcePager) {
		s.newListByInformaticaOrganizationResourcePager.remove(req)
	}
	return resp, nil
}

func (s *ServerlessRuntimesServerTransport) dispatchServerlessResourceByID(req *http.Request) (*http.Response, error) {
	if s.srv.ServerlessResourceByID == nil {
		return nil, &nonRetriableError{errors.New("fake for method ServerlessResourceByID not implemented")}
	}
	const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Informatica\.DataManagement/organizations/(?P<organizationName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/serverlessRuntimes/(?P<serverlessRuntimeName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/serverlessResourceById`
	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)
	}
	resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
	if err != nil {
		return nil, err
	}
	organizationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("organizationName")])
	if err != nil {
		return nil, err
	}
	serverlessRuntimeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serverlessRuntimeName")])
	if err != nil {
		return nil, err
	}
	respr, errRespr := s.srv.ServerlessResourceByID(req.Context(), resourceGroupNameParam, organizationNameParam, serverlessRuntimeNameParam, 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).InformaticaServerlessRuntimeResource, req)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

func (s *ServerlessRuntimesServerTransport) dispatchStartFailedServerlessRuntime(req *http.Request) (*http.Response, error) {
	if s.srv.StartFailedServerlessRuntime == nil {
		return nil, &nonRetriableError{errors.New("fake for method StartFailedServerlessRuntime not implemented")}
	}
	const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Informatica\.DataManagement/organizations/(?P<organizationName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/serverlessRuntimes/(?P<serverlessRuntimeName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/startFailedServerlessRuntime`
	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)
	}
	resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
	if err != nil {
		return nil, err
	}
	organizationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("organizationName")])
	if err != nil {
		return nil, err
	}
	serverlessRuntimeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serverlessRuntimeName")])
	if err != nil {
		return nil, err
	}
	respr, errRespr := s.srv.StartFailedServerlessRuntime(req.Context(), resourceGroupNameParam, organizationNameParam, serverlessRuntimeNameParam, nil)
	if respErr := server.GetError(errRespr, req); respErr != nil {
		return nil, respErr
	}
	respContent := server.GetResponseContent(respr)
	if !contains([]int{http.StatusNoContent}, respContent.HTTPStatus) {
		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusNoContent", respContent.HTTPStatus)}
	}
	resp, err := server.NewResponse(respContent, req, nil)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

func (s *ServerlessRuntimesServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) {
	if s.srv.Update == nil {
		return nil, &nonRetriableError{errors.New("fake for method Update not implemented")}
	}
	const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Informatica\.DataManagement/organizations/(?P<organizationName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/serverlessRuntimes/(?P<serverlessRuntimeName>[!#&$-;=?-\[\]_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)
	}
	body, err := server.UnmarshalRequestAsJSON[arminformaticadatamgmt.InformaticaServerlessRuntimeResourceUpdate](req)
	if err != nil {
		return nil, err
	}
	resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
	if err != nil {
		return nil, err
	}
	organizationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("organizationName")])
	if err != nil {
		return nil, err
	}
	serverlessRuntimeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serverlessRuntimeName")])
	if err != nil {
		return nil, err
	}
	respr, errRespr := s.srv.Update(req.Context(), resourceGroupNameParam, organizationNameParam, serverlessRuntimeNameParam, body, 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).InformaticaServerlessRuntimeResource, req)
	if err != nil {
		return nil, err
	}
	return resp, nil
}
