diff --git a/README.md b/README.md index 1a08658..b2f55e6 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,108 @@ # gRPC -an example of how to generate gRPC APIs directly from your DB schema + +An example of how to generate gRPC APIs directly from your DB schema. + +The generated proto file has the following characteristics: + +- One message is generated per database table +- One enum is generated per database enum +- Request and response messages are generated for each basic CRUD operation (List, Get, Create, Update, and Delete) +- An RPC is created for each CRUD operation for each table + +# Example + +The example output is based on the following SQL: + +```sql +CREATE TABLE public.books +( + id integer NOT NULL DEFAULT nextval('books_id_seq'::regclass), + author_id uuid NOT NULL, + isbn character(32) COLLATE pg_catalog."default" NOT NULL, + booktype book_type NOT NULL, + title text COLLATE pg_catalog."default" NOT NULL, + pages integer NOT NULL, + summary text COLLATE pg_catalog."default", + available timestamp with time zone NOT NULL DEFAULT '2017-09-04 18:43:39.197538-07'::timestamp with time zone, + CONSTRAINT books_pkey PRIMARY KEY (id), + CONSTRAINT books_isbn_key UNIQUE (isbn), + CONSTRAINT books_author_id_fkey FOREIGN KEY (author_id) + REFERENCES public.authors (id) MATCH SIMPLE + ON UPDATE NO ACTION + ON DELETE NO ACTION +) + +CREATE INDEX books_title_idx + ON public.books USING btree + (author_id ASC NULLS LAST, title COLLATE pg_catalog."default" ASC NULLS LAST) + TABLESPACE pg_default; +``` + +A message will be generated for the table `public.books`: + +```protobuf +message Books { + int32 id = 1 [(gogoproto.customname) = "ID"]; // (PK) + string author_id = 2 [(gogoproto.customname) = "AuthorID"]; + google.protobuf.Timestamp available = 3 [(gogoproto.customname) = "Available"]; + BookType booktype = 4 [(gogoproto.customname) = "Booktype"]; + string isbn = 5 [(gogoproto.customname) = "Isbn"]; + int32 pages = 6 [(gogoproto.customname) = "Pages"]; + google.protobuf.StringValue summary = 7 [(gogoproto.customname) = "Summary"]; + string title = 8 [(gogoproto.customname) = "Title"]; +} +``` + +Request and response messages will be generated for all CRUD operations: + +```protobuf +message ListBooksRequest { + // The fields on this ListBooksRequest are used to filter for rows from + // the books table backend. The templates generate fields for primary and + // foreign keys automatically. If additional fields are needed for filtering, they + // would need to be added after code generation. + repeated int32 id = 1 [(gogoproto.customname) = "ID"]; // (PK) + repeated string author_id = 2 [(gogoproto.customname) = "AuthorID"]; // (FK) + + // Manually added filters: +} + +message ListBooksResponse { + repeated Books books = 1 [(gogoproto.customname) = "Books"]; +} + +message GetBooksRequest { + int32 id = 1 [(gogoproto.customname) = "ID"]; // (PK) +} + +message CreateBooksRequest { + Books books = 1 [(gogoproto.customname) = "Books"]; +} + +message UpdateBooksRequest { + Books books = 1 [(gogoproto.customname) = "Books"]; + google.protobuf.FieldMask update_mask = 2; +} + +message DeleteBooksRequest { + int32 id = 1 [(gogoproto.customname) = "ID"]; // (PK) +} +``` + +Finally, a service will be generated for each CRUD operation using the generated messages: + +```protobuf +service GeneratedService { + rpc ListBooks(ListBooksRequest) returns (ListBooksResponse) {}; + rpc GetBooks(GetBooksRequest) returns (Books) {}; + rpc CreateBooks(CreateBooksRequest) returns (Books) {}; + rpc UpdateBooks(UpdateBooksRequest) returns (Books) {}; + rpc DeleteBooks(DeleteBooksRequest) returns (google.protobuf.Empty) {}; +} +``` + +# List requests + +List requests, such as the `ListBooks` RPC from the example are meant to filter the related database rows based on the the provided keys. Most commonly the backend will `OR` the fields together in a `WHERE` clause. This makes it easy to e.g. get all rows that reference one or more foreign keys, or get all rows in a list of primary key IDs. + +Additional fields can be added after generation if more filtering is necessary. It would also be trivial to alter the template to include all fields on a message, making them available for filtering on as well. diff --git a/build-grpc.sh b/build-grpc.sh new file mode 100755 index 0000000..dd58f7b --- /dev/null +++ b/build-grpc.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Compile gRPC code for Go +# Run gnorm to generate the proto file first + +echo -e "[+] Generating Go-gPRC from proto files" + +protoc \ +-I "./" \ +-I="${GOPATH}/src/" \ +-I="${GOPATH}/src/github.com/gogo/protobuf/protobuf/" \ +--gogofast_out="plugins=grpc,\ +Mgoogle/protobuf/wrappers.proto=github.com/gogo/protobuf/types,\ +Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,\ +Mgoogle/protobuf/empty.proto=github.com/gogo/protobuf/types,\ +Mgoogle/protobuf/field_mask.proto=github.com/gogo/protobuf/types:\ +./" \ +./generated/generated.proto \ No newline at end of file diff --git a/generated/generated.pb.go b/generated/generated.pb.go new file mode 100644 index 0000000..6db4df1 --- /dev/null +++ b/generated/generated.pb.go @@ -0,0 +1,3740 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: generated/generated.proto + +package generated + +import ( + context "context" + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + types "github.com/gogo/protobuf/types" + grpc "google.golang.org/grpc" + io "io" + math "math" +) + +// 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.GoGoProtoPackageIsVersion2 // please upgrade the proto package + +type BookType int32 + +const ( + BookType_FICTION BookType = 0 + BookType_NONFICTION BookType = 1 +) + +var BookType_name = map[int32]string{ + 0: "FICTION", + 1: "NONFICTION", +} + +var BookType_value = map[string]int32{ + "FICTION": 0, + "NONFICTION": 1, +} + +func (x BookType) String() string { + return proto.EnumName(BookType_name, int32(x)) +} + +func (BookType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_4b039a449fe9b332, []int{0} +} + +type Authors struct { + ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Authors) Reset() { *m = Authors{} } +func (m *Authors) String() string { return proto.CompactTextString(m) } +func (*Authors) ProtoMessage() {} +func (*Authors) Descriptor() ([]byte, []int) { + return fileDescriptor_4b039a449fe9b332, []int{0} +} +func (m *Authors) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Authors) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Authors.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Authors) XXX_Merge(src proto.Message) { + xxx_messageInfo_Authors.Merge(m, src) +} +func (m *Authors) XXX_Size() int { + return m.Size() +} +func (m *Authors) XXX_DiscardUnknown() { + xxx_messageInfo_Authors.DiscardUnknown(m) +} + +var xxx_messageInfo_Authors proto.InternalMessageInfo + +func (m *Authors) GetID() string { + if m != nil { + return m.ID + } + return "" +} + +func (m *Authors) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +type ListAuthorsRequest struct { + // The fields on this ListAuthorsRequest are used to filter for rows from + // the authors table backend. The templates generate fields for primary and + // foreign keys automatically. If additional fields are needed for filtering, they + // would need to be added after code generation. + ID []string `protobuf:"bytes,1,rep,name=id,proto3" json:"id,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ListAuthorsRequest) Reset() { *m = ListAuthorsRequest{} } +func (m *ListAuthorsRequest) String() string { return proto.CompactTextString(m) } +func (*ListAuthorsRequest) ProtoMessage() {} +func (*ListAuthorsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4b039a449fe9b332, []int{1} +} +func (m *ListAuthorsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ListAuthorsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ListAuthorsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ListAuthorsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ListAuthorsRequest.Merge(m, src) +} +func (m *ListAuthorsRequest) XXX_Size() int { + return m.Size() +} +func (m *ListAuthorsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ListAuthorsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ListAuthorsRequest proto.InternalMessageInfo + +func (m *ListAuthorsRequest) GetID() []string { + if m != nil { + return m.ID + } + return nil +} + +type ListAuthorsResponse struct { + Authors []*Authors `protobuf:"bytes,1,rep,name=authors,proto3" json:"authors,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ListAuthorsResponse) Reset() { *m = ListAuthorsResponse{} } +func (m *ListAuthorsResponse) String() string { return proto.CompactTextString(m) } +func (*ListAuthorsResponse) ProtoMessage() {} +func (*ListAuthorsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4b039a449fe9b332, []int{2} +} +func (m *ListAuthorsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ListAuthorsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ListAuthorsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ListAuthorsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ListAuthorsResponse.Merge(m, src) +} +func (m *ListAuthorsResponse) XXX_Size() int { + return m.Size() +} +func (m *ListAuthorsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ListAuthorsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ListAuthorsResponse proto.InternalMessageInfo + +func (m *ListAuthorsResponse) GetAuthors() []*Authors { + if m != nil { + return m.Authors + } + return nil +} + +type GetAuthorsRequest struct { + ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetAuthorsRequest) Reset() { *m = GetAuthorsRequest{} } +func (m *GetAuthorsRequest) String() string { return proto.CompactTextString(m) } +func (*GetAuthorsRequest) ProtoMessage() {} +func (*GetAuthorsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4b039a449fe9b332, []int{3} +} +func (m *GetAuthorsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetAuthorsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetAuthorsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GetAuthorsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetAuthorsRequest.Merge(m, src) +} +func (m *GetAuthorsRequest) XXX_Size() int { + return m.Size() +} +func (m *GetAuthorsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetAuthorsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetAuthorsRequest proto.InternalMessageInfo + +func (m *GetAuthorsRequest) GetID() string { + if m != nil { + return m.ID + } + return "" +} + +type CreateAuthorsRequest struct { + Authors *Authors `protobuf:"bytes,1,opt,name=authors,proto3" json:"authors,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *CreateAuthorsRequest) Reset() { *m = CreateAuthorsRequest{} } +func (m *CreateAuthorsRequest) String() string { return proto.CompactTextString(m) } +func (*CreateAuthorsRequest) ProtoMessage() {} +func (*CreateAuthorsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4b039a449fe9b332, []int{4} +} +func (m *CreateAuthorsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CreateAuthorsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CreateAuthorsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *CreateAuthorsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_CreateAuthorsRequest.Merge(m, src) +} +func (m *CreateAuthorsRequest) XXX_Size() int { + return m.Size() +} +func (m *CreateAuthorsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_CreateAuthorsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_CreateAuthorsRequest proto.InternalMessageInfo + +func (m *CreateAuthorsRequest) GetAuthors() *Authors { + if m != nil { + return m.Authors + } + return nil +} + +type UpdateAuthorsRequest struct { + Authors *Authors `protobuf:"bytes,1,opt,name=authors,proto3" json:"authors,omitempty"` + UpdateMask *types.FieldMask `protobuf:"bytes,2,opt,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *UpdateAuthorsRequest) Reset() { *m = UpdateAuthorsRequest{} } +func (m *UpdateAuthorsRequest) String() string { return proto.CompactTextString(m) } +func (*UpdateAuthorsRequest) ProtoMessage() {} +func (*UpdateAuthorsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4b039a449fe9b332, []int{5} +} +func (m *UpdateAuthorsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *UpdateAuthorsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_UpdateAuthorsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *UpdateAuthorsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_UpdateAuthorsRequest.Merge(m, src) +} +func (m *UpdateAuthorsRequest) XXX_Size() int { + return m.Size() +} +func (m *UpdateAuthorsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_UpdateAuthorsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_UpdateAuthorsRequest proto.InternalMessageInfo + +func (m *UpdateAuthorsRequest) GetAuthors() *Authors { + if m != nil { + return m.Authors + } + return nil +} + +func (m *UpdateAuthorsRequest) GetUpdateMask() *types.FieldMask { + if m != nil { + return m.UpdateMask + } + return nil +} + +type DeleteAuthorsRequest struct { + ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *DeleteAuthorsRequest) Reset() { *m = DeleteAuthorsRequest{} } +func (m *DeleteAuthorsRequest) String() string { return proto.CompactTextString(m) } +func (*DeleteAuthorsRequest) ProtoMessage() {} +func (*DeleteAuthorsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4b039a449fe9b332, []int{6} +} +func (m *DeleteAuthorsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DeleteAuthorsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DeleteAuthorsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *DeleteAuthorsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_DeleteAuthorsRequest.Merge(m, src) +} +func (m *DeleteAuthorsRequest) XXX_Size() int { + return m.Size() +} +func (m *DeleteAuthorsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_DeleteAuthorsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_DeleteAuthorsRequest proto.InternalMessageInfo + +func (m *DeleteAuthorsRequest) GetID() string { + if m != nil { + return m.ID + } + return "" +} + +type Books struct { + ID int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + AuthorID string `protobuf:"bytes,2,opt,name=author_id,json=authorId,proto3" json:"author_id,omitempty"` + Available *types.Timestamp `protobuf:"bytes,3,opt,name=available,proto3" json:"available,omitempty"` + Booktype BookType `protobuf:"varint,4,opt,name=booktype,proto3,enum=generated.BookType" json:"booktype,omitempty"` + Isbn string `protobuf:"bytes,5,opt,name=isbn,proto3" json:"isbn,omitempty"` + Pages int32 `protobuf:"varint,6,opt,name=pages,proto3" json:"pages,omitempty"` + Summary *types.StringValue `protobuf:"bytes,7,opt,name=summary,proto3" json:"summary,omitempty"` + Title string `protobuf:"bytes,8,opt,name=title,proto3" json:"title,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Books) Reset() { *m = Books{} } +func (m *Books) String() string { return proto.CompactTextString(m) } +func (*Books) ProtoMessage() {} +func (*Books) Descriptor() ([]byte, []int) { + return fileDescriptor_4b039a449fe9b332, []int{7} +} +func (m *Books) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Books) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Books.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Books) XXX_Merge(src proto.Message) { + xxx_messageInfo_Books.Merge(m, src) +} +func (m *Books) XXX_Size() int { + return m.Size() +} +func (m *Books) XXX_DiscardUnknown() { + xxx_messageInfo_Books.DiscardUnknown(m) +} + +var xxx_messageInfo_Books proto.InternalMessageInfo + +func (m *Books) GetID() int32 { + if m != nil { + return m.ID + } + return 0 +} + +func (m *Books) GetAuthorID() string { + if m != nil { + return m.AuthorID + } + return "" +} + +func (m *Books) GetAvailable() *types.Timestamp { + if m != nil { + return m.Available + } + return nil +} + +func (m *Books) GetBooktype() BookType { + if m != nil { + return m.Booktype + } + return BookType_FICTION +} + +func (m *Books) GetIsbn() string { + if m != nil { + return m.Isbn + } + return "" +} + +func (m *Books) GetPages() int32 { + if m != nil { + return m.Pages + } + return 0 +} + +func (m *Books) GetSummary() *types.StringValue { + if m != nil { + return m.Summary + } + return nil +} + +func (m *Books) GetTitle() string { + if m != nil { + return m.Title + } + return "" +} + +type ListBooksRequest struct { + // The fields on this ListBooksRequest are used to filter for rows from + // the books table backend. The templates generate fields for primary and + // foreign keys automatically. If additional fields are needed for filtering, they + // would need to be added after code generation. + ID []int32 `protobuf:"varint,1,rep,packed,name=id,proto3" json:"id,omitempty"` + AuthorID []string `protobuf:"bytes,2,rep,name=author_id,json=authorId,proto3" json:"author_id,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ListBooksRequest) Reset() { *m = ListBooksRequest{} } +func (m *ListBooksRequest) String() string { return proto.CompactTextString(m) } +func (*ListBooksRequest) ProtoMessage() {} +func (*ListBooksRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4b039a449fe9b332, []int{8} +} +func (m *ListBooksRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ListBooksRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ListBooksRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ListBooksRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ListBooksRequest.Merge(m, src) +} +func (m *ListBooksRequest) XXX_Size() int { + return m.Size() +} +func (m *ListBooksRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ListBooksRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ListBooksRequest proto.InternalMessageInfo + +func (m *ListBooksRequest) GetID() []int32 { + if m != nil { + return m.ID + } + return nil +} + +func (m *ListBooksRequest) GetAuthorID() []string { + if m != nil { + return m.AuthorID + } + return nil +} + +type ListBooksResponse struct { + Books []*Books `protobuf:"bytes,1,rep,name=books,proto3" json:"books,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ListBooksResponse) Reset() { *m = ListBooksResponse{} } +func (m *ListBooksResponse) String() string { return proto.CompactTextString(m) } +func (*ListBooksResponse) ProtoMessage() {} +func (*ListBooksResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4b039a449fe9b332, []int{9} +} +func (m *ListBooksResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ListBooksResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ListBooksResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ListBooksResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ListBooksResponse.Merge(m, src) +} +func (m *ListBooksResponse) XXX_Size() int { + return m.Size() +} +func (m *ListBooksResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ListBooksResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ListBooksResponse proto.InternalMessageInfo + +func (m *ListBooksResponse) GetBooks() []*Books { + if m != nil { + return m.Books + } + return nil +} + +type GetBooksRequest struct { + ID int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetBooksRequest) Reset() { *m = GetBooksRequest{} } +func (m *GetBooksRequest) String() string { return proto.CompactTextString(m) } +func (*GetBooksRequest) ProtoMessage() {} +func (*GetBooksRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4b039a449fe9b332, []int{10} +} +func (m *GetBooksRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetBooksRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetBooksRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GetBooksRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetBooksRequest.Merge(m, src) +} +func (m *GetBooksRequest) XXX_Size() int { + return m.Size() +} +func (m *GetBooksRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetBooksRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetBooksRequest proto.InternalMessageInfo + +func (m *GetBooksRequest) GetID() int32 { + if m != nil { + return m.ID + } + return 0 +} + +type CreateBooksRequest struct { + Books *Books `protobuf:"bytes,1,opt,name=books,proto3" json:"books,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *CreateBooksRequest) Reset() { *m = CreateBooksRequest{} } +func (m *CreateBooksRequest) String() string { return proto.CompactTextString(m) } +func (*CreateBooksRequest) ProtoMessage() {} +func (*CreateBooksRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4b039a449fe9b332, []int{11} +} +func (m *CreateBooksRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CreateBooksRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CreateBooksRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *CreateBooksRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_CreateBooksRequest.Merge(m, src) +} +func (m *CreateBooksRequest) XXX_Size() int { + return m.Size() +} +func (m *CreateBooksRequest) XXX_DiscardUnknown() { + xxx_messageInfo_CreateBooksRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_CreateBooksRequest proto.InternalMessageInfo + +func (m *CreateBooksRequest) GetBooks() *Books { + if m != nil { + return m.Books + } + return nil +} + +type UpdateBooksRequest struct { + Books *Books `protobuf:"bytes,1,opt,name=books,proto3" json:"books,omitempty"` + UpdateMask *types.FieldMask `protobuf:"bytes,2,opt,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *UpdateBooksRequest) Reset() { *m = UpdateBooksRequest{} } +func (m *UpdateBooksRequest) String() string { return proto.CompactTextString(m) } +func (*UpdateBooksRequest) ProtoMessage() {} +func (*UpdateBooksRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4b039a449fe9b332, []int{12} +} +func (m *UpdateBooksRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *UpdateBooksRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_UpdateBooksRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *UpdateBooksRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_UpdateBooksRequest.Merge(m, src) +} +func (m *UpdateBooksRequest) XXX_Size() int { + return m.Size() +} +func (m *UpdateBooksRequest) XXX_DiscardUnknown() { + xxx_messageInfo_UpdateBooksRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_UpdateBooksRequest proto.InternalMessageInfo + +func (m *UpdateBooksRequest) GetBooks() *Books { + if m != nil { + return m.Books + } + return nil +} + +func (m *UpdateBooksRequest) GetUpdateMask() *types.FieldMask { + if m != nil { + return m.UpdateMask + } + return nil +} + +type DeleteBooksRequest struct { + ID int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *DeleteBooksRequest) Reset() { *m = DeleteBooksRequest{} } +func (m *DeleteBooksRequest) String() string { return proto.CompactTextString(m) } +func (*DeleteBooksRequest) ProtoMessage() {} +func (*DeleteBooksRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4b039a449fe9b332, []int{13} +} +func (m *DeleteBooksRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DeleteBooksRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DeleteBooksRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *DeleteBooksRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_DeleteBooksRequest.Merge(m, src) +} +func (m *DeleteBooksRequest) XXX_Size() int { + return m.Size() +} +func (m *DeleteBooksRequest) XXX_DiscardUnknown() { + xxx_messageInfo_DeleteBooksRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_DeleteBooksRequest proto.InternalMessageInfo + +func (m *DeleteBooksRequest) GetID() int32 { + if m != nil { + return m.ID + } + return 0 +} + +func init() { + proto.RegisterEnum("generated.BookType", BookType_name, BookType_value) + proto.RegisterType((*Authors)(nil), "generated.Authors") + proto.RegisterType((*ListAuthorsRequest)(nil), "generated.ListAuthorsRequest") + proto.RegisterType((*ListAuthorsResponse)(nil), "generated.ListAuthorsResponse") + proto.RegisterType((*GetAuthorsRequest)(nil), "generated.GetAuthorsRequest") + proto.RegisterType((*CreateAuthorsRequest)(nil), "generated.CreateAuthorsRequest") + proto.RegisterType((*UpdateAuthorsRequest)(nil), "generated.UpdateAuthorsRequest") + proto.RegisterType((*DeleteAuthorsRequest)(nil), "generated.DeleteAuthorsRequest") + proto.RegisterType((*Books)(nil), "generated.Books") + proto.RegisterType((*ListBooksRequest)(nil), "generated.ListBooksRequest") + proto.RegisterType((*ListBooksResponse)(nil), "generated.ListBooksResponse") + proto.RegisterType((*GetBooksRequest)(nil), "generated.GetBooksRequest") + proto.RegisterType((*CreateBooksRequest)(nil), "generated.CreateBooksRequest") + proto.RegisterType((*UpdateBooksRequest)(nil), "generated.UpdateBooksRequest") + proto.RegisterType((*DeleteBooksRequest)(nil), "generated.DeleteBooksRequest") +} + +func init() { proto.RegisterFile("generated/generated.proto", fileDescriptor_4b039a449fe9b332) } + +var fileDescriptor_4b039a449fe9b332 = []byte{ + // 810 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x41, 0x53, 0xd3, 0x50, + 0x10, 0x6e, 0x0a, 0xa5, 0xed, 0x46, 0xb0, 0x3c, 0x18, 0x8c, 0xa1, 0x36, 0x4c, 0x2e, 0x82, 0x62, + 0x19, 0xeb, 0x49, 0x1d, 0x47, 0x29, 0xd8, 0x5a, 0x47, 0x0b, 0x86, 0xe2, 0xc1, 0x0b, 0x93, 0xd2, + 0x47, 0xc8, 0xb4, 0x69, 0x62, 0x92, 0xe2, 0xf4, 0xee, 0xd9, 0xdf, 0xe5, 0xd1, 0xf1, 0x07, 0x74, + 0x9c, 0xfc, 0x09, 0xaf, 0x4e, 0xde, 0x4b, 0xda, 0xbc, 0xa4, 0x71, 0x70, 0xf0, 0xd6, 0xec, 0x7e, + 0xfb, 0xed, 0xbe, 0xdd, 0xfd, 0x16, 0xe0, 0xae, 0x86, 0x87, 0xd8, 0x56, 0x5d, 0xdc, 0xdb, 0x9b, + 0xfe, 0xaa, 0x5a, 0xb6, 0xe9, 0x9a, 0xa8, 0x38, 0x35, 0x88, 0x8f, 0x34, 0xdd, 0xbd, 0x1c, 0x75, + 0xab, 0xe7, 0xa6, 0xb1, 0xa7, 0x99, 0x9a, 0xb9, 0x47, 0x10, 0xdd, 0xd1, 0x05, 0xf9, 0x22, 0x1f, + 0xe4, 0x17, 0x8d, 0x14, 0x2b, 0x9a, 0x69, 0x6a, 0x03, 0x3c, 0x43, 0x7d, 0xb1, 0x55, 0xcb, 0xc2, + 0xb6, 0x13, 0xf8, 0xa5, 0xb8, 0xdf, 0xd5, 0x0d, 0xec, 0xb8, 0xaa, 0x61, 0x05, 0x80, 0xcd, 0x38, + 0x00, 0x1b, 0x96, 0x3b, 0x0e, 0x9c, 0x5b, 0x71, 0xe7, 0x85, 0x8e, 0x07, 0xbd, 0x33, 0x43, 0x75, + 0xfa, 0x14, 0x21, 0xbf, 0x84, 0xfc, 0xfe, 0xc8, 0xbd, 0x34, 0x6d, 0x07, 0x6d, 0x40, 0x56, 0xef, + 0x09, 0xdc, 0x16, 0xb7, 0x5d, 0xac, 0x2f, 0x79, 0x13, 0x29, 0xdb, 0x3a, 0x54, 0xb2, 0x7a, 0x0f, + 0x95, 0x61, 0x71, 0xa8, 0x1a, 0x58, 0xc8, 0x12, 0x4f, 0xc1, 0x9b, 0x48, 0x8b, 0x6d, 0xd5, 0xc0, + 0x0a, 0xb1, 0xca, 0xbb, 0x80, 0xde, 0xe9, 0x8e, 0x1b, 0x90, 0x28, 0xf8, 0xf3, 0x08, 0x3b, 0xee, + 0x94, 0x6b, 0x81, 0xe5, 0x92, 0x8f, 0x61, 0x8d, 0x41, 0x3b, 0x96, 0x39, 0x74, 0x30, 0x7a, 0x0a, + 0x79, 0x95, 0x9a, 0x48, 0x0c, 0x5f, 0x43, 0xd5, 0x59, 0x8b, 0x03, 0x70, 0x9d, 0xf7, 0x26, 0x52, + 0x58, 0xac, 0x12, 0xe2, 0xe5, 0x87, 0xb0, 0xda, 0xc4, 0x69, 0xe9, 0x63, 0x4f, 0x91, 0x3f, 0xc0, + 0xfa, 0x81, 0x8d, 0x55, 0x17, 0xc7, 0xf0, 0x4c, 0x7e, 0xee, 0x9f, 0xf2, 0x7f, 0xe3, 0x60, 0xfd, + 0xd4, 0xea, 0xfd, 0x4f, 0x4e, 0xf4, 0x1c, 0xf8, 0x11, 0xa1, 0x24, 0x93, 0x22, 0x8d, 0xe7, 0x6b, + 0x62, 0x95, 0x0e, 0xb3, 0x1a, 0x0e, 0xb3, 0xda, 0xf0, 0x87, 0xf9, 0x5e, 0x75, 0xfa, 0x0a, 0x50, + 0xb8, 0xff, 0x5b, 0xae, 0xc2, 0xfa, 0x21, 0x1e, 0xe0, 0x44, 0x3d, 0x69, 0x3d, 0xf9, 0x9d, 0x85, + 0x5c, 0xdd, 0x34, 0xfb, 0xd1, 0x05, 0xc8, 0x31, 0x0b, 0xb0, 0x03, 0x45, 0x5a, 0xd9, 0x99, 0xde, + 0x0b, 0xb6, 0xe0, 0x96, 0x37, 0x91, 0x0a, 0x34, 0x41, 0xeb, 0x50, 0x29, 0x50, 0x77, 0xab, 0x87, + 0x9a, 0x50, 0x54, 0xaf, 0x54, 0x7d, 0xa0, 0x76, 0x07, 0x58, 0x58, 0x48, 0xa9, 0xbb, 0x13, 0xae, + 0x70, 0x7d, 0xd9, 0x9b, 0x48, 0xc5, 0xfd, 0x30, 0x40, 0x99, 0xc5, 0xa2, 0x17, 0x50, 0xe8, 0x9a, + 0x66, 0xdf, 0x1d, 0x5b, 0x58, 0x58, 0xdc, 0xe2, 0xb6, 0x57, 0x6a, 0x6b, 0x91, 0xf6, 0xf9, 0xf5, + 0x76, 0xc6, 0x16, 0xa6, 0x75, 0xd4, 0x03, 0xa0, 0x32, 0x0d, 0xf1, 0x77, 0x56, 0x77, 0xba, 0x43, + 0x21, 0x37, 0xdb, 0xd9, 0x96, 0xd3, 0x1d, 0x2a, 0xc4, 0x8a, 0x24, 0xc8, 0x59, 0xaa, 0x86, 0x1d, + 0x61, 0x89, 0xbc, 0xb5, 0xe8, 0x4d, 0xa4, 0xdc, 0xb1, 0x6f, 0x50, 0xa8, 0x1d, 0x1d, 0x40, 0xde, + 0x19, 0x19, 0x86, 0x6a, 0x8f, 0x85, 0x3c, 0x79, 0x44, 0x39, 0xf1, 0x88, 0x13, 0xd7, 0xd6, 0x87, + 0xda, 0x47, 0x75, 0x30, 0xc2, 0x74, 0x8a, 0x27, 0x34, 0x40, 0x09, 0x23, 0xfd, 0x2c, 0xae, 0xee, + 0x0e, 0xb0, 0x50, 0x20, 0x45, 0x90, 0x2c, 0x1d, 0xdf, 0xa0, 0x50, 0xbb, 0x7c, 0x0a, 0x25, 0x5f, + 0x0c, 0xa4, 0xf9, 0x49, 0xe1, 0xfc, 0x75, 0x06, 0x0b, 0xe9, 0x33, 0x90, 0x1b, 0xb0, 0x1a, 0xa1, + 0x0d, 0x14, 0xf6, 0x18, 0x72, 0x7e, 0x73, 0x42, 0x7d, 0x95, 0x62, 0xcd, 0x74, 0x68, 0x79, 0x34, + 0x86, 0x22, 0xe5, 0x1d, 0xb8, 0xdd, 0xc4, 0xf3, 0xab, 0x8b, 0x6d, 0x88, 0xdc, 0x04, 0x44, 0x75, + 0xc5, 0xa0, 0x23, 0x39, 0xb9, 0x6b, 0xe6, 0xfc, 0xca, 0x01, 0xa2, 0x6a, 0xba, 0x21, 0xd3, 0xcd, + 0x34, 0xb4, 0x0b, 0x88, 0x6a, 0xe8, 0x3a, 0xaf, 0x7f, 0x70, 0x1f, 0x0a, 0xe1, 0x42, 0x22, 0x1e, + 0xf2, 0x8d, 0xd6, 0x41, 0xa7, 0x75, 0xd4, 0x2e, 0x65, 0xd0, 0x0a, 0x40, 0xfb, 0xa8, 0x1d, 0x7e, + 0x73, 0xb5, 0x9f, 0x39, 0x28, 0x35, 0xc3, 0xca, 0x4f, 0xb0, 0x7d, 0xa5, 0x9f, 0x63, 0xd4, 0x06, + 0x3e, 0x72, 0x12, 0xd1, 0xbd, 0xc8, 0xdb, 0x92, 0x87, 0x55, 0xac, 0xa4, 0xb9, 0xe9, 0x9c, 0xe5, + 0x0c, 0x7a, 0x05, 0x30, 0x3b, 0x88, 0xa8, 0x1c, 0xc1, 0x27, 0xee, 0xa4, 0x38, 0xe7, 0x24, 0xc9, + 0x19, 0xd4, 0x80, 0x65, 0xe6, 0x4a, 0x22, 0x29, 0x02, 0x9b, 0x77, 0x3f, 0xd3, 0x79, 0x98, 0xcb, + 0xc8, 0xf0, 0xcc, 0xbb, 0x99, 0x29, 0x3c, 0x6f, 0x61, 0x99, 0xb9, 0x68, 0x0c, 0xcf, 0xbc, 0x5b, + 0x27, 0x6e, 0x24, 0xe6, 0xfc, 0xda, 0xff, 0xab, 0x28, 0x67, 0xd0, 0x1b, 0x28, 0x4e, 0xc5, 0x81, + 0x36, 0x63, 0xcd, 0x8c, 0x4e, 0x5b, 0x2c, 0xcf, 0x77, 0x4e, 0xfb, 0xfc, 0x0c, 0x0a, 0xa1, 0x3c, + 0x90, 0xc8, 0x76, 0x99, 0xe1, 0x49, 0x2c, 0x2b, 0x99, 0x11, 0x1f, 0xd1, 0x0b, 0x33, 0xf3, 0xa4, + 0x8e, 0xd2, 0x18, 0x22, 0x3a, 0x61, 0x18, 0x92, 0xfa, 0x99, 0xcb, 0xd0, 0x00, 0x3e, 0xb2, 0xe3, + 0x0c, 0x43, 0x72, 0xf7, 0xd3, 0x3b, 0x5a, 0xbf, 0xf3, 0xdd, 0xab, 0x70, 0x3f, 0xbc, 0x0a, 0xf7, + 0xcb, 0xab, 0x70, 0x9f, 0x66, 0xff, 0x09, 0x75, 0x97, 0x08, 0xf4, 0xc9, 0x9f, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x3a, 0x40, 0xb5, 0x33, 0x38, 0x09, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// GeneratedServiceClient is the client API for GeneratedService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type GeneratedServiceClient interface { + ListAuthors(ctx context.Context, in *ListAuthorsRequest, opts ...grpc.CallOption) (*ListAuthorsResponse, error) + GetAuthors(ctx context.Context, in *GetAuthorsRequest, opts ...grpc.CallOption) (*Authors, error) + CreateAuthors(ctx context.Context, in *CreateAuthorsRequest, opts ...grpc.CallOption) (*Authors, error) + UpdateAuthors(ctx context.Context, in *UpdateAuthorsRequest, opts ...grpc.CallOption) (*Authors, error) + DeleteAuthors(ctx context.Context, in *DeleteAuthorsRequest, opts ...grpc.CallOption) (*types.Empty, error) + ListBooks(ctx context.Context, in *ListBooksRequest, opts ...grpc.CallOption) (*ListBooksResponse, error) + GetBooks(ctx context.Context, in *GetBooksRequest, opts ...grpc.CallOption) (*Books, error) + CreateBooks(ctx context.Context, in *CreateBooksRequest, opts ...grpc.CallOption) (*Books, error) + UpdateBooks(ctx context.Context, in *UpdateBooksRequest, opts ...grpc.CallOption) (*Books, error) + DeleteBooks(ctx context.Context, in *DeleteBooksRequest, opts ...grpc.CallOption) (*types.Empty, error) +} + +type generatedServiceClient struct { + cc *grpc.ClientConn +} + +func NewGeneratedServiceClient(cc *grpc.ClientConn) GeneratedServiceClient { + return &generatedServiceClient{cc} +} + +func (c *generatedServiceClient) ListAuthors(ctx context.Context, in *ListAuthorsRequest, opts ...grpc.CallOption) (*ListAuthorsResponse, error) { + out := new(ListAuthorsResponse) + err := c.cc.Invoke(ctx, "/generated.GeneratedService/ListAuthors", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *generatedServiceClient) GetAuthors(ctx context.Context, in *GetAuthorsRequest, opts ...grpc.CallOption) (*Authors, error) { + out := new(Authors) + err := c.cc.Invoke(ctx, "/generated.GeneratedService/GetAuthors", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *generatedServiceClient) CreateAuthors(ctx context.Context, in *CreateAuthorsRequest, opts ...grpc.CallOption) (*Authors, error) { + out := new(Authors) + err := c.cc.Invoke(ctx, "/generated.GeneratedService/CreateAuthors", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *generatedServiceClient) UpdateAuthors(ctx context.Context, in *UpdateAuthorsRequest, opts ...grpc.CallOption) (*Authors, error) { + out := new(Authors) + err := c.cc.Invoke(ctx, "/generated.GeneratedService/UpdateAuthors", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *generatedServiceClient) DeleteAuthors(ctx context.Context, in *DeleteAuthorsRequest, opts ...grpc.CallOption) (*types.Empty, error) { + out := new(types.Empty) + err := c.cc.Invoke(ctx, "/generated.GeneratedService/DeleteAuthors", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *generatedServiceClient) ListBooks(ctx context.Context, in *ListBooksRequest, opts ...grpc.CallOption) (*ListBooksResponse, error) { + out := new(ListBooksResponse) + err := c.cc.Invoke(ctx, "/generated.GeneratedService/ListBooks", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *generatedServiceClient) GetBooks(ctx context.Context, in *GetBooksRequest, opts ...grpc.CallOption) (*Books, error) { + out := new(Books) + err := c.cc.Invoke(ctx, "/generated.GeneratedService/GetBooks", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *generatedServiceClient) CreateBooks(ctx context.Context, in *CreateBooksRequest, opts ...grpc.CallOption) (*Books, error) { + out := new(Books) + err := c.cc.Invoke(ctx, "/generated.GeneratedService/CreateBooks", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *generatedServiceClient) UpdateBooks(ctx context.Context, in *UpdateBooksRequest, opts ...grpc.CallOption) (*Books, error) { + out := new(Books) + err := c.cc.Invoke(ctx, "/generated.GeneratedService/UpdateBooks", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *generatedServiceClient) DeleteBooks(ctx context.Context, in *DeleteBooksRequest, opts ...grpc.CallOption) (*types.Empty, error) { + out := new(types.Empty) + err := c.cc.Invoke(ctx, "/generated.GeneratedService/DeleteBooks", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// GeneratedServiceServer is the server API for GeneratedService service. +type GeneratedServiceServer interface { + ListAuthors(context.Context, *ListAuthorsRequest) (*ListAuthorsResponse, error) + GetAuthors(context.Context, *GetAuthorsRequest) (*Authors, error) + CreateAuthors(context.Context, *CreateAuthorsRequest) (*Authors, error) + UpdateAuthors(context.Context, *UpdateAuthorsRequest) (*Authors, error) + DeleteAuthors(context.Context, *DeleteAuthorsRequest) (*types.Empty, error) + ListBooks(context.Context, *ListBooksRequest) (*ListBooksResponse, error) + GetBooks(context.Context, *GetBooksRequest) (*Books, error) + CreateBooks(context.Context, *CreateBooksRequest) (*Books, error) + UpdateBooks(context.Context, *UpdateBooksRequest) (*Books, error) + DeleteBooks(context.Context, *DeleteBooksRequest) (*types.Empty, error) +} + +func RegisterGeneratedServiceServer(s *grpc.Server, srv GeneratedServiceServer) { + s.RegisterService(&_GeneratedService_serviceDesc, srv) +} + +func _GeneratedService_ListAuthors_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListAuthorsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GeneratedServiceServer).ListAuthors(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/generated.GeneratedService/ListAuthors", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GeneratedServiceServer).ListAuthors(ctx, req.(*ListAuthorsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _GeneratedService_GetAuthors_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetAuthorsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GeneratedServiceServer).GetAuthors(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/generated.GeneratedService/GetAuthors", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GeneratedServiceServer).GetAuthors(ctx, req.(*GetAuthorsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _GeneratedService_CreateAuthors_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateAuthorsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GeneratedServiceServer).CreateAuthors(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/generated.GeneratedService/CreateAuthors", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GeneratedServiceServer).CreateAuthors(ctx, req.(*CreateAuthorsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _GeneratedService_UpdateAuthors_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateAuthorsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GeneratedServiceServer).UpdateAuthors(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/generated.GeneratedService/UpdateAuthors", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GeneratedServiceServer).UpdateAuthors(ctx, req.(*UpdateAuthorsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _GeneratedService_DeleteAuthors_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteAuthorsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GeneratedServiceServer).DeleteAuthors(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/generated.GeneratedService/DeleteAuthors", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GeneratedServiceServer).DeleteAuthors(ctx, req.(*DeleteAuthorsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _GeneratedService_ListBooks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListBooksRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GeneratedServiceServer).ListBooks(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/generated.GeneratedService/ListBooks", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GeneratedServiceServer).ListBooks(ctx, req.(*ListBooksRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _GeneratedService_GetBooks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetBooksRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GeneratedServiceServer).GetBooks(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/generated.GeneratedService/GetBooks", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GeneratedServiceServer).GetBooks(ctx, req.(*GetBooksRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _GeneratedService_CreateBooks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateBooksRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GeneratedServiceServer).CreateBooks(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/generated.GeneratedService/CreateBooks", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GeneratedServiceServer).CreateBooks(ctx, req.(*CreateBooksRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _GeneratedService_UpdateBooks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateBooksRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GeneratedServiceServer).UpdateBooks(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/generated.GeneratedService/UpdateBooks", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GeneratedServiceServer).UpdateBooks(ctx, req.(*UpdateBooksRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _GeneratedService_DeleteBooks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteBooksRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GeneratedServiceServer).DeleteBooks(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/generated.GeneratedService/DeleteBooks", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GeneratedServiceServer).DeleteBooks(ctx, req.(*DeleteBooksRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _GeneratedService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "generated.GeneratedService", + HandlerType: (*GeneratedServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ListAuthors", + Handler: _GeneratedService_ListAuthors_Handler, + }, + { + MethodName: "GetAuthors", + Handler: _GeneratedService_GetAuthors_Handler, + }, + { + MethodName: "CreateAuthors", + Handler: _GeneratedService_CreateAuthors_Handler, + }, + { + MethodName: "UpdateAuthors", + Handler: _GeneratedService_UpdateAuthors_Handler, + }, + { + MethodName: "DeleteAuthors", + Handler: _GeneratedService_DeleteAuthors_Handler, + }, + { + MethodName: "ListBooks", + Handler: _GeneratedService_ListBooks_Handler, + }, + { + MethodName: "GetBooks", + Handler: _GeneratedService_GetBooks_Handler, + }, + { + MethodName: "CreateBooks", + Handler: _GeneratedService_CreateBooks_Handler, + }, + { + MethodName: "UpdateBooks", + Handler: _GeneratedService_UpdateBooks_Handler, + }, + { + MethodName: "DeleteBooks", + Handler: _GeneratedService_DeleteBooks_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "generated/generated.proto", +} + +func (m *Authors) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Authors) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.ID) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintGenerated(dAtA, i, uint64(len(m.ID))) + i += copy(dAtA[i:], m.ID) + } + if len(m.Name) > 0 { + dAtA[i] = 0x12 + i++ + i = encodeVarintGenerated(dAtA, i, uint64(len(m.Name))) + i += copy(dAtA[i:], m.Name) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *ListAuthorsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ListAuthorsRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.ID) > 0 { + for _, s := range m.ID { + dAtA[i] = 0xa + i++ + l = len(s) + for l >= 1<<7 { + dAtA[i] = uint8(uint64(l)&0x7f | 0x80) + l >>= 7 + i++ + } + dAtA[i] = uint8(l) + i++ + i += copy(dAtA[i:], s) + } + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *ListAuthorsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ListAuthorsResponse) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Authors) > 0 { + for _, msg := range m.Authors { + dAtA[i] = 0xa + i++ + i = encodeVarintGenerated(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *GetAuthorsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GetAuthorsRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.ID) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintGenerated(dAtA, i, uint64(len(m.ID))) + i += copy(dAtA[i:], m.ID) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *CreateAuthorsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CreateAuthorsRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Authors != nil { + dAtA[i] = 0xa + i++ + i = encodeVarintGenerated(dAtA, i, uint64(m.Authors.Size())) + n1, err := m.Authors.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n1 + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *UpdateAuthorsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *UpdateAuthorsRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Authors != nil { + dAtA[i] = 0xa + i++ + i = encodeVarintGenerated(dAtA, i, uint64(m.Authors.Size())) + n2, err := m.Authors.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n2 + } + if m.UpdateMask != nil { + dAtA[i] = 0x12 + i++ + i = encodeVarintGenerated(dAtA, i, uint64(m.UpdateMask.Size())) + n3, err := m.UpdateMask.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n3 + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *DeleteAuthorsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DeleteAuthorsRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.ID) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintGenerated(dAtA, i, uint64(len(m.ID))) + i += copy(dAtA[i:], m.ID) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *Books) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Books) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.ID != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintGenerated(dAtA, i, uint64(m.ID)) + } + if len(m.AuthorID) > 0 { + dAtA[i] = 0x12 + i++ + i = encodeVarintGenerated(dAtA, i, uint64(len(m.AuthorID))) + i += copy(dAtA[i:], m.AuthorID) + } + if m.Available != nil { + dAtA[i] = 0x1a + i++ + i = encodeVarintGenerated(dAtA, i, uint64(m.Available.Size())) + n4, err := m.Available.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n4 + } + if m.Booktype != 0 { + dAtA[i] = 0x20 + i++ + i = encodeVarintGenerated(dAtA, i, uint64(m.Booktype)) + } + if len(m.Isbn) > 0 { + dAtA[i] = 0x2a + i++ + i = encodeVarintGenerated(dAtA, i, uint64(len(m.Isbn))) + i += copy(dAtA[i:], m.Isbn) + } + if m.Pages != 0 { + dAtA[i] = 0x30 + i++ + i = encodeVarintGenerated(dAtA, i, uint64(m.Pages)) + } + if m.Summary != nil { + dAtA[i] = 0x3a + i++ + i = encodeVarintGenerated(dAtA, i, uint64(m.Summary.Size())) + n5, err := m.Summary.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n5 + } + if len(m.Title) > 0 { + dAtA[i] = 0x42 + i++ + i = encodeVarintGenerated(dAtA, i, uint64(len(m.Title))) + i += copy(dAtA[i:], m.Title) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *ListBooksRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ListBooksRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.ID) > 0 { + dAtA7 := make([]byte, len(m.ID)*10) + var j6 int + for _, num1 := range m.ID { + num := uint64(num1) + for num >= 1<<7 { + dAtA7[j6] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j6++ + } + dAtA7[j6] = uint8(num) + j6++ + } + dAtA[i] = 0xa + i++ + i = encodeVarintGenerated(dAtA, i, uint64(j6)) + i += copy(dAtA[i:], dAtA7[:j6]) + } + if len(m.AuthorID) > 0 { + for _, s := range m.AuthorID { + dAtA[i] = 0x12 + i++ + l = len(s) + for l >= 1<<7 { + dAtA[i] = uint8(uint64(l)&0x7f | 0x80) + l >>= 7 + i++ + } + dAtA[i] = uint8(l) + i++ + i += copy(dAtA[i:], s) + } + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *ListBooksResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ListBooksResponse) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Books) > 0 { + for _, msg := range m.Books { + dAtA[i] = 0xa + i++ + i = encodeVarintGenerated(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *GetBooksRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GetBooksRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.ID != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintGenerated(dAtA, i, uint64(m.ID)) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *CreateBooksRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CreateBooksRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Books != nil { + dAtA[i] = 0xa + i++ + i = encodeVarintGenerated(dAtA, i, uint64(m.Books.Size())) + n8, err := m.Books.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n8 + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *UpdateBooksRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *UpdateBooksRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Books != nil { + dAtA[i] = 0xa + i++ + i = encodeVarintGenerated(dAtA, i, uint64(m.Books.Size())) + n9, err := m.Books.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n9 + } + if m.UpdateMask != nil { + dAtA[i] = 0x12 + i++ + i = encodeVarintGenerated(dAtA, i, uint64(m.UpdateMask.Size())) + n10, err := m.UpdateMask.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n10 + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *DeleteBooksRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DeleteBooksRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.ID != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintGenerated(dAtA, i, uint64(m.ID)) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func encodeVarintGenerated(dAtA []byte, offset int, v uint64) int { + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return offset + 1 +} +func (m *Authors) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ID) + if l > 0 { + n += 1 + l + sovGenerated(uint64(l)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovGenerated(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *ListAuthorsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.ID) > 0 { + for _, s := range m.ID { + l = len(s) + n += 1 + l + sovGenerated(uint64(l)) + } + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *ListAuthorsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Authors) > 0 { + for _, e := range m.Authors { + l = e.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *GetAuthorsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ID) + if l > 0 { + n += 1 + l + sovGenerated(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *CreateAuthorsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Authors != nil { + l = m.Authors.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *UpdateAuthorsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Authors != nil { + l = m.Authors.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + if m.UpdateMask != nil { + l = m.UpdateMask.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *DeleteAuthorsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ID) + if l > 0 { + n += 1 + l + sovGenerated(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *Books) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ID != 0 { + n += 1 + sovGenerated(uint64(m.ID)) + } + l = len(m.AuthorID) + if l > 0 { + n += 1 + l + sovGenerated(uint64(l)) + } + if m.Available != nil { + l = m.Available.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + if m.Booktype != 0 { + n += 1 + sovGenerated(uint64(m.Booktype)) + } + l = len(m.Isbn) + if l > 0 { + n += 1 + l + sovGenerated(uint64(l)) + } + if m.Pages != 0 { + n += 1 + sovGenerated(uint64(m.Pages)) + } + if m.Summary != nil { + l = m.Summary.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + l = len(m.Title) + if l > 0 { + n += 1 + l + sovGenerated(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *ListBooksRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.ID) > 0 { + l = 0 + for _, e := range m.ID { + l += sovGenerated(uint64(e)) + } + n += 1 + sovGenerated(uint64(l)) + l + } + if len(m.AuthorID) > 0 { + for _, s := range m.AuthorID { + l = len(s) + n += 1 + l + sovGenerated(uint64(l)) + } + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *ListBooksResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Books) > 0 { + for _, e := range m.Books { + l = e.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *GetBooksRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ID != 0 { + n += 1 + sovGenerated(uint64(m.ID)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *CreateBooksRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Books != nil { + l = m.Books.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *UpdateBooksRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Books != nil { + l = m.Books.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + if m.UpdateMask != nil { + l = m.UpdateMask.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *DeleteBooksRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ID != 0 { + n += 1 + sovGenerated(uint64(m.ID)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func sovGenerated(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} +func sozGenerated(x uint64) (n int) { + return sovGenerated(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Authors) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Authors: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Authors: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ListAuthorsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ListAuthorsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ListAuthorsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ID = append(m.ID, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ListAuthorsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ListAuthorsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ListAuthorsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authors", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authors = append(m.Authors, &Authors{}) + if err := m.Authors[len(m.Authors)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GetAuthorsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GetAuthorsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetAuthorsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CreateAuthorsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CreateAuthorsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CreateAuthorsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authors", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Authors == nil { + m.Authors = &Authors{} + } + if err := m.Authors.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *UpdateAuthorsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: UpdateAuthorsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UpdateAuthorsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authors", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Authors == nil { + m.Authors = &Authors{} + } + if err := m.Authors.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UpdateMask", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.UpdateMask == nil { + m.UpdateMask = &types.FieldMask{} + } + if err := m.UpdateMask.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DeleteAuthorsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DeleteAuthorsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DeleteAuthorsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Books) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Books: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Books: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + m.ID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ID |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AuthorID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AuthorID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Available", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Available == nil { + m.Available = &types.Timestamp{} + } + if err := m.Available.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Booktype", wireType) + } + m.Booktype = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Booktype |= BookType(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Isbn", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Isbn = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Pages", wireType) + } + m.Pages = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Pages |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Summary", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Summary == nil { + m.Summary = &types.StringValue{} + } + if err := m.Summary.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ListBooksRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ListBooksRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ListBooksRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType == 0 { + var v int32 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ID = append(m.ID, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.ID) == 0 { + m.ID = make([]int32, 0, elementCount) + } + for iNdEx < postIndex { + var v int32 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ID = append(m.ID, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AuthorID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AuthorID = append(m.AuthorID, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ListBooksResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ListBooksResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ListBooksResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Books", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Books = append(m.Books, &Books{}) + if err := m.Books[len(m.Books)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GetBooksRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GetBooksRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetBooksRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + m.ID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ID |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CreateBooksRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CreateBooksRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CreateBooksRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Books", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Books == nil { + m.Books = &Books{} + } + if err := m.Books.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *UpdateBooksRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: UpdateBooksRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UpdateBooksRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Books", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Books == nil { + m.Books = &Books{} + } + if err := m.Books.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UpdateMask", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.UpdateMask == nil { + m.UpdateMask = &types.FieldMask{} + } + if err := m.UpdateMask.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DeleteBooksRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DeleteBooksRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DeleteBooksRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + m.ID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ID |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenerated(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenerated + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenerated + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + return iNdEx, nil + case 1: + iNdEx += 8 + return iNdEx, nil + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenerated + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenerated + } + iNdEx += length + if iNdEx < 0 { + return 0, ErrInvalidLengthGenerated + } + return iNdEx, nil + case 3: + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenerated + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipGenerated(dAtA[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next + if iNdEx < 0 { + return 0, ErrInvalidLengthGenerated + } + } + return iNdEx, nil + case 4: + return iNdEx, nil + case 5: + iNdEx += 4 + return iNdEx, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} + +var ( + ErrInvalidLengthGenerated = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenerated = fmt.Errorf("proto: integer overflow") +) diff --git a/generated/generated.proto b/generated/generated.proto new file mode 100644 index 0000000..dbe6676 --- /dev/null +++ b/generated/generated.proto @@ -0,0 +1,110 @@ +// Code generated by gnorm, DO NOT EDIT! +syntax = "proto3"; + +package generated; + +import "github.com/gogo/protobuf/gogoproto/gogo.proto"; +import "google/protobuf/wrappers.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option go_package = "generated"; + +enum BookType { + FICTION = 0; + NONFICTION = 1; +} + +message Authors { + string id = 1 [(gogoproto.customname) = "ID"]; // (PK) + string name = 2 [(gogoproto.customname) = "Name"]; +} + +message ListAuthorsRequest { + // The fields on this ListAuthorsRequest are used to filter for rows from + // the authors table backend. The templates generate fields for primary and + // foreign keys automatically. If additional fields are needed for filtering, they + // would need to be added after code generation. + repeated string id = 1 [(gogoproto.customname) = "ID"]; // (PK) + + // Manually added filters: +} + +message ListAuthorsResponse { + repeated Authors authors = 1 [(gogoproto.customname) = "Authors"]; +} + +message GetAuthorsRequest { + string id = 1 [(gogoproto.customname) = "ID"]; // (PK) +} + +message CreateAuthorsRequest { + Authors authors = 1 [(gogoproto.customname) = "Authors"]; +} + +message UpdateAuthorsRequest { + Authors authors = 1 [(gogoproto.customname) = "Authors"]; + google.protobuf.FieldMask update_mask = 2; +} + +message DeleteAuthorsRequest { + string id = 1 [(gogoproto.customname) = "ID"]; // (PK) +} + +message Books { + int32 id = 1 [(gogoproto.customname) = "ID"]; // (PK) + string author_id = 2 [(gogoproto.customname) = "AuthorID"]; + google.protobuf.Timestamp available = 3 [(gogoproto.customname) = "Available"]; + BookType booktype = 4 [(gogoproto.customname) = "Booktype"]; + string isbn = 5 [(gogoproto.customname) = "Isbn"]; + int32 pages = 6 [(gogoproto.customname) = "Pages"]; + google.protobuf.StringValue summary = 7 [(gogoproto.customname) = "Summary"]; + string title = 8 [(gogoproto.customname) = "Title"]; +} + +message ListBooksRequest { + // The fields on this ListBooksRequest are used to filter for rows from + // the books table backend. The templates generate fields for primary and + // foreign keys automatically. If additional fields are needed for filtering, they + // would need to be added after code generation. + repeated int32 id = 1 [(gogoproto.customname) = "ID"]; // (PK) + repeated string author_id = 2 [(gogoproto.customname) = "AuthorID"]; // (FK) + + // Manually added filters: +} + +message ListBooksResponse { + repeated Books books = 1 [(gogoproto.customname) = "Books"]; +} + +message GetBooksRequest { + int32 id = 1 [(gogoproto.customname) = "ID"]; // (PK) +} + +message CreateBooksRequest { + Books books = 1 [(gogoproto.customname) = "Books"]; +} + +message UpdateBooksRequest { + Books books = 1 [(gogoproto.customname) = "Books"]; + google.protobuf.FieldMask update_mask = 2; +} + +message DeleteBooksRequest { + int32 id = 1 [(gogoproto.customname) = "ID"]; // (PK) +} + +service GeneratedService { + rpc ListAuthors(ListAuthorsRequest) returns (ListAuthorsResponse) {}; + rpc GetAuthors(GetAuthorsRequest) returns (Authors) {}; + rpc CreateAuthors(CreateAuthorsRequest) returns (Authors) {}; + rpc UpdateAuthors(UpdateAuthorsRequest) returns (Authors) {}; + rpc DeleteAuthors(DeleteAuthorsRequest) returns (google.protobuf.Empty) {}; + + rpc ListBooks(ListBooksRequest) returns (ListBooksResponse) {}; + rpc GetBooks(GetBooksRequest) returns (Books) {}; + rpc CreateBooks(CreateBooksRequest) returns (Books) {}; + rpc UpdateBooks(UpdateBooksRequest) returns (Books) {}; + rpc DeleteBooks(DeleteBooksRequest) returns (google.protobuf.Empty) {}; +} diff --git a/gnorm.sql b/gnorm.sql new file mode 100644 index 0000000..0498294 --- /dev/null +++ b/gnorm.sql @@ -0,0 +1,53 @@ +-- +-- PostgreSQL database dump +-- + +CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA public; + +CREATE TYPE public.book_type AS ENUM ( + 'FICTION', + 'NONFICTION' +); + +CREATE TABLE public.authors ( + id uuid DEFAULT public.uuid_generate_v4() NOT NULL, + name text NOT NULL +); + +CREATE TABLE public.books ( + id integer NOT NULL, + author_id uuid NOT NULL, + isbn character(32) NOT NULL, + booktype public.book_type NOT NULL, + title text NOT NULL, + pages integer NOT NULL, + summary text, + available timestamp with time zone DEFAULT '2017-09-04 21:43:39.197538-04'::timestamp with time zone NOT NULL +); + +CREATE SEQUENCE public.books_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE ONLY public.books ALTER COLUMN id SET DEFAULT nextval('public.books_id_seq'::regclass); + + +ALTER TABLE ONLY public.authors + ADD CONSTRAINT authors_pkey PRIMARY KEY (id); + +ALTER TABLE ONLY public.books + ADD CONSTRAINT books_isbn_key UNIQUE (isbn); + +ALTER TABLE ONLY public.books + ADD CONSTRAINT books_pkey PRIMARY KEY (id); + +CREATE INDEX authors_name_idx ON public.authors USING btree (name); + +CREATE INDEX books_title_idx ON public.books USING btree (author_id, title); + +ALTER TABLE ONLY public.books + ADD CONSTRAINT books_author_id_fkey FOREIGN KEY (author_id) REFERENCES public.authors(id); \ No newline at end of file diff --git a/gnorm.toml b/gnorm.toml new file mode 100644 index 0000000..78376f7 --- /dev/null +++ b/gnorm.toml @@ -0,0 +1,60 @@ +# !!!! YOU NEED TO CHANGE THIS !!!! +# This is the connection string for your database +ConnStr = "dbname=grpc host=127.0.0.1 sslmode=disable user=$GRPCDBUSER password=$GRPCDBPASS" + +DBType = "postgres" + +Schemas = ["public"] + +PluginDirs = ["./gnorm/plugin"] + +NameConversion = "{{pascal .}}" + +ExcludeTables = ["schema_version"] + +# You need clang-format installed for this to work +PostRun = ["clang-format", "-i", "-style", "{BasedOnStyle: Google, ColumnLimit: 132, AlignConsecutiveAssignments: true, AlignConsecutiveDeclarations: true}", "$GNORMFILE"] + +OutputDir = "./generated" + +[SchemaPaths] +"generated.proto" = "./gnorm_templates/proto.gotmpl" + +[TypeMap] +"bigint" = "int64" # Go: "int64" +"boolean" = "bool" # Go: "bool" +"bytea" = "bytes" # Go: "[]byte" +"character" = "string" # Go: "string" +"character varying" = "string" # Go: "string" +"date" = "google.protobuf.Timestamp" # Go: "time.Time" +"float4" = "float" # Go: "float32" +"float8" = "double" # Go: "float64" +"integer" = "int32" # Go: "int32" +"jsonb" = "bytes" # Go: "pgtype.JSONB" +"text" = "string" # Go: "string" +"timestamp with time zone" = "google.protobuf.Timestamp" # Go: "time.Time" +"tsvector" = "string" # Go: "string" +"uuid" = "string" # Go: "string" +# enums: These must be kept in sync with the database schema +"book_type" = "BookType" + +[NullableTypeMap] +"bigint" = "google.protobuf.Int64Value" # Go: "pgtype.Int8" +"boolean" = "google.protobuf.BoolValue" # Go: "pgtype.Bool" +"bytea" = "google.protobuf.BytesValue" # Go: "pgtype.Bytea" +"character" = "google.protobuf.StringValue" # Go: "pgtype.Text" +"character varying" = "google.protobuf.StringValue" # Go: "pgtype.Text" +"date" = "google.protobuf.Timestamp" # Go: "pgtype.Date" +"float4" = "google.protobuf.FloatValue" # Go: "pgtype.Float4" +"float8" = "google.protobuf.DoubleValue" # Go: "pgtype.Float8" +"integer" = "google.protobuf.Int32Value" # Go: "pgtype.Int4" +"jsonb" = "google.protobuf.BytesValue" # Go: "pgtype.JSONB" +"text" = "google.protobuf.StringValue" # Go: "pgtype.Text" +"timestamp with time zone" = "google.protobuf.Timestamp" # Go: "pgtype.Timestamptz" +"tsvector" = "google.protobuf.StringValue" # Go: "pgtype.Text" +"uuid" = "google.protobuf.StringValue" # GO: "pgtype.Text" + +[Params] +RootPkg = "generated" +RootImport = "github.com/gnormal/gRPC/generated" +GRPCService = "GeneratedService" \ No newline at end of file diff --git a/gnorm_templates/proto.gotmpl b/gnorm_templates/proto.gotmpl new file mode 100644 index 0000000..7ff0384 --- /dev/null +++ b/gnorm_templates/proto.gotmpl @@ -0,0 +1,112 @@ +// Code generated by gnorm, DO NOT EDIT! +{{- $rootPkg := .Params.RootPkg}} +{{- /* +If you have more than one enum, you will hit this issue: +- https://github.com/gnormal/gnorm/issues/115 +*/}} +syntax = "proto3"; + +package {{$rootPkg}}; + +import "github.com/gogo/protobuf/gogoproto/gogo.proto"; +import "google/protobuf/wrappers.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + + +option go_package = "{{$rootPkg}}"; + + +{{range .Schema.Enums}} +enum {{.Name}} { +{{- $fieldIdx := 0 -}} +{{- range .Values}} + {{snakeUpper .DBName}} = {{$fieldIdx}}; + {{- $fieldIdx = inc $fieldIdx -}} +{{- end}} +}{{end}} + +{{range .Schema.Tables}}{{if eq .Type "BASE TABLE"}} +{{$table := .DBName -}} +{{$schema := .Schema.DBName -}} +{{$colsByName := .ColumnsByName -}} +{{$nonPKDBNames := .Columns.DBNames.Sorted.Except .PrimaryKeys.DBNames -}} + +{{if .Comment}}// {{.Comment}}{{end}} +message {{.Name}} { +{{- $fieldIdx := 1 -}} +{{- range .PrimaryKeys.DBNames.Sorted}}{{ with (index $colsByName .)}} + {{- if .Comment}} + // {{.DBName}}, {{.Comment}}{{end}} + {{.Type}} {{.DBName}} = {{$fieldIdx}} [(gogoproto.customname) = "{{.Name}}"]; // (PK) + {{- $fieldIdx = inc $fieldIdx -}} +{{- end}}{{end}} +{{- range $nonPKDBNames}}{{ with (index $colsByName .) }} + {{- if .Comment}} + // {{.DBName}}, {{.Comment}}{{end}} + {{.Type}} {{.DBName}} = {{$fieldIdx}} [(gogoproto.customname) = "{{.Name}}"]; + {{- $fieldIdx = inc $fieldIdx -}} +{{- end}}{{end}} +} + +message List{{plural .Name}}Request { + // The fields on this List{{plural .Name}}Request are used to filter for rows from + // the {{.DBName}} table backend. The templates generate fields for primary and + // foreign keys automatically. If additional fields are needed for filtering, they + // would need to be added after code generation. +{{- $fieldIdx := 1 -}} +{{- range .PrimaryKeys.DBNames.Sorted}}{{ with (index $colsByName .)}} + repeated {{.Type}} {{.DBName}} = {{$fieldIdx}} [(gogoproto.customname) = "{{.Name}}"]; // (PK) + {{- $fieldIdx = inc $fieldIdx -}} +{{- end}}{{end}} +{{- range .ForeignKeys}} +{{- range .FKColumns}} +{{- with .Column}} + repeated {{.Type}} {{.DBName}} = {{$fieldIdx}} [(gogoproto.customname) = "{{.Name}}"]; // (FK) + {{- $fieldIdx = inc $fieldIdx -}} +{{- end}}{{end}}{{end}} + + // Manually added filters: +} + +message List{{plural .Name}}Response { + repeated {{.Name}} {{toLower (plural .Name)}} = 1 [(gogoproto.customname) = "{{plural .Name}}"]; +} + +message Get{{.Name}}Request { + {{- $fieldIdx := 1 -}} + {{- range .PrimaryKeys.DBNames.Sorted}}{{ with (index $colsByName .)}} + {{.Type}} {{.DBName}} = {{$fieldIdx}} [(gogoproto.customname) = "{{.Name}}"]; // (PK) + {{- $fieldIdx = inc $fieldIdx -}} + {{end}}{{end}} +} + +message Create{{.Name}}Request { + {{.Name}} {{.DBName}} = 1 [(gogoproto.customname) = "{{.Name}}"]; +} + +message Update{{.Name}}Request { + {{.Name}} {{.DBName}} = 1 [(gogoproto.customname) = "{{.Name}}"]; + google.protobuf.FieldMask update_mask = 2; +} + +message Delete{{.Name}}Request { + {{- $fieldIdx := 1 -}} + {{- range .PrimaryKeys.DBNames.Sorted}}{{ with (index $colsByName .)}} + {{.Type}} {{.DBName}} = {{$fieldIdx}} [(gogoproto.customname) = "{{.Name}}"]; // (PK) + {{- $fieldIdx = inc $fieldIdx -}} + {{end}}{{end}} +} +{{end}}{{end}} + +service {{.Params.GRPCService}} { + {{range .Schema.Tables -}}{{if eq .Type "BASE TABLE" -}} + rpc List{{plural .Name}} (List{{plural .Name}}Request) returns (List{{plural .Name}}Response) {}; + rpc Get{{.Name}} (Get{{.Name}}Request) returns ({{.Name}}) {}; + rpc Create{{.Name}} (Create{{.Name}}Request) returns ({{.Name}}) {}; + rpc Update{{.Name}} (Update{{.Name}}Request) returns ({{.Name}}) {}; + rpc Delete{{.Name}} (Delete{{.Name}}Request) returns (google.protobuf.Empty) {}; + + {{end}}{{end}} +}