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

package lookupv1connect

import (
	connect "connectrpc.com/connect"
	context "context"
	errors "errors"
	v1 "github.com/tetrateio/agentrouter-go/genapi/api/tars/lookup/v1"
	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 (
	// LookupServiceName is the fully-qualified name of the LookupService service.
	LookupServiceName = "tars.lookup.v1.LookupService"
)

// 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 (
	// LookupServiceGetMCPProfileByURLProcedure is the fully-qualified name of the LookupService's
	// GetMCPProfileByURL RPC.
	LookupServiceGetMCPProfileByURLProcedure = "/tars.lookup.v1.LookupService/GetMCPProfileByURL"
	// LookupServiceResolveRouteIdentityByKeyProcedure is the fully-qualified name of the
	// LookupService's ResolveRouteIdentityByKey RPC.
	LookupServiceResolveRouteIdentityByKeyProcedure = "/tars.lookup.v1.LookupService/ResolveRouteIdentityByKey"
)

// LookupServiceClient is a client for the tars.lookup.v1.LookupService service.
type LookupServiceClient interface {
	// GetMCPProfileByURL retrieves an MCP profile by its URL.
	// Aggressively cached for ext_authz performance in the dataplane.
	//
	// Accepts both SERVICE_ACCOUNT (corporate dataplane with mounted SA file)
	// and API_KEY (SaaS dataplane authenticating with VALET_API_KEY). Without
	// API_KEY, SaaS dataplanes whose GetAuthToken returns a raw API key
	// (not a JWT) cannot authenticate at all. Kept out of the customer
	// reference by the service-level (tars.docs.v1.internal) marker.
	GetMCPProfileByURL(context.Context, *connect.Request[v1.GetMCPProfileByURLRequest]) (*connect.Response[v1.GetMCPProfileByURLResponse], error)
	// ResolveRouteIdentityByKey resolves effective route identity for an authenticated key.
	// Mapping-aware behavior:
	// - mapped key => effective client UUID as tars_id
	// - unmapped key => key UUID (jti) as tars_id
	ResolveRouteIdentityByKey(context.Context, *connect.Request[v1.ResolveRouteIdentityByKeyRequest]) (*connect.Response[v1.ResolveRouteIdentityByKeyResponse], error)
}

// NewLookupServiceClient constructs a client for the tars.lookup.v1.LookupService 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 NewLookupServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) LookupServiceClient {
	baseURL = strings.TrimRight(baseURL, "/")
	lookupServiceMethods := v1.File_tars_lookup_v1_lookup_proto.Services().ByName("LookupService").Methods()
	return &lookupServiceClient{
		getMCPProfileByURL: connect.NewClient[v1.GetMCPProfileByURLRequest, v1.GetMCPProfileByURLResponse](
			httpClient,
			baseURL+LookupServiceGetMCPProfileByURLProcedure,
			connect.WithSchema(lookupServiceMethods.ByName("GetMCPProfileByURL")),
			connect.WithIdempotency(connect.IdempotencyNoSideEffects),
			connect.WithClientOptions(opts...),
		),
		resolveRouteIdentityByKey: connect.NewClient[v1.ResolveRouteIdentityByKeyRequest, v1.ResolveRouteIdentityByKeyResponse](
			httpClient,
			baseURL+LookupServiceResolveRouteIdentityByKeyProcedure,
			connect.WithSchema(lookupServiceMethods.ByName("ResolveRouteIdentityByKey")),
			connect.WithIdempotency(connect.IdempotencyNoSideEffects),
			connect.WithClientOptions(opts...),
		),
	}
}

// lookupServiceClient implements LookupServiceClient.
type lookupServiceClient struct {
	getMCPProfileByURL        *connect.Client[v1.GetMCPProfileByURLRequest, v1.GetMCPProfileByURLResponse]
	resolveRouteIdentityByKey *connect.Client[v1.ResolveRouteIdentityByKeyRequest, v1.ResolveRouteIdentityByKeyResponse]
}

