// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.6.1
// - protoc             v5.29.3
// source: cilium/api/npds.proto

package cilium

import (
	context "context"
	v3 "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3"
	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 (
	NetworkPolicyDiscoveryService_StreamNetworkPolicies_FullMethodName = "/cilium.NetworkPolicyDiscoveryService/StreamNetworkPolicies"
	NetworkPolicyDiscoveryService_FetchNetworkPolicies_FullMethodName  = "/cilium.NetworkPolicyDiscoveryService/FetchNetworkPolicies"
)

// NetworkPolicyDiscoveryServiceClient is the client API for NetworkPolicyDiscoveryService 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.
//
// Each resource name is a network policy identifier.
type NetworkPolicyDiscoveryServiceClient interface {
	StreamNetworkPolicies(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[v3.DiscoveryRequest, v3.DiscoveryResponse], error)
	FetchNetworkPolicies(ctx context.Context, in *v3.DiscoveryRequest, opts ...grpc.CallOption) (*v3.DiscoveryResponse, error)
}

type networkPolicyDiscoveryServiceClient struct {
	cc grpc.ClientConnInterface
}

func NewNetworkPolicyDiscoveryServiceClient(cc grpc.ClientConnInterface) NetworkPolicyDiscoveryServiceClient {
	return &networkPolicyDiscoveryServiceClient{cc}
}

func (c *networkPolicyDiscoveryServiceClient) StreamNetworkPolicies(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[v3.DiscoveryRequest, v3.DiscoveryResponse], error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	stream, err := c.cc.NewStream(ctx, &NetworkPolicyDiscoveryService_ServiceDesc.Streams[0], NetworkPolicyDiscoveryService_StreamNetworkPolicies_FullMethodName, cOpts...)
	if err != nil {
		return nil, err
	}
	x := &grpc.GenericClientStream[v3.DiscoveryRequest, v3.DiscoveryResponse]{ClientStream: stream}
	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 NetworkPolicyDiscoveryService_StreamNetworkPoliciesClient = grpc.BidiStreamingClient[v3.DiscoveryRequest, v3.DiscoveryResponse]

func (c *networkPolicyDiscoveryServiceClient) FetchNetworkPolicies(ctx context.Context, in *v3.DiscoveryRequest, opts ...grpc.CallOption) (*v3.DiscoveryResponse, error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	out := new(v3.DiscoveryResponse)
	err := c.cc.Invoke(ctx, NetworkPolicyDiscoveryService_FetchNetworkPolicies_FullMethodName, in, out, cOpts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

// NetworkPolicyDiscoveryServiceServer is the server API for NetworkPolicyDiscoveryService service.
// All implementations must embed UnimplementedNetworkPolicyDiscoveryServiceServer
// for forward compatibility.
//
// Each resource name is a network policy identifier.
type NetworkPolicyDiscoveryServiceServer interface {
	StreamNetworkPolicies(grpc.BidiStreamingServer[v3.DiscoveryRequest, v3.DiscoveryResponse]) error
	FetchNetworkPolicies(context.Context, *v3.DiscoveryRequest) (*v3.DiscoveryResponse, error)
	mustEmbedUnimplementedNetworkPolicyDiscoveryServiceServer()
}

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

func (UnimplementedNetworkPolicyDiscoveryServiceServer) StreamNetworkPolicies(grpc.BidiStreamingServer[v3.DiscoveryRequest, v3.DiscoveryResponse]) error {
	return status.Error(codes.Unimplemented, "method StreamNetworkPolicies not implemented")
}
func (UnimplementedNetworkPolicyDiscoveryServiceServer) FetchNetworkPolicies(context.Context, *v3.DiscoveryRequest) (*v3.DiscoveryResponse, error) {
	return nil, status.Error(codes.Unimplemented, "method FetchNetworkPolicies not implemented")
}
func (UnimplementedNetworkPolicyDiscoveryServiceServer) mustEmbedUnimplementedNetworkPolicyDiscoveryServiceServer() {
}
func (UnimplementedNetworkPolicyDiscoveryServiceServer) testEmbeddedByValue() {}

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

func RegisterNetworkPolicyDiscoveryServiceServer(s grpc.ServiceRegistrar, srv NetworkPolicyDiscoveryServiceServer) {
	// If the following call panics, it indicates UnimplementedNetworkPolicyDiscoveryServiceServer 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(&NetworkPolicyDiscoveryService_ServiceDesc, srv)
}

func _NetworkPolicyDiscoveryService_StreamNetworkPolicies_Handler(srv interface{}, stream grpc.ServerStream) error {
	return srv.(NetworkPolicyDiscoveryServiceServer).StreamNetworkPolicies(&grpc.GenericServerStream[v3.DiscoveryRequest, v3.DiscoveryResponse]{ServerStream: stream})
}

// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type NetworkPolicyDiscoveryService_StreamNetworkPoliciesServer = grpc.BidiStreamingServer[v3.DiscoveryRequest, v3.DiscoveryResponse]

func _NetworkPolicyDiscoveryService_FetchNetworkPolicies_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(v3.DiscoveryRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(NetworkPolicyDiscoveryServiceServer).FetchNetworkPolicies(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: NetworkPolicyDiscoveryService_FetchNetworkPolicies_FullMethodName,
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(NetworkPolicyDiscoveryServiceServer).FetchNetworkPolicies(ctx, req.(*v3.DiscoveryRequest))
	}
	return interceptor(ctx, in, info, handler)
}

// NetworkPolicyDiscoveryService_ServiceDesc is the grpc.ServiceDesc for NetworkPolicyDiscoveryService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var NetworkPolicyDiscoveryService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "cilium.NetworkPolicyDiscoveryService",
	HandlerType: (*NetworkPolicyDiscoveryServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "FetchNetworkPolicies",
			Handler:    _NetworkPolicyDiscoveryService_FetchNetworkPolicies_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "StreamNetworkPolicies",
			Handler:       _NetworkPolicyDiscoveryService_StreamNetworkPolicies_Handler,
			ServerStreams: true,
			ClientStreams: true,
		},
	},
	Metadata: "cilium/api/npds.proto",
}
