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

package api_keysv1connect

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

// 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 (
	// ApiKeysServiceCreateApiKeyProcedure is the fully-qualified name of the ApiKeysService's
	// CreateApiKey RPC.
	ApiKeysServiceCreateApiKeyProcedure = "/tars.api_keys.v1.ApiKeysService/CreateApiKey"
	// ApiKeysServiceUpdateApiKeyProcedure is the fully-qualified name of the ApiKeysService's
	// UpdateApiKey RPC.
	ApiKeysServiceUpdateApiKeyProcedure = "/tars.api_keys.v1.ApiKeysService/UpdateApiKey"
	// ApiKeysServiceDeleteApiKeyProcedure is the fully-qualified name of the ApiKeysService's
	// DeleteApiKey RPC.
	ApiKeysServiceDeleteApiKeyProcedure = "/tars.api_keys.v1.ApiKeysService/DeleteApiKey"
)

// ApiKeysServiceClient is a client for the tars.api_keys.v1.ApiKeysService service.
type ApiKeysServiceClient interface {
	// CreateApiKey creates a new JWT user-token API key for a user and returns the plaintext token exactly once.
	CreateApiKey(context.Context, *connect.Request[v1.CreateApiKeyRequest]) (*connect.Response[v1.CreateApiKeyResponse], error)
	// UpdateApiKey updates mutable fields of an API key (name and/or active state).
	UpdateApiKey(context.Context, *connect.Request[v1.UpdateApiKeyRequest]) (*connect.Response[v1.UpdateApiKeyResponse], error)
	// DeleteApiKey soft-deletes an API key (sets deleted_at).
	DeleteApiKey(context.Context, *connect.Request[v1.DeleteApiKeyRequest]) (*connect.Response[v1.DeleteApiKeyResponse], error)
}

// NewApiKeysServiceClient constructs a client for the tars.api_keys.v1.ApiKeysService 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 NewApiKeysServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) ApiKeysServiceClient {
	baseURL = strings.TrimRight(baseURL, "/")
	apiKeysServiceMethods := v1.File_tars_api_keys_v1_api_keys_proto.Services().ByName("ApiKeysService").Methods()
	return &apiKeysServiceClient{
		createApiKey: connect.NewClient[v1.CreateApiKeyRequest, v1.CreateApiKeyResponse](
			httpClient,
			baseURL+ApiKeysServiceCreateApiKeyProcedure,
			connect.WithSchema(apiKeysServiceMethods.ByName("CreateApiKey")),
			connect.WithClientOptions(opts...),
		),
		updateApiKey: connect.NewClient[v1.UpdateApiKeyRequest, v1.UpdateApiKeyResponse](
			httpClient,
			baseURL+ApiKeysServiceUpdateApiKeyProcedure,
			connect.WithSchema(apiKeysServiceMethods.ByName("UpdateApiKey")),
			connect.WithClientOptions(opts...),
		),
		deleteApiKey: connect.NewClient[v1.DeleteApiKeyRequest, v1.DeleteApiKeyResponse](
			httpClient,
			baseURL+ApiKeysServiceDeleteApiKeyProcedure,
			connect.WithSchema(apiKeysServiceMethods.ByName("DeleteApiKey")),
			connect.WithClientOptions(opts...),
		),
	}
}

// apiKeysServiceClient implements ApiKeysServiceClient.
type apiKeysServiceClient struct {
	createApiKey *connect.Client[v1.CreateApiKeyRequest, v1.CreateApiKeyResponse]
	updateApiKey *connect.Client[v1.UpdateApiKeyRequest, v1.UpdateApiKeyResponse]
	deleteApiKey *connect.Client[v1.DeleteApiKeyRequest, v1.DeleteApiKeyResponse]
}

// CreateApiKey calls tars.api_keys.v1.ApiKeysService.CreateApiKey.
func (c *apiKeysServiceClient) CreateApiKey(ctx context.Context, req *connect.Request[v1.CreateApiKeyRequest]) (*connect.Response[v1.CreateApiKeyResponse], error) {
	return c.createApiKey.CallUnary(ctx, req)
}

