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

package delegatedidentityv1

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 (
	DelegatedIdentity_SubscribeToX509SVIDs_FullMethodName   = "/spire.api.agent.delegatedidentity.v1.DelegatedIdentity/SubscribeToX509SVIDs"
	DelegatedIdentity_SubscribeToX509Bundles_FullMethodName = "/spire.api.agent.delegatedidentity.v1.DelegatedIdentity/SubscribeToX509Bundles"
	DelegatedIdentity_FetchJWTSVIDs_FullMethodName          = "/spire.api.agent.delegatedidentity.v1.DelegatedIdentity/FetchJWTSVIDs"
	DelegatedIdentity_SubscribeToJWTBundles_FullMethodName  = "/spire.api.agent.delegatedidentity.v1.DelegatedIdentity/SubscribeToJWTBundles"
)

// DelegatedIdentityClient is the client API for DelegatedIdentity 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.
//
// The delegatedIdentity service provides an interface to get the SVIDs of other
// workloads on the host. This service is intended for use cases where a process
// (different than the workload one) should access the workload's SVID to
// perform actions on behalf of the workload. One example of is using a single
// node instance of Envoy that upgrades TCP connections for different processes
// running in such a node.
//
// The caller must be local and its identity must be listed in the allowed
// clients on the spire-agent configuration.
type DelegatedIdentityClient interface {
	// Subscribe to get X.509-SVIDs for workloads that match the given selectors.
	// The lifetime of the subscription aligns to the lifetime of the stream.
	SubscribeToX509SVIDs(ctx context.Context, in *SubscribeToX509SVIDsRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[SubscribeToX509SVIDsResponse], error)
	// Subscribe to get local and all federated bundles.
	// The lifetime of the subscription aligns to the lifetime of the stream.
	SubscribeToX509Bundles(ctx context.Context, in *SubscribeToX509BundlesRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[SubscribeToX509BundlesResponse], error)
	// Fetch JWT-SVIDs for workloads that match the given selectors, and
	// for the requested audience.
	FetchJWTSVIDs(ctx context.Context, in *FetchJWTSVIDsRequest, opts ...grpc.CallOption) (*FetchJWTSVIDsResponse, error)
	// Subscribe to get local and all federated JWKS bundles.
	// The lifetime of the subscription aligns to the lifetime of the stream.
	SubscribeToJWTBundles(ctx context.Context, in *SubscribeToJWTBundlesRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[SubscribeToJWTBundlesResponse], error)
}

type delegatedIdentityClient struct {
	cc grpc.ClientConnInterface
}

func NewDelegatedIdentityClient(cc grpc.ClientConnInterface) DelegatedIdentityClient {
	return &delegatedIdentityClient{cc}
}

func (c *delegatedIdentityClient) SubscribeToX509SVIDs(ctx context.Context, in *SubscribeToX509SVIDsRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[SubscribeToX509SVIDsResponse], error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	stream, err := c.cc.NewStream(ctx, &DelegatedIdentity_ServiceDesc.Streams[0], DelegatedIdentity_SubscribeToX509SVIDs_FullMethodName, cOpts...)
	if err != nil {
		return nil, err
	}
	x := &grpc.GenericClientStream[SubscribeToX509SVIDsRequest, SubscribeToX509SVIDsResponse]{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 DelegatedIdentity_SubscribeToX509SVIDsClient = grpc.ServerStreamingClient[SubscribeToX509SVIDsResponse]

func (c *delegatedIdentityClient) 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, &DelegatedIdentity_ServiceDesc.Streams[1], DelegatedIdentity_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 DelegatedIdentity_SubscribeToX509BundlesClient = grpc.ServerStreamingClient[SubscribeToX509BundlesResponse]

func (c *delegatedIdentityClient) FetchJWTSVIDs(ctx context.Context, in *FetchJWTSVIDsRequest, opts ...grpc.CallOption) (*FetchJWTSVIDsResponse, error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	out := new(FetchJWTSVIDsResponse)
	err := c.cc.Invoke(ctx, DelegatedIdentity_FetchJWTSVIDs_FullMethodName, in, out, cOpts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *delegatedIdentityClient) 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, &DelegatedIdentity_ServiceDesc.Streams[2], DelegatedIdentity_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 DelegatedIdentity_SubscribeToJWTBundlesClient = grpc.ServerStreamingClient[SubscribeToJWTBundlesResponse]

// DelegatedIdentityServer is the server API for DelegatedIdentity service.
// All implementations must embed UnimplementedDelegatedIdentityServer
// for forward compatibility.
//
// The delegatedIdentity service provides an interface to get the SVIDs of other
// workloads on the host. This service is intended for use cases where a process
// (different than the workload one) should access the workload's SVID to
// perform actions on behalf of the workload. One example of is using a single
// node instance of Envoy that upgrades TCP connections for different processes
// running in such a node.
//
// The caller must be local and its identity must be listed in the allowed
// clients on the spire-agent configuration.
type DelegatedIdentityServer interface {
	// Subscribe to get X.509-SVIDs for workloads that match the given selectors.
	// The lifetime of the subscription aligns to the lifetime of the stream.
	SubscribeToX509SVIDs(*SubscribeToX509SVIDsRequest, grpc.ServerStreamingServer[SubscribeToX509SVIDsResponse]) error
	// Subscribe to get local and all federated bundles.
	// The lifetime of the subscription aligns to the lifetime of the stream.
	SubscribeToX509Bundles(*SubscribeToX509BundlesRequest, grpc.ServerStreamingServer[SubscribeToX509BundlesResponse]) error
	// Fetch JWT-SVIDs for workloads that match the given selectors, and
	// for the requested audience.
	FetchJWTSVIDs(context.Context, *FetchJWTSVIDsRequest) (*FetchJWTSVIDsResponse, error)
	// Subscribe to get local and all federated JWKS bundles.
	// The lifetime of the subscription aligns to the lifetime of the stream.
	SubscribeToJWTBundles(*SubscribeToJWTBundlesRequest, grpc.ServerStreamingServer[SubscribeToJWTBundlesResponse]) error
	mustEmbedUnimplementedDelegatedIdentityServer()
}

// UnimplementedDelegatedIdentityServer 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 UnimplementedDelegatedIdentityServer struct{}

func (UnimplementedDelegatedIdentityServer) SubscribeToX509SVIDs(*SubscribeToX509SVIDsRequest, grpc.ServerStreamingServer[SubscribeToX509SVIDsResponse]) error {
	return status.Errorf(codes.Unimplemented, "method SubscribeToX509SVIDs not implemented")
}
func (UnimplementedDelegatedIdentityServer) SubscribeToX509Bundles(*SubscribeToX509BundlesRequest, grpc.ServerStreamingServer[SubscribeToX509BundlesResponse]) error {
	return status.Errorf(codes.Unimplemented, "method SubscribeToX509Bundles not implemented")
}
func (UnimplementedDelegatedIdentityServer) FetchJWTSVIDs(context.Context, *FetchJWTSVIDsRequest) (*FetchJWTSVIDsResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method FetchJWTSVIDs not implemented")
}
func (UnimplementedDelegatedIdentityServer) SubscribeToJWTBundles(*SubscribeToJWTBundlesRequest, grpc.ServerStreamingServer[SubscribeToJWTBundlesResponse]) error {
	return status.Errorf(codes.Unimplemented, "method SubscribeToJWTBundles not implemented")
}
func (UnimplementedDelegatedIdentityServer) mustEmbedUnimplementedDelegatedIdentityServer() {}
func (UnimplementedDelegatedIdentityServer) testEmbeddedByValue()                           {}

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

func RegisterDelegatedIdentityServer(s grpc.ServiceRegistrar, srv DelegatedIdentityServer) {
	// If the following call pancis, it indicates UnimplementedDelegatedIdentityServer 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(&DelegatedIdentity_ServiceDesc, srv)
}

func _DelegatedIdentity_SubscribeToX509SVIDs_Handler(srv interface{}, stream grpc.ServerStream) error {
	m := new(SubscribeToX509SVIDsRequest)
	if err := stream.RecvMsg(m); err != nil {
		return err
	}
	return srv.(DelegatedIdentityServer).SubscribeToX509SVIDs(m, &grpc.GenericServerStream[SubscribeToX509SVIDsRequest, SubscribeToX509SVIDsResponse]{ServerStream: stream})
}

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

func _DelegatedIdentity_SubscribeToX509Bundles_Handler(srv interface{}, stream grpc.ServerStream) error {
	m := new(SubscribeToX509BundlesRequest)
	if err := stream.RecvMsg(m); err != nil {
		return err
	}
	return srv.(DelegatedIdentityServer).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 DelegatedIdentity_SubscribeToX509BundlesServer = grpc.ServerStreamingServer[SubscribeToX509BundlesResponse]

func _DelegatedIdentity_FetchJWTSVIDs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(FetchJWTSVIDsRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(DelegatedIdentityServer).FetchJWTSVIDs(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: DelegatedIdentity_FetchJWTSVIDs_FullMethodName,
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(DelegatedIdentityServer).FetchJWTSVIDs(ctx, req.(*FetchJWTSVIDsRequest))
	}
	return interceptor(ctx, in, info, handler)
}

func _DelegatedIdentity_SubscribeToJWTBundles_Handler(srv interface{}, stream grpc.ServerStream) error {
	m := new(SubscribeToJWTBundlesRequest)
	if err := stream.RecvMsg(m); err != nil {
		return err
	}
	return srv.(DelegatedIdentityServer).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 DelegatedIdentity_SubscribeToJWTBundlesServer = grpc.ServerStreamingServer[SubscribeToJWTBundlesResponse]

// DelegatedIdentity_ServiceDesc is the grpc.ServiceDesc for DelegatedIdentity service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var DelegatedIdentity_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "spire.api.agent.delegatedidentity.v1.DelegatedIdentity",
	HandlerType: (*DelegatedIdentityServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "FetchJWTSVIDs",
			Handler:    _DelegatedIdentity_FetchJWTSVIDs_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "SubscribeToX509SVIDs",
			Handler:       _DelegatedIdentity_SubscribeToX509SVIDs_Handler,
			ServerStreams: true,
		},
		{
			StreamName:    "SubscribeToX509Bundles",
			Handler:       _DelegatedIdentity_SubscribeToX509Bundles_Handler,
			ServerStreams: true,
		},
		{
			StreamName:    "SubscribeToJWTBundles",
			Handler:       _DelegatedIdentity_SubscribeToJWTBundles_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "spire/api/agent/delegatedidentity/v1/delegatedidentity.proto",
}
