// Inference ingress surface -- the public RPC customers call to issue a
// prompt. The control plane picks an eligible dataplane and forwards
// the request; this proto is the customer-visible shape.
//
// Skeleton: a single unary Prompt RPC. Streaming via SSE / server
// streaming lands when the dataplane filter chain matures (milestone C).
//
// Plan reference: B4 in check-ia-and-plan-optimized-cook.md.

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

package inferencev1connect

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

// 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 (
	// InferenceIngressServicePromptProcedure is the fully-qualified name of the
	// InferenceIngressService's Prompt RPC.
	InferenceIngressServicePromptProcedure = "/tars.inference.v1.InferenceIngressService/Prompt"
	// InferenceIngressServiceGetDataplaneURLProcedure is the fully-qualified name of the
	// InferenceIngressService's GetDataplaneURL RPC.
	InferenceIngressServiceGetDataplaneURLProcedure = "/tars.inference.v1.InferenceIngressService/GetDataplaneURL"
	// InferenceIngressServiceListDataplaneURLsProcedure is the fully-qualified name of the
	// InferenceIngressService's ListDataplaneURLs RPC.
	InferenceIngressServiceListDataplaneURLsProcedure = "/tars.inference.v1.InferenceIngressService/ListDataplaneURLs"
)

// InferenceIngressServiceClient is a client for the tars.inference.v1.InferenceIngressService
// service.
type InferenceIngressServiceClient interface {
	// Prompt sends a prompt to an upstream LLM and returns the model's
	// completion. The gateway selects an eligible data plane, retrieves
	// and applies the project's BYOK key, enforces quota, records a
	// request log entry, and proxies the call to the upstream provider.
	// Streaming, multi-turn conversations, tools, and vision are not yet
	// supported on this path.
	Prompt(context.Context, *connect.Request[v1.PromptRequest]) (*connect.Response[v1.PromptResponse], error)
	// GetDataplaneURL returns the dataplane (gateway) URL for a single project.
	// The project is deduced from the caller's credential -- no input is required
	// in the common case: a caller who belongs to one project gets that project's
	// dataplane; one whose identity spans several gets their default (the oldest
	// membership). Pass project_id to disambiguate or target a specific project
	// (it is membership-checked). The customer is derived the same way. When the
	// credential itself already pins a workspace, that workspace is used directly.
	GetDataplaneURL(context.Context, *connect.Request[v1.GetDataplaneURLRequest]) (*connect.Response[v1.GetDataplaneURLResponse], error)
	// ListDataplaneURLs returns every dataplane URL the caller can reach -- one
	// per workspace under the customer deduced from the credential. Key-deduced;
	// no input. Use GetDataplaneURL when a single project's URL is wanted.
	ListDataplaneURLs(context.Context, *connect.Request[v1.ListDataplaneURLsRequest]) (*connect.Response[v1.ListDataplaneURLsResponse], error)
}

// NewInferenceIngressServiceClient constructs a client for the
// tars.inference.v1.InferenceIngressService 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 NewInferenceIngressServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) InferenceIngressServiceClient {
	baseURL = strings.TrimRight(baseURL, "/")
	inferenceIngressServiceMethods := v1.File_tars_inference_v1_inference_proto.Services().ByName("InferenceIngressService").Methods()
	return &inferenceIngressServiceClient{
		prompt: connect.NewClient[v1.PromptRequest, v1.PromptResponse](
			httpClient,
			baseURL+InferenceIngressServicePromptProcedure,
			connect.WithSchema(inferenceIngressServiceMethods.ByName("Prompt")),
			connect.WithClientOptions(opts...),
		),
		getDataplaneURL: connect.NewClient[v1.GetDataplaneURLRequest, v1.GetDataplaneURLResponse](
			httpClient,
			baseURL+InferenceIngressServiceGetDataplaneURLProcedure,
			connect.WithSchema(inferenceIngressServiceMethods.ByName("GetDataplaneURL")),
			connect.WithClientOptions(opts...),
		),
		listDataplaneURLs: connect.NewClient[v1.ListDataplaneURLsRequest, v1.ListDataplaneURLsResponse](
			httpClient,
			baseURL+InferenceIngressServiceListDataplaneURLsProcedure,
			connect.WithSchema(inferenceIngressServiceMethods.ByName("ListDataplaneURLs")),
			connect.WithClientOptions(opts...),
		),
	}
}

// inferenceIngressServiceClient implements InferenceIngressServiceClient.
type inferenceIngressServiceClient struct {
	prompt            *connect.Client[v1.PromptRequest, v1.PromptResponse]
	getDataplaneURL   *connect.Client[v1.GetDataplaneURLRequest, v1.GetDataplaneURLResponse]
	listDataplaneURLs *connect.Client[v1.ListDataplaneURLsRequest, v1.ListDataplaneURLsResponse]
}

// Prompt calls tars.inference.v1.InferenceIngressService.Prompt.
func (c *inferenceIngressServiceClient) Prompt(ctx context.Context, req *connect.Request[v1.PromptRequest]) (*connect.Response[v1.PromptResponse], error) {
	return c.prompt.CallUnary(ctx, req)
}

