// McpOAuthClientsService -- project-scoped CRUD for the OAuth clients that
// front MCP servers.
//
// An OAuth client holds the credentials TARS uses to drive an OAuth
// authorization-code flow against an upstream identity provider on behalf
// of an MCP server: the client_id, the client_secret, the authorization /
// token endpoints, the requested scopes, and the redirect URIs. The
// client_secret is WRITE-ONLY: it is wrapped by the fraser secret service
// on the way in (an "sm://<name>" reference is persisted in
// client_secret_ref) and is NEVER returned on any response, exactly like
// the BYOK provider key in tars.aikeys.v1.
//
// Tenancy: every record is scoped to (customer_id, project_id). Writes
// (Create/Update/Delete) require the "project_owner" scope (project rw);
// reads (Get/List) carry no scope and are gated by the handler's project
// membership check (account tier), mirroring MCPProfilesService reads.
//
// Data model adapts the dashboard's mcp_server_oauth_clients table
// (src/db/schemas/mcpOauthClients.ts) into fraser's tenancy model.

// Code generated by protoc-gen-connect-go. DO NOT EDIT.
//
// Source: tars/mcp/v1/mcp_oauth_clients.proto

package mcpv1connect

import (
	connect "connectrpc.com/connect"
	context "context"
	errors "errors"
	v1 "github.com/tetrateio/agentrouter-go/genapi/api/tars/mcp/v1"
	emptypb "google.golang.org/protobuf/types/known/emptypb"
	http "net/http"
	strings "strings"
)

// This is a compile-time assertion to ensure that this generated file and the connect package are
// compatible. If you get a compiler error that this constant is not defined, this code was
// generated with a version of connect newer than the one compiled into your binary. You can fix the
// problem by either regenerating this code with an older version of connect or updating the connect
// version compiled into your binary.
const _ = connect.IsAtLeastVersion1_13_0

const (
	// McpOAuthClientsServiceName is the fully-qualified name of the McpOAuthClientsService service.
	McpOAuthClientsServiceName = "tars.mcp.v1.McpOAuthClientsService"
)

// These constants are the fully-qualified names of the RPCs defined in this package. They're
// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
//
// Note that these are different from the fully-qualified method names used by
// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
// period.
const (
	// McpOAuthClientsServiceCreateMcpOAuthClientProcedure is the fully-qualified name of the
	// McpOAuthClientsService's CreateMcpOAuthClient RPC.
	McpOAuthClientsServiceCreateMcpOAuthClientProcedure = "/tars.mcp.v1.McpOAuthClientsService/CreateMcpOAuthClient"
	// McpOAuthClientsServiceGetMcpOAuthClientProcedure is the fully-qualified name of the
	// McpOAuthClientsService's GetMcpOAuthClient RPC.
	McpOAuthClientsServiceGetMcpOAuthClientProcedure = "/tars.mcp.v1.McpOAuthClientsService/GetMcpOAuthClient"
	// McpOAuthClientsServiceListMcpOAuthClientsProcedure is the fully-qualified name of the
	// McpOAuthClientsService's ListMcpOAuthClients RPC.
	McpOAuthClientsServiceListMcpOAuthClientsProcedure = "/tars.mcp.v1.McpOAuthClientsService/ListMcpOAuthClients"
	// McpOAuthClientsServiceUpdateMcpOAuthClientProcedure is the fully-qualified name of the
	// McpOAuthClientsService's UpdateMcpOAuthClient RPC.
	McpOAuthClientsServiceUpdateMcpOAuthClientProcedure = "/tars.mcp.v1.McpOAuthClientsService/UpdateMcpOAuthClient"
	// McpOAuthClientsServiceDeleteMcpOAuthClientProcedure is the fully-qualified name of the
	// McpOAuthClientsService's DeleteMcpOAuthClient RPC.
	McpOAuthClientsServiceDeleteMcpOAuthClientProcedure = "/tars.mcp.v1.McpOAuthClientsService/DeleteMcpOAuthClient"
)

// McpOAuthClientsServiceClient is a client for the tars.mcp.v1.McpOAuthClientsService service.
type McpOAuthClientsServiceClient interface {
	// CreateMcpOAuthClient registers a new OAuth client under a project.
	// The client_secret is wrapped by the secret service and discarded;
	// only an sm:// reference is persisted.
	CreateMcpOAuthClient(context.Context, *connect.Request[v1.CreateMcpOAuthClientRequest]) (*connect.Response[v1.McpOAuthClient], error)
	// GetMcpOAuthClient returns a single OAuth client by id. Never returns
	// the client_secret. Account tier: any project member may read.
	GetMcpOAuthClient(context.Context, *connect.Request[v1.GetMcpOAuthClientRequest]) (*connect.Response[v1.McpOAuthClient], error)
	// ListMcpOAuthClients lists every non-deleted OAuth client in the
	// (customer, project) scope. Account tier: any project member may read.
	ListMcpOAuthClients(context.Context, *connect.Request[v1.ListMcpOAuthClientsRequest]) (*connect.Response[v1.ListMcpOAuthClientsResponse], error)
	// UpdateMcpOAuthClient applies a partial patch. Omitted scalar strings
	// ("") leave the existing value untouched. A non-empty client_secret
	// rotates the wrapped secret in place.
	UpdateMcpOAuthClient(context.Context, *connect.Request[v1.UpdateMcpOAuthClientRequest]) (*connect.Response[v1.McpOAuthClient], error)
	// DeleteMcpOAuthClient soft-deletes a client (deleted_at set).
	DeleteMcpOAuthClient(context.Context, *connect.Request[v1.DeleteMcpOAuthClientRequest]) (*connect.Response[emptypb.Empty], error)
}

// NewMcpOAuthClientsServiceClient constructs a client for the tars.mcp.v1.McpOAuthClientsService
// service. By default, it uses the Connect protocol with the binary Protobuf Codec, asks for
// gzipped responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply
// the connect.WithGRPC() or connect.WithGRPCWeb() options.
//
// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
// http://api.acme.com or https://acme.com/grpc).
func NewMcpOAuthClientsServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) McpOAuthClientsServiceClient {
	baseURL = strings.TrimRight(baseURL, "/")
	mcpOAuthClientsServiceMethods := v1.File_tars_mcp_v1_mcp_oauth_clients_proto.Services().ByName("McpOAuthClientsService").Methods()
	return &mcpOAuthClientsServiceClient{
		createMcpOAuthClient: connect.NewClient[v1.CreateMcpOAuthClientRequest, v1.McpOAuthClient](
			httpClient,
			baseURL+McpOAuthClientsServiceCreateMcpOAuthClientProcedure,
			connect.WithSchema(mcpOAuthClientsServiceMethods.ByName("CreateMcpOAuthClient")),
			connect.WithClientOptions(opts...),
		),
		getMcpOAuthClient: connect.NewClient[v1.GetMcpOAuthClientRequest, v1.McpOAuthClient](
			httpClient,
			baseURL+McpOAuthClientsServiceGetMcpOAuthClientProcedure,
			connect.WithSchema(mcpOAuthClientsServiceMethods.ByName("GetMcpOAuthClient")),
			connect.WithIdempotency(connect.IdempotencyNoSideEffects),
			connect.WithClientOptions(opts...),
		),
		listMcpOAuthClients: connect.NewClient[v1.ListMcpOAuthClientsRequest, v1.ListMcpOAuthClientsResponse](
			httpClient,
			baseURL+McpOAuthClientsServiceListMcpOAuthClientsProcedure,
			connect.WithSchema(mcpOAuthClientsServiceMethods.ByName("ListMcpOAuthClients")),
			connect.WithIdempotency(connect.IdempotencyNoSideEffects),
			connect.WithClientOptions(opts...),
		),
		updateMcpOAuthClient: connect.NewClient[v1.UpdateMcpOAuthClientRequest, v1.McpOAuthClient](
			httpClient,
			baseURL+McpOAuthClientsServiceUpdateMcpOAuthClientProcedure,
			connect.WithSchema(mcpOAuthClientsServiceMethods.ByName("UpdateMcpOAuthClient")),
			connect.WithClientOptions(opts...),
		),
		deleteMcpOAuthClient: connect.NewClient[v1.DeleteMcpOAuthClientRequest, emptypb.Empty](
			httpClient,
			baseURL+McpOAuthClientsServiceDeleteMcpOAuthClientProcedure,
			connect.WithSchema(mcpOAuthClientsServiceMethods.ByName("DeleteMcpOAuthClient")),
			connect.WithClientOptions(opts...),
		),
	}
}

// mcpOAuthClientsServiceClient implements McpOAuthClientsServiceClient.
type mcpOAuthClientsServiceClient struct {
	createMcpOAuthClient *connect.Client[v1.CreateMcpOAuthClientRequest, v1.McpOAuthClient]
	getMcpOAuthClient    *connect.Client[v1.GetMcpOAuthClientRequest, v1.McpOAuthClient]
	listMcpOAuthClients  *connect.Client[v1.ListMcpOAuthClientsRequest, v1.ListMcpOAuthClientsResponse]
	updateMcpOAuthClient *connect.Client[v1.UpdateMcpOAuthClientRequest, v1.McpOAuthClient]
	deleteMcpOAuthClient *connect.Client[v1.DeleteMcpOAuthClientRequest, emptypb.Empty]
}

