// Code generated by tools/sdkgen. DO NOT EDIT.
//
// Client wiring for the proto-driven service wrappers in services_gen.go. Each
// accessor lazily constructs and memoizes its Connect client using the same
// transport and interceptor chain client.go's bind() applies to the
// hand-written services. New services route to the base URL (they have no
// per-service Endpoints field). Regenerate with: make sdk.wrappers.generate
package agentrouter

import (
	"sync"

	"connectrpc.com/connect"

	adminv1connect "github.com/tetrateio/agentrouter-go/genapi/api/tars/admin/v1/adminv1connect"
	api_keysv1connect "github.com/tetrateio/agentrouter-go/genapi/api/tars/api_keys/v1/api_keysv1connect"
	authv1connect "github.com/tetrateio/agentrouter-go/genapi/api/tars/auth/v1/authv1connect"
	configuratorv1connect "github.com/tetrateio/agentrouter-go/genapi/api/tars/configurator/v1/configuratorv1connect"
	insightsv1connect "github.com/tetrateio/agentrouter-go/genapi/api/tars/insights/v1/insightsv1connect"
	secretv1connect "github.com/tetrateio/agentrouter-go/genapi/api/tars/secret/v1/secretv1connect"
	tokensv1connect "github.com/tetrateio/agentrouter-go/genapi/api/tars/tokens/v1/tokensv1connect"
)

// generatedClients holds the memoized Connect clients for the proto-driven
// wrappers. It is lazily populated by the accessors below so an SDK consumer
// that never touches a generated service pays no construction cost.
type generatedClients struct {
	once                sync.Once
	admin               adminv1connect.AdminServiceClient
	configurator        configuratorv1connect.ConfiguratorServiceClient
	secret              secretv1connect.SecretServiceClient
	apiKeys             api_keysv1connect.ApiKeysServiceClient
	customerRequestLogs insightsv1connect.CustomerRequestLogsServiceClient
	requestLogs         insightsv1connect.RequestLogsServiceClient
	auth                authv1connect.AuthServiceClient
	tokens              tokensv1connect.TokensServiceClient
}

// genClients is the per-Client store of memoized generated Connect clients,
// keyed by Client pointer so the generated wiring never has to add a field to
// the hand-written Client struct in client.go.
var (
	genMu      sync.Mutex
	genClients = map[*Client]*generatedClients{}
)

// generated returns (constructing on first use) the memoized Connect clients
// for c. Construction mirrors client.go's bind(): the same HTTP client and the
// same auth / user-agent / retry interceptor chain, routed at the base URL.
func (c *Client) generated() *generatedClients {
	genMu.Lock()
	g, ok := genClients[c]
	if !ok {
		g = &generatedClients{}
		genClients[c] = g
	}
	genMu.Unlock()
	g.once.Do(func() {
		httpc := c.cfg.httpClient
		base := c.cfg.baseURL
		opts := []connect.ClientOption{
			connect.WithInterceptors(
				authInterceptor(c.cfg),
				userAgentInterceptor(c.cfg.userAgent),
				retryInterceptor(c.cfg.retry),
			),
		}
		g.admin = adminv1connect.NewAdminServiceClient(httpc, base, opts...)
		g.configurator = configuratorv1connect.NewConfiguratorServiceClient(httpc, base, opts...)
		g.secret = secretv1connect.NewSecretServiceClient(httpc, base, opts...)
		g.apiKeys = api_keysv1connect.NewApiKeysServiceClient(httpc, base, opts...)
		g.customerRequestLogs = insightsv1connect.NewCustomerRequestLogsServiceClient(httpc, base, opts...)
		g.requestLogs = insightsv1connect.NewRequestLogsServiceClient(httpc, base, opts...)
		g.auth = authv1connect.NewAuthServiceClient(httpc, base, opts...)
		g.tokens = tokensv1connect.NewTokensServiceClient(httpc, base, opts...)
	})
	return g
}

// Admin returns a handle to AdminService (tars.admin.v1).
func (c *Client) Admin() *AdminClient {
	return &AdminClient{c: c.generated().admin}
}

// Configurator returns a handle to ConfiguratorService (tars.configurator.v1).
func (c *Client) Configurator() *ConfiguratorClient {
	return &ConfiguratorClient{c: c.generated().configurator}
}

// Secret returns a handle to SecretService (tars.secret.v1).
func (c *Client) Secret() *SecretClient {
	return &SecretClient{c: c.generated().secret}
}

// ApiKeys returns a handle to ApiKeysService (tars.api_keys.v1).
func (c *Client) ApiKeys() *ApiKeysClient {
	return &ApiKeysClient{c: c.generated().apiKeys}
}

// CustomerRequestLogs returns a handle to CustomerRequestLogsService (tars.insights.v1).
func (c *Client) CustomerRequestLogs() *CustomerRequestLogsClient {
	return &CustomerRequestLogsClient{c: c.generated().customerRequestLogs}
}

// RequestLogs returns a handle to RequestLogsService (tars.insights.v1).
func (c *Client) RequestLogs() *RequestLogsClient {
	return &RequestLogsClient{c: c.generated().requestLogs}
}

// Auth returns a handle to AuthService (tars.auth.v1).
func (c *Client) Auth() *AuthClient {
	return &AuthClient{c: c.generated().auth}
}

// Tokens returns a handle to TokensService (tars.tokens.v1).
func (c *Client) Tokens() *TokensClient {
	return &TokensClient{c: c.generated().tokens}
}
