// 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/containerserviceaimanager/armcontainerserviceaimanager"
	"net/http"
	"net/url"
	"regexp"
	"slices"
)

// AIManagerNamespacesServer is a fake server for instances of the armcontainerserviceaimanager.AIManagerNamespacesClient type.
type AIManagerNamespacesServer struct {
	// BeginCreateOrUpdate is the fake for method AIManagerNamespacesClient.BeginCreateOrUpdate
	// HTTP status codes to indicate success: http.StatusOK, http.StatusCreated
	BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, aiManagerName string, namespaceName string, resource armcontainerserviceaimanager.AIManagerNamespace, options *armcontainerserviceaimanager.AIManagerNamespacesClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armcontainerserviceaimanager.AIManagerNamespacesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder)

	// BeginDelete is the fake for method AIManagerNamespacesClient.BeginDelete
	// HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent
	BeginDelete func(ctx context.Context, resourceGroupName string, aiManagerName string, namespaceName string, options *armcontainerserviceaimanager.AIManagerNamespacesClientBeginDeleteOptions) (resp azfake.PollerResponder[armcontainerserviceaimanager.AIManagerNamespacesClientDeleteResponse], errResp azfake.ErrorResponder)

	// Get is the fake for method AIManagerNamespacesClient.Get
	// HTTP status codes to indicate success: http.StatusOK
	Get func(ctx context.Context, resourceGroupName string, aiManagerName string, namespaceName string, options *armcontainerserviceaimanager.AIManagerNamespacesClientGetOptions) (resp azfake.Responder[armcontainerserviceaimanager.AIManagerNamespacesClientGetResponse], errResp azfake.ErrorResponder)

	// ListAccessKeys is the fake for method AIManagerNamespacesClient.ListAccessKeys
	// HTTP status codes to indicate success: http.StatusOK
	ListAccessKeys func(ctx context.Context, resourceGroupName string, aiManagerName string, namespaceName string, options *armcontainerserviceaimanager.AIManagerNamespacesClientListAccessKeysOptions) (resp azfake.Responder[armcontainerserviceaimanager.AIManagerNamespacesClientListAccessKeysResponse], errResp azfake.ErrorResponder)

	// NewListByAIManagerPager is the fake for method AIManagerNamespacesClient.NewListByAIManagerPager
	// HTTP status codes to indicate success: http.StatusOK
	NewListByAIManagerPager func(resourceGroupName string, aiManagerName string, options *armcontainerserviceaimanager.AIManagerNamespacesClientListByAIManagerOptions) (resp azfake.PagerResponder[armcontainerserviceaimanager.AIManagerNamespacesClientListByAIManagerResponse])

	// ListCredential is the fake for method AIManagerNamespacesClient.ListCredential
	// HTTP status codes to indicate success: http.StatusOK
	ListCredential func(ctx context.Context, resourceGroupName string, aiManagerName string, namespaceName string, options *armcontainerserviceaimanager.AIManagerNamespacesClientListCredentialOptions) (resp azfake.Responder[armcontainerserviceaimanager.AIManagerNamespacesClientListCredentialResponse], errResp azfake.ErrorResponder)

	// RotateKeys is the fake for method AIManagerNamespacesClient.RotateKeys
	// HTTP status codes to indicate success: http.StatusOK
	RotateKeys func(ctx context.Context, resourceGroupName string, aiManagerName string, namespaceName string, options *armcontainerserviceaimanager.AIManagerNamespacesClientRotateKeysOptions) (resp azfake.Responder[armcontainerserviceaimanager.AIManagerNamespacesClientRotateKeysResponse], errResp azfake.ErrorResponder)
}

// NewAIManagerNamespacesServerTransport creates a new instance of AIManagerNamespacesServerTransport with the provided implementation.
// The returned AIManagerNamespacesServerTransport instance is connected to an instance of armcontainerserviceaimanager.AIManagerNamespacesClient via the
// azcore.ClientOptions.Transporter field in the client's constructor parameters.
func NewAIManagerNamespacesServerTransport(srv *AIManagerNamespacesServer) *AIManagerNamespacesServerTransport {
	return &AIManagerNamespacesServerTransport{
		srv:                     srv,
		beginCreateOrUpdate:     newTracker[azfake.PollerResponder[armcontainerserviceaimanager.AIManagerNamespacesClientCreateOrUpdateResponse]](),
		beginDelete:             newTracker[azfake.PollerResponder[armcontainerserviceaimanager.AIManagerNamespacesClientDeleteResponse]](),
		newListByAIManagerPager: newTracker[azfake.PagerResponder[armcontainerserviceaimanager.AIManagerNamespacesClientListByAIManagerResponse]](),
	}
}

