// 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 (
	"errors"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
	"net/http"
	"strings"
	"sync"
)

// ServerFactory is a fake server for instances of the armappcontainers.ClientFactory type.
type ServerFactory struct {
	// AppResiliencyServer contains the fakes for client AppResiliencyClient
	AppResiliencyServer AppResiliencyServer

	// AvailableWorkloadProfilesServer contains the fakes for client AvailableWorkloadProfilesClient
	AvailableWorkloadProfilesServer AvailableWorkloadProfilesServer

	// BillingMetersServer contains the fakes for client BillingMetersClient
	BillingMetersServer BillingMetersServer

	// BuildAuthTokenServer contains the fakes for client BuildAuthTokenClient
	BuildAuthTokenServer BuildAuthTokenServer

	// BuildersServer contains the fakes for client BuildersClient
	BuildersServer BuildersServer

	// BuildsByBuilderResourceServer contains the fakes for client BuildsByBuilderResourceClient
	BuildsByBuilderResourceServer BuildsByBuilderResourceServer

	// BuildsServer contains the fakes for client BuildsClient
	BuildsServer BuildsServer

	// CertificatesServer contains the fakes for client CertificatesClient
	CertificatesServer CertificatesServer

	// ConnectedEnvironmentsCertificatesServer contains the fakes for client ConnectedEnvironmentsCertificatesClient
	ConnectedEnvironmentsCertificatesServer ConnectedEnvironmentsCertificatesServer

	// ConnectedEnvironmentsServer contains the fakes for client ConnectedEnvironmentsClient
	ConnectedEnvironmentsServer ConnectedEnvironmentsServer

	// ConnectedEnvironmentsDaprComponentsServer contains the fakes for client ConnectedEnvironmentsDaprComponentsClient
	ConnectedEnvironmentsDaprComponentsServer ConnectedEnvironmentsDaprComponentsServer

	// ConnectedEnvironmentsStoragesServer contains the fakes for client ConnectedEnvironmentsStoragesClient
	ConnectedEnvironmentsStoragesServer ConnectedEnvironmentsStoragesServer

	// ContainerAppsAPIServer contains the fakes for client ContainerAppsAPIClient
	ContainerAppsAPIServer ContainerAppsAPIServer

	// ContainerAppsAuthConfigsServer contains the fakes for client ContainerAppsAuthConfigsClient
	ContainerAppsAuthConfigsServer ContainerAppsAuthConfigsServer

	// ContainerAppsBuildsByContainerAppServer contains the fakes for client ContainerAppsBuildsByContainerAppClient
	ContainerAppsBuildsByContainerAppServer ContainerAppsBuildsByContainerAppServer

	// ContainerAppsBuildsServer contains the fakes for client ContainerAppsBuildsClient
	ContainerAppsBuildsServer ContainerAppsBuildsServer

	// ContainerAppsServer contains the fakes for client ContainerAppsClient
	ContainerAppsServer ContainerAppsServer

	// ContainerAppsDiagnosticsServer contains the fakes for client ContainerAppsDiagnosticsClient
	ContainerAppsDiagnosticsServer ContainerAppsDiagnosticsServer

	// ContainerAppsLabelHistoryServer contains the fakes for client ContainerAppsLabelHistoryClient
	ContainerAppsLabelHistoryServer ContainerAppsLabelHistoryServer

	// ContainerAppsPatchesServer contains the fakes for client ContainerAppsPatchesClient
	ContainerAppsPatchesServer ContainerAppsPatchesServer

	// ContainerAppsRevisionReplicasServer contains the fakes for client ContainerAppsRevisionReplicasClient
	ContainerAppsRevisionReplicasServer ContainerAppsRevisionReplicasServer

	// ContainerAppsRevisionsServer contains the fakes for client ContainerAppsRevisionsClient
	ContainerAppsRevisionsServer ContainerAppsRevisionsServer

	// ContainerAppsSessionPoolsServer contains the fakes for client ContainerAppsSessionPoolsClient
	ContainerAppsSessionPoolsServer ContainerAppsSessionPoolsServer

	// ContainerAppsSourceControlsServer contains the fakes for client ContainerAppsSourceControlsClient
	ContainerAppsSourceControlsServer ContainerAppsSourceControlsServer

	// DaprComponentResiliencyPoliciesServer contains the fakes for client DaprComponentResiliencyPoliciesClient
	DaprComponentResiliencyPoliciesServer DaprComponentResiliencyPoliciesServer

	// DaprComponentsServer contains the fakes for client DaprComponentsClient
	DaprComponentsServer DaprComponentsServer

	// DaprSubscriptionsServer contains the fakes for client DaprSubscriptionsClient
	DaprSubscriptionsServer DaprSubscriptionsServer

	// DotNetComponentsServer contains the fakes for client DotNetComponentsClient
	DotNetComponentsServer DotNetComponentsServer

	// FunctionsExtensionServer contains the fakes for client FunctionsExtensionClient
	FunctionsExtensionServer FunctionsExtensionServer

	// HTTPRouteConfigServer contains the fakes for client HTTPRouteConfigClient
	HTTPRouteConfigServer HTTPRouteConfigServer

	// JavaComponentsServer contains the fakes for client JavaComponentsClient
	JavaComponentsServer JavaComponentsServer

	// JobsServer contains the fakes for client JobsClient
	JobsServer JobsServer

	// JobsExecutionsServer contains the fakes for client JobsExecutionsClient
	JobsExecutionsServer JobsExecutionsServer

	// LogicAppsServer contains the fakes for client LogicAppsClient
	LogicAppsServer LogicAppsServer

	// MaintenanceConfigurationsServer contains the fakes for client MaintenanceConfigurationsClient
	MaintenanceConfigurationsServer MaintenanceConfigurationsServer

	// ManagedCertificatesServer contains the fakes for client ManagedCertificatesClient
	ManagedCertificatesServer ManagedCertificatesServer

	// ManagedEnvironmentDiagnosticsServer contains the fakes for client ManagedEnvironmentDiagnosticsClient
	ManagedEnvironmentDiagnosticsServer ManagedEnvironmentDiagnosticsServer

	// ManagedEnvironmentPrivateEndpointConnectionsServer contains the fakes for client ManagedEnvironmentPrivateEndpointConnectionsClient
	ManagedEnvironmentPrivateEndpointConnectionsServer ManagedEnvironmentPrivateEndpointConnectionsServer

	// ManagedEnvironmentPrivateLinkResourcesServer contains the fakes for client ManagedEnvironmentPrivateLinkResourcesClient
	ManagedEnvironmentPrivateLinkResourcesServer ManagedEnvironmentPrivateLinkResourcesServer

	// ManagedEnvironmentUsagesServer contains the fakes for client ManagedEnvironmentUsagesClient
	ManagedEnvironmentUsagesServer ManagedEnvironmentUsagesServer

	// ManagedEnvironmentsServer contains the fakes for client ManagedEnvironmentsClient
	ManagedEnvironmentsServer ManagedEnvironmentsServer

	// ManagedEnvironmentsDiagnosticsServer contains the fakes for client ManagedEnvironmentsDiagnosticsClient
	ManagedEnvironmentsDiagnosticsServer ManagedEnvironmentsDiagnosticsServer

	// ManagedEnvironmentsStoragesServer contains the fakes for client ManagedEnvironmentsStoragesClient
	ManagedEnvironmentsStoragesServer ManagedEnvironmentsStoragesServer

	// NamespacesServer contains the fakes for client NamespacesClient
	NamespacesServer NamespacesServer

	// OperationsServer contains the fakes for client OperationsClient
	OperationsServer OperationsServer

	// UsagesServer contains the fakes for client UsagesClient
	UsagesServer UsagesServer
}

// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation.
// The returned ServerFactoryTransport instance is connected to an instance of armappcontainers.ClientFactory via the
// azcore.ClientOptions.Transporter field in the client's constructor parameters.
func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport {
	return &ServerFactoryTransport{
		srv: srv,
	}
}

// ServerFactoryTransport connects instances of armappcontainers.ClientFactory to instances of ServerFactory.
// Don't use this type directly, use NewServerFactoryTransport instead.
type ServerFactoryTransport struct {
	srv                                                  *ServerFactory
	trMu                                                 sync.Mutex
	trAppResiliencyServer                                *AppResiliencyServerTransport
	trAvailableWorkloadProfilesServer                    *AvailableWorkloadProfilesServerTransport
	trBillingMetersServer                                *BillingMetersServerTransport
	trBuildAuthTokenServer                               *BuildAuthTokenServerTransport
	trBuildersServer                                     *BuildersServerTransport
	trBuildsByBuilderResourceServer                      *BuildsByBuilderResourceServerTransport
	trBuildsServer                                       *BuildsServerTransport
	trCertificatesServer                                 *CertificatesServerTransport
	trConnectedEnvironmentsCertificatesServer            *ConnectedEnvironmentsCertificatesServerTransport
	trConnectedEnvironmentsServer                        *ConnectedEnvironmentsServerTransport
	trConnectedEnvironmentsDaprComponentsServer          *ConnectedEnvironmentsDaprComponentsServerTransport
	trConnectedEnvironmentsStoragesServer                *ConnectedEnvironmentsStoragesServerTransport
	trContainerAppsAPIServer                             *ContainerAppsAPIServerTransport
	trContainerAppsAuthConfigsServer                     *ContainerAppsAuthConfigsServerTransport
	trContainerAppsBuildsByContainerAppServer            *ContainerAppsBuildsByContainerAppServerTransport
	trContainerAppsBuildsServer                          *ContainerAppsBuildsServerTransport
	trContainerAppsServer                                *ContainerAppsServerTransport
	trContainerAppsDiagnosticsServer                     *ContainerAppsDiagnosticsServerTransport
	trContainerAppsLabelHistoryServer                    *ContainerAppsLabelHistoryServerTransport
	trContainerAppsPatchesServer                         *ContainerAppsPatchesServerTransport
	trContainerAppsRevisionReplicasServer                *ContainerAppsRevisionReplicasServerTransport
	trContainerAppsRevisionsServer                       *ContainerAppsRevisionsServerTransport
	trContainerAppsSessionPoolsServer                    *ContainerAppsSessionPoolsServerTransport
	trContainerAppsSourceControlsServer                  *ContainerAppsSourceControlsServerTransport
	trDaprComponentResiliencyPoliciesServer              *DaprComponentResiliencyPoliciesServerTransport
	trDaprComponentsServer                               *DaprComponentsServerTransport
	trDaprSubscriptionsServer                            *DaprSubscriptionsServerTransport
	trDotNetComponentsServer                             *DotNetComponentsServerTransport
	trFunctionsExtensionServer                           *FunctionsExtensionServerTransport
	trHTTPRouteConfigServer                              *HTTPRouteConfigServerTransport
	trJavaComponentsServer                               *JavaComponentsServerTransport
	trJobsServer                                         *JobsServerTransport
	trJobsExecutionsServer                               *JobsExecutionsServerTransport
	trLogicAppsServer                                    *LogicAppsServerTransport
	trMaintenanceConfigurationsServer                    *MaintenanceConfigurationsServerTransport
	trManagedCertificatesServer                          *ManagedCertificatesServerTransport
	trManagedEnvironmentDiagnosticsServer                *ManagedEnvironmentDiagnosticsServerTransport
	trManagedEnvironmentPrivateEndpointConnectionsServer *ManagedEnvironmentPrivateEndpointConnectionsServerTransport
	trManagedEnvironmentPrivateLinkResourcesServer       *ManagedEnvironmentPrivateLinkResourcesServerTransport
	trManagedEnvironmentUsagesServer                     *ManagedEnvironmentUsagesServerTransport
	trManagedEnvironmentsServer                          *ManagedEnvironmentsServerTransport
	trManagedEnvironmentsDiagnosticsServer               *ManagedEnvironmentsDiagnosticsServerTransport
	trManagedEnvironmentsStoragesServer                  *ManagedEnvironmentsStoragesServerTransport
	trNamespacesServer                                   *NamespacesServerTransport
	trOperationsServer                                   *OperationsServerTransport
	trUsagesServer                                       *UsagesServerTransport
}

