// Copyright (c) 2020 Arista Networks, Inc.
// Use of this source code is governed by the Apache License 2.0
// that can be found in the COPYING file.

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

// Package gNMIReverse defines a service specification that reverses the
// direction of the dial for gNMI Subscribe and gNMI Get.
//
// gNMI is a "dial-in" service, where the telemetry collector must make a
// connection to the gNMI target. With gNMIReverse, a client can be run
// alongside the gNMI target and then "dial-out" to a gNMIReverse server
// to send streaming data.

package gnmireverse

import (
	context "context"
	gnmi "github.com/openconfig/gnmi/proto/gnmi"
	grpc "google.golang.org/grpc"
	codes "google.golang.org/grpc/codes"
	status "google.golang.org/grpc/status"
	emptypb "google.golang.org/protobuf/types/known/emptypb"
)

// 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 (
	GNMIReverse_Publish_FullMethodName    = "/gnmireverse.gNMIReverse/Publish"
	GNMIReverse_PublishGet_FullMethodName = "/gnmireverse.gNMIReverse/PublishGet"
)

// GNMIReverseClient is the client API for GNMIReverse 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 GNMIReverseClient interface {
	// Publish allows the client to publish gNMI SubscribeResponses to the
	// collector server. The client is typically run alongside the gNMI target
	// and forwards SubscribeResponses from the target to the collector server.
	// The request is specified by the client.
	Publish(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[gnmi.SubscribeResponse, emptypb.Empty], error)
	// PublishGet allows the client to publish gNMI GetResponses to the
	// collector server. The client is typically run alongside the gNMI target
	// and forwards GetResponses from the target to the collector server.
	// The request and sample interval are specified by the client.
	PublishGet(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[gnmi.GetResponse, emptypb.Empty], error)
}

type gNMIReverseClient struct {
	cc grpc.ClientConnInterface
}

func NewGNMIReverseClient(cc grpc.ClientConnInterface) GNMIReverseClient {
	return &gNMIReverseClient{cc}
}

func (c *gNMIReverseClient) Publish(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[gnmi.SubscribeResponse, emptypb.Empty], error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	stream, err := c.cc.NewStream(ctx, &GNMIReverse_ServiceDesc.Streams[0], GNMIReverse_Publish_FullMethodName, cOpts...)
	if err != nil {
		return nil, err
	}
	x := &grpc.GenericClientStream[gnmi.SubscribeResponse, emptypb.Empty]{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 GNMIReverse_PublishClient = grpc.ClientStreamingClient[gnmi.SubscribeResponse, emptypb.Empty]

func (c *gNMIReverseClient) PublishGet(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[gnmi.GetResponse, emptypb.Empty], error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	stream, err := c.cc.NewStream(ctx, &GNMIReverse_ServiceDesc.Streams[1], GNMIReverse_PublishGet_FullMethodName, cOpts...)
	if err != nil {
		return nil, err
	}
	x := &grpc.GenericClientStream[gnmi.GetResponse, emptypb.Empty]{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 GNMIReverse_PublishGetClient = grpc.ClientStreamingClient[gnmi.GetResponse, emptypb.Empty]

// GNMIReverseServer is the server API for GNMIReverse service.
// All implementations must embed UnimplementedGNMIReverseServer
// for forward compatibility.
type GNMIReverseServer interface {
	// Publish allows the client to publish gNMI SubscribeResponses to the
	// collector server. The client is typically run alongside the gNMI target
	// and forwards SubscribeResponses from the target to the collector server.
	// The request is specified by the client.
	Publish(grpc.ClientStreamingServer[gnmi.SubscribeResponse, emptypb.Empty]) error
	// PublishGet allows the client to publish gNMI GetResponses to the
	// collector server. The client is typically run alongside the gNMI target
	// and forwards GetResponses from the target to the collector server.
	// The request and sample interval are specified by the client.
	PublishGet(grpc.ClientStreamingServer[gnmi.GetResponse, emptypb.Empty]) error
	mustEmbedUnimplementedGNMIReverseServer()
}

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

func (UnimplementedGNMIReverseServer) Publish(grpc.ClientStreamingServer[gnmi.SubscribeResponse, emptypb.Empty]) error {
	return status.Errorf(codes.Unimplemented, "method Publish not implemented")
}
func (UnimplementedGNMIReverseServer) PublishGet(grpc.ClientStreamingServer[gnmi.GetResponse, emptypb.Empty]) error {
	return status.Errorf(codes.Unimplemented, "method PublishGet not implemented")
}
func (UnimplementedGNMIReverseServer) mustEmbedUnimplementedGNMIReverseServer() {}
func (UnimplementedGNMIReverseServer) testEmbeddedByValue()                     {}

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

func RegisterGNMIReverseServer(s grpc.ServiceRegistrar, srv GNMIReverseServer) {
	// If the following call pancis, it indicates UnimplementedGNMIReverseServer 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(&GNMIReverse_ServiceDesc, srv)
}

func _GNMIReverse_Publish_Handler(srv interface{}, stream grpc.ServerStream) error {
	return srv.(GNMIReverseServer).Publish(&grpc.GenericServerStream[gnmi.SubscribeResponse, emptypb.Empty]{ServerStream: stream})
}

// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type GNMIReverse_PublishServer = grpc.ClientStreamingServer[gnmi.SubscribeResponse, emptypb.Empty]

func _GNMIReverse_PublishGet_Handler(srv interface{}, stream grpc.ServerStream) error {
	return srv.(GNMIReverseServer).PublishGet(&grpc.GenericServerStream[gnmi.GetResponse, emptypb.Empty]{ServerStream: stream})
}

// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type GNMIReverse_PublishGetServer = grpc.ClientStreamingServer[gnmi.GetResponse, emptypb.Empty]

// GNMIReverse_ServiceDesc is the grpc.ServiceDesc for GNMIReverse service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var GNMIReverse_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "gnmireverse.gNMIReverse",
	HandlerType: (*GNMIReverseServer)(nil),
	Methods:     []grpc.MethodDesc{},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Publish",
			Handler:       _GNMIReverse_Publish_Handler,
			ClientStreams: true,
		},
		{
			StreamName:    "PublishGet",
			Handler:       _GNMIReverse_PublishGet_Handler,
			ClientStreams: true,
		},
	},
	Metadata: "gnmireverse.proto",
}