// AIManagerNamespacesServerTransport connects instances of armcontainerserviceaimanager.AIManagerNamespacesClient to instances of AIManagerNamespacesServer.
// Don't use this type directly, use NewAIManagerNamespacesServerTransport instead.
type AIManagerNamespacesServerTransport struct {
	srv                     *AIManagerNamespacesServer
	beginCreateOrUpdate     *tracker[azfake.PollerResponder[armcontainerserviceaimanager.AIManagerNamespacesClientCreateOrUpdateResponse]]
	beginDelete             *tracker[azfake.PollerResponder[armcontainerserviceaimanager.AIManagerNamespacesClientDeleteResponse]]
	newListByAIManagerPager *tracker[azfake.PagerResponder[armcontainerserviceaimanager.AIManagerNamespacesClientListByAIManagerResponse]]
}

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

func (a *AIManagerNamespacesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) {
	resultChan := make(chan result, 1)
	go func() {
		var intercepted bool
		var res result
		if aiManagerNamespacesServerTransportInterceptor != nil {
			res.resp, res.err, intercepted = aiManagerNamespacesServerTransportInterceptor.Do(req)
		}
		if !intercepted {
			switch method {
			case "AIManagerNamespacesClient.BeginCreateOrUpdate":
				res.resp, res.err = a.dispatchBeginCreateOrUpdate(req)
			case "AIManagerNamespacesClient.BeginDelete":
				res.resp, res.err = a.dispatchBeginDelete(req)
			case "AIManagerNamespacesClient.Get":
				res.resp, res.err = a.dispatchGet(req)
			case "AIManagerNamespacesClient.ListAccessKeys":
				res.resp, res.err = a.dispatchListAccessKeys(req)
			case "AIManagerNamespacesClient.NewListByAIManagerPager":
				res.resp, res.err = a.dispatchNewListByAIManagerPager(req)
			case "AIManagerNamespacesClient.ListCredential":
				res.resp, res.err = a.dispatchListCredential(req)
			case "AIManagerNamespacesClient.RotateKeys":
				res.resp, res.err = a.dispatchRotateKeys(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 (a *AIManagerNamespacesServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) {
	if a.srv.BeginCreateOrUpdate == nil {
		return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")}
	}
	beginCreateOrUpdate := a.beginCreateOrUpdate.get(req)
	if beginCreateOrUpdate == nil {
		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerService/aiManagers/(?P<aiManagerName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/namespaces/(?P<namespaceName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)`
		regex := regexp.MustCompile(regexStr)
		matches := regex.FindStringSubmatch(req.URL.EscapedPath())
		if len(matches) < 5 {
			return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
		}
		body, err := server.UnmarshalRequestAsJSON[armcontainerserviceaimanager.AIManagerNamespace](req)
		if err != nil {
			return nil, err
		}
		resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
		if err != nil {
			return nil, err
		}
		ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match"))
		ifNoneMatchParam := getOptional(getHeaderValue(req.Header, "If-None-Match"))
		aiManagerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("aiManagerName")])
		if err != nil {
			return nil, err
		}
		namespaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("namespaceName")])
		if err != nil {
			return nil, err
		}
		var options *armcontainerserviceaimanager.AIManagerNamespacesClientBeginCreateOrUpdateOptions
		if ifMatchParam != nil || ifNoneMatchParam != nil {
			options = &armcontainerserviceaimanager.AIManagerNamespacesClientBeginCreateOrUpdateOptions{
				IfMatch:     ifMatchParam,
				IfNoneMatch: ifNoneMatchParam,
			}
		}
		respr, errRespr := a.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, aiManagerNameParam, namespaceNameParam, body, options)
		if respErr := server.GetError(errRespr, req); respErr != nil {
			return nil, respErr
		}
		beginCreateOrUpdate = &respr
		a.beginCreateOrUpdate.add(req, beginCreateOrUpdate)
	}

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

	if !slices.Contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) {
		a.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) {
		a.beginCreateOrUpdate.remove(req)
	}

	return resp, nil
}

func (a *AIManagerNamespacesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) {
	if a.srv.BeginDelete == nil {
		return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")}
	}
	beginDelete := a.beginDelete.get(req)
	if beginDelete == nil {
		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerService/aiManagers/(?P<aiManagerName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/namespaces/(?P<namespaceName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)`
		regex := regexp.MustCompile(regexStr)
		matches := regex.FindStringSubmatch(req.URL.EscapedPath())
		if len(matches) < 5 {
			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
		}
		ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match"))
		aiManagerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("aiManagerName")])
		if err != nil {
			return nil, err
		}
		namespaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("namespaceName")])
		if err != nil {
			return nil, err
		}
		var options *armcontainerserviceaimanager.AIManagerNamespacesClientBeginDeleteOptions
		if ifMatchParam != nil {
			options = &armcontainerserviceaimanager.AIManagerNamespacesClientBeginDeleteOptions{
				IfMatch: ifMatchParam,
			}
		}
		respr, errRespr := a.srv.BeginDelete(req.Context(), resourceGroupNameParam, aiManagerNameParam, namespaceNameParam, options)
		if respErr := server.GetError(errRespr, req); respErr != nil {
			return nil, respErr
		}
		beginDelete = &respr
		a.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) {
		a.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) {
		a.beginDelete.remove(req)
	}

	return resp, nil
}

func (a *AIManagerNamespacesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) {
	if a.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\.ContainerService/aiManagers/(?P<aiManagerName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/namespaces/(?P<namespaceName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)`
	regex := regexp.MustCompile(regexStr)
	matches := regex.FindStringSubmatch(req.URL.EscapedPath())
	if len(matches) < 5 {
		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
	}
	aiManagerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("aiManagerName")])
	if err != nil {
		return nil, err
	}
	namespaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("namespaceName")])
	if err != nil {
		return nil, err
	}
	respr, errRespr := a.srv.Get(req.Context(), resourceGroupNameParam, aiManagerNameParam, namespaceNameParam, 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).AIManagerNamespace, req)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

func (a *AIManagerNamespacesServerTransport) dispatchListAccessKeys(req *http.Request) (*http.Response, error) {
	if a.srv.ListAccessKeys == nil {
		return nil, &nonRetriableError{errors.New("fake for method ListAccessKeys not implemented")}
	}
	const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerService/aiManagers/(?P<aiManagerName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/namespaces/(?P<namespaceName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listAccessKeys`
	regex := regexp.MustCompile(regexStr)
	matches := regex.FindStringSubmatch(req.URL.EscapedPath())
	if len(matches) < 5 {
		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
	}
	aiManagerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("aiManagerName")])
	if err != nil {
		return nil, err
	}
	namespaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("namespaceName")])
	if err != nil {
		return nil, err
	}
	respr, errRespr := a.srv.ListAccessKeys(req.Context(), resourceGroupNameParam, aiManagerNameParam, namespaceNameParam, 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).NamespaceAccessInfo, req)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

