// 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/hybridcompute/armhybridcompute/v3"
	"net/http"
	"net/url"
	"regexp"
	"slices"
)

// MachinesServer is a fake server for instances of the armhybridcompute.MachinesClient type.
type MachinesServer struct {
	// BeginAssessPatches is the fake for method MachinesClient.BeginAssessPatches
	// HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted
	BeginAssessPatches func(ctx context.Context, resourceGroupName string, name string, options *armhybridcompute.MachinesClientBeginAssessPatchesOptions) (resp azfake.PollerResponder[armhybridcompute.MachinesClientAssessPatchesResponse], errResp azfake.ErrorResponder)

	// CreateOrUpdate is the fake for method MachinesClient.CreateOrUpdate
	// HTTP status codes to indicate success: http.StatusOK
	CreateOrUpdate func(ctx context.Context, resourceGroupName string, machineName string, parameters armhybridcompute.Machine, options *armhybridcompute.MachinesClientCreateOrUpdateOptions) (resp azfake.Responder[armhybridcompute.MachinesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder)

	// BeginDelete is the fake for method MachinesClient.BeginDelete
	// HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent
	BeginDelete func(ctx context.Context, resourceGroupName string, machineName string, options *armhybridcompute.MachinesClientBeginDeleteOptions) (resp azfake.PollerResponder[armhybridcompute.MachinesClientDeleteResponse], errResp azfake.ErrorResponder)

	// Get is the fake for method MachinesClient.Get
	// HTTP status codes to indicate success: http.StatusOK
	Get func(ctx context.Context, resourceGroupName string, machineName string, options *armhybridcompute.MachinesClientGetOptions) (resp azfake.Responder[armhybridcompute.MachinesClientGetResponse], errResp azfake.ErrorResponder)

	// BeginInstallPatches is the fake for method MachinesClient.BeginInstallPatches
	// HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted
	BeginInstallPatches func(ctx context.Context, resourceGroupName string, name string, installPatchesInput armhybridcompute.MachineInstallPatchesParameters, options *armhybridcompute.MachinesClientBeginInstallPatchesOptions) (resp azfake.PollerResponder[armhybridcompute.MachinesClientInstallPatchesResponse], errResp azfake.ErrorResponder)

	// NewListByResourceGroupPager is the fake for method MachinesClient.NewListByResourceGroupPager
	// HTTP status codes to indicate success: http.StatusOK
	NewListByResourceGroupPager func(resourceGroupName string, options *armhybridcompute.MachinesClientListByResourceGroupOptions) (resp azfake.PagerResponder[armhybridcompute.MachinesClientListByResourceGroupResponse])

	// NewListBySubscriptionPager is the fake for method MachinesClient.NewListBySubscriptionPager
	// HTTP status codes to indicate success: http.StatusOK
	NewListBySubscriptionPager func(options *armhybridcompute.MachinesClientListBySubscriptionOptions) (resp azfake.PagerResponder[armhybridcompute.MachinesClientListBySubscriptionResponse])

	// Update is the fake for method MachinesClient.Update
	// HTTP status codes to indicate success: http.StatusOK
	Update func(ctx context.Context, resourceGroupName string, machineName string, parameters armhybridcompute.MachineUpdate, options *armhybridcompute.MachinesClientUpdateOptions) (resp azfake.Responder[armhybridcompute.MachinesClientUpdateResponse], errResp azfake.ErrorResponder)
}

// NewMachinesServerTransport creates a new instance of MachinesServerTransport with the provided implementation.
// The returned MachinesServerTransport instance is connected to an instance of armhybridcompute.MachinesClient via the
// azcore.ClientOptions.Transporter field in the client's constructor parameters.
func NewMachinesServerTransport(srv *MachinesServer) *MachinesServerTransport {
	return &MachinesServerTransport{
		srv:                         srv,
		beginAssessPatches:          newTracker[azfake.PollerResponder[armhybridcompute.MachinesClientAssessPatchesResponse]](),
		beginDelete:                 newTracker[azfake.PollerResponder[armhybridcompute.MachinesClientDeleteResponse]](),
		beginInstallPatches:         newTracker[azfake.PollerResponder[armhybridcompute.MachinesClientInstallPatchesResponse]](),
		newListByResourceGroupPager: newTracker[azfake.PagerResponder[armhybridcompute.MachinesClientListByResourceGroupResponse]](),
		newListBySubscriptionPager:  newTracker[azfake.PagerResponder[armhybridcompute.MachinesClientListBySubscriptionResponse]](),
	}
}

// MachinesServerTransport connects instances of armhybridcompute.MachinesClient to instances of MachinesServer.
// Don't use this type directly, use NewMachinesServerTransport instead.
type MachinesServerTransport struct {
	srv                         *MachinesServer
	beginAssessPatches          *tracker[azfake.PollerResponder[armhybridcompute.MachinesClientAssessPatchesResponse]]
	beginDelete                 *tracker[azfake.PollerResponder[armhybridcompute.MachinesClientDeleteResponse]]
	beginInstallPatches         *tracker[azfake.PollerResponder[armhybridcompute.MachinesClientInstallPatchesResponse]]
	newListByResourceGroupPager *tracker[azfake.PagerResponder[armhybridcompute.MachinesClientListByResourceGroupResponse]]
	newListBySubscriptionPager  *tracker[azfake.PagerResponder[armhybridcompute.MachinesClientListBySubscriptionResponse]]
}

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

func (m *MachinesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) {
	resultChan := make(chan result, 1)
	go func() {
		var intercepted bool
		var res result
		if machinesServerTransportInterceptor != nil {
			res.resp, res.err, intercepted = machinesServerTransportInterceptor.Do(req)
		}
		if !intercepted {
			switch method {
			case "MachinesClient.BeginAssessPatches":
				res.resp, res.err = m.dispatchBeginAssessPatches(req)
			case "MachinesClient.CreateOrUpdate":
				res.resp, res.err = m.dispatchCreateOrUpdate(req)
			case "MachinesClient.BeginDelete":
				res.resp, res.err = m.dispatchBeginDelete(req)
			case "MachinesClient.Get":
				res.resp, res.err = m.dispatchGet(req)
			case "MachinesClient.BeginInstallPatches":
				res.resp, res.err = m.dispatchBeginInstallPatches(req)
			case "MachinesClient.NewListByResourceGroupPager":
				res.resp, res.err = m.dispatchNewListByResourceGroupPager(req)
			case "MachinesClient.NewListBySubscriptionPager":
				res.resp, res.err = m.dispatchNewListBySubscriptionPager(req)
			case "MachinesClient.Update":
				res.resp, res.err = m.dispatchUpdate(req)
			default:
				res.err = fmt.Errorf("unhandled API %s", method)
			}

		}
		resultChan <- res
	}()

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

func (m *MachinesServerTransport) dispatchBeginAssessPatches(req *http.Request) (*http.Response, error) {
	if m.srv.BeginAssessPatches == nil {
		return nil, &nonRetriableError{errors.New("fake for method BeginAssessPatches not implemented")}
	}
	beginAssessPatches := m.beginAssessPatches.get(req)
	if beginAssessPatches == nil {
		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HybridCompute/machines/(?P<name>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/assessPatches`
		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
		}
		nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")])
		if err != nil {
			return nil, err
		}
		respr, errRespr := m.srv.BeginAssessPatches(req.Context(), resourceGroupNameParam, nameParam, nil)
		if respErr := server.GetError(errRespr, req); respErr != nil {
			return nil, respErr
		}
		beginAssessPatches = &respr
		m.beginAssessPatches.add(req, beginAssessPatches)
	}

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

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

	return resp, nil
}

func (m *MachinesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) {
	if m.srv.CreateOrUpdate == nil {
		return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")}
	}
	const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HybridCompute/machines/(?P<machineName>[!#&$-;=?-\[\]_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)
	}
	qp := req.URL.Query()
	body, err := server.UnmarshalRequestAsJSON[armhybridcompute.Machine](req)
	if err != nil {
		return nil, err
	}
	resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
	if err != nil {
		return nil, err
	}
	machineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("machineName")])
	if err != nil {
		return nil, err
	}
	expandParam := getOptional(qp.Get("$expand"))
	var options *armhybridcompute.MachinesClientCreateOrUpdateOptions
	if expandParam != nil {
		options = &armhybridcompute.MachinesClientCreateOrUpdateOptions{
			Expand: expandParam,
		}
	}
	respr, errRespr := m.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, machineNameParam, body, options)
	if respErr := server.GetError(errRespr, req); respErr != nil {
		return nil, respErr
	}
	respContent := server.GetResponseContent(respr)
	if !slices.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).Machine, req)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

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

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

	if !slices.Contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) {
		m.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) {
		m.beginDelete.remove(req)
	}

	return resp, nil
}

func (m *MachinesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) {
	if m.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\.HybridCompute/machines/(?P<machineName>[!#&$-;=?-\[\]_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)
	}
	qp := req.URL.Query()
	resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
	if err != nil {
		return nil, err
	}
	machineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("machineName")])
	if err != nil {
		return nil, err
	}
	expandParam := getOptional(armhybridcompute.InstanceViewTypes(qp.Get("$expand")))
	var options *armhybridcompute.MachinesClientGetOptions
	if expandParam != nil {
		options = &armhybridcompute.MachinesClientGetOptions{
			Expand: expandParam,
		}
	}
	respr, errRespr := m.srv.Get(req.Context(), resourceGroupNameParam, machineNameParam, options)
	if respErr := server.GetError(errRespr, req); respErr != nil {
		return nil, respErr
	}
	respContent := server.GetResponseContent(respr)
	if !slices.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).Machine, req)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

func (m *MachinesServerTransport) dispatchBeginInstallPatches(req *http.Request) (*http.Response, error) {
	if m.srv.BeginInstallPatches == nil {
		return nil, &nonRetriableError{errors.New("fake for method BeginInstallPatches not implemented")}
	}
	beginInstallPatches := m.beginInstallPatches.get(req)
	if beginInstallPatches == nil {
		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HybridCompute/machines/(?P<name>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/installPatches`
		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[armhybridcompute.MachineInstallPatchesParameters](req)
		if err != nil {
			return nil, err
		}
		resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
		if err != nil {
			return nil, err
		}
		nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")])
		if err != nil {
			return nil, err
		}
		respr, errRespr := m.srv.BeginInstallPatches(req.Context(), resourceGroupNameParam, nameParam, body, nil)
		if respErr := server.GetError(errRespr, req); respErr != nil {
			return nil, respErr
		}
		beginInstallPatches = &respr
		m.beginInstallPatches.add(req, beginInstallPatches)
	}

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

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

	return resp, nil
}

func (m *MachinesServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) {
	if m.srv.NewListByResourceGroupPager == nil {
		return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")}
	}
	newListByResourceGroupPager := m.newListByResourceGroupPager.get(req)
	if newListByResourceGroupPager == nil {
		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HybridCompute/machines`
		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)
		}
		qp := req.URL.Query()
		resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
		if err != nil {
			return nil, err
		}
		expandParam := getOptional(qp.Get("$expand"))
		var options *armhybridcompute.MachinesClientListByResourceGroupOptions
		if expandParam != nil {
			options = &armhybridcompute.MachinesClientListByResourceGroupOptions{
				Expand: expandParam,
			}
		}
		resp := m.srv.NewListByResourceGroupPager(resourceGroupNameParam, options)
		newListByResourceGroupPager = &resp
		m.newListByResourceGroupPager.add(req, newListByResourceGroupPager)
		server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armhybridcompute.MachinesClientListByResourceGroupResponse, createLink func() string) {
			page.NextLink = to.Ptr(createLink())
		})
	}
	resp, err := server.PagerResponderNext(newListByResourceGroupPager, req)
	if err != nil {
		return nil, err
	}
	if !slices.Contains([]int{http.StatusOK}, resp.StatusCode) {
		m.newListByResourceGroupPager.remove(req)
		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)}
	}
	if !server.PagerResponderMore(newListByResourceGroupPager) {
		m.newListByResourceGroupPager.remove(req)
	}
	return resp, nil
}

func (m *MachinesServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) {
	if m.srv.NewListBySubscriptionPager == nil {
		return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")}
	}
	newListBySubscriptionPager := m.newListBySubscriptionPager.get(req)
	if newListBySubscriptionPager == nil {
		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HybridCompute/machines`
		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 := m.srv.NewListBySubscriptionPager(nil)
		newListBySubscriptionPager = &resp
		m.newListBySubscriptionPager.add(req, newListBySubscriptionPager)
		server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armhybridcompute.MachinesClientListBySubscriptionResponse, createLink func() string) {
			page.NextLink = to.Ptr(createLink())
		})
	}
	resp, err := server.PagerResponderNext(newListBySubscriptionPager, req)
	if err != nil {
		return nil, err
	}
	if !slices.Contains([]int{http.StatusOK}, resp.StatusCode) {
		m.newListBySubscriptionPager.remove(req)
		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)}
	}
	if !server.PagerResponderMore(newListBySubscriptionPager) {
		m.newListBySubscriptionPager.remove(req)
	}
	return resp, nil
}

func (m *MachinesServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) {
	if m.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/Microsoft\.HybridCompute/machines/(?P<machineName>[!#&$-;=?-\[\]_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[armhybridcompute.MachineUpdate](req)
	if err != nil {
		return nil, err
	}
	resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
	if err != nil {
		return nil, err
	}
	machineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("machineName")])
	if err != nil {
		return nil, err
	}
	respr, errRespr := m.srv.Update(req.Context(), resourceGroupNameParam, machineNameParam, body, nil)
	if respErr := server.GetError(errRespr, req); respErr != nil {
		return nil, respErr
	}
	respContent := server.GetResponseContent(respr)
	if !slices.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).Machine, req)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

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