// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc             v6.30.2
// source: api.proto

package broker

import (
	context "context"
	grpc "google.golang.org/grpc"
	codes "google.golang.org/grpc/codes"
	status "google.golang.org/grpc/status"
)

// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9

const (
	API_SubscribeToX509SVID_FullMethodName    = "/spiffe.broker.API/SubscribeToX509SVID"
	API_SubscribeToX509Bundles_FullMethodName = "/spiffe.broker.API/SubscribeToX509Bundles"
	API_FetchJWTSVID_FullMethodName           = "/spiffe.broker.API/FetchJWTSVID"
	API_SubscribeToJWTBundles_FullMethodName  = "/spiffe.broker.API/SubscribeToJWTBundles"
)

// APIClient is the client API for API service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type APIClient interface {
	// Fetch X.509-SVIDs for all SPIFFE identities the referenced workload is
	// entitled to, as well as related information like trust bundles. As this
	// information changes, subsequent messages will be streamed from the server.
	SubscribeToX509SVID(ctx context.Context, in *SubscribeToX509SVIDRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[SubscribeToX509SVIDResponse], error)
	// Fetch trust bundles of the referenced workload. Useful in situations that
	// only need to validate SVIDs without obtaining an SVID for themself. As this
	// information changes, subsequent messages will be streamed from the server.
	SubscribeToX509Bundles(ctx context.Context, in *SubscribeToX509BundlesRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[SubscribeToX509BundlesResponse], error)
	// Fetch JWT-SVIDs for all SPIFFE identities the referenced workload is
	// entitled to, for the requested audience. If an optional SPIFFE ID is
	// requested, only the JWT-SVID for that SPIFFE ID is returned.
	FetchJWTSVID(ctx context.Context, in *FetchJWTSVIDRequest, opts ...grpc.CallOption) (*FetchJWTSVIDResponse, error)
	// Fetches the JWT bundles, formatted as JWKS documents, keyed by the
	// SPIFFE ID of the trust domain. As this information changes, subsequent
	// messages will be streamed from the server.
	SubscribeToJWTBundles(ctx context.Context, in *SubscribeToJWTBundlesRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[SubscribeToJWTBundlesResponse], error)
}

type aPIClient struct {
	cc grpc.ClientConnInterface
}

func NewAPIClient(cc grpc.ClientConnInterface) APIClient {
	return &aPIClient{cc}
}

func (c *aPIClient) SubscribeToX509SVID(ctx context.Context, in *SubscribeToX509SVIDRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[SubscribeToX509SVIDResponse], error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	stream, err := c.cc.NewStream(ctx, &API_ServiceDesc.Streams[0], API_SubscribeToX509SVID_FullMethodName, cOpts...)
	if err != nil {
		return nil, err
	}
	x := &grpc.GenericClientStream[SubscribeToX509SVIDRequest, SubscribeToX509SVIDResponse]{ClientStream: stream}
	if err := x.ClientStream.SendMsg(in); err != nil {
		return nil, err
	}
	if err := x.ClientStream.CloseSend(); err != nil {
		return nil, err
	}
	return x, nil
}

// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type API_SubscribeToX509SVIDClient = grpc.ServerStreamingClient[SubscribeToX509SVIDResponse]

func (c *aPIClient) SubscribeToX509Bundles(ctx context.Context, in *SubscribeToX509BundlesRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[SubscribeToX509BundlesResponse], error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	stream, err := c.cc.NewStream(ctx, &API_ServiceDesc.Streams[1], API_SubscribeToX509Bundles_FullMethodName, cOpts...)
	if err != nil {
		return nil, err
	}
	x := &grpc.GenericClientStream[SubscribeToX509BundlesRequest, SubscribeToX509BundlesResponse]{ClientStream: stream}
	if err := x.ClientStream.SendMsg(in); err != nil {
		return nil, err
	}
	if err := x.ClientStream.CloseSend(); err != nil {
		return nil, err
	}
	return x, nil
}

// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type API_SubscribeToX509BundlesClient = grpc.ServerStreamingClient[SubscribeToX509BundlesResponse]