// UpdateApiKey calls tars.api_keys.v1.ApiKeysService.UpdateApiKey.
func (c *apiKeysServiceClient) UpdateApiKey(ctx context.Context, req *connect.Request[v1.UpdateApiKeyRequest]) (*connect.Response[v1.UpdateApiKeyResponse], error) {
	return c.updateApiKey.CallUnary(ctx, req)
}

// DeleteApiKey calls tars.api_keys.v1.ApiKeysService.DeleteApiKey.
func (c *apiKeysServiceClient) DeleteApiKey(ctx context.Context, req *connect.Request[v1.DeleteApiKeyRequest]) (*connect.Response[v1.DeleteApiKeyResponse], error) {
	return c.deleteApiKey.CallUnary(ctx, req)
}

// ApiKeysServiceHandler is an implementation of the tars.api_keys.v1.ApiKeysService service.
type ApiKeysServiceHandler interface {
	// CreateApiKey creates a new JWT user-token API key for a user and returns the plaintext token exactly once.
	CreateApiKey(context.Context, *connect.Request[v1.CreateApiKeyRequest]) (*connect.Response[v1.CreateApiKeyResponse], error)
	// UpdateApiKey updates mutable fields of an API key (name and/or active state).
	UpdateApiKey(context.Context, *connect.Request[v1.UpdateApiKeyRequest]) (*connect.Response[v1.UpdateApiKeyResponse], error)
	// DeleteApiKey soft-deletes an API key (sets deleted_at).
	DeleteApiKey(context.Context, *connect.Request[v1.DeleteApiKeyRequest]) (*connect.Response[v1.DeleteApiKeyResponse], error)
}

// NewApiKeysServiceHandler 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 NewApiKeysServiceHandler(svc ApiKeysServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
	apiKeysServiceMethods := v1.File_tars_api_keys_v1_api_keys_proto.Services().ByName("ApiKeysService").Methods()
	apiKeysServiceCreateApiKeyHandler := connect.NewUnaryHandler(
		ApiKeysServiceCreateApiKeyProcedure,
		svc.CreateApiKey,
		connect.WithSchema(apiKeysServiceMethods.ByName("CreateApiKey")),
		connect.WithHandlerOptions(opts...),
	)
	apiKeysServiceUpdateApiKeyHandler := connect.NewUnaryHandler(
		ApiKeysServiceUpdateApiKeyProcedure,
		svc.UpdateApiKey,
		connect.WithSchema(apiKeysServiceMethods.ByName("UpdateApiKey")),
		connect.WithHandlerOptions(opts...),
	)
	apiKeysServiceDeleteApiKeyHandler := connect.NewUnaryHandler(
		ApiKeysServiceDeleteApiKeyProcedure,
		svc.DeleteApiKey,
		connect.WithSchema(apiKeysServiceMethods.ByName("DeleteApiKey")),
		connect.WithHandlerOptions(opts...),
	)
	return "/tars.api_keys.v1.ApiKeysService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		switch r.URL.Path {
		case ApiKeysServiceCreateApiKeyProcedure:
			apiKeysServiceCreateApiKeyHandler.ServeHTTP(w, r)
		case ApiKeysServiceUpdateApiKeyProcedure:
			apiKeysServiceUpdateApiKeyHandler.ServeHTTP(w, r)
		case ApiKeysServiceDeleteApiKeyProcedure:
			apiKeysServiceDeleteApiKeyHandler.ServeHTTP(w, r)
		default:
			http.NotFound(w, r)
		}
	})
}

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

func (UnimplementedApiKeysServiceHandler) CreateApiKey(context.Context, *connect.Request[v1.CreateApiKeyRequest]) (*connect.Response[v1.CreateApiKeyResponse], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("tars.api_keys.v1.ApiKeysService.CreateApiKey is not implemented"))
}

func (UnimplementedApiKeysServiceHandler) UpdateApiKey(context.Context, *connect.Request[v1.UpdateApiKeyRequest]) (*connect.Response[v1.UpdateApiKeyResponse], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("tars.api_keys.v1.ApiKeysService.UpdateApiKey is not implemented"))
}

func (UnimplementedApiKeysServiceHandler) DeleteApiKey(context.Context, *connect.Request[v1.DeleteApiKeyRequest]) (*connect.Response[v1.DeleteApiKeyResponse], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("tars.api_keys.v1.ApiKeysService.DeleteApiKey is not implemented"))
}
