// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.6.1
// - protoc             (unknown)
// source: machine/lifecycle.proto

package machine

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 (
	LifecycleService_Install_FullMethodName = "/machine.LifecycleService/Install"
	LifecycleService_Upgrade_FullMethodName = "/machine.LifecycleService/Upgrade"
)

// LifecycleServiceClient is the client API for LifecycleService 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 LifecycleService handles installation and upgrade operations.
type LifecycleServiceClient interface {
	// Install Talos to disk.
	// The RPC should fail if the Talos is already installed on the target disk.
	Install(ctx context.Context, in *LifecycleServiceInstallRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[LifecycleServiceInstallResponse], error)
	// Upgrade Talos to a new version.
	// The RPC should fail if Talos is not already installed on the target disk.
	Upgrade(ctx context.Context, in *LifecycleServiceUpgradeRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[LifecycleServiceUpgradeResponse], error)
}

type lifecycleServiceClient struct {
	cc grpc.ClientConnInterface
}

func NewLifecycleServiceClient(cc grpc.ClientConnInterface) LifecycleServiceClient {
	return &lifecycleServiceClient{cc}
}

func (c *lifecycleServiceClient) Install(ctx context.Context, in *LifecycleServiceInstallRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[LifecycleServiceInstallResponse], error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	stream, err := c.cc.NewStream(ctx, &LifecycleService_ServiceDesc.Streams[0], LifecycleService_Install_FullMethodName, cOpts...)
	if err != nil {
		return nil, err
	}
	x := &grpc.GenericClientStream[LifecycleServiceInstallRequest, LifecycleServiceInstallResponse]{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 LifecycleService_InstallClient = grpc.ServerStreamingClient[LifecycleServiceInstallResponse]

func (c *lifecycleServiceClient) Upgrade(ctx context.Context, in *LifecycleServiceUpgradeRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[LifecycleServiceUpgradeResponse], error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	stream, err := c.cc.NewStream(ctx, &LifecycleService_ServiceDesc.Streams[1], LifecycleService_Upgrade_FullMethodName, cOpts...)
	if err != nil {
		return nil, err
	}
	x := &grpc.GenericClientStream[LifecycleServiceUpgradeRequest, LifecycleServiceUpgradeResponse]{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 LifecycleService_UpgradeClient = grpc.ServerStreamingClient[LifecycleServiceUpgradeResponse]

// LifecycleServiceServer is the server API for LifecycleService service.
// All implementations must embed UnimplementedLifecycleServiceServer
// for forward compatibility.
//
// The LifecycleService handles installation and upgrade operations.
type LifecycleServiceServer interface {
	// Install Talos to disk.
	// The RPC should fail if the Talos is already installed on the target disk.
	Install(*LifecycleServiceInstallRequest, grpc.ServerStreamingServer[LifecycleServiceInstallResponse]) error
	// Upgrade Talos to a new version.
	// The RPC should fail if Talos is not already installed on the target disk.
	Upgrade(*LifecycleServiceUpgradeRequest, grpc.ServerStreamingServer[LifecycleServiceUpgradeResponse]) error
	mustEmbedUnimplementedLifecycleServiceServer()
}

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

func (UnimplementedLifecycleServiceServer) Install(*LifecycleServiceInstallRequest, grpc.ServerStreamingServer[LifecycleServiceInstallResponse]) error {
	return status.Error(codes.Unimplemented, "method Install not implemented")
}
func (UnimplementedLifecycleServiceServer) Upgrade(*LifecycleServiceUpgradeRequest, grpc.ServerStreamingServer[LifecycleServiceUpgradeResponse]) error {
	return status.Error(codes.Unimplemented, "method Upgrade not implemented")
}
func (UnimplementedLifecycleServiceServer) mustEmbedUnimplementedLifecycleServiceServer() {}
func (UnimplementedLifecycleServiceServer) testEmbeddedByValue()                          {}

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

func RegisterLifecycleServiceServer(s grpc.ServiceRegistrar, srv LifecycleServiceServer) {
	// If the following call panics, it indicates UnimplementedLifecycleServiceServer 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(&LifecycleService_ServiceDesc, srv)
}

func _LifecycleService_Install_Handler(srv interface{}, stream grpc.ServerStream) error {
	m := new(LifecycleServiceInstallRequest)
	if err := stream.RecvMsg(m); err != nil {
		return err
	}
	return srv.(LifecycleServiceServer).Install(m, &grpc.GenericServerStream[LifecycleServiceInstallRequest, LifecycleServiceInstallResponse]{ServerStream: stream})
}

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

func _LifecycleService_Upgrade_Handler(srv interface{}, stream grpc.ServerStream) error {
	m := new(LifecycleServiceUpgradeRequest)
	if err := stream.RecvMsg(m); err != nil {
		return err
	}
	return srv.(LifecycleServiceServer).Upgrade(m, &grpc.GenericServerStream[LifecycleServiceUpgradeRequest, LifecycleServiceUpgradeResponse]{ServerStream: stream})
}

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

// LifecycleService_ServiceDesc is the grpc.ServiceDesc for LifecycleService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var LifecycleService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "machine.LifecycleService",
	HandlerType: (*LifecycleServiceServer)(nil),
	Methods:     []grpc.MethodDesc{},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Install",
			Handler:       _LifecycleService_Install_Handler,
			ServerStreams: true,
		},
		{
			StreamName:    "Upgrade",
			Handler:       _LifecycleService_Upgrade_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "machine/lifecycle.proto",
}