func (c *aPIClient) FetchJWTSVID(ctx context.Context, in *FetchJWTSVIDRequest, opts ...grpc.CallOption) (*FetchJWTSVIDResponse, error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	out := new(FetchJWTSVIDResponse)
	err := c.cc.Invoke(ctx, API_FetchJWTSVID_FullMethodName, in, out, cOpts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *aPIClient) SubscribeToJWTBundles(ctx context.Context, in *SubscribeToJWTBundlesRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[SubscribeToJWTBundlesResponse], error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	stream, err := c.cc.NewStream(ctx, &API_ServiceDesc.Streams[2], API_SubscribeToJWTBundles_FullMethodName, cOpts...)
	if err != nil {
		return nil, err
	}
	x := &grpc.GenericClientStream[SubscribeToJWTBundlesRequest, SubscribeToJWTBundlesResponse]{ClientStream: stream}
	if err := x.ClientStream.SendMsg(in); err != nil {
		return nil, err
	}
	if err := x.ClientStream.CloseSend(); err != nil {
		return nil, err
	}
	return x, nil
}

// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type API_SubscribeToJWTBundlesClient = grpc.ServerStreamingClient[SubscribeToJWTBundlesResponse]

// APIServer is the server API for API service.
// All implementations must embed UnimplementedAPIServer
// for forward compatibility.
type APIServer interface {
	// Fetch X.509-SVIDs for all SPIFFE identities the referenced workload is
	// entitled to, as well as related information like trust bundles. As this
	// information changes, subsequent messages will be streamed from the server.
	SubscribeToX509SVID(*SubscribeToX509SVIDRequest, grpc.ServerStreamingServer[SubscribeToX509SVIDResponse]) error
	// Fetch trust bundles of the referenced workload. Useful in situations that
	// only need to validate SVIDs without obtaining an SVID for themself. As this
	// information changes, subsequent messages will be streamed from the server.
	SubscribeToX509Bundles(*SubscribeToX509BundlesRequest, grpc.ServerStreamingServer[SubscribeToX509BundlesResponse]) error
	// Fetch JWT-SVIDs for all SPIFFE identities the referenced workload is
	// entitled to, for the requested audience. If an optional SPIFFE ID is
	// requested, only the JWT-SVID for that SPIFFE ID is returned.
	FetchJWTSVID(context.Context, *FetchJWTSVIDRequest) (*FetchJWTSVIDResponse, error)
	// Fetches the JWT bundles, formatted as JWKS documents, keyed by the
	// SPIFFE ID of the trust domain. As this information changes, subsequent
	// messages will be streamed from the server.
	SubscribeToJWTBundles(*SubscribeToJWTBundlesRequest, grpc.ServerStreamingServer[SubscribeToJWTBundlesResponse]) error
	mustEmbedUnimplementedAPIServer()
}

// UnimplementedAPIServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedAPIServer struct{}

func (UnimplementedAPIServer) SubscribeToX509SVID(*SubscribeToX509SVIDRequest, grpc.ServerStreamingServer[SubscribeToX509SVIDResponse]) error {
	return status.Errorf(codes.Unimplemented, "method SubscribeToX509SVID not implemented")
}
func (UnimplementedAPIServer) SubscribeToX509Bundles(*SubscribeToX509BundlesRequest, grpc.ServerStreamingServer[SubscribeToX509BundlesResponse]) error {
	return status.Errorf(codes.Unimplemented, "method SubscribeToX509Bundles not implemented")
}
func (UnimplementedAPIServer) FetchJWTSVID(context.Context, *FetchJWTSVIDRequest) (*FetchJWTSVIDResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method FetchJWTSVID not implemented")
}
func (UnimplementedAPIServer) SubscribeToJWTBundles(*SubscribeToJWTBundlesRequest, grpc.ServerStreamingServer[SubscribeToJWTBundlesResponse]) error {
	return status.Errorf(codes.Unimplemented, "method SubscribeToJWTBundles not implemented")
}
func (UnimplementedAPIServer) mustEmbedUnimplementedAPIServer() {}
func (UnimplementedAPIServer) testEmbeddedByValue()             {}

// UnsafeAPIServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to APIServer will
// result in compilation errors.
type UnsafeAPIServer interface {
	mustEmbedUnimplementedAPIServer()
}

func RegisterAPIServer(s grpc.ServiceRegistrar, srv APIServer) {
	// If the following call pancis, it indicates UnimplementedAPIServer was
	// embedded by pointer and is nil.  This will cause panics if an
	// unimplemented method is ever invoked, so we test this at initialization
	// time to prevent it from happening at runtime later due to I/O.
	if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
		t.testEmbeddedByValue()
	}
	s.RegisterService(&API_ServiceDesc, srv)
}

func _API_SubscribeToX509SVID_Handler(srv interface{}, stream grpc.ServerStream) error {
	m := new(SubscribeToX509SVIDRequest)
	if err := stream.RecvMsg(m); err != nil {
		return err
	}
	return srv.(APIServer).SubscribeToX509SVID(m, &grpc.GenericServerStream[SubscribeToX509SVIDRequest, SubscribeToX509SVIDResponse]{ServerStream: stream})
}

// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type API_SubscribeToX509SVIDServer = grpc.ServerStreamingServer[SubscribeToX509SVIDResponse]

func _API_SubscribeToX509Bundles_Handler(srv interface{}, stream grpc.ServerStream) error {
	m := new(SubscribeToX509BundlesRequest)
	if err := stream.RecvMsg(m); err != nil {
		return err
	}
	return srv.(APIServer).SubscribeToX509Bundles(m, &grpc.GenericServerStream[SubscribeToX509BundlesRequest, SubscribeToX509BundlesResponse]{ServerStream: stream})
}

// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type API_SubscribeToX509BundlesServer = grpc.ServerStreamingServer[SubscribeToX509BundlesResponse]

func _API_FetchJWTSVID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(FetchJWTSVIDRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(APIServer).FetchJWTSVID(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: API_FetchJWTSVID_FullMethodName,
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(APIServer).FetchJWTSVID(ctx, req.(*FetchJWTSVIDRequest))
	}
	return interceptor(ctx, in, info, handler)
}

func _API_SubscribeToJWTBundles_Handler(srv interface{}, stream grpc.ServerStream) error {
	m := new(SubscribeToJWTBundlesRequest)
	if err := stream.RecvMsg(m); err != nil {
		return err
	}
	return srv.(APIServer).SubscribeToJWTBundles(m, &grpc.GenericServerStream[SubscribeToJWTBundlesRequest, SubscribeToJWTBundlesResponse]{ServerStream: stream})
}

// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type API_SubscribeToJWTBundlesServer = grpc.ServerStreamingServer[SubscribeToJWTBundlesResponse]

// API_ServiceDesc is the grpc.ServiceDesc for API service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var API_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "spiffe.broker.API",
	HandlerType: (*APIServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "FetchJWTSVID",
			Handler:    _API_FetchJWTSVID_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "SubscribeToX509SVID",
			Handler:       _API_SubscribeToX509SVID_Handler,
			ServerStreams: true,
		},
		{
			StreamName:    "SubscribeToX509Bundles",
			Handler:       _API_SubscribeToX509Bundles_Handler,
			ServerStreams: true,
		},
		{
			StreamName:    "SubscribeToJWTBundles",
			Handler:       _API_SubscribeToJWTBundles_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "api.proto",
}