// CreateMcpOAuthClient calls tars.mcp.v1.McpOAuthClientsService.CreateMcpOAuthClient.
func (c *mcpOAuthClientsServiceClient) CreateMcpOAuthClient(ctx context.Context, req *connect.Request[v1.CreateMcpOAuthClientRequest]) (*connect.Response[v1.McpOAuthClient], error) {
	return c.createMcpOAuthClient.CallUnary(ctx, req)
}

// GetMcpOAuthClient calls tars.mcp.v1.McpOAuthClientsService.GetMcpOAuthClient.
func (c *mcpOAuthClientsServiceClient) GetMcpOAuthClient(ctx context.Context, req *connect.Request[v1.GetMcpOAuthClientRequest]) (*connect.Response[v1.McpOAuthClient], error) {
	return c.getMcpOAuthClient.CallUnary(ctx, req)
}

// ListMcpOAuthClients calls tars.mcp.v1.McpOAuthClientsService.ListMcpOAuthClients.
func (c *mcpOAuthClientsServiceClient) ListMcpOAuthClients(ctx context.Context, req *connect.Request[v1.ListMcpOAuthClientsRequest]) (*connect.Response[v1.ListMcpOAuthClientsResponse], error) {
	return c.listMcpOAuthClients.CallUnary(ctx, req)
}

// UpdateMcpOAuthClient calls tars.mcp.v1.McpOAuthClientsService.UpdateMcpOAuthClient.
func (c *mcpOAuthClientsServiceClient) UpdateMcpOAuthClient(ctx context.Context, req *connect.Request[v1.UpdateMcpOAuthClientRequest]) (*connect.Response[v1.McpOAuthClient], error) {
	return c.updateMcpOAuthClient.CallUnary(ctx, req)
}

// DeleteMcpOAuthClient calls tars.mcp.v1.McpOAuthClientsService.DeleteMcpOAuthClient.
func (c *mcpOAuthClientsServiceClient) DeleteMcpOAuthClient(ctx context.Context, req *connect.Request[v1.DeleteMcpOAuthClientRequest]) (*connect.Response[emptypb.Empty], error) {
	return c.deleteMcpOAuthClient.CallUnary(ctx, req)
}

// McpOAuthClientsServiceHandler is an implementation of the tars.mcp.v1.McpOAuthClientsService
// service.
type McpOAuthClientsServiceHandler interface {
	// CreateMcpOAuthClient registers a new OAuth client under a project.
	// The client_secret is wrapped by the secret service and discarded;
	// only an sm:// reference is persisted.
	CreateMcpOAuthClient(context.Context, *connect.Request[v1.CreateMcpOAuthClientRequest]) (*connect.Response[v1.McpOAuthClient], error)
	// GetMcpOAuthClient returns a single OAuth client by id. Never returns
	// the client_secret. Account tier: any project member may read.
	GetMcpOAuthClient(context.Context, *connect.Request[v1.GetMcpOAuthClientRequest]) (*connect.Response[v1.McpOAuthClient], error)
	// ListMcpOAuthClients lists every non-deleted OAuth client in the
	// (customer, project) scope. Account tier: any project member may read.
	ListMcpOAuthClients(context.Context, *connect.Request[v1.ListMcpOAuthClientsRequest]) (*connect.Response[v1.ListMcpOAuthClientsResponse], error)
	// UpdateMcpOAuthClient applies a partial patch. Omitted scalar strings
	// ("") leave the existing value untouched. A non-empty client_secret
	// rotates the wrapped secret in place.
	UpdateMcpOAuthClient(context.Context, *connect.Request[v1.UpdateMcpOAuthClientRequest]) (*connect.Response[v1.McpOAuthClient], error)
	// DeleteMcpOAuthClient soft-deletes a client (deleted_at set).
	DeleteMcpOAuthClient(context.Context, *connect.Request[v1.DeleteMcpOAuthClientRequest]) (*connect.Response[emptypb.Empty], error)
}