// GetMCPProfileByURL calls tars.lookup.v1.LookupService.GetMCPProfileByURL.
func (c *lookupServiceClient) GetMCPProfileByURL(ctx context.Context, req *connect.Request[v1.GetMCPProfileByURLRequest]) (*connect.Response[v1.GetMCPProfileByURLResponse], error) {
	return c.getMCPProfileByURL.CallUnary(ctx, req)
}

// ResolveRouteIdentityByKey calls tars.lookup.v1.LookupService.ResolveRouteIdentityByKey.
func (c *lookupServiceClient) ResolveRouteIdentityByKey(ctx context.Context, req *connect.Request[v1.ResolveRouteIdentityByKeyRequest]) (*connect.Response[v1.ResolveRouteIdentityByKeyResponse], error) {
	return c.resolveRouteIdentityByKey.CallUnary(ctx, req)
}

// LookupServiceHandler is an implementation of the tars.lookup.v1.LookupService service.
type LookupServiceHandler interface {
	// GetMCPProfileByURL retrieves an MCP profile by its URL.
	// Aggressively cached for ext_authz performance in the dataplane.
	//
	// Accepts both SERVICE_ACCOUNT (corporate dataplane with mounted SA file)
	// and API_KEY (SaaS dataplane authenticating with VALET_API_KEY). Without
	// API_KEY, SaaS dataplanes whose GetAuthToken returns a raw API key
	// (not a JWT) cannot authenticate at all. Kept out of the customer
	// reference by the service-level (tars.docs.v1.internal) marker.
	GetMCPProfileByURL(context.Context, *connect.Request[v1.GetMCPProfileByURLRequest]) (*connect.Response[v1.GetMCPProfileByURLResponse], error)
	// ResolveRouteIdentityByKey resolves effective route identity for an authenticated key.
	// Mapping-aware behavior:
	// - mapped key => effective client UUID as tars_id
	// - unmapped key => key UUID (jti) as tars_id
	ResolveRouteIdentityByKey(context.Context, *connect.Request[v1.ResolveRouteIdentityByKeyRequest]) (*connect.Response[v1.ResolveRouteIdentityByKeyResponse], error)
}

// NewLookupServiceHandler 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 NewLookupServiceHandler(svc LookupServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
	lookupServiceMethods := v1.File_tars_lookup_v1_lookup_proto.Services().ByName("LookupService").Methods()
	lookupServiceGetMCPProfileByURLHandler := connect.NewUnaryHandler(
		LookupServiceGetMCPProfileByURLProcedure,
		svc.GetMCPProfileByURL,
		connect.WithSchema(lookupServiceMethods.ByName("GetMCPProfileByURL")),
		connect.WithIdempotency(connect.IdempotencyNoSideEffects),
		connect.WithHandlerOptions(opts...),
	)
	lookupServiceResolveRouteIdentityByKeyHandler := connect.NewUnaryHandler(
		LookupServiceResolveRouteIdentityByKeyProcedure,
		svc.ResolveRouteIdentityByKey,
		connect.WithSchema(lookupServiceMethods.ByName("ResolveRouteIdentityByKey")),
		connect.WithIdempotency(connect.IdempotencyNoSideEffects),
		connect.WithHandlerOptions(opts...),
	)
	return "/tars.lookup.v1.LookupService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		switch r.URL.Path {
		case LookupServiceGetMCPProfileByURLProcedure:
			lookupServiceGetMCPProfileByURLHandler.ServeHTTP(w, r)
		case LookupServiceResolveRouteIdentityByKeyProcedure:
			lookupServiceResolveRouteIdentityByKeyHandler.ServeHTTP(w, r)
		default:
			http.NotFound(w, r)
		}
	})
}

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

func (UnimplementedLookupServiceHandler) GetMCPProfileByURL(context.Context, *connect.Request[v1.GetMCPProfileByURLRequest]) (*connect.Response[v1.GetMCPProfileByURLResponse], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("tars.lookup.v1.LookupService.GetMCPProfileByURL is not implemented"))
}

func (UnimplementedLookupServiceHandler) ResolveRouteIdentityByKey(context.Context, *connect.Request[v1.ResolveRouteIdentityByKeyRequest]) (*connect.Response[v1.ResolveRouteIdentityByKeyResponse], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("tars.lookup.v1.LookupService.ResolveRouteIdentityByKey is not implemented"))
}
