// Code generated by protoc-gen-connect-go. DO NOT EDIT.
//
// Source: xyz/block/ftl/timeline/v1/timeline.proto

package timelinepbconnect

import (
	connect "connectrpc.com/connect"
	context "context"
	errors "errors"
	v11 "github.com/block/ftl/backend/protos/xyz/block/ftl/timeline/v1"
	v1 "github.com/block/ftl/backend/protos/xyz/block/ftl/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 (
	// TimelineServiceName is the fully-qualified name of the TimelineService service.
	TimelineServiceName = "xyz.block.ftl.timeline.v1.TimelineService"
)

// 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 (
	// TimelineServicePingProcedure is the fully-qualified name of the TimelineService's Ping RPC.
	TimelineServicePingProcedure = "/xyz.block.ftl.timeline.v1.TimelineService/Ping"
	// TimelineServiceGetTimelineProcedure is the fully-qualified name of the TimelineService's
	// GetTimeline RPC.
	TimelineServiceGetTimelineProcedure = "/xyz.block.ftl.timeline.v1.TimelineService/GetTimeline"
	// TimelineServiceStreamTimelineProcedure is the fully-qualified name of the TimelineService's
	// StreamTimeline RPC.
	TimelineServiceStreamTimelineProcedure = "/xyz.block.ftl.timeline.v1.TimelineService/StreamTimeline"
	// TimelineServiceCreateEventsProcedure is the fully-qualified name of the TimelineService's
	// CreateEvents RPC.
	TimelineServiceCreateEventsProcedure = "/xyz.block.ftl.timeline.v1.TimelineService/CreateEvents"
	// TimelineServiceDeleteOldEventsProcedure is the fully-qualified name of the TimelineService's
	// DeleteOldEvents RPC.
	TimelineServiceDeleteOldEventsProcedure = "/xyz.block.ftl.timeline.v1.TimelineService/DeleteOldEvents"
)

// TimelineServiceClient is a client for the xyz.block.ftl.timeline.v1.TimelineService service.
type TimelineServiceClient interface {
	// Ping service for readiness
	Ping(context.Context, *connect.Request[v1.PingRequest]) (*connect.Response[v1.PingResponse], error)
	// Get timeline events with optional filters
	GetTimeline(context.Context, *connect.Request[v11.GetTimelineRequest]) (*connect.Response[v11.GetTimelineResponse], error)
	// Stream timeline events with optional filters
	StreamTimeline(context.Context, *connect.Request[v11.StreamTimelineRequest]) (*connect.ServerStreamForClient[v11.StreamTimelineResponse], error)
	CreateEvents(context.Context, *connect.Request[v11.CreateEventsRequest]) (*connect.Response[v11.CreateEventsResponse], error)
	// Delete old events of a specific type
	DeleteOldEvents(context.Context, *connect.Request[v11.DeleteOldEventsRequest]) (*connect.Response[v11.DeleteOldEventsResponse], error)
}

// NewTimelineServiceClient constructs a client for the xyz.block.ftl.timeline.v1.TimelineService
// 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 NewTimelineServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) TimelineServiceClient {
	baseURL = strings.TrimRight(baseURL, "/")
	timelineServiceMethods := v11.File_xyz_block_ftl_timeline_v1_timeline_proto.Services().ByName("TimelineService").Methods()
	return &timelineServiceClient{
		ping: connect.NewClient[v1.PingRequest, v1.PingResponse](
			httpClient,
			baseURL+TimelineServicePingProcedure,
			connect.WithSchema(timelineServiceMethods.ByName("Ping")),
			connect.WithIdempotency(connect.IdempotencyNoSideEffects),
			connect.WithClientOptions(opts...),
		),
		getTimeline: connect.NewClient[v11.GetTimelineRequest, v11.GetTimelineResponse](
			httpClient,
			baseURL+TimelineServiceGetTimelineProcedure,
			connect.WithSchema(timelineServiceMethods.ByName("GetTimeline")),
			connect.WithIdempotency(connect.IdempotencyNoSideEffects),
			connect.WithClientOptions(opts...),
		),
		streamTimeline: connect.NewClient[v11.StreamTimelineRequest, v11.StreamTimelineResponse](
			httpClient,
			baseURL+TimelineServiceStreamTimelineProcedure,
			connect.WithSchema(timelineServiceMethods.ByName("StreamTimeline")),
			connect.WithClientOptions(opts...),
		),
		createEvents: connect.NewClient[v11.CreateEventsRequest, v11.CreateEventsResponse](
			httpClient,
			baseURL+TimelineServiceCreateEventsProcedure,
			connect.WithSchema(timelineServiceMethods.ByName("CreateEvents")),
			connect.WithClientOptions(opts...),
		),
		deleteOldEvents: connect.NewClient[v11.DeleteOldEventsRequest, v11.DeleteOldEventsResponse](
			httpClient,
			baseURL+TimelineServiceDeleteOldEventsProcedure,
			connect.WithSchema(timelineServiceMethods.ByName("DeleteOldEvents")),
			connect.WithClientOptions(opts...),
		),
	}
}