// Do implements the policy.Transporter interface for ServerFactoryTransport.
func (s *ServerFactoryTransport) 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")}
	}

	client := method[:strings.Index(method, ".")]
	var resp *http.Response
	var err error

	switch client {
	case "AppResiliencyClient":
		initServer(s, &s.trAppResiliencyServer, func() *AppResiliencyServerTransport {
			return NewAppResiliencyServerTransport(&s.srv.AppResiliencyServer)
		})
		resp, err = s.trAppResiliencyServer.Do(req)
	case "AvailableWorkloadProfilesClient":
		initServer(s, &s.trAvailableWorkloadProfilesServer, func() *AvailableWorkloadProfilesServerTransport {
			return NewAvailableWorkloadProfilesServerTransport(&s.srv.AvailableWorkloadProfilesServer)
		})
		resp, err = s.trAvailableWorkloadProfilesServer.Do(req)
	case "BillingMetersClient":
		initServer(s, &s.trBillingMetersServer, func() *BillingMetersServerTransport {
			return NewBillingMetersServerTransport(&s.srv.BillingMetersServer)
		})
		resp, err = s.trBillingMetersServer.Do(req)
	case "BuildAuthTokenClient":
		initServer(s, &s.trBuildAuthTokenServer, func() *BuildAuthTokenServerTransport {
			return NewBuildAuthTokenServerTransport(&s.srv.BuildAuthTokenServer)
		})
		resp, err = s.trBuildAuthTokenServer.Do(req)
	case "BuildersClient":
		initServer(s, &s.trBuildersServer, func() *BuildersServerTransport { return NewBuildersServerTransport(&s.srv.BuildersServer) })
		resp, err = s.trBuildersServer.Do(req)
	case "BuildsByBuilderResourceClient":
		initServer(s, &s.trBuildsByBuilderResourceServer, func() *BuildsByBuilderResourceServerTransport {
			return NewBuildsByBuilderResourceServerTransport(&s.srv.BuildsByBuilderResourceServer)
		})
		resp, err = s.trBuildsByBuilderResourceServer.Do(req)
	case "BuildsClient":
		initServer(s, &s.trBuildsServer, func() *BuildsServerTransport { return NewBuildsServerTransport(&s.srv.BuildsServer) })
		resp, err = s.trBuildsServer.Do(req)
	case "CertificatesClient":
		initServer(s, &s.trCertificatesServer, func() *CertificatesServerTransport { return NewCertificatesServerTransport(&s.srv.CertificatesServer) })
		resp, err = s.trCertificatesServer.Do(req)
	case "ConnectedEnvironmentsCertificatesClient":
		initServer(s, &s.trConnectedEnvironmentsCertificatesServer, func() *ConnectedEnvironmentsCertificatesServerTransport {
			return NewConnectedEnvironmentsCertificatesServerTransport(&s.srv.ConnectedEnvironmentsCertificatesServer)
		})
		resp, err = s.trConnectedEnvironmentsCertificatesServer.Do(req)
	case "ConnectedEnvironmentsClient":
		initServer(s, &s.trConnectedEnvironmentsServer, func() *ConnectedEnvironmentsServerTransport {
			return NewConnectedEnvironmentsServerTransport(&s.srv.ConnectedEnvironmentsServer)
		})
		resp, err = s.trConnectedEnvironmentsServer.Do(req)
	case "ConnectedEnvironmentsDaprComponentsClient":
		initServer(s, &s.trConnectedEnvironmentsDaprComponentsServer, func() *ConnectedEnvironmentsDaprComponentsServerTransport {
			return NewConnectedEnvironmentsDaprComponentsServerTransport(&s.srv.ConnectedEnvironmentsDaprComponentsServer)
		})
		resp, err = s.trConnectedEnvironmentsDaprComponentsServer.Do(req)
	case "ConnectedEnvironmentsStoragesClient":
		initServer(s, &s.trConnectedEnvironmentsStoragesServer, func() *ConnectedEnvironmentsStoragesServerTransport {
			return NewConnectedEnvironmentsStoragesServerTransport(&s.srv.ConnectedEnvironmentsStoragesServer)
		})
		resp, err = s.trConnectedEnvironmentsStoragesServer.Do(req)
	case "ContainerAppsAPIClient":
		initServer(s, &s.trContainerAppsAPIServer, func() *ContainerAppsAPIServerTransport {
			return NewContainerAppsAPIServerTransport(&s.srv.ContainerAppsAPIServer)
		})
		resp, err = s.trContainerAppsAPIServer.Do(req)
	case "ContainerAppsAuthConfigsClient":
		initServer(s, &s.trContainerAppsAuthConfigsServer, func() *ContainerAppsAuthConfigsServerTransport {
			return NewContainerAppsAuthConfigsServerTransport(&s.srv.ContainerAppsAuthConfigsServer)
		})
		resp, err = s.trContainerAppsAuthConfigsServer.Do(req)
	case "ContainerAppsBuildsByContainerAppClient":
		initServer(s, &s.trContainerAppsBuildsByContainerAppServer, func() *ContainerAppsBuildsByContainerAppServerTransport {
			return NewContainerAppsBuildsByContainerAppServerTransport(&s.srv.ContainerAppsBuildsByContainerAppServer)
		})
		resp, err = s.trContainerAppsBuildsByContainerAppServer.Do(req)
	case "ContainerAppsBuildsClient":
		initServer(s, &s.trContainerAppsBuildsServer, func() *ContainerAppsBuildsServerTransport {
			return NewContainerAppsBuildsServerTransport(&s.srv.ContainerAppsBuildsServer)
		})
		resp, err = s.trContainerAppsBuildsServer.Do(req)
	case "ContainerAppsClient":
		initServer(s, &s.trContainerAppsServer, func() *ContainerAppsServerTransport {
			return NewContainerAppsServerTransport(&s.srv.ContainerAppsServer)
		})
		resp, err = s.trContainerAppsServer.Do(req)
	case "ContainerAppsDiagnosticsClient":
		initServer(s, &s.trContainerAppsDiagnosticsServer, func() *ContainerAppsDiagnosticsServerTransport {
			return NewContainerAppsDiagnosticsServerTransport(&s.srv.ContainerAppsDiagnosticsServer)
		})
		resp, err = s.trContainerAppsDiagnosticsServer.Do(req)
	case "ContainerAppsLabelHistoryClient":
		initServer(s, &s.trContainerAppsLabelHistoryServer, func() *ContainerAppsLabelHistoryServerTransport {
			return NewContainerAppsLabelHistoryServerTransport(&s.srv.ContainerAppsLabelHistoryServer)
		})
		resp, err = s.trContainerAppsLabelHistoryServer.Do(req)
	case "ContainerAppsPatchesClient":
		initServer(s, &s.trContainerAppsPatchesServer, func() *ContainerAppsPatchesServerTransport {
			return NewContainerAppsPatchesServerTransport(&s.srv.ContainerAppsPatchesServer)
		})
		resp, err = s.trContainerAppsPatchesServer.Do(req)
	case "ContainerAppsRevisionReplicasClient":
		initServer(s, &s.trContainerAppsRevisionReplicasServer, func() *ContainerAppsRevisionReplicasServerTransport {
			return NewContainerAppsRevisionReplicasServerTransport(&s.srv.ContainerAppsRevisionReplicasServer)
		})
		resp, err = s.trContainerAppsRevisionReplicasServer.Do(req)
	case "ContainerAppsRevisionsClient":
		initServer(s, &s.trContainerAppsRevisionsServer, func() *ContainerAppsRevisionsServerTransport {
			return NewContainerAppsRevisionsServerTransport(&s.srv.ContainerAppsRevisionsServer)
		})
		resp, err = s.trContainerAppsRevisionsServer.Do(req)
	case "ContainerAppsSessionPoolsClient":
		initServer(s, &s.trContainerAppsSessionPoolsServer, func() *ContainerAppsSessionPoolsServerTransport {
			return NewContainerAppsSessionPoolsServerTransport(&s.srv.ContainerAppsSessionPoolsServer)
		})
		resp, err = s.trContainerAppsSessionPoolsServer.Do(req)
	case "ContainerAppsSourceControlsClient":
		initServer(s, &s.trContainerAppsSourceControlsServer, func() *ContainerAppsSourceControlsServerTransport {
			return NewContainerAppsSourceControlsServerTransport(&s.srv.ContainerAppsSourceControlsServer)
		})
		resp, err = s.trContainerAppsSourceControlsServer.Do(req)
	case "DaprComponentResiliencyPoliciesClient":
		initServer(s, &s.trDaprComponentResiliencyPoliciesServer, func() *DaprComponentResiliencyPoliciesServerTransport {
			return NewDaprComponentResiliencyPoliciesServerTransport(&s.srv.DaprComponentResiliencyPoliciesServer)
		})
		resp, err = s.trDaprComponentResiliencyPoliciesServer.Do(req)
	case "DaprComponentsClient":
		initServer(s, &s.trDaprComponentsServer, func() *DaprComponentsServerTransport {
			return NewDaprComponentsServerTransport(&s.srv.DaprComponentsServer)
		})
		resp, err = s.trDaprComponentsServer.Do(req)
	case "DaprSubscriptionsClient":
		initServer(s, &s.trDaprSubscriptionsServer, func() *DaprSubscriptionsServerTransport {
			return NewDaprSubscriptionsServerTransport(&s.srv.DaprSubscriptionsServer)
		})
		resp, err = s.trDaprSubscriptionsServer.Do(req)
	case "DotNetComponentsClient":
		initServer(s, &s.trDotNetComponentsServer, func() *DotNetComponentsServerTransport {
			return NewDotNetComponentsServerTransport(&s.srv.DotNetComponentsServer)
		})
		resp, err = s.trDotNetComponentsServer.Do(req)
	case "FunctionsExtensionClient":
		initServer(s, &s.trFunctionsExtensionServer, func() *FunctionsExtensionServerTransport {
			return NewFunctionsExtensionServerTransport(&s.srv.FunctionsExtensionServer)
		})
		resp, err = s.trFunctionsExtensionServer.Do(req)
	case "HTTPRouteConfigClient":
		initServer(s, &s.trHTTPRouteConfigServer, func() *HTTPRouteConfigServerTransport {
			return NewHTTPRouteConfigServerTransport(&s.srv.HTTPRouteConfigServer)
		})
		resp, err = s.trHTTPRouteConfigServer.Do(req)
	case "JavaComponentsClient":
		initServer(s, &s.trJavaComponentsServer, func() *JavaComponentsServerTransport {
			return NewJavaComponentsServerTransport(&s.srv.JavaComponentsServer)
		})
		resp, err = s.trJavaComponentsServer.Do(req)
	case "JobsClient":
		initServer(s, &s.trJobsServer, func() *JobsServerTransport { return NewJobsServerTransport(&s.srv.JobsServer) })
		resp, err = s.trJobsServer.Do(req)
	case "JobsExecutionsClient":
		initServer(s, &s.trJobsExecutionsServer, func() *JobsExecutionsServerTransport {
			return NewJobsExecutionsServerTransport(&s.srv.JobsExecutionsServer)
		})
		resp, err = s.trJobsExecutionsServer.Do(req)
	case "LogicAppsClient":
		initServer(s, &s.trLogicAppsServer, func() *LogicAppsServerTransport { return NewLogicAppsServerTransport(&s.srv.LogicAppsServer) })
		resp, err = s.trLogicAppsServer.Do(req)
	case "MaintenanceConfigurationsClient":
		initServer(s, &s.trMaintenanceConfigurationsServer, func() *MaintenanceConfigurationsServerTransport {
			return NewMaintenanceConfigurationsServerTransport(&s.srv.MaintenanceConfigurationsServer)
		})
		resp, err = s.trMaintenanceConfigurationsServer.Do(req)
	case "ManagedCertificatesClient":
		initServer(s, &s.trManagedCertificatesServer, func() *ManagedCertificatesServerTransport {
			return NewManagedCertificatesServerTransport(&s.srv.ManagedCertificatesServer)
		})
		resp, err = s.trManagedCertificatesServer.Do(req)
	case "ManagedEnvironmentDiagnosticsClient":
		initServer(s, &s.trManagedEnvironmentDiagnosticsServer, func() *ManagedEnvironmentDiagnosticsServerTransport {
			return NewManagedEnvironmentDiagnosticsServerTransport(&s.srv.ManagedEnvironmentDiagnosticsServer)
		})
		resp, err = s.trManagedEnvironmentDiagnosticsServer.Do(req)
	case "ManagedEnvironmentPrivateEndpointConnectionsClient":
		initServer(s, &s.trManagedEnvironmentPrivateEndpointConnectionsServer, func() *ManagedEnvironmentPrivateEndpointConnectionsServerTransport {
			return NewManagedEnvironmentPrivateEndpointConnectionsServerTransport(&s.srv.ManagedEnvironmentPrivateEndpointConnectionsServer)
		})
		resp, err = s.trManagedEnvironmentPrivateEndpointConnectionsServer.Do(req)
	case "ManagedEnvironmentPrivateLinkResourcesClient":
		initServer(s, &s.trManagedEnvironmentPrivateLinkResourcesServer, func() *ManagedEnvironmentPrivateLinkResourcesServerTransport {
			return NewManagedEnvironmentPrivateLinkResourcesServerTransport(&s.srv.ManagedEnvironmentPrivateLinkResourcesServer)
		})
		resp, err = s.trManagedEnvironmentPrivateLinkResourcesServer.Do(req)
	case "ManagedEnvironmentUsagesClient":
		initServer(s, &s.trManagedEnvironmentUsagesServer, func() *ManagedEnvironmentUsagesServerTransport {
			return NewManagedEnvironmentUsagesServerTransport(&s.srv.ManagedEnvironmentUsagesServer)
		})
		resp, err = s.trManagedEnvironmentUsagesServer.Do(req)
	case "ManagedEnvironmentsClient":
		initServer(s, &s.trManagedEnvironmentsServer, func() *ManagedEnvironmentsServerTransport {
			return NewManagedEnvironmentsServerTransport(&s.srv.ManagedEnvironmentsServer)
		})
		resp, err = s.trManagedEnvironmentsServer.Do(req)
	case "ManagedEnvironmentsDiagnosticsClient":
		initServer(s, &s.trManagedEnvironmentsDiagnosticsServer, func() *ManagedEnvironmentsDiagnosticsServerTransport {
			return NewManagedEnvironmentsDiagnosticsServerTransport(&s.srv.ManagedEnvironmentsDiagnosticsServer)
		})
		resp, err = s.trManagedEnvironmentsDiagnosticsServer.Do(req)
	case "ManagedEnvironmentsStoragesClient":
		initServer(s, &s.trManagedEnvironmentsStoragesServer, func() *ManagedEnvironmentsStoragesServerTransport {
			return NewManagedEnvironmentsStoragesServerTransport(&s.srv.ManagedEnvironmentsStoragesServer)
		})
		resp, err = s.trManagedEnvironmentsStoragesServer.Do(req)
	case "NamespacesClient":
		initServer(s, &s.trNamespacesServer, func() *NamespacesServerTransport { return NewNamespacesServerTransport(&s.srv.NamespacesServer) })
		resp, err = s.trNamespacesServer.Do(req)
	case "OperationsClient":
		initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) })
		resp, err = s.trOperationsServer.Do(req)
	case "UsagesClient":
		initServer(s, &s.trUsagesServer, func() *UsagesServerTransport { return NewUsagesServerTransport(&s.srv.UsagesServer) })
		resp, err = s.trUsagesServer.Do(req)
	default:
		err = fmt.Errorf("unhandled client %s", client)
	}

	if err != nil {
		return nil, err
	}

	return resp, nil
}

func initServer[T any](s *ServerFactoryTransport, dst **T, src func() *T) {
	s.trMu.Lock()
	if *dst == nil {
		*dst = src()
	}
	s.trMu.Unlock()
}