// GetDataplaneURL calls tars.inference.v1.InferenceIngressService.GetDataplaneURL.
func (c *inferenceIngressServiceClient) GetDataplaneURL(ctx context.Context, req *connect.Request[v1.GetDataplaneURLRequest]) (*connect.Response[v1.GetDataplaneURLResponse], error) {
	return c.getDataplaneURL.CallUnary(ctx, req)
}

// ListDataplaneURLs calls tars.inference.v1.InferenceIngressService.ListDataplaneURLs.
func (c *inferenceIngressServiceClient) ListDataplaneURLs(ctx context.Context, req *connect.Request[v1.ListDataplaneURLsRequest]) (*connect.Response[v1.ListDataplaneURLsResponse], error) {
	return c.listDataplaneURLs.CallUnary(ctx, req)
}

// InferenceIngressServiceHandler is an implementation of the
// tars.inference.v1.InferenceIngressService service.
type InferenceIngressServiceHandler interface {
	// Prompt sends a prompt to an upstream LLM and returns the model's
	// completion. The gateway selects an eligible data plane, retrieves
	// and applies the project's BYOK key, enforces quota, records a
	// request log entry, and proxies the call to the upstream provider.
	// Streaming, multi-turn conversations, tools, and vision are not yet
	// supported on this path.
	Prompt(context.Context, *connect.Request[v1.PromptRequest]) (*connect.Response[v1.PromptResponse], error)
	// GetDataplaneURL returns the dataplane (gateway) URL for a single project.
	// The project is deduced from the caller's credential -- no input is required
	// in the common case: a caller who belongs to one project gets that project's
	// dataplane; one whose identity spans several gets their default (the oldest
	// membership). Pass project_id to disambiguate or target a specific project
	// (it is membership-checked). The customer is derived the same way. When the
	// credential itself already pins a workspace, that workspace is used directly.
	GetDataplaneURL(context.Context, *connect.Request[v1.GetDataplaneURLRequest]) (*connect.Response[v1.GetDataplaneURLResponse], error)
	// ListDataplaneURLs returns every dataplane URL the caller can reach -- one
	// per workspace under the customer deduced from the credential. Key-deduced;
	// no input. Use GetDataplaneURL when a single project's URL is wanted.
	ListDataplaneURLs(context.Context, *connect.Request[v1.ListDataplaneURLsRequest]) (*connect.Response[v1.ListDataplaneURLsResponse], error)
}

// NewInferenceIngressServiceHandler 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 NewInferenceIngressServiceHandler(svc InferenceIngressServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
	inferenceIngressServiceMethods := v1.File_tars_inference_v1_inference_proto.Services().ByName("InferenceIngressService").Methods()
	inferenceIngressServicePromptHandler := connect.NewUnaryHandler(
		InferenceIngressServicePromptProcedure,
		svc.Prompt,
		connect.WithSchema(inferenceIngressServiceMethods.ByName("Prompt")),
		connect.WithHandlerOptions(opts...),
	)
	inferenceIngressServiceGetDataplaneURLHandler := connect.NewUnaryHandler(
		InferenceIngressServiceGetDataplaneURLProcedure,
		svc.GetDataplaneURL,
		connect.WithSchema(inferenceIngressServiceMethods.ByName("GetDataplaneURL")),
		connect.WithHandlerOptions(opts...),
	)
	inferenceIngressServiceListDataplaneURLsHandler := connect.NewUnaryHandler(
		InferenceIngressServiceListDataplaneURLsProcedure,
		svc.ListDataplaneURLs,
		connect.WithSchema(inferenceIngressServiceMethods.ByName("ListDataplaneURLs")),
		connect.WithHandlerOptions(opts...),
	)
	return "/tars.inference.v1.InferenceIngressService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		switch r.URL.Path {
		case InferenceIngressServicePromptProcedure:
			inferenceIngressServicePromptHandler.ServeHTTP(w, r)
		case InferenceIngressServiceGetDataplaneURLProcedure:
			inferenceIngressServiceGetDataplaneURLHandler.ServeHTTP(w, r)
		case InferenceIngressServiceListDataplaneURLsProcedure:
			inferenceIngressServiceListDataplaneURLsHandler.ServeHTTP(w, r)
		default:
			http.NotFound(w, r)
		}
	})
}

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

func (UnimplementedInferenceIngressServiceHandler) Prompt(context.Context, *connect.Request[v1.PromptRequest]) (*connect.Response[v1.PromptResponse], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("tars.inference.v1.InferenceIngressService.Prompt is not implemented"))
}

func (UnimplementedInferenceIngressServiceHandler) GetDataplaneURL(context.Context, *connect.Request[v1.GetDataplaneURLRequest]) (*connect.Response[v1.GetDataplaneURLResponse], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("tars.inference.v1.InferenceIngressService.GetDataplaneURL is not implemented"))
}

func (UnimplementedInferenceIngressServiceHandler) ListDataplaneURLs(context.Context, *connect.Request[v1.ListDataplaneURLsRequest]) (*connect.Response[v1.ListDataplaneURLsResponse], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("tars.inference.v1.InferenceIngressService.ListDataplaneURLs is not implemented"))
}