// timelineServiceClient implements TimelineServiceClient.
type timelineServiceClient struct {
	ping            *connect.Client[v1.PingRequest, v1.PingResponse]
	getTimeline     *connect.Client[v11.GetTimelineRequest, v11.GetTimelineResponse]
	streamTimeline  *connect.Client[v11.StreamTimelineRequest, v11.StreamTimelineResponse]
	createEvents    *connect.Client[v11.CreateEventsRequest, v11.CreateEventsResponse]
	deleteOldEvents *connect.Client[v11.DeleteOldEventsRequest, v11.DeleteOldEventsResponse]
}

// Ping calls xyz.block.ftl.timeline.v1.TimelineService.Ping.
func (c *timelineServiceClient) Ping(ctx context.Context, req *connect.Request[v1.PingRequest]) (*connect.Response[v1.PingResponse], error) {
	return c.ping.CallUnary(ctx, req)
}

// GetTimeline calls xyz.block.ftl.timeline.v1.TimelineService.GetTimeline.
func (c *timelineServiceClient) GetTimeline(ctx context.Context, req *connect.Request[v11.GetTimelineRequest]) (*connect.Response[v11.GetTimelineResponse], error) {
	return c.getTimeline.CallUnary(ctx, req)
}

// StreamTimeline calls xyz.block.ftl.timeline.v1.TimelineService.StreamTimeline.
func (c *timelineServiceClient) StreamTimeline(ctx context.Context, req *connect.Request[v11.StreamTimelineRequest]) (*connect.ServerStreamForClient[v11.StreamTimelineResponse], error) {
	return c.streamTimeline.CallServerStream(ctx, req)
}

// CreateEvents calls xyz.block.ftl.timeline.v1.TimelineService.CreateEvents.
func (c *timelineServiceClient) CreateEvents(ctx context.Context, req *connect.Request[v11.CreateEventsRequest]) (*connect.Response[v11.CreateEventsResponse], error) {
	return c.createEvents.CallUnary(ctx, req)
}

// DeleteOldEvents calls xyz.block.ftl.timeline.v1.TimelineService.DeleteOldEvents.
func (c *timelineServiceClient) DeleteOldEvents(ctx context.Context, req *connect.Request[v11.DeleteOldEventsRequest]) (*connect.Response[v11.DeleteOldEventsResponse], error) {
	return c.deleteOldEvents.CallUnary(ctx, req)
}

// TimelineServiceHandler is an implementation of the xyz.block.ftl.timeline.v1.TimelineService
// service.
type TimelineServiceHandler interface {
	// Ping service for readiness
	Ping(context.Context, *connect.Request[v1.PingRequest]) (*connect.Response[v1.PingResponse], error)
	// Get timeline events with optional filters
	GetTimeline(context.Context, *connect.Request[v11.GetTimelineRequest]) (*connect.Response[v11.GetTimelineResponse], error)
	// Stream timeline events with optional filters
	StreamTimeline(context.Context, *connect.Request[v11.StreamTimelineRequest], *connect.ServerStream[v11.StreamTimelineResponse]) error
	CreateEvents(context.Context, *connect.Request[v11.CreateEventsRequest]) (*connect.Response[v11.CreateEventsResponse], error)
	// Delete old events of a specific type
	DeleteOldEvents(context.Context, *connect.Request[v11.DeleteOldEventsRequest]) (*connect.Response[v11.DeleteOldEventsResponse], error)
}

// NewTimelineServiceHandler 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 NewTimelineServiceHandler(svc TimelineServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
	timelineServiceMethods := v11.File_xyz_block_ftl_timeline_v1_timeline_proto.Services().ByName("TimelineService").Methods()
	timelineServicePingHandler := connect.NewUnaryHandler(
		TimelineServicePingProcedure,
		svc.Ping,
		connect.WithSchema(timelineServiceMethods.ByName("Ping")),
		connect.WithIdempotency(connect.IdempotencyNoSideEffects),
		connect.WithHandlerOptions(opts...),
	)
	timelineServiceGetTimelineHandler := connect.NewUnaryHandler(
		TimelineServiceGetTimelineProcedure,
		svc.GetTimeline,
		connect.WithSchema(timelineServiceMethods.ByName("GetTimeline")),
		connect.WithIdempotency(connect.IdempotencyNoSideEffects),
		connect.WithHandlerOptions(opts...),
	)
	timelineServiceStreamTimelineHandler := connect.NewServerStreamHandler(
		TimelineServiceStreamTimelineProcedure,
		svc.StreamTimeline,
		connect.WithSchema(timelineServiceMethods.ByName("StreamTimeline")),
		connect.WithHandlerOptions(opts...),
	)
	timelineServiceCreateEventsHandler := connect.NewUnaryHandler(
		TimelineServiceCreateEventsProcedure,
		svc.CreateEvents,
		connect.WithSchema(timelineServiceMethods.ByName("CreateEvents")),
		connect.WithHandlerOptions(opts...),
	)
	timelineServiceDeleteOldEventsHandler := connect.NewUnaryHandler(
		TimelineServiceDeleteOldEventsProcedure,
		svc.DeleteOldEvents,
		connect.WithSchema(timelineServiceMethods.ByName("DeleteOldEvents")),
		connect.WithHandlerOptions(opts...),
	)
	return "/xyz.block.ftl.timeline.v1.TimelineService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		switch r.URL.Path {
		case TimelineServicePingProcedure:
			timelineServicePingHandler.ServeHTTP(w, r)
		case TimelineServiceGetTimelineProcedure:
			timelineServiceGetTimelineHandler.ServeHTTP(w, r)
		case TimelineServiceStreamTimelineProcedure:
			timelineServiceStreamTimelineHandler.ServeHTTP(w, r)
		case TimelineServiceCreateEventsProcedure:
			timelineServiceCreateEventsHandler.ServeHTTP(w, r)
		case TimelineServiceDeleteOldEventsProcedure:
			timelineServiceDeleteOldEventsHandler.ServeHTTP(w, r)
		default:
			http.NotFound(w, r)
		}
	})
}

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

func (UnimplementedTimelineServiceHandler) Ping(context.Context, *connect.Request[v1.PingRequest]) (*connect.Response[v1.PingResponse], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("xyz.block.ftl.timeline.v1.TimelineService.Ping is not implemented"))
}

func (UnimplementedTimelineServiceHandler) GetTimeline(context.Context, *connect.Request[v11.GetTimelineRequest]) (*connect.Response[v11.GetTimelineResponse], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("xyz.block.ftl.timeline.v1.TimelineService.GetTimeline is not implemented"))
}

func (UnimplementedTimelineServiceHandler) StreamTimeline(context.Context, *connect.Request[v11.StreamTimelineRequest], *connect.ServerStream[v11.StreamTimelineResponse]) error {
	return connect.NewError(connect.CodeUnimplemented, errors.New("xyz.block.ftl.timeline.v1.TimelineService.StreamTimeline is not implemented"))
}

func (UnimplementedTimelineServiceHandler) CreateEvents(context.Context, *connect.Request[v11.CreateEventsRequest]) (*connect.Response[v11.CreateEventsResponse], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("xyz.block.ftl.timeline.v1.TimelineService.CreateEvents is not implemented"))
}

func (UnimplementedTimelineServiceHandler) DeleteOldEvents(context.Context, *connect.Request[v11.DeleteOldEventsRequest]) (*connect.Response[v11.DeleteOldEventsResponse], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("xyz.block.ftl.timeline.v1.TimelineService.DeleteOldEvents is not implemented"))
}