// NewMcpOAuthClientsServiceHandler builds an HTTP handler from the service implementation. It
// returns the path on which to mount the handler and the handler itself.
//
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
// and JSON codecs. They also support gzip compression.
func NewMcpOAuthClientsServiceHandler(svc McpOAuthClientsServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
	mcpOAuthClientsServiceMethods := v1.File_tars_mcp_v1_mcp_oauth_clients_proto.Services().ByName("McpOAuthClientsService").Methods()
	mcpOAuthClientsServiceCreateMcpOAuthClientHandler := connect.NewUnaryHandler(
		McpOAuthClientsServiceCreateMcpOAuthClientProcedure,
		svc.CreateMcpOAuthClient,
		connect.WithSchema(mcpOAuthClientsServiceMethods.ByName("CreateMcpOAuthClient")),
		connect.WithHandlerOptions(opts...),
	)
	mcpOAuthClientsServiceGetMcpOAuthClientHandler := connect.NewUnaryHandler(
		McpOAuthClientsServiceGetMcpOAuthClientProcedure,
		svc.GetMcpOAuthClient,
		connect.WithSchema(mcpOAuthClientsServiceMethods.ByName("GetMcpOAuthClient")),
		connect.WithIdempotency(connect.IdempotencyNoSideEffects),
		connect.WithHandlerOptions(opts...),
	)
	mcpOAuthClientsServiceListMcpOAuthClientsHandler := connect.NewUnaryHandler(
		McpOAuthClientsServiceListMcpOAuthClientsProcedure,
		svc.ListMcpOAuthClients,
		connect.WithSchema(mcpOAuthClientsServiceMethods.ByName("ListMcpOAuthClients")),
		connect.WithIdempotency(connect.IdempotencyNoSideEffects),
		connect.WithHandlerOptions(opts...),
	)
	mcpOAuthClientsServiceUpdateMcpOAuthClientHandler := connect.NewUnaryHandler(
		McpOAuthClientsServiceUpdateMcpOAuthClientProcedure,
		svc.UpdateMcpOAuthClient,
		connect.WithSchema(mcpOAuthClientsServiceMethods.ByName("UpdateMcpOAuthClient")),
		connect.WithHandlerOptions(opts...),
	)
	mcpOAuthClientsServiceDeleteMcpOAuthClientHandler := connect.NewUnaryHandler(
		McpOAuthClientsServiceDeleteMcpOAuthClientProcedure,
		svc.DeleteMcpOAuthClient,
		connect.WithSchema(mcpOAuthClientsServiceMethods.ByName("DeleteMcpOAuthClient")),
		connect.WithHandlerOptions(opts...),
	)
	return "/tars.mcp.v1.McpOAuthClientsService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		switch r.URL.Path {
		case McpOAuthClientsServiceCreateMcpOAuthClientProcedure:
			mcpOAuthClientsServiceCreateMcpOAuthClientHandler.ServeHTTP(w, r)
		case McpOAuthClientsServiceGetMcpOAuthClientProcedure:
			mcpOAuthClientsServiceGetMcpOAuthClientHandler.ServeHTTP(w, r)
		case McpOAuthClientsServiceListMcpOAuthClientsProcedure:
			mcpOAuthClientsServiceListMcpOAuthClientsHandler.ServeHTTP(w, r)
		case McpOAuthClientsServiceUpdateMcpOAuthClientProcedure:
			mcpOAuthClientsServiceUpdateMcpOAuthClientHandler.ServeHTTP(w, r)
		case McpOAuthClientsServiceDeleteMcpOAuthClientProcedure:
			mcpOAuthClientsServiceDeleteMcpOAuthClientHandler.ServeHTTP(w, r)
		default:
			http.NotFound(w, r)
		}
	})
}

// UnimplementedMcpOAuthClientsServiceHandler returns CodeUnimplemented from all methods.
type UnimplementedMcpOAuthClientsServiceHandler struct{}

func (UnimplementedMcpOAuthClientsServiceHandler) CreateMcpOAuthClient(context.Context, *connect.Request[v1.CreateMcpOAuthClientRequest]) (*connect.Response[v1.McpOAuthClient], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("tars.mcp.v1.McpOAuthClientsService.CreateMcpOAuthClient is not implemented"))
}

func (UnimplementedMcpOAuthClientsServiceHandler) GetMcpOAuthClient(context.Context, *connect.Request[v1.GetMcpOAuthClientRequest]) (*connect.Response[v1.McpOAuthClient], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("tars.mcp.v1.McpOAuthClientsService.GetMcpOAuthClient is not implemented"))
}

func (UnimplementedMcpOAuthClientsServiceHandler) ListMcpOAuthClients(context.Context, *connect.Request[v1.ListMcpOAuthClientsRequest]) (*connect.Response[v1.ListMcpOAuthClientsResponse], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("tars.mcp.v1.McpOAuthClientsService.ListMcpOAuthClients is not implemented"))
}

func (UnimplementedMcpOAuthClientsServiceHandler) UpdateMcpOAuthClient(context.Context, *connect.Request[v1.UpdateMcpOAuthClientRequest]) (*connect.Response[v1.McpOAuthClient], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("tars.mcp.v1.McpOAuthClientsService.UpdateMcpOAuthClient is not implemented"))
}

func (UnimplementedMcpOAuthClientsServiceHandler) DeleteMcpOAuthClient(context.Context, *connect.Request[v1.DeleteMcpOAuthClientRequest]) (*connect.Response[emptypb.Empty], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("tars.mcp.v1.McpOAuthClientsService.DeleteMcpOAuthClient is not implemented"))
}
