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

package provisionerpbconnect

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

// 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 (
	// ProvisionerPluginServicePingProcedure is the fully-qualified name of the
	// ProvisionerPluginService's Ping RPC.
	ProvisionerPluginServicePingProcedure = "/xyz.block.ftl.provisioner.v1.ProvisionerPluginService/Ping"
	// ProvisionerPluginServiceProvisionProcedure is the fully-qualified name of the
	// ProvisionerPluginService's Provision RPC.
	ProvisionerPluginServiceProvisionProcedure = "/xyz.block.ftl.provisioner.v1.ProvisionerPluginService/Provision"
	// ProvisionerPluginServiceStatusProcedure is the fully-qualified name of the
	// ProvisionerPluginService's Status RPC.
	ProvisionerPluginServiceStatusProcedure = "/xyz.block.ftl.provisioner.v1.ProvisionerPluginService/Status"
)

// ProvisionerPluginServiceClient is a client for the
// xyz.block.ftl.provisioner.v1.ProvisionerPluginService service.
type ProvisionerPluginServiceClient interface {
	Ping(context.Context, *connect.Request[v1.PingRequest]) (*connect.Response[v1.PingResponse], error)
	Provision(context.Context, *connect.Request[v11.ProvisionRequest]) (*connect.Response[v11.ProvisionResponse], error)
	Status(context.Context, *connect.Request[v11.StatusRequest]) (*connect.Response[v11.StatusResponse], error)
}

// NewProvisionerPluginServiceClient constructs a client for the
// xyz.block.ftl.provisioner.v1.ProvisionerPluginService 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 NewProvisionerPluginServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) ProvisionerPluginServiceClient {
	baseURL = strings.TrimRight(baseURL, "/")
	provisionerPluginServiceMethods := v11.File_xyz_block_ftl_provisioner_v1_plugin_proto.Services().ByName("ProvisionerPluginService").Methods()
	return &provisionerPluginServiceClient{
		ping: connect.NewClient[v1.PingRequest, v1.PingResponse](
			httpClient,
			baseURL+ProvisionerPluginServicePingProcedure,
			connect.WithSchema(provisionerPluginServiceMethods.ByName("Ping")),
			connect.WithClientOptions(opts...),
		),
		provision: connect.NewClient[v11.ProvisionRequest, v11.ProvisionResponse](
			httpClient,
			baseURL+ProvisionerPluginServiceProvisionProcedure,
			connect.WithSchema(provisionerPluginServiceMethods.ByName("Provision")),
			connect.WithClientOptions(opts...),
		),
		status: connect.NewClient[v11.StatusRequest, v11.StatusResponse](
			httpClient,
			baseURL+ProvisionerPluginServiceStatusProcedure,
			connect.WithSchema(provisionerPluginServiceMethods.ByName("Status")),
			connect.WithClientOptions(opts...),
		),
	}
}

// provisionerPluginServiceClient implements ProvisionerPluginServiceClient.
type provisionerPluginServiceClient struct {
	ping      *connect.Client[v1.PingRequest, v1.PingResponse]
	provision *connect.Client[v11.ProvisionRequest, v11.ProvisionResponse]
	status    *connect.Client[v11.StatusRequest, v11.StatusResponse]
}

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

// Provision calls xyz.block.ftl.provisioner.v1.ProvisionerPluginService.Provision.
func (c *provisionerPluginServiceClient) Provision(ctx context.Context, req *connect.Request[v11.ProvisionRequest]) (*connect.Response[v11.ProvisionResponse], error) {
	return c.provision.CallUnary(ctx, req)
}

// Status calls xyz.block.ftl.provisioner.v1.ProvisionerPluginService.Status.
func (c *provisionerPluginServiceClient) Status(ctx context.Context, req *connect.Request[v11.StatusRequest]) (*connect.Response[v11.StatusResponse], error) {
	return c.status.CallUnary(ctx, req)
}

// ProvisionerPluginServiceHandler is an implementation of the
// xyz.block.ftl.provisioner.v1.ProvisionerPluginService service.
type ProvisionerPluginServiceHandler interface {
	Ping(context.Context, *connect.Request[v1.PingRequest]) (*connect.Response[v1.PingResponse], error)
	Provision(context.Context, *connect.Request[v11.ProvisionRequest]) (*connect.Response[v11.ProvisionResponse], error)
	Status(context.Context, *connect.Request[v11.StatusRequest]) (*connect.Response[v11.StatusResponse], error)
}

// NewProvisionerPluginServiceHandler 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 NewProvisionerPluginServiceHandler(svc ProvisionerPluginServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
	provisionerPluginServiceMethods := v11.File_xyz_block_ftl_provisioner_v1_plugin_proto.Services().ByName("ProvisionerPluginService").Methods()
	provisionerPluginServicePingHandler := connect.NewUnaryHandler(
		ProvisionerPluginServicePingProcedure,
		svc.Ping,
		connect.WithSchema(provisionerPluginServiceMethods.ByName("Ping")),
		connect.WithHandlerOptions(opts...),
	)
	provisionerPluginServiceProvisionHandler := connect.NewUnaryHandler(
		ProvisionerPluginServiceProvisionProcedure,
		svc.Provision,
		connect.WithSchema(provisionerPluginServiceMethods.ByName("Provision")),
		connect.WithHandlerOptions(opts...),
	)
	provisionerPluginServiceStatusHandler := connect.NewUnaryHandler(
		ProvisionerPluginServiceStatusProcedure,
		svc.Status,
		connect.WithSchema(provisionerPluginServiceMethods.ByName("Status")),
		connect.WithHandlerOptions(opts...),
	)
	return "/xyz.block.ftl.provisioner.v1.ProvisionerPluginService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		switch r.URL.Path {
		case ProvisionerPluginServicePingProcedure:
			provisionerPluginServicePingHandler.ServeHTTP(w, r)
		case ProvisionerPluginServiceProvisionProcedure:
			provisionerPluginServiceProvisionHandler.ServeHTTP(w, r)
		case ProvisionerPluginServiceStatusProcedure:
			provisionerPluginServiceStatusHandler.ServeHTTP(w, r)
		default:
			http.NotFound(w, r)
		}
	})
}

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

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

func (UnimplementedProvisionerPluginServiceHandler) Provision(context.Context, *connect.Request[v11.ProvisionRequest]) (*connect.Response[v11.ProvisionResponse], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("xyz.block.ftl.provisioner.v1.ProvisionerPluginService.Provision is not implemented"))
}

func (UnimplementedProvisionerPluginServiceHandler) Status(context.Context, *connect.Request[v11.StatusRequest]) (*connect.Response[v11.StatusResponse], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("xyz.block.ftl.provisioner.v1.ProvisionerPluginService.Status is not implemented"))
}