func (a *AIManagerNamespacesServerTransport) dispatchNewListByAIManagerPager(req *http.Request) (*http.Response, error) {
	if a.srv.NewListByAIManagerPager == nil {
		return nil, &nonRetriableError{errors.New("fake for method NewListByAIManagerPager not implemented")}
	}
	newListByAIManagerPager := a.newListByAIManagerPager.get(req)
	if newListByAIManagerPager == nil {
		const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerService/aiManagers/(?P<aiManagerName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/namespaces`
		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
		}
		aiManagerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("aiManagerName")])
		if err != nil {
			return nil, err
		}
		resp := a.srv.NewListByAIManagerPager(resourceGroupNameParam, aiManagerNameParam, nil)
		newListByAIManagerPager = &resp
		a.newListByAIManagerPager.add(req, newListByAIManagerPager)
		server.PagerResponderInjectNextLinks(newListByAIManagerPager, req, func(page *armcontainerserviceaimanager.AIManagerNamespacesClientListByAIManagerResponse, createLink func() string) {
			page.NextLink = to.Ptr(createLink())
		})
	}
	resp, err := server.PagerResponderNext(newListByAIManagerPager, req)
	if err != nil {
		return nil, err
	}
	if !slices.Contains([]int{http.StatusOK}, resp.StatusCode) {
		a.newListByAIManagerPager.remove(req)
		return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)}
	}
	if !server.PagerResponderMore(newListByAIManagerPager) {
		a.newListByAIManagerPager.remove(req)
	}
	return resp, nil
}

func (a *AIManagerNamespacesServerTransport) dispatchListCredential(req *http.Request) (*http.Response, error) {
	if a.srv.ListCredential == nil {
		return nil, &nonRetriableError{errors.New("fake for method ListCredential not implemented")}
	}
	const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerService/aiManagers/(?P<aiManagerName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/namespaces/(?P<namespaceName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listCredential`
	regex := regexp.MustCompile(regexStr)
	matches := regex.FindStringSubmatch(req.URL.EscapedPath())
	if len(matches) < 5 {
		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
	}
	aiManagerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("aiManagerName")])
	if err != nil {
		return nil, err
	}
	namespaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("namespaceName")])
	if err != nil {
		return nil, err
	}
	respr, errRespr := a.srv.ListCredential(req.Context(), resourceGroupNameParam, aiManagerNameParam, namespaceNameParam, 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).CredentialResults, req)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

func (a *AIManagerNamespacesServerTransport) dispatchRotateKeys(req *http.Request) (*http.Response, error) {
	if a.srv.RotateKeys == nil {
		return nil, &nonRetriableError{errors.New("fake for method RotateKeys not implemented")}
	}
	const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerService/aiManagers/(?P<aiManagerName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/namespaces/(?P<namespaceName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/rotateKeys`
	regex := regexp.MustCompile(regexStr)
	matches := regex.FindStringSubmatch(req.URL.EscapedPath())
	if len(matches) < 5 {
		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
	}
	aiManagerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("aiManagerName")])
	if err != nil {
		return nil, err
	}
	namespaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("namespaceName")])
	if err != nil {
		return nil, err
	}
	respr, errRespr := a.srv.RotateKeys(req.Context(), resourceGroupNameParam, aiManagerNameParam, namespaceNameParam, 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).NamespaceAccessInfo, req)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

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