// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium

// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc             v6.32.1
// source: standalone-dns-proxy/standalone-dns-proxy.proto

package standalonednsproxy

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 (
	FQDNData_StreamPolicyState_FullMethodName    = "/standalonednsproxy.FQDNData/StreamPolicyState"
	FQDNData_UpdateMappingRequest_FullMethodName = "/standalonednsproxy.FQDNData/UpdateMappingRequest"
)

// FQDNDataClient is the client API for FQDNData 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.
//
// Cilium agent runs the FQDNData service and Standalone DNS proxy connects to it to get the DNS Policy rules.
// Standalone DNS proxy sends FQDN-IP mapping updates to Cilium Agent.
// CFP: https://github.com/cilium/design-cfps/pull/54
type FQDNDataClient interface {
	// StreamPolicyState is used by the Standalone DNS proxy to get the current policy state.
	// Policy state includes the DNS policies and the identity to IP mapping.
	// Cilium agent will stream DNS policies state to Standalone DNS proxy.
	// In case of any client side error, cilium agent will cancel the stream and SDP will have to re-subscribe.
	// In case of any server side error, cilium agent will send an error response and SDP will have to re-subscribe.
	StreamPolicyState(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[PolicyStateResponse, PolicyState], error)
	// UpdateMappingRequest is used by the Standalone DNS proxy to update ciliium agent with FQDN-IP mappings which in turn update L3/L4 policy maps.
	// In case of any error, SDP will either retry the connection if the error is server side or will error out.
	// Note: In case of concurrent updates, since this is called in a callback(notifyDNSMsg) from the DNS server it follows the same behavior as
	// the inbuilt dns proxy in cilium.
	UpdateMappingRequest(ctx context.Context, in *FQDNMapping, opts ...grpc.CallOption) (*UpdateMappingResponse, error)
}

type fQDNDataClient struct {
	cc grpc.ClientConnInterface
}

func NewFQDNDataClient(cc grpc.ClientConnInterface) FQDNDataClient {
	return &fQDNDataClient{cc}
}

func (c *fQDNDataClient) StreamPolicyState(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[PolicyStateResponse, PolicyState], error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	stream, err := c.cc.NewStream(ctx, &FQDNData_ServiceDesc.Streams[0], FQDNData_StreamPolicyState_FullMethodName, cOpts...)
	if err != nil {
		return nil, err
	}
	x := &grpc.GenericClientStream[PolicyStateResponse, PolicyState]{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 FQDNData_StreamPolicyStateClient = grpc.BidiStreamingClient[PolicyStateResponse, PolicyState]

func (c *fQDNDataClient) UpdateMappingRequest(ctx context.Context, in *FQDNMapping, opts ...grpc.CallOption) (*UpdateMappingResponse, error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	out := new(UpdateMappingResponse)
	err := c.cc.Invoke(ctx, FQDNData_UpdateMappingRequest_FullMethodName, in, out, cOpts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

// FQDNDataServer is the server API for FQDNData service.
// All implementations should embed UnimplementedFQDNDataServer
// for forward compatibility.
//
// Cilium agent runs the FQDNData service and Standalone DNS proxy connects to it to get the DNS Policy rules.
// Standalone DNS proxy sends FQDN-IP mapping updates to Cilium Agent.
// CFP: https://github.com/cilium/design-cfps/pull/54
type FQDNDataServer interface {
	// StreamPolicyState is used by the Standalone DNS proxy to get the current policy state.
	// Policy state includes the DNS policies and the identity to IP mapping.
	// Cilium agent will stream DNS policies state to Standalone DNS proxy.
	// In case of any client side error, cilium agent will cancel the stream and SDP will have to re-subscribe.
	// In case of any server side error, cilium agent will send an error response and SDP will have to re-subscribe.
	StreamPolicyState(grpc.BidiStreamingServer[PolicyStateResponse, PolicyState]) error
	// UpdateMappingRequest is used by the Standalone DNS proxy to update ciliium agent with FQDN-IP mappings which in turn update L3/L4 policy maps.
	// In case of any error, SDP will either retry the connection if the error is server side or will error out.
	// Note: In case of concurrent updates, since this is called in a callback(notifyDNSMsg) from the DNS server it follows the same behavior as
	// the inbuilt dns proxy in cilium.
	UpdateMappingRequest(context.Context, *FQDNMapping) (*UpdateMappingResponse, error)
}

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

func (UnimplementedFQDNDataServer) StreamPolicyState(grpc.BidiStreamingServer[PolicyStateResponse, PolicyState]) error {
	return status.Errorf(codes.Unimplemented, "method StreamPolicyState not implemented")
}
func (UnimplementedFQDNDataServer) UpdateMappingRequest(context.Context, *FQDNMapping) (*UpdateMappingResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method UpdateMappingRequest not implemented")
}
func (UnimplementedFQDNDataServer) testEmbeddedByValue() {}

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

func RegisterFQDNDataServer(s grpc.ServiceRegistrar, srv FQDNDataServer) {
	// If the following call pancis, it indicates UnimplementedFQDNDataServer 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(&FQDNData_ServiceDesc, srv)
}

func _FQDNData_StreamPolicyState_Handler(srv interface{}, stream grpc.ServerStream) error {
	return srv.(FQDNDataServer).StreamPolicyState(&grpc.GenericServerStream[PolicyStateResponse, PolicyState]{ServerStream: stream})
}

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

func _FQDNData_UpdateMappingRequest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(FQDNMapping)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(FQDNDataServer).UpdateMappingRequest(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: FQDNData_UpdateMappingRequest_FullMethodName,
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(FQDNDataServer).UpdateMappingRequest(ctx, req.(*FQDNMapping))
	}
	return interceptor(ctx, in, info, handler)
}

// FQDNData_ServiceDesc is the grpc.ServiceDesc for FQDNData service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var FQDNData_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "standalonednsproxy.FQDNData",
	HandlerType: (*FQDNDataServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "UpdateMappingRequest",
			Handler:    _FQDNData_UpdateMappingRequest_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "StreamPolicyState",
			Handler:       _FQDNData_StreamPolicyState_Handler,
			ServerStreams: true,
			ClientStreams: true,
		},
	},
	Metadata: "standalone-dns-proxy/standalone-dns-proxy.proto",
}
