// Code generated by protoc-gen-micro. DO NOT EDIT.
// source: proto/notes.proto

package notes

import (
	fmt "fmt"
	proto "github.com/golang/protobuf/proto"
	math "math"
)

import (
	context "context"
	api "github.com/micro/micro/v3/service/api"
	client "github.com/micro/micro/v3/service/client"
	server "github.com/micro/micro/v3/service/server"
)

// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf

// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package

// Reference imports to suppress errors if they are not otherwise used.
var _ api.Endpoint
var _ context.Context
var _ client.Option
var _ server.Option

// Api Endpoints for Notes service

func NewNotesEndpoints() []*api.Endpoint {
	return []*api.Endpoint{}
}

// Client API for Notes service

type NotesService interface {
	List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error)
	Create(ctx context.Context, in *CreateRequest, opts ...client.CallOption) (*CreateResponse, error)
	Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error)
	Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error)
	Update(ctx context.Context, in *UpdateRequest, opts ...client.CallOption) (*UpdateResponse, error)
	Events(ctx context.Context, in *EventsRequest, opts ...client.CallOption) (Notes_EventsService, error)
}

type notesService struct {
	c    client.Client
	name string
}

func NewNotesService(name string, c client.Client) NotesService {
	return &notesService{
		c:    c,
		name: name,
	}
}

func (c *notesService) List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) {
	req := c.c.NewRequest(c.name, "Notes.List", in)
	out := new(ListResponse)
	err := c.c.Call(ctx, req, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *notesService) Create(ctx context.Context, in *CreateRequest, opts ...client.CallOption) (*CreateResponse, error) {
	req := c.c.NewRequest(c.name, "Notes.Create", in)
	out := new(CreateResponse)
	err := c.c.Call(ctx, req, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *notesService) Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error) {
	req := c.c.NewRequest(c.name, "Notes.Read", in)
	out := new(ReadResponse)
	err := c.c.Call(ctx, req, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *notesService) Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error) {
	req := c.c.NewRequest(c.name, "Notes.Delete", in)
	out := new(DeleteResponse)
	err := c.c.Call(ctx, req, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *notesService) Update(ctx context.Context, in *UpdateRequest, opts ...client.CallOption) (*UpdateResponse, error) {
	req := c.c.NewRequest(c.name, "Notes.Update", in)
	out := new(UpdateResponse)
	err := c.c.Call(ctx, req, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *notesService) Events(ctx context.Context, in *EventsRequest, opts ...client.CallOption) (Notes_EventsService, error) {
	req := c.c.NewRequest(c.name, "Notes.Events", &EventsRequest{})
	stream, err := c.c.Stream(ctx, req, opts...)
	if err != nil {
		return nil, err
	}
	if err := stream.Send(in); err != nil {
		return nil, err
	}
	return &notesServiceEvents{stream}, nil
}

type Notes_EventsService interface {
	Context() context.Context
	SendMsg(interface{}) error
	RecvMsg(interface{}) error
	Close() error
	Recv() (*EventsResponse, error)
}

type notesServiceEvents struct {
	stream client.Stream
}

func (x *notesServiceEvents) Close() error {
	return x.stream.Close()
}

func (x *notesServiceEvents) Context() context.Context {
	return x.stream.Context()
}

func (x *notesServiceEvents) SendMsg(m interface{}) error {
	return x.stream.Send(m)
}

func (x *notesServiceEvents) RecvMsg(m interface{}) error {
	return x.stream.Recv(m)
}

func (x *notesServiceEvents) Recv() (*EventsResponse, error) {
	m := new(EventsResponse)
	err := x.stream.Recv(m)
	if err != nil {
		return nil, err
	}
	return m, nil
}

// Server API for Notes service

type NotesHandler interface {
	List(context.Context, *ListRequest, *ListResponse) error
	Create(context.Context, *CreateRequest, *CreateResponse) error
	Read(context.Context, *ReadRequest, *ReadResponse) error
	Delete(context.Context, *DeleteRequest, *DeleteResponse) error
	Update(context.Context, *UpdateRequest, *UpdateResponse) error
	Events(context.Context, *EventsRequest, Notes_EventsStream) error
}

func RegisterNotesHandler(s server.Server, hdlr NotesHandler, opts ...server.HandlerOption) error {
	type notes interface {
		List(ctx context.Context, in *ListRequest, out *ListResponse) error
		Create(ctx context.Context, in *CreateRequest, out *CreateResponse) error
		Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error
		Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error
		Update(ctx context.Context, in *UpdateRequest, out *UpdateResponse) error
		Events(ctx context.Context, stream server.Stream) error
	}
	type Notes struct {
		notes
	}
	h := &notesHandler{hdlr}
	return s.Handle(s.NewHandler(&Notes{h}, opts...))
}

type notesHandler struct {
	NotesHandler
}

func (h *notesHandler) List(ctx context.Context, in *ListRequest, out *ListResponse) error {
	return h.NotesHandler.List(ctx, in, out)
}

func (h *notesHandler) Create(ctx context.Context, in *CreateRequest, out *CreateResponse) error {
	return h.NotesHandler.Create(ctx, in, out)
}

func (h *notesHandler) Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error {
	return h.NotesHandler.Read(ctx, in, out)
}

func (h *notesHandler) Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error {
	return h.NotesHandler.Delete(ctx, in, out)
}

func (h *notesHandler) Update(ctx context.Context, in *UpdateRequest, out *UpdateResponse) error {
	return h.NotesHandler.Update(ctx, in, out)
}

func (h *notesHandler) Events(ctx context.Context, stream server.Stream) error {
	m := new(EventsRequest)
	if err := stream.Recv(m); err != nil {
		return err
	}
	return h.NotesHandler.Events(ctx, m, &notesEventsStream{stream})
}

type Notes_EventsStream interface {
	Context() context.Context
	SendMsg(interface{}) error
	RecvMsg(interface{}) error
	Close() error
	Send(*EventsResponse) error
}

type notesEventsStream struct {
	stream server.Stream
}

func (x *notesEventsStream) Close() error {
	return x.stream.Close()
}

func (x *notesEventsStream) Context() context.Context {
	return x.stream.Context()
}

func (x *notesEventsStream) SendMsg(m interface{}) error {
	return x.stream.Send(m)
}

func (x *notesEventsStream) RecvMsg(m interface{}) error {
	return x.stream.Recv(m)
}

func (x *notesEventsStream) Send(m *EventsResponse) error {
	return x.stream.Send(m)
}
