diff --git a/DESIGN.md b/DESIGN.md new file mode 100644 index 0000000..640ee3b --- /dev/null +++ b/DESIGN.md @@ -0,0 +1,30 @@ +# Design Notes + +## Protobuf + +AEP and protobuf best practices forces a particular structure between the following that should align: + +- Protobuf directory structure and filenames. +- Package names. +- AEP API name. + +Using the example in this directory, a file "example/bookstore/bookstore.yaml" from the resource root: + +- aep API name is bookstore.example.com +- com.example.bookstore should be the package name. +- so com/example/bookstore.proto should be the directory name. + +Open questions: + +- Should the AEPC generation match the protobuf convention? so that openapi json files end up in the same directory as the proto files? +- For the AEP API name - is it more correct to go from broadest domain to most qualified domain (e.g. com.example.bookstore instead of example.bookstore.com)? + - this aligns well with the proto, java, and golang packages. It does not align well with how domain names work. + +Thinking about something like the following for `bookstore.example.com`: + +``` +com/ + example/ + bookstore.proto + bookstore_openapi.json +``` \ No newline at end of file diff --git a/cmd/root.go b/cmd/root.go index 99b022b..cfae6ce 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -34,25 +34,26 @@ import ( func NewCommand() *cobra.Command { var inputFile string - var outputFile string + var outputFilePrefix string c := &cobra.Command{ Use: "aepc", Short: "aepc compiles resource representations to full proto rpcs", Long: "aepc compiles resource representations to full proto rpcs", Run: func(cmd *cobra.Command, args []string) { - err := ProcessInput(inputFile, outputFile) + err := ProcessInput(inputFile, outputFilePrefix) if err != nil { log.Fatal(err) } }, } c.Flags().StringVarP(&inputFile, "input", "i", "", "input files with resource") - c.Flags().StringVarP(&outputFile, "output", "o", "", "output file to use") + c.Flags().StringVarP(&outputFilePrefix, "output", "o", "", "output file to write to. File types will be appended to this prefix)") return c } -func ProcessInput(inputFile, outputFile string) error { +func ProcessInput(inputFile, outputFilePrefix string) error { + outputDir := filepath.Dir(outputFilePrefix) s := &schema.Service{} input, err := ReadFile(inputFile) fmt.Printf("input: %s\n", string(input)) @@ -72,15 +73,15 @@ func ProcessInput(inputFile, outputFile string) error { if err != nil { return fmt.Errorf("error parsing service: %w", err) } - proto, _ := proto.WriteServiceToProto(ps) - protoFile := fmt.Sprintf("%s.proto", outputFile) + proto, _ := proto.WriteServiceToProto(ps, outputDir) + protoFile := fmt.Sprintf("%s.proto", outputFilePrefix) err = WriteFile(protoFile, proto) if err != nil { return fmt.Errorf("error writing file: %w", err) } fmt.Printf("output proto file: %s\n", protoFile) openapi, _ := openapi.WriteServiceToOpenAPI(ps) - openapiFile := fmt.Sprintf("%s.openapi.json", outputFile) + openapiFile := fmt.Sprintf("%s_openapi.json", outputFilePrefix) err = WriteFile(openapiFile, openapi) if err != nil { return fmt.Errorf("error writing file: %w", err) diff --git a/example/bookstore/bookstore.yaml.output.pb.go b/example/bookstore/bookstore.yaml.output.pb.go deleted file mode 100644 index 195c6ed..0000000 --- a/example/bookstore/bookstore.yaml.output.pb.go +++ /dev/null @@ -1,794 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.31.0 -// protoc (unknown) -// source: example/bookstore/bookstore.yaml.output.proto - -package bookstore - -import ( - _ "google.golang.org/genproto/googleapis/api/annotations" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - emptypb "google.golang.org/protobuf/types/known/emptypb" - fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// A Book resource. -type Book struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Field for isbn. - Isbn string `protobuf:"bytes,1,opt,name=isbn,proto3" json:"isbn,omitempty"` - // Field for path. - Path string `protobuf:"bytes,10000,opt,name=path,proto3" json:"path,omitempty"` - // Field for id. - Id string `protobuf:"bytes,10001,opt,name=id,proto3" json:"id,omitempty"` -} - -func (x *Book) Reset() { - *x = Book{} - if protoimpl.UnsafeEnabled { - mi := &file_example_bookstore_bookstore_yaml_output_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Book) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Book) ProtoMessage() {} - -func (x *Book) ProtoReflect() protoreflect.Message { - mi := &file_example_bookstore_bookstore_yaml_output_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Book.ProtoReflect.Descriptor instead. -func (*Book) Descriptor() ([]byte, []int) { - return file_example_bookstore_bookstore_yaml_output_proto_rawDescGZIP(), []int{0} -} - -func (x *Book) GetIsbn() string { - if x != nil { - return x.Isbn - } - return "" -} - -func (x *Book) GetPath() string { - if x != nil { - return x.Path - } - return "" -} - -func (x *Book) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -// A Create request for a Book resource. -type CreateBookRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // A field for the parent of Book - Parent string `protobuf:"bytes,10013,opt,name=parent,proto3" json:"parent,omitempty"` - // An id that uniquely identifies the resource within the collection%!(EXTRA string=Book) - Id string `protobuf:"bytes,10014,opt,name=id,proto3" json:"id,omitempty"` - // The globally unique identifier for the resource - Path string `protobuf:"bytes,10018,opt,name=path,proto3" json:"path,omitempty"` - // The resource to perform the operation on. - Book *Book `protobuf:"bytes,10015,opt,name=book,proto3" json:"book,omitempty"` -} - -func (x *CreateBookRequest) Reset() { - *x = CreateBookRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_example_bookstore_bookstore_yaml_output_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CreateBookRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateBookRequest) ProtoMessage() {} - -func (x *CreateBookRequest) ProtoReflect() protoreflect.Message { - mi := &file_example_bookstore_bookstore_yaml_output_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CreateBookRequest.ProtoReflect.Descriptor instead. -func (*CreateBookRequest) Descriptor() ([]byte, []int) { - return file_example_bookstore_bookstore_yaml_output_proto_rawDescGZIP(), []int{1} -} - -func (x *CreateBookRequest) GetParent() string { - if x != nil { - return x.Parent - } - return "" -} - -func (x *CreateBookRequest) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *CreateBookRequest) GetPath() string { - if x != nil { - return x.Path - } - return "" -} - -func (x *CreateBookRequest) GetBook() *Book { - if x != nil { - return x.Book - } - return nil -} - -// Request message for the GetBook method -type GetBookRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The globally unique identifier for the resource - Path string `protobuf:"bytes,10018,opt,name=path,proto3" json:"path,omitempty"` -} - -func (x *GetBookRequest) Reset() { - *x = GetBookRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_example_bookstore_bookstore_yaml_output_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetBookRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetBookRequest) ProtoMessage() {} - -func (x *GetBookRequest) ProtoReflect() protoreflect.Message { - mi := &file_example_bookstore_bookstore_yaml_output_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetBookRequest.ProtoReflect.Descriptor instead. -func (*GetBookRequest) Descriptor() ([]byte, []int) { - return file_example_bookstore_bookstore_yaml_output_proto_rawDescGZIP(), []int{2} -} - -func (x *GetBookRequest) GetPath() string { - if x != nil { - return x.Path - } - return "" -} - -// Request message for the UpdateBook method -type UpdateBookRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The globally unique identifier for the resource - Path string `protobuf:"bytes,10018,opt,name=path,proto3" json:"path,omitempty"` - // The resource to perform the operation on. - Book *Book `protobuf:"bytes,10015,opt,name=book,proto3" json:"book,omitempty"` - // The update mask for the resource - UpdateMask *fieldmaskpb.FieldMask `protobuf:"bytes,10012,opt,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"` -} - -func (x *UpdateBookRequest) Reset() { - *x = UpdateBookRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_example_bookstore_bookstore_yaml_output_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *UpdateBookRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateBookRequest) ProtoMessage() {} - -func (x *UpdateBookRequest) ProtoReflect() protoreflect.Message { - mi := &file_example_bookstore_bookstore_yaml_output_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UpdateBookRequest.ProtoReflect.Descriptor instead. -func (*UpdateBookRequest) Descriptor() ([]byte, []int) { - return file_example_bookstore_bookstore_yaml_output_proto_rawDescGZIP(), []int{3} -} - -func (x *UpdateBookRequest) GetPath() string { - if x != nil { - return x.Path - } - return "" -} - -func (x *UpdateBookRequest) GetBook() *Book { - if x != nil { - return x.Book - } - return nil -} - -func (x *UpdateBookRequest) GetUpdateMask() *fieldmaskpb.FieldMask { - if x != nil { - return x.UpdateMask - } - return nil -} - -// Request message for the DeleteBook method -type DeleteBookRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The globally unique identifier for the resource - Path string `protobuf:"bytes,10018,opt,name=path,proto3" json:"path,omitempty"` -} - -func (x *DeleteBookRequest) Reset() { - *x = DeleteBookRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_example_bookstore_bookstore_yaml_output_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DeleteBookRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteBookRequest) ProtoMessage() {} - -func (x *DeleteBookRequest) ProtoReflect() protoreflect.Message { - mi := &file_example_bookstore_bookstore_yaml_output_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DeleteBookRequest.ProtoReflect.Descriptor instead. -func (*DeleteBookRequest) Descriptor() ([]byte, []int) { - return file_example_bookstore_bookstore_yaml_output_proto_rawDescGZIP(), []int{4} -} - -func (x *DeleteBookRequest) GetPath() string { - if x != nil { - return x.Path - } - return "" -} - -// Request message for the DeleteBook method -type ListBookRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // A field for the parent of Book - Parent string `protobuf:"bytes,10013,opt,name=parent,proto3" json:"parent,omitempty"` - // The page token indicating the starting point of the page - PageToken string `protobuf:"bytes,10010,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` - // The maximum number of resources to return in a single page. - MaxPageSize int32 `protobuf:"varint,10017,opt,name=max_page_size,json=maxPageSize,proto3" json:"max_page_size,omitempty"` -} - -func (x *ListBookRequest) Reset() { - *x = ListBookRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_example_bookstore_bookstore_yaml_output_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListBookRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListBookRequest) ProtoMessage() {} - -func (x *ListBookRequest) ProtoReflect() protoreflect.Message { - mi := &file_example_bookstore_bookstore_yaml_output_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListBookRequest.ProtoReflect.Descriptor instead. -func (*ListBookRequest) Descriptor() ([]byte, []int) { - return file_example_bookstore_bookstore_yaml_output_proto_rawDescGZIP(), []int{5} -} - -func (x *ListBookRequest) GetParent() string { - if x != nil { - return x.Parent - } - return "" -} - -func (x *ListBookRequest) GetPageToken() string { - if x != nil { - return x.PageToken - } - return "" -} - -func (x *ListBookRequest) GetMaxPageSize() int32 { - if x != nil { - return x.MaxPageSize - } - return 0 -} - -// Response message for the DeleteBook method -type ListBookResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // A list of books - Books *Book `protobuf:"bytes,10016,opt,name=books,proto3" json:"books,omitempty"` - // The page token indicating the ending point of this response. - NextPageToken string `protobuf:"bytes,10011,opt,name=next_page_token,json=nextPageToken,proto3" json:"next_page_token,omitempty"` -} - -func (x *ListBookResponse) Reset() { - *x = ListBookResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_example_bookstore_bookstore_yaml_output_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListBookResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListBookResponse) ProtoMessage() {} - -func (x *ListBookResponse) ProtoReflect() protoreflect.Message { - mi := &file_example_bookstore_bookstore_yaml_output_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListBookResponse.ProtoReflect.Descriptor instead. -func (*ListBookResponse) Descriptor() ([]byte, []int) { - return file_example_bookstore_bookstore_yaml_output_proto_rawDescGZIP(), []int{6} -} - -func (x *ListBookResponse) GetBooks() *Book { - if x != nil { - return x.Books - } - return nil -} - -func (x *ListBookResponse) GetNextPageToken() string { - if x != nil { - return x.NextPageToken - } - return "" -} - -// Request message for the ApplyBook method -type ApplyBookRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The globally unique identifier for the resource - Path string `protobuf:"bytes,10018,opt,name=path,proto3" json:"path,omitempty"` - // The resource to perform the operation on. - Book *Book `protobuf:"bytes,10015,opt,name=book,proto3" json:"book,omitempty"` -} - -func (x *ApplyBookRequest) Reset() { - *x = ApplyBookRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_example_bookstore_bookstore_yaml_output_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ApplyBookRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ApplyBookRequest) ProtoMessage() {} - -func (x *ApplyBookRequest) ProtoReflect() protoreflect.Message { - mi := &file_example_bookstore_bookstore_yaml_output_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ApplyBookRequest.ProtoReflect.Descriptor instead. -func (*ApplyBookRequest) Descriptor() ([]byte, []int) { - return file_example_bookstore_bookstore_yaml_output_proto_rawDescGZIP(), []int{7} -} - -func (x *ApplyBookRequest) GetPath() string { - if x != nil { - return x.Path - } - return "" -} - -func (x *ApplyBookRequest) GetBook() *Book { - if x != nil { - return x.Book - } - return nil -} - -var File_example_bookstore_bookstore_yaml_output_proto protoreflect.FileDescriptor - -var file_example_bookstore_bookstore_yaml_output_proto_rawDesc = []byte{ - 0x0a, 0x2d, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, - 0x6f, 0x72, 0x65, 0x2f, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x79, 0x61, - 0x6d, 0x6c, 0x2e, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, - 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, - 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, - 0x70, 0x69, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, - 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, - 0x61, 0x70, 0x69, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, - 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x22, 0x40, 0x0a, 0x04, 0x42, 0x6f, 0x6f, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x73, 0x62, - 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x69, 0x73, 0x62, 0x6e, 0x12, 0x13, 0x0a, - 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x90, 0x4e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, - 0x74, 0x68, 0x12, 0x0f, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x91, 0x4e, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x02, 0x69, 0x64, 0x22, 0x9c, 0x01, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x6f, - 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x06, 0x70, 0x61, 0x72, - 0x65, 0x6e, 0x74, 0x18, 0x9d, 0x4e, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, - 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x0f, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x9e, 0x4e, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x37, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, - 0x18, 0xa2, 0x4e, 0x20, 0x01, 0x28, 0x09, 0x42, 0x22, 0xe0, 0x41, 0x02, 0xfa, 0x41, 0x1c, 0x0a, - 0x1a, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, - 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x04, 0x70, 0x61, 0x74, - 0x68, 0x12, 0x1f, 0x0a, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x18, 0x9f, 0x4e, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x05, 0x2e, 0x42, 0x6f, 0x6f, 0x6b, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x04, 0x62, 0x6f, - 0x6f, 0x6b, 0x22, 0x49, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x37, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0xa2, 0x4e, 0x20, - 0x01, 0x28, 0x09, 0x42, 0x22, 0xe0, 0x41, 0x02, 0xfa, 0x41, 0x1c, 0x0a, 0x1a, 0x62, 0x6f, 0x6f, - 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x22, 0xab, 0x01, - 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x37, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0xa2, 0x4e, 0x20, 0x01, - 0x28, 0x09, 0x42, 0x22, 0xe0, 0x41, 0x02, 0xfa, 0x41, 0x1c, 0x0a, 0x1a, 0x62, 0x6f, 0x6f, 0x6b, - 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x1f, 0x0a, 0x04, - 0x62, 0x6f, 0x6f, 0x6b, 0x18, 0x9f, 0x4e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x05, 0x2e, 0x42, 0x6f, - 0x6f, 0x6b, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x12, 0x3c, 0x0a, - 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x18, 0x9c, 0x4e, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4d, 0x61, 0x73, 0x6b, 0x52, - 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x73, 0x6b, 0x22, 0x4c, 0x0a, 0x11, 0x44, - 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x37, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0xa2, 0x4e, 0x20, 0x01, 0x28, 0x09, 0x42, - 0x22, 0xe0, 0x41, 0x02, 0xfa, 0x41, 0x1c, 0x0a, 0x1a, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, - 0x72, 0x65, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x42, - 0x6f, 0x6f, 0x6b, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x22, 0x74, 0x0a, 0x0f, 0x4c, 0x69, 0x73, - 0x74, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x06, - 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x9d, 0x4e, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, - 0x41, 0x02, 0x52, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x61, - 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x9a, 0x4e, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x23, 0x0a, 0x0d, 0x6d, 0x61, - 0x78, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0xa1, 0x4e, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x0b, 0x6d, 0x61, 0x78, 0x50, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x22, - 0x59, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x05, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x18, 0xa0, 0x4e, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x05, 0x2e, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x05, 0x62, 0x6f, 0x6f, 0x6b, - 0x73, 0x12, 0x27, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, - 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x9b, 0x4e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, - 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x6c, 0x0a, 0x10, 0x41, 0x70, - 0x70, 0x6c, 0x79, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x37, - 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0xa2, 0x4e, 0x20, 0x01, 0x28, 0x09, 0x42, 0x22, 0xe0, - 0x41, 0x02, 0xfa, 0x41, 0x1c, 0x0a, 0x1a, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, - 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x42, 0x6f, 0x6f, - 0x6b, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x1f, 0x0a, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x18, - 0x9f, 0x4e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x05, 0x2e, 0x42, 0x6f, 0x6f, 0x6b, 0x42, 0x03, 0xe0, - 0x41, 0x02, 0x52, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x32, 0xe6, 0x03, 0x0a, 0x09, 0x42, 0x6f, 0x6f, - 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x12, 0x4f, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x42, 0x6f, 0x6f, 0x6b, 0x12, 0x12, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x6f, 0x6f, - 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x05, 0x2e, 0x42, 0x6f, 0x6f, 0x6b, 0x22, - 0x26, 0xda, 0x41, 0x0f, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x2c, 0x72, 0x65, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x3a, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x22, - 0x06, 0x2f, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x12, 0x3a, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x42, 0x6f, - 0x6f, 0x6b, 0x12, 0x0f, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x05, 0x2e, 0x42, 0x6f, 0x6f, 0x6b, 0x22, 0x17, 0x82, 0xd3, 0xe4, 0x93, - 0x02, 0x11, 0x12, 0x0f, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x3d, 0x62, 0x6f, 0x6f, 0x6b, 0x73, - 0x2f, 0x2a, 0x7d, 0x12, 0x62, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x42, 0x6f, 0x6f, - 0x6b, 0x12, 0x12, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x05, 0x2e, 0x42, 0x6f, 0x6f, 0x6b, 0x22, 0x39, 0xda, 0x41, - 0x14, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x2c, 0x72, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1c, 0x3a, 0x04, 0x62, 0x6f, 0x6f, - 0x6b, 0x32, 0x14, 0x2f, 0x7b, 0x62, 0x6f, 0x6f, 0x6b, 0x2e, 0x70, 0x61, 0x74, 0x68, 0x3d, 0x62, - 0x6f, 0x6f, 0x6b, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0x58, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, - 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x12, 0x12, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x6f, - 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, - 0x79, 0x22, 0x1e, 0xda, 0x41, 0x04, 0x70, 0x61, 0x74, 0x68, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x11, - 0x2a, 0x0f, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x3d, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x2f, 0x2a, - 0x7d, 0x12, 0x48, 0x0a, 0x08, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x6f, 0x6f, 0x6b, 0x12, 0x10, 0x2e, - 0x4c, 0x69, 0x73, 0x74, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x11, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x17, 0xda, 0x41, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x08, 0x12, 0x06, 0x2f, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x12, 0x44, 0x0a, 0x09, 0x41, - 0x70, 0x70, 0x6c, 0x79, 0x42, 0x6f, 0x6f, 0x6b, 0x12, 0x11, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x79, - 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x05, 0x2e, 0x42, 0x6f, - 0x6f, 0x6b, 0x22, 0x1d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x17, 0x3a, 0x04, 0x62, 0x6f, 0x6f, 0x6b, - 0x1a, 0x0f, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x3d, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x2f, 0x2a, - 0x7d, 0x42, 0x0c, 0x5a, 0x0a, 0x2f, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_example_bookstore_bookstore_yaml_output_proto_rawDescOnce sync.Once - file_example_bookstore_bookstore_yaml_output_proto_rawDescData = file_example_bookstore_bookstore_yaml_output_proto_rawDesc -) - -func file_example_bookstore_bookstore_yaml_output_proto_rawDescGZIP() []byte { - file_example_bookstore_bookstore_yaml_output_proto_rawDescOnce.Do(func() { - file_example_bookstore_bookstore_yaml_output_proto_rawDescData = protoimpl.X.CompressGZIP(file_example_bookstore_bookstore_yaml_output_proto_rawDescData) - }) - return file_example_bookstore_bookstore_yaml_output_proto_rawDescData -} - -var file_example_bookstore_bookstore_yaml_output_proto_msgTypes = make([]protoimpl.MessageInfo, 8) -var file_example_bookstore_bookstore_yaml_output_proto_goTypes = []interface{}{ - (*Book)(nil), // 0: Book - (*CreateBookRequest)(nil), // 1: CreateBookRequest - (*GetBookRequest)(nil), // 2: GetBookRequest - (*UpdateBookRequest)(nil), // 3: UpdateBookRequest - (*DeleteBookRequest)(nil), // 4: DeleteBookRequest - (*ListBookRequest)(nil), // 5: ListBookRequest - (*ListBookResponse)(nil), // 6: ListBookResponse - (*ApplyBookRequest)(nil), // 7: ApplyBookRequest - (*fieldmaskpb.FieldMask)(nil), // 8: google.protobuf.FieldMask - (*emptypb.Empty)(nil), // 9: google.protobuf.Empty -} -var file_example_bookstore_bookstore_yaml_output_proto_depIdxs = []int32{ - 0, // 0: CreateBookRequest.book:type_name -> Book - 0, // 1: UpdateBookRequest.book:type_name -> Book - 8, // 2: UpdateBookRequest.update_mask:type_name -> google.protobuf.FieldMask - 0, // 3: ListBookResponse.books:type_name -> Book - 0, // 4: ApplyBookRequest.book:type_name -> Book - 1, // 5: Bookstore.CreateBook:input_type -> CreateBookRequest - 2, // 6: Bookstore.GetBook:input_type -> GetBookRequest - 3, // 7: Bookstore.UpdateBook:input_type -> UpdateBookRequest - 4, // 8: Bookstore.DeleteBook:input_type -> DeleteBookRequest - 5, // 9: Bookstore.ListBook:input_type -> ListBookRequest - 7, // 10: Bookstore.ApplyBook:input_type -> ApplyBookRequest - 0, // 11: Bookstore.CreateBook:output_type -> Book - 0, // 12: Bookstore.GetBook:output_type -> Book - 0, // 13: Bookstore.UpdateBook:output_type -> Book - 9, // 14: Bookstore.DeleteBook:output_type -> google.protobuf.Empty - 6, // 15: Bookstore.ListBook:output_type -> ListBookResponse - 0, // 16: Bookstore.ApplyBook:output_type -> Book - 11, // [11:17] is the sub-list for method output_type - 5, // [5:11] is the sub-list for method input_type - 5, // [5:5] is the sub-list for extension type_name - 5, // [5:5] is the sub-list for extension extendee - 0, // [0:5] is the sub-list for field type_name -} - -func init() { file_example_bookstore_bookstore_yaml_output_proto_init() } -func file_example_bookstore_bookstore_yaml_output_proto_init() { - if File_example_bookstore_bookstore_yaml_output_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_example_bookstore_bookstore_yaml_output_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Book); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_example_bookstore_bookstore_yaml_output_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateBookRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_example_bookstore_bookstore_yaml_output_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetBookRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_example_bookstore_bookstore_yaml_output_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateBookRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_example_bookstore_bookstore_yaml_output_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteBookRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_example_bookstore_bookstore_yaml_output_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListBookRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_example_bookstore_bookstore_yaml_output_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListBookResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_example_bookstore_bookstore_yaml_output_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ApplyBookRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_example_bookstore_bookstore_yaml_output_proto_rawDesc, - NumEnums: 0, - NumMessages: 8, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_example_bookstore_bookstore_yaml_output_proto_goTypes, - DependencyIndexes: file_example_bookstore_bookstore_yaml_output_proto_depIdxs, - MessageInfos: file_example_bookstore_bookstore_yaml_output_proto_msgTypes, - }.Build() - File_example_bookstore_bookstore_yaml_output_proto = out.File - file_example_bookstore_bookstore_yaml_output_proto_rawDesc = nil - file_example_bookstore_bookstore_yaml_output_proto_goTypes = nil - file_example_bookstore_bookstore_yaml_output_proto_depIdxs = nil -} diff --git a/example/bookstore/v1/bookstore.pb.go b/example/bookstore/v1/bookstore.pb.go new file mode 100644 index 0000000..8ba97d3 --- /dev/null +++ b/example/bookstore/v1/bookstore.pb.go @@ -0,0 +1,804 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc (unknown) +// source: example/bookstore/v1/bookstore.proto + +package bookstore + +import ( + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + emptypb "google.golang.org/protobuf/types/known/emptypb" + fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// A Book resource. +type Book struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Field for isbn. + Isbn string `protobuf:"bytes,1,opt,name=isbn,proto3" json:"isbn,omitempty"` + // Field for path. + Path string `protobuf:"bytes,10000,opt,name=path,proto3" json:"path,omitempty"` + // Field for id. + Id string `protobuf:"bytes,10001,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *Book) Reset() { + *x = Book{} + if protoimpl.UnsafeEnabled { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Book) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Book) ProtoMessage() {} + +func (x *Book) ProtoReflect() protoreflect.Message { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Book.ProtoReflect.Descriptor instead. +func (*Book) Descriptor() ([]byte, []int) { + return file_example_bookstore_v1_bookstore_proto_rawDescGZIP(), []int{0} +} + +func (x *Book) GetIsbn() string { + if x != nil { + return x.Isbn + } + return "" +} + +func (x *Book) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +func (x *Book) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +// A Create request for a Book resource. +type CreateBookRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // A field for the parent of Book + Parent string `protobuf:"bytes,10013,opt,name=parent,proto3" json:"parent,omitempty"` + // An id that uniquely identifies the resource within the collection%!(EXTRA string=Book) + Id string `protobuf:"bytes,10014,opt,name=id,proto3" json:"id,omitempty"` + // The resource to perform the operation on. + Book *Book `protobuf:"bytes,10015,opt,name=book,proto3" json:"book,omitempty"` +} + +func (x *CreateBookRequest) Reset() { + *x = CreateBookRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateBookRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateBookRequest) ProtoMessage() {} + +func (x *CreateBookRequest) ProtoReflect() protoreflect.Message { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateBookRequest.ProtoReflect.Descriptor instead. +func (*CreateBookRequest) Descriptor() ([]byte, []int) { + return file_example_bookstore_v1_bookstore_proto_rawDescGZIP(), []int{1} +} + +func (x *CreateBookRequest) GetParent() string { + if x != nil { + return x.Parent + } + return "" +} + +func (x *CreateBookRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *CreateBookRequest) GetBook() *Book { + if x != nil { + return x.Book + } + return nil +} + +// Request message for the GetBook method +type GetBookRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The globally unique identifier for the resource + Path string `protobuf:"bytes,10018,opt,name=path,proto3" json:"path,omitempty"` +} + +func (x *GetBookRequest) Reset() { + *x = GetBookRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetBookRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetBookRequest) ProtoMessage() {} + +func (x *GetBookRequest) ProtoReflect() protoreflect.Message { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetBookRequest.ProtoReflect.Descriptor instead. +func (*GetBookRequest) Descriptor() ([]byte, []int) { + return file_example_bookstore_v1_bookstore_proto_rawDescGZIP(), []int{2} +} + +func (x *GetBookRequest) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +// Request message for the UpdateBook method +type UpdateBookRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The globally unique identifier for the resource + Path string `protobuf:"bytes,10018,opt,name=path,proto3" json:"path,omitempty"` + // The resource to perform the operation on. + Book *Book `protobuf:"bytes,10015,opt,name=book,proto3" json:"book,omitempty"` + // The update mask for the resource + UpdateMask *fieldmaskpb.FieldMask `protobuf:"bytes,10012,opt,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"` +} + +func (x *UpdateBookRequest) Reset() { + *x = UpdateBookRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateBookRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateBookRequest) ProtoMessage() {} + +func (x *UpdateBookRequest) ProtoReflect() protoreflect.Message { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateBookRequest.ProtoReflect.Descriptor instead. +func (*UpdateBookRequest) Descriptor() ([]byte, []int) { + return file_example_bookstore_v1_bookstore_proto_rawDescGZIP(), []int{3} +} + +func (x *UpdateBookRequest) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +func (x *UpdateBookRequest) GetBook() *Book { + if x != nil { + return x.Book + } + return nil +} + +func (x *UpdateBookRequest) GetUpdateMask() *fieldmaskpb.FieldMask { + if x != nil { + return x.UpdateMask + } + return nil +} + +// Request message for the DeleteBook method +type DeleteBookRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The globally unique identifier for the resource + Path string `protobuf:"bytes,10018,opt,name=path,proto3" json:"path,omitempty"` +} + +func (x *DeleteBookRequest) Reset() { + *x = DeleteBookRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteBookRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteBookRequest) ProtoMessage() {} + +func (x *DeleteBookRequest) ProtoReflect() protoreflect.Message { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteBookRequest.ProtoReflect.Descriptor instead. +func (*DeleteBookRequest) Descriptor() ([]byte, []int) { + return file_example_bookstore_v1_bookstore_proto_rawDescGZIP(), []int{4} +} + +func (x *DeleteBookRequest) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +// Request message for the ListBook method +type ListBookRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // A field for the parent of Book + Parent string `protobuf:"bytes,10013,opt,name=parent,proto3" json:"parent,omitempty"` + // The page token indicating the starting point of the page + PageToken string `protobuf:"bytes,10010,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` + // The maximum number of resources to return in a single page. + MaxPageSize int32 `protobuf:"varint,10017,opt,name=max_page_size,json=maxPageSize,proto3" json:"max_page_size,omitempty"` +} + +func (x *ListBookRequest) Reset() { + *x = ListBookRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListBookRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListBookRequest) ProtoMessage() {} + +func (x *ListBookRequest) ProtoReflect() protoreflect.Message { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListBookRequest.ProtoReflect.Descriptor instead. +func (*ListBookRequest) Descriptor() ([]byte, []int) { + return file_example_bookstore_v1_bookstore_proto_rawDescGZIP(), []int{5} +} + +func (x *ListBookRequest) GetParent() string { + if x != nil { + return x.Parent + } + return "" +} + +func (x *ListBookRequest) GetPageToken() string { + if x != nil { + return x.PageToken + } + return "" +} + +func (x *ListBookRequest) GetMaxPageSize() int32 { + if x != nil { + return x.MaxPageSize + } + return 0 +} + +// Response message for the ListBook method +type ListBookResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // A list of books + Results []*Book `protobuf:"bytes,10016,rep,name=results,proto3" json:"results,omitempty"` + // The page token indicating the ending point of this response. + NextPageToken string `protobuf:"bytes,10011,opt,name=next_page_token,json=nextPageToken,proto3" json:"next_page_token,omitempty"` +} + +func (x *ListBookResponse) Reset() { + *x = ListBookResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListBookResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListBookResponse) ProtoMessage() {} + +func (x *ListBookResponse) ProtoReflect() protoreflect.Message { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListBookResponse.ProtoReflect.Descriptor instead. +func (*ListBookResponse) Descriptor() ([]byte, []int) { + return file_example_bookstore_v1_bookstore_proto_rawDescGZIP(), []int{6} +} + +func (x *ListBookResponse) GetResults() []*Book { + if x != nil { + return x.Results + } + return nil +} + +func (x *ListBookResponse) GetNextPageToken() string { + if x != nil { + return x.NextPageToken + } + return "" +} + +// Request message for the ApplyBook method +type ApplyBookRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The globally unique identifier for the resource + Path string `protobuf:"bytes,10018,opt,name=path,proto3" json:"path,omitempty"` + // The resource to perform the operation on. + Book *Book `protobuf:"bytes,10015,opt,name=book,proto3" json:"book,omitempty"` +} + +func (x *ApplyBookRequest) Reset() { + *x = ApplyBookRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ApplyBookRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ApplyBookRequest) ProtoMessage() {} + +func (x *ApplyBookRequest) ProtoReflect() protoreflect.Message { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ApplyBookRequest.ProtoReflect.Descriptor instead. +func (*ApplyBookRequest) Descriptor() ([]byte, []int) { + return file_example_bookstore_v1_bookstore_proto_rawDescGZIP(), []int{7} +} + +func (x *ApplyBookRequest) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +func (x *ApplyBookRequest) GetBook() *Book { + if x != nil { + return x.Book + } + return nil +} + +var File_example_bookstore_v1_bookstore_proto protoreflect.FileDescriptor + +var file_example_bookstore_v1_bookstore_proto_rawDesc = []byte{ + 0x0a, 0x24, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, + 0x6f, 0x72, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x14, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, + 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x1c, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, + 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x72, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, + 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x66, 0x69, + 0x65, 0x6c, 0x64, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x40, + 0x0a, 0x04, 0x42, 0x6f, 0x6f, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x73, 0x62, 0x6e, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x69, 0x73, 0x62, 0x6e, 0x12, 0x13, 0x0a, 0x04, 0x70, 0x61, + 0x74, 0x68, 0x18, 0x90, 0x4e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, + 0x0f, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x91, 0x4e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, + 0x22, 0x7b, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, + 0x9d, 0x4e, 0x20, 0x01, 0x28, 0x09, 0x42, 0x06, 0xe0, 0x41, 0x02, 0xfa, 0x41, 0x00, 0x52, 0x06, + 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x0f, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x9e, 0x4e, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x34, 0x0a, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x18, + 0x9f, 0x4e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, + 0x2e, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6f, + 0x6f, 0x6b, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x22, 0x49, 0x0a, + 0x0e, 0x47, 0x65, 0x74, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x37, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0xa2, 0x4e, 0x20, 0x01, 0x28, 0x09, 0x42, 0x22, + 0xe0, 0x41, 0x02, 0xfa, 0x41, 0x1c, 0x0a, 0x1a, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, + 0x65, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x42, 0x6f, + 0x6f, 0x6b, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x22, 0xc0, 0x01, 0x0a, 0x11, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x37, + 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0xa2, 0x4e, 0x20, 0x01, 0x28, 0x09, 0x42, 0x22, 0xe0, + 0x41, 0x02, 0xfa, 0x41, 0x1c, 0x0a, 0x1a, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, + 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x42, 0x6f, 0x6f, + 0x6b, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x34, 0x0a, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x18, + 0x9f, 0x4e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, + 0x2e, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6f, + 0x6f, 0x6b, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x12, 0x3c, 0x0a, + 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x18, 0x9c, 0x4e, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4d, 0x61, 0x73, 0x6b, 0x52, + 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x73, 0x6b, 0x22, 0x4c, 0x0a, 0x11, 0x44, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x37, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0xa2, 0x4e, 0x20, 0x01, 0x28, 0x09, 0x42, + 0x22, 0xe0, 0x41, 0x02, 0xfa, 0x41, 0x1c, 0x0a, 0x1a, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, + 0x72, 0x65, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x42, + 0x6f, 0x6f, 0x6b, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x22, 0x77, 0x0a, 0x0f, 0x4c, 0x69, 0x73, + 0x74, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x06, + 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x9d, 0x4e, 0x20, 0x01, 0x28, 0x09, 0x42, 0x06, 0xe0, + 0x41, 0x02, 0xfa, 0x41, 0x00, 0x52, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x1e, 0x0a, + 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x9a, 0x4e, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x23, 0x0a, + 0x0d, 0x6d, 0x61, 0x78, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0xa1, + 0x4e, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x6d, 0x61, 0x78, 0x50, 0x61, 0x67, 0x65, 0x53, 0x69, + 0x7a, 0x65, 0x22, 0x72, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, + 0x73, 0x18, 0xa0, 0x4e, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, + 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x12, 0x27, 0x0a, + 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, + 0x18, 0x9b, 0x4e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, + 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x81, 0x01, 0x0a, 0x10, 0x41, 0x70, 0x70, 0x6c, 0x79, + 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x37, 0x0a, 0x04, 0x70, + 0x61, 0x74, 0x68, 0x18, 0xa2, 0x4e, 0x20, 0x01, 0x28, 0x09, 0x42, 0x22, 0xe0, 0x41, 0x02, 0xfa, + 0x41, 0x1c, 0x0a, 0x1a, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x65, 0x78, + 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x04, + 0x70, 0x61, 0x74, 0x68, 0x12, 0x34, 0x0a, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x18, 0x9f, 0x4e, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, + 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6f, 0x6f, 0x6b, 0x42, + 0x03, 0xe0, 0x41, 0x02, 0x52, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x32, 0xdf, 0x05, 0x0a, 0x09, 0x42, + 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x12, 0x7e, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x12, 0x27, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, + 0x2e, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x1a, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, + 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6f, 0x6f, 0x6b, 0x22, 0x2b, 0xda, 0x41, 0x0b, + 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x2c, 0x62, 0x6f, 0x6f, 0x6b, 0x82, 0xd3, 0xe4, 0x93, 0x02, + 0x17, 0x3a, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x22, 0x0f, 0x2f, 0x7b, 0x70, 0x61, 0x72, 0x65, 0x6e, + 0x74, 0x3d, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x7d, 0x12, 0x6b, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x42, + 0x6f, 0x6f, 0x6b, 0x12, 0x24, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, + 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6f, + 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x65, 0x78, 0x61, 0x6d, + 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, + 0x2e, 0x42, 0x6f, 0x6f, 0x6b, 0x22, 0x1e, 0xda, 0x41, 0x04, 0x70, 0x61, 0x74, 0x68, 0x82, 0xd3, + 0xe4, 0x93, 0x02, 0x11, 0x12, 0x0f, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x3d, 0x62, 0x6f, 0x6f, + 0x6b, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0x88, 0x01, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x42, 0x6f, 0x6f, 0x6b, 0x12, 0x27, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, + 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, + 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, + 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6f, 0x6f, 0x6b, 0x22, 0x35, 0xda, 0x41, 0x10, 0x62, 0x6f, + 0x6f, 0x6b, 0x2c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x82, 0xd3, + 0xe4, 0x93, 0x02, 0x1c, 0x3a, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x32, 0x14, 0x2f, 0x7b, 0x62, 0x6f, + 0x6f, 0x6b, 0x2e, 0x70, 0x61, 0x74, 0x68, 0x3d, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x2f, 0x2a, 0x7d, + 0x12, 0x6d, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x12, 0x27, + 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, + 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, + 0x1e, 0xda, 0x41, 0x04, 0x70, 0x61, 0x74, 0x68, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x11, 0x2a, 0x0f, + 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x3d, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x2f, 0x2a, 0x7d, 0x12, + 0x7b, 0x0a, 0x08, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x6f, 0x6f, 0x6b, 0x12, 0x25, 0x2e, 0x65, 0x78, + 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, + 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, + 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x6f, + 0x6f, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x20, 0xda, 0x41, 0x06, 0x70, + 0x61, 0x72, 0x65, 0x6e, 0x74, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x11, 0x12, 0x0f, 0x2f, 0x7b, 0x70, + 0x61, 0x72, 0x65, 0x6e, 0x74, 0x3d, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x7d, 0x12, 0x6e, 0x0a, 0x09, + 0x41, 0x70, 0x70, 0x6c, 0x79, 0x42, 0x6f, 0x6f, 0x6b, 0x12, 0x26, 0x2e, 0x65, 0x78, 0x61, 0x6d, + 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, + 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x1a, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, + 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6f, 0x6f, 0x6b, 0x22, 0x1d, 0x82, + 0xd3, 0xe4, 0x93, 0x02, 0x17, 0x3a, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x1a, 0x0f, 0x2f, 0x7b, 0x70, + 0x61, 0x74, 0x68, 0x3d, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x2f, 0x2a, 0x7d, 0x42, 0x0c, 0x5a, 0x0a, + 0x2f, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, +} + +var ( + file_example_bookstore_v1_bookstore_proto_rawDescOnce sync.Once + file_example_bookstore_v1_bookstore_proto_rawDescData = file_example_bookstore_v1_bookstore_proto_rawDesc +) + +func file_example_bookstore_v1_bookstore_proto_rawDescGZIP() []byte { + file_example_bookstore_v1_bookstore_proto_rawDescOnce.Do(func() { + file_example_bookstore_v1_bookstore_proto_rawDescData = protoimpl.X.CompressGZIP(file_example_bookstore_v1_bookstore_proto_rawDescData) + }) + return file_example_bookstore_v1_bookstore_proto_rawDescData +} + +var file_example_bookstore_v1_bookstore_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_example_bookstore_v1_bookstore_proto_goTypes = []interface{}{ + (*Book)(nil), // 0: example.bookstore.v1.Book + (*CreateBookRequest)(nil), // 1: example.bookstore.v1.CreateBookRequest + (*GetBookRequest)(nil), // 2: example.bookstore.v1.GetBookRequest + (*UpdateBookRequest)(nil), // 3: example.bookstore.v1.UpdateBookRequest + (*DeleteBookRequest)(nil), // 4: example.bookstore.v1.DeleteBookRequest + (*ListBookRequest)(nil), // 5: example.bookstore.v1.ListBookRequest + (*ListBookResponse)(nil), // 6: example.bookstore.v1.ListBookResponse + (*ApplyBookRequest)(nil), // 7: example.bookstore.v1.ApplyBookRequest + (*fieldmaskpb.FieldMask)(nil), // 8: google.protobuf.FieldMask + (*emptypb.Empty)(nil), // 9: google.protobuf.Empty +} +var file_example_bookstore_v1_bookstore_proto_depIdxs = []int32{ + 0, // 0: example.bookstore.v1.CreateBookRequest.book:type_name -> example.bookstore.v1.Book + 0, // 1: example.bookstore.v1.UpdateBookRequest.book:type_name -> example.bookstore.v1.Book + 8, // 2: example.bookstore.v1.UpdateBookRequest.update_mask:type_name -> google.protobuf.FieldMask + 0, // 3: example.bookstore.v1.ListBookResponse.results:type_name -> example.bookstore.v1.Book + 0, // 4: example.bookstore.v1.ApplyBookRequest.book:type_name -> example.bookstore.v1.Book + 1, // 5: example.bookstore.v1.Bookstore.CreateBook:input_type -> example.bookstore.v1.CreateBookRequest + 2, // 6: example.bookstore.v1.Bookstore.GetBook:input_type -> example.bookstore.v1.GetBookRequest + 3, // 7: example.bookstore.v1.Bookstore.UpdateBook:input_type -> example.bookstore.v1.UpdateBookRequest + 4, // 8: example.bookstore.v1.Bookstore.DeleteBook:input_type -> example.bookstore.v1.DeleteBookRequest + 5, // 9: example.bookstore.v1.Bookstore.ListBook:input_type -> example.bookstore.v1.ListBookRequest + 7, // 10: example.bookstore.v1.Bookstore.ApplyBook:input_type -> example.bookstore.v1.ApplyBookRequest + 0, // 11: example.bookstore.v1.Bookstore.CreateBook:output_type -> example.bookstore.v1.Book + 0, // 12: example.bookstore.v1.Bookstore.GetBook:output_type -> example.bookstore.v1.Book + 0, // 13: example.bookstore.v1.Bookstore.UpdateBook:output_type -> example.bookstore.v1.Book + 9, // 14: example.bookstore.v1.Bookstore.DeleteBook:output_type -> google.protobuf.Empty + 6, // 15: example.bookstore.v1.Bookstore.ListBook:output_type -> example.bookstore.v1.ListBookResponse + 0, // 16: example.bookstore.v1.Bookstore.ApplyBook:output_type -> example.bookstore.v1.Book + 11, // [11:17] is the sub-list for method output_type + 5, // [5:11] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name +} + +func init() { file_example_bookstore_v1_bookstore_proto_init() } +func file_example_bookstore_v1_bookstore_proto_init() { + if File_example_bookstore_v1_bookstore_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_example_bookstore_v1_bookstore_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Book); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_example_bookstore_v1_bookstore_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateBookRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_example_bookstore_v1_bookstore_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetBookRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_example_bookstore_v1_bookstore_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateBookRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_example_bookstore_v1_bookstore_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteBookRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_example_bookstore_v1_bookstore_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListBookRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_example_bookstore_v1_bookstore_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListBookResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_example_bookstore_v1_bookstore_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ApplyBookRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_example_bookstore_v1_bookstore_proto_rawDesc, + NumEnums: 0, + NumMessages: 8, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_example_bookstore_v1_bookstore_proto_goTypes, + DependencyIndexes: file_example_bookstore_v1_bookstore_proto_depIdxs, + MessageInfos: file_example_bookstore_v1_bookstore_proto_msgTypes, + }.Build() + File_example_bookstore_v1_bookstore_proto = out.File + file_example_bookstore_v1_bookstore_proto_rawDesc = nil + file_example_bookstore_v1_bookstore_proto_goTypes = nil + file_example_bookstore_v1_bookstore_proto_depIdxs = nil +} diff --git a/example/bookstore/bookstore.yaml.output.pb.gw.go b/example/bookstore/v1/bookstore.pb.gw.go similarity index 90% rename from example/bookstore/bookstore.yaml.output.pb.gw.go rename to example/bookstore/v1/bookstore.pb.gw.go index e0e6ad1..0e9f68a 100644 --- a/example/bookstore/bookstore.yaml.output.pb.gw.go +++ b/example/bookstore/v1/bookstore.pb.gw.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: example/bookstore/bookstore.yaml.output.proto +// source: example/bookstore/v1/bookstore.proto /* Package bookstore is a reverse proxy. @@ -32,7 +32,7 @@ var _ = utilities.NewDoubleArray var _ = metadata.Join var ( - filter_Bookstore_CreateBook_0 = &utilities.DoubleArray{Encoding: map[string]int{"book": 0}, Base: []int{1, 2, 0, 0}, Check: []int{0, 1, 2, 2}} + filter_Bookstore_CreateBook_0 = &utilities.DoubleArray{Encoding: map[string]int{"book": 0, "parent": 1}, Base: []int{1, 2, 4, 0, 0, 0, 0}, Check: []int{0, 1, 1, 2, 2, 3, 3}} ) func request_Bookstore_CreateBook_0(ctx context.Context, marshaler runtime.Marshaler, client BookstoreClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -47,6 +47,23 @@ func request_Bookstore_CreateBook_0(ctx context.Context, marshaler runtime.Marsh return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["parent"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") + } + + protoReq.Parent, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err) + } + if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -71,6 +88,23 @@ func local_request_Bookstore_CreateBook_0(ctx context.Context, marshaler runtime return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["parent"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") + } + + protoReq.Parent, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err) + } + if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -288,13 +322,30 @@ func local_request_Bookstore_DeleteBook_0(ctx context.Context, marshaler runtime } var ( - filter_Bookstore_ListBook_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + filter_Bookstore_ListBook_0 = &utilities.DoubleArray{Encoding: map[string]int{"parent": 0}, Base: []int{1, 2, 0, 0}, Check: []int{0, 1, 2, 2}} ) func request_Bookstore_ListBook_0(ctx context.Context, marshaler runtime.Marshaler, client BookstoreClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq ListBookRequest var metadata runtime.ServerMetadata + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["parent"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") + } + + protoReq.Parent, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err) + } + if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -311,6 +362,23 @@ func local_request_Bookstore_ListBook_0(ctx context.Context, marshaler runtime.M var protoReq ListBookRequest var metadata runtime.ServerMetadata + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["parent"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") + } + + protoReq.Parent, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err) + } + if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -405,7 +473,7 @@ func RegisterBookstoreHandlerServer(ctx context.Context, mux *runtime.ServeMux, inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/.Bookstore/CreateBook", runtime.WithHTTPPathPattern("/books")) + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/CreateBook", runtime.WithHTTPPathPattern("/{parent=books}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -430,7 +498,7 @@ func RegisterBookstoreHandlerServer(ctx context.Context, mux *runtime.ServeMux, inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/.Bookstore/GetBook", runtime.WithHTTPPathPattern("/{path=books/*}")) + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/GetBook", runtime.WithHTTPPathPattern("/{path=books/*}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -455,7 +523,7 @@ func RegisterBookstoreHandlerServer(ctx context.Context, mux *runtime.ServeMux, inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/.Bookstore/UpdateBook", runtime.WithHTTPPathPattern("/{book.path=books/*}")) + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/UpdateBook", runtime.WithHTTPPathPattern("/{book.path=books/*}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -480,7 +548,7 @@ func RegisterBookstoreHandlerServer(ctx context.Context, mux *runtime.ServeMux, inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/.Bookstore/DeleteBook", runtime.WithHTTPPathPattern("/{path=books/*}")) + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/DeleteBook", runtime.WithHTTPPathPattern("/{path=books/*}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -505,7 +573,7 @@ func RegisterBookstoreHandlerServer(ctx context.Context, mux *runtime.ServeMux, inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/.Bookstore/ListBook", runtime.WithHTTPPathPattern("/books")) + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/ListBook", runtime.WithHTTPPathPattern("/{parent=books}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -530,7 +598,7 @@ func RegisterBookstoreHandlerServer(ctx context.Context, mux *runtime.ServeMux, inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/.Bookstore/ApplyBook", runtime.WithHTTPPathPattern("/{path=books/*}")) + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/ApplyBook", runtime.WithHTTPPathPattern("/{path=books/*}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -594,7 +662,7 @@ func RegisterBookstoreHandlerClient(ctx context.Context, mux *runtime.ServeMux, inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/.Bookstore/CreateBook", runtime.WithHTTPPathPattern("/books")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/CreateBook", runtime.WithHTTPPathPattern("/{parent=books}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -616,7 +684,7 @@ func RegisterBookstoreHandlerClient(ctx context.Context, mux *runtime.ServeMux, inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/.Bookstore/GetBook", runtime.WithHTTPPathPattern("/{path=books/*}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/GetBook", runtime.WithHTTPPathPattern("/{path=books/*}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -638,7 +706,7 @@ func RegisterBookstoreHandlerClient(ctx context.Context, mux *runtime.ServeMux, inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/.Bookstore/UpdateBook", runtime.WithHTTPPathPattern("/{book.path=books/*}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/UpdateBook", runtime.WithHTTPPathPattern("/{book.path=books/*}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -660,7 +728,7 @@ func RegisterBookstoreHandlerClient(ctx context.Context, mux *runtime.ServeMux, inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/.Bookstore/DeleteBook", runtime.WithHTTPPathPattern("/{path=books/*}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/DeleteBook", runtime.WithHTTPPathPattern("/{path=books/*}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -682,7 +750,7 @@ func RegisterBookstoreHandlerClient(ctx context.Context, mux *runtime.ServeMux, inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/.Bookstore/ListBook", runtime.WithHTTPPathPattern("/books")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/ListBook", runtime.WithHTTPPathPattern("/{parent=books}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -704,7 +772,7 @@ func RegisterBookstoreHandlerClient(ctx context.Context, mux *runtime.ServeMux, inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/.Bookstore/ApplyBook", runtime.WithHTTPPathPattern("/{path=books/*}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/ApplyBook", runtime.WithHTTPPathPattern("/{path=books/*}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -724,7 +792,7 @@ func RegisterBookstoreHandlerClient(ctx context.Context, mux *runtime.ServeMux, } var ( - pattern_Bookstore_CreateBook_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"books"}, "")) + pattern_Bookstore_CreateBook_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 4, 1, 5, 1}, []string{"books", "parent"}, "")) pattern_Bookstore_GetBook_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 2, 5, 1}, []string{"books", "path"}, "")) @@ -732,7 +800,7 @@ var ( pattern_Bookstore_DeleteBook_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 2, 5, 1}, []string{"books", "path"}, "")) - pattern_Bookstore_ListBook_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"books"}, "")) + pattern_Bookstore_ListBook_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 4, 1, 5, 1}, []string{"books", "parent"}, "")) pattern_Bookstore_ApplyBook_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 2, 5, 1}, []string{"books", "path"}, "")) ) diff --git a/example/bookstore/bookstore.yaml.output.proto b/example/bookstore/v1/bookstore.proto similarity index 85% rename from example/bookstore/bookstore.yaml.output.proto rename to example/bookstore/v1/bookstore.proto index e562747..b9ce559 100644 --- a/example/bookstore/bookstore.yaml.output.proto +++ b/example/bookstore/v1/bookstore.proto @@ -1,5 +1,7 @@ syntax = "proto3"; +package example.bookstore.v1; + import "google/api/annotations.proto"; import "google/api/client.proto"; @@ -14,6 +16,49 @@ import "google/protobuf/field_mask.proto"; option go_package = "/bookstore"; +// A service. +service Bookstore { + // An aep-compliant Create method for Book. + rpc CreateBook ( CreateBookRequest ) returns ( Book ) { + option (google.api.http) = { post: "/{parent=books}", body: "book" }; + + option (google.api.method_signature) = "parent,book"; + } + + // An aep-compliant Get method for Book. + rpc GetBook ( GetBookRequest ) returns ( Book ) { + option (google.api.http) = { get: "/{path=books/*}" }; + + option (google.api.method_signature) = "path"; + } + + // An aep-compliant Update method for Book. + rpc UpdateBook ( UpdateBookRequest ) returns ( Book ) { + option (google.api.http) = { patch: "/{book.path=books/*}", body: "book" }; + + option (google.api.method_signature) = "book,update_mask"; + } + + // An aep-compliant Delete method for Book. + rpc DeleteBook ( DeleteBookRequest ) returns ( google.protobuf.Empty ) { + option (google.api.http) = { delete: "/{path=books/*}" }; + + option (google.api.method_signature) = "path"; + } + + // An aep-compliant List method for books. + rpc ListBook ( ListBookRequest ) returns ( ListBookResponse ) { + option (google.api.http) = { get: "/{parent=books}" }; + + option (google.api.method_signature) = "parent"; + } + + // An aep-compliant Apply method for books. + rpc ApplyBook ( ApplyBookRequest ) returns ( Book ) { + option (google.api.http) = { put: "/{path=books/*}", body: "book" }; + } +} + // A Book resource. message Book { // Field for isbn. @@ -29,17 +74,14 @@ message Book { // A Create request for a Book resource. message CreateBookRequest { // A field for the parent of Book - string parent = 10013 [(google.api.field_behavior) = REQUIRED]; + string parent = 10013 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { } + ]; // An id that uniquely identifies the resource within the collection%!(EXTRA string=Book) string id = 10014; - // The globally unique identifier for the resource - string path = 10018 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "bookstore.example.com/Book" } - ]; - // The resource to perform the operation on. Book book = 10015 [(google.api.field_behavior) = REQUIRED]; } @@ -77,10 +119,13 @@ message DeleteBookRequest { ]; } -// Request message for the DeleteBook method +// Request message for the ListBook method message ListBookRequest { // A field for the parent of Book - string parent = 10013 [(google.api.field_behavior) = REQUIRED]; + string parent = 10013 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { } + ]; // The page token indicating the starting point of the page string page_token = 10010; @@ -89,10 +134,10 @@ message ListBookRequest { int32 max_page_size = 10017; } -// Response message for the DeleteBook method +// Response message for the ListBook method message ListBookResponse { // A list of books - Book books = 10016; + repeated Book results = 10016; // The page token indicating the ending point of this response. string next_page_token = 10011; @@ -109,44 +154,3 @@ message ApplyBookRequest { // The resource to perform the operation on. Book book = 10015 [(google.api.field_behavior) = REQUIRED]; } - -// A service. -service Bookstore { - // An aep-compliant Create method for Book. - rpc CreateBook ( CreateBookRequest ) returns ( Book ) { - option (google.api.http) = { post: "/books", body: "book" }; - - option (google.api.method_signature) = "parent,resource"; - } - - // An aep-compliant Get method for Book. - rpc GetBook ( GetBookRequest ) returns ( Book ) { - option (google.api.http) = { get: "/{path=books/*}" }; - } - - // An aep-compliant Update method for Book. - rpc UpdateBook ( UpdateBookRequest ) returns ( Book ) { - option (google.api.http) = { patch: "/{book.path=books/*}", body: "book" }; - - option (google.api.method_signature) = "update_mask,resource"; - } - - // An aep-compliant Delete method for Book. - rpc DeleteBook ( DeleteBookRequest ) returns ( google.protobuf.Empty ) { - option (google.api.http) = { delete: "/{path=books/*}" }; - - option (google.api.method_signature) = "path"; - } - - // An aep-compliant List method for books. - rpc ListBook ( ListBookRequest ) returns ( ListBookResponse ) { - option (google.api.http) = { get: "/books" }; - - option (google.api.method_signature) = "parent"; - } - - // An aep-compliant Apply method for books. - rpc ApplyBook ( ApplyBookRequest ) returns ( Book ) { - option (google.api.http) = { put: "/{path=books/*}", body: "book" }; - } -} diff --git a/example/bookstore/bookstore.yaml.output.swagger.json b/example/bookstore/v1/bookstore.swagger.json similarity index 90% rename from example/bookstore/bookstore.yaml.output.swagger.json rename to example/bookstore/v1/bookstore.swagger.json index 6c58a4d..a33f6a5 100644 --- a/example/bookstore/bookstore.yaml.output.swagger.json +++ b/example/bookstore/v1/bookstore.swagger.json @@ -1,7 +1,7 @@ { "swagger": "2.0", "info": { - "title": "example/bookstore/bookstore.yaml.output.proto", + "title": "example/bookstore/v1/bookstore.proto", "version": "version not set" }, "tags": [ @@ -16,15 +16,15 @@ "application/json" ], "paths": { - "/books": { - "get": { - "summary": "An aep-compliant List method for books.", - "operationId": "Bookstore_ListBook", + "/{book.path}": { + "patch": { + "summary": "An aep-compliant Update method for Book.", + "operationId": "Bookstore_UpdateBook", "responses": { "200": { "description": "A successful response.", "schema": { - "$ref": "#/definitions/ListBookResponse" + "$ref": "#/definitions/v1Book" } }, "default": { @@ -36,40 +36,55 @@ }, "parameters": [ { - "name": "parent", - "description": "A field for the parent of Book", - "in": "query", + "name": "book.path", + "description": "Field for path.", + "in": "path", "required": true, - "type": "string" + "type": "string", + "pattern": "books/[^/]+" }, { - "name": "pageToken", - "description": "The page token indicating the starting point of the page", - "in": "query", - "required": false, - "type": "string" + "name": "book", + "description": "The resource to perform the operation on.", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "isbn": { + "type": "string", + "description": "Field for isbn." + }, + "id": { + "type": "string", + "description": "Field for id." + } + }, + "title": "The resource to perform the operation on." + } }, { - "name": "maxPageSize", - "description": "The maximum number of resources to return in a single page.", + "name": "path", + "description": "The globally unique identifier for the resource", "in": "query", - "required": false, - "type": "integer", - "format": "int32" + "required": true, + "type": "string" } ], "tags": [ "Bookstore" ] - }, - "post": { - "summary": "An aep-compliant Create method for Book.", - "operationId": "Bookstore_CreateBook", + } + }, + "/{parent}": { + "get": { + "summary": "An aep-compliant List method for books.", + "operationId": "Bookstore_ListBook", "responses": { "200": { "description": "A successful response.", "schema": { - "$ref": "#/definitions/Book" + "$ref": "#/definitions/v1ListBookResponse" } }, "default": { @@ -80,54 +95,42 @@ } }, "parameters": [ - { - "name": "book", - "description": "The resource to perform the operation on.", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/Book", - "required": [ - "book" - ] - } - }, { "name": "parent", "description": "A field for the parent of Book", - "in": "query", + "in": "path", "required": true, - "type": "string" + "type": "string", + "pattern": "books" }, { - "name": "id", - "description": "An id that uniquely identifies the resource within the collection%!(EXTRA string=Book)", + "name": "pageToken", + "description": "The page token indicating the starting point of the page", "in": "query", "required": false, "type": "string" }, { - "name": "path", - "description": "The globally unique identifier for the resource", + "name": "maxPageSize", + "description": "The maximum number of resources to return in a single page.", "in": "query", - "required": true, - "type": "string" + "required": false, + "type": "integer", + "format": "int32" } ], "tags": [ "Bookstore" ] - } - }, - "/{book.path}": { - "patch": { - "summary": "An aep-compliant Update method for Book.", - "operationId": "Bookstore_UpdateBook", + }, + "post": { + "summary": "An aep-compliant Create method for Book.", + "operationId": "Bookstore_CreateBook", "responses": { "200": { "description": "A successful response.", "schema": { - "$ref": "#/definitions/Book" + "$ref": "#/definitions/v1Book" } }, "default": { @@ -139,12 +142,12 @@ }, "parameters": [ { - "name": "book.path", - "description": "Field for path.", + "name": "parent", + "description": "A field for the parent of Book", "in": "path", "required": true, "type": "string", - "pattern": "books/[^/]+" + "pattern": "books" }, { "name": "book", @@ -152,25 +155,17 @@ "in": "body", "required": true, "schema": { - "type": "object", - "properties": { - "isbn": { - "type": "string", - "description": "Field for isbn." - }, - "id": { - "type": "string", - "description": "Field for id." - } - }, - "title": "The resource to perform the operation on." + "$ref": "#/definitions/v1Book", + "required": [ + "book" + ] } }, { - "name": "path", - "description": "The globally unique identifier for the resource", + "name": "id", + "description": "An id that uniquely identifies the resource within the collection%!(EXTRA string=Book)", "in": "query", - "required": true, + "required": false, "type": "string" } ], @@ -187,7 +182,7 @@ "200": { "description": "A successful response.", "schema": { - "$ref": "#/definitions/Book" + "$ref": "#/definitions/v1Book" } }, "default": { @@ -250,7 +245,7 @@ "200": { "description": "A successful response.", "schema": { - "$ref": "#/definitions/Book" + "$ref": "#/definitions/v1Book" } }, "default": { @@ -275,7 +270,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/Book", + "$ref": "#/definitions/v1Book", "required": [ "book" ] @@ -289,38 +284,6 @@ } }, "definitions": { - "Book": { - "type": "object", - "properties": { - "isbn": { - "type": "string", - "description": "Field for isbn." - }, - "path": { - "type": "string", - "description": "Field for path." - }, - "id": { - "type": "string", - "description": "Field for id." - } - }, - "description": "A Book resource." - }, - "ListBookResponse": { - "type": "object", - "properties": { - "books": { - "$ref": "#/definitions/Book", - "title": "A list of books" - }, - "nextPageToken": { - "type": "string", - "description": "The page token indicating the ending point of this response." - } - }, - "title": "Response message for the DeleteBook method" - }, "protobufAny": { "type": "object", "properties": { @@ -348,6 +311,42 @@ } } } + }, + "v1Book": { + "type": "object", + "properties": { + "isbn": { + "type": "string", + "description": "Field for isbn." + }, + "path": { + "type": "string", + "description": "Field for path." + }, + "id": { + "type": "string", + "description": "Field for id." + } + }, + "description": "A Book resource." + }, + "v1ListBookResponse": { + "type": "object", + "properties": { + "results": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/v1Book" + }, + "title": "A list of books" + }, + "nextPageToken": { + "type": "string", + "description": "The page token indicating the ending point of this response." + } + }, + "title": "Response message for the ListBook method" } } } diff --git a/example/bookstore/bookstore.yaml b/example/bookstore/v1/bookstore.yaml similarity index 91% rename from example/bookstore/bookstore.yaml rename to example/bookstore/v1/bookstore.yaml index 343d942..2dd192e 100644 --- a/example/bookstore/bookstore.yaml +++ b/example/bookstore/v1/bookstore.yaml @@ -1,3 +1,4 @@ +# normally this would be suffixed with the domain (.com) name: "bookstore.example.com" resources: - kind: "Book" diff --git a/example/bookstore/bookstore.yaml.output_grpc.pb.go b/example/bookstore/v1/bookstore_grpc.pb.go similarity index 94% rename from example/bookstore/bookstore.yaml.output_grpc.pb.go rename to example/bookstore/v1/bookstore_grpc.pb.go index 6a2f9fb..8fbaba2 100644 --- a/example/bookstore/bookstore.yaml.output_grpc.pb.go +++ b/example/bookstore/v1/bookstore_grpc.pb.go @@ -2,7 +2,7 @@ // versions: // - protoc-gen-go-grpc v1.3.0 // - protoc (unknown) -// source: example/bookstore/bookstore.yaml.output.proto +// source: example/bookstore/v1/bookstore.proto package bookstore @@ -20,12 +20,12 @@ import ( const _ = grpc.SupportPackageIsVersion7 const ( - Bookstore_CreateBook_FullMethodName = "/Bookstore/CreateBook" - Bookstore_GetBook_FullMethodName = "/Bookstore/GetBook" - Bookstore_UpdateBook_FullMethodName = "/Bookstore/UpdateBook" - Bookstore_DeleteBook_FullMethodName = "/Bookstore/DeleteBook" - Bookstore_ListBook_FullMethodName = "/Bookstore/ListBook" - Bookstore_ApplyBook_FullMethodName = "/Bookstore/ApplyBook" + Bookstore_CreateBook_FullMethodName = "/example.bookstore.v1.Bookstore/CreateBook" + Bookstore_GetBook_FullMethodName = "/example.bookstore.v1.Bookstore/GetBook" + Bookstore_UpdateBook_FullMethodName = "/example.bookstore.v1.Bookstore/UpdateBook" + Bookstore_DeleteBook_FullMethodName = "/example.bookstore.v1.Bookstore/DeleteBook" + Bookstore_ListBook_FullMethodName = "/example.bookstore.v1.Bookstore/ListBook" + Bookstore_ApplyBook_FullMethodName = "/example.bookstore.v1.Bookstore/ApplyBook" ) // BookstoreClient is the client API for Bookstore service. @@ -274,7 +274,7 @@ func _Bookstore_ApplyBook_Handler(srv interface{}, ctx context.Context, dec func // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var Bookstore_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "Bookstore", + ServiceName: "example.bookstore.v1.Bookstore", HandlerType: (*BookstoreServer)(nil), Methods: []grpc.MethodDesc{ { @@ -303,5 +303,5 @@ var Bookstore_ServiceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "example/bookstore/bookstore.yaml.output.proto", + Metadata: "example/bookstore/v1/bookstore.proto", } diff --git a/example/bookstore/bookstore.yaml.output.openapi.json b/example/bookstore/v1/bookstore_openapi.json similarity index 100% rename from example/bookstore/bookstore.yaml.output.openapi.json rename to example/bookstore/v1/bookstore_openapi.json diff --git a/example/gateway/gateway.go b/example/gateway/gateway.go index 7e5fdb8..4335784 100644 --- a/example/gateway/gateway.go +++ b/example/gateway/gateway.go @@ -14,7 +14,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" - bpb "github.com/aep-dev/aepc/example/bookstore" + bpb "github.com/aep-dev/aepc/example/bookstore/v1/bookstore" ) // gRPC server endpoint diff --git a/example/service/service.go b/example/service/service.go index 168754e..e337e9d 100644 --- a/example/service/service.go +++ b/example/service/service.go @@ -10,7 +10,7 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - bpb "github.com/aep-dev/aepc/example/bookstore" + bpb "github.com/aep-dev/aepc/example/bookstore/v1/bookstore" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/emptypb" ) diff --git a/parser/parser.go b/parser/parser.go index 84c18df..88f415c 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -19,6 +19,11 @@ type ParsedService struct { ResourceByType map[string]*ParsedResource } +func (ps *ParsedService) GetShortName() string { + before, _, _ := strings.Cut(ps.Name, ".") + return before +} + type ParsedResource struct { *schema.Resource Type string diff --git a/scripts/regenerate-all.sh b/scripts/regenerate-all.sh index ebfaf91..aacf7e1 100755 --- a/scripts/regenerate-all.sh +++ b/scripts/regenerate-all.sh @@ -10,8 +10,12 @@ set -ex buf generate --path ./schema/ # protoc ./schema/resourcedefinition.proto --go_opt paths=source_relative --go_out=. # generate service proto from resource proto -go run main.go -i ./example/bookstore/bookstore.yaml -o example/bookstore/bookstore.yaml.output -# +# proto package names have to match a-z0-9_ +go run main.go -i ./example/bookstore/v1/bookstore.yaml -o ./example/bookstore/v1/bookstore +# bookstore.pb.go +# bookstore.yaml +# bookstore.proto +# bookstore-openapi.json buf generate # generated all downstream proto code # protoc \ diff --git a/scripts/run-api-linter.sh b/scripts/run-api-linter.sh new file mode 100755 index 0000000..0e7c9bb --- /dev/null +++ b/scripts/run-api-linter.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +if ! which api-linter ; then + go install github.com/aep-dev/api-linter/cmd/api-linter@latest +fi + +if [ ! -d /tmp/googleapis ]; then + git clone https://github.com/googleapis/googleapis.git --depth=1 /tmp/googleapis +fi + +api-linter \ + ./example/bookstore/v1/bookstore.proto \ + -I /tmp/googleapis \ No newline at end of file diff --git a/writer/proto/proto.go b/writer/proto/proto.go index 4dd36c2..59534be 100644 --- a/writer/proto/proto.go +++ b/writer/proto/proto.go @@ -16,6 +16,8 @@ package proto import ( "bytes" "fmt" + "path/filepath" + "slices" "sort" "strings" @@ -33,8 +35,21 @@ func init() { capitalizer = cases.Title(language.AmericanEnglish) } -func WriteServiceToProto(ps *parser.ParsedService) ([]byte, error) { +func WriteServiceToProto(ps *parser.ParsedService, outputDir string) ([]byte, error) { + dir, file := filepath.Split(outputDir) + packageParts := []string{file} + for dir != "." { + dir = filepath.Clean(dir) + dir, file = filepath.Split(dir) + dir = filepath.Clean(dir) + packageParts = append(packageParts, file) + } + slices.Reverse(packageParts) + packageName := strings.Join(packageParts, ".") + println(packageName) + fb := builder.NewFile("test.proto") + fb.Package = packageName fb.IsProto3 = true fb.SetComments(builder.Comments{ LeadingComment: "this file is autogenerated by aepc", @@ -60,7 +75,9 @@ func WriteServiceToProto(ps *parser.ParsedService) ([]byte, error) { if err != nil { return []byte{}, fmt.Errorf("unable to build service file %v: %w", fb.GetName(), err) } - printer := protoprint.Printer{} + printer := protoprint.Printer{ + CustomSortFunction: compareProtoElements, + } var output bytes.Buffer err = printer.PrintProtoFile(fd, &output) if err != nil { @@ -86,3 +103,43 @@ func getSortedResources(prsByString map[string]*parser.ParsedResource) []*parser } return resources } + +// compareProtoElements compares two protoprint.Element instances +// and returns true if the first element should come before the second element. +// customize to adhere to the AEPs. +func compareProtoElements(a, b protoprint.Element) bool { + return protoPrintKindToElement(a.Kind()) < protoPrintKindToElement(b.Kind()) +} + +func protoPrintKindToElement(ek protoprint.ElementKind) int { + switch ek { + case protoprint.KindPackage: + return 0 + case protoprint.KindImport: + return 1 + case protoprint.KindOption: + return 2 + case protoprint.KindService: + return 4 + case protoprint.KindEnum: + return 5 + case protoprint.KindMessage: + return 6 + case protoprint.KindField: + return 7 + case protoprint.KindExtensionRange: + return 8 + case protoprint.KindExtension: + return 9 + case protoprint.KindReservedRange: + return 10 + case protoprint.KindReservedName: + return 11 + case protoprint.KindEnumValue: + return 12 + case protoprint.KindMethod: + return 13 + default: + return 99 + } +} diff --git a/writer/proto/resource.go b/writer/proto/resource.go index bbdedb6..31c351f 100644 --- a/writer/proto/resource.go +++ b/writer/proto/resource.go @@ -125,7 +125,6 @@ func AddCreate(r *parser.ParsedResource, resourceMb *builder.MessageBuilder, fb }) addParentField(r, mb) addIdField(r, mb) - addPathField(r, mb) addResourceField(r, resourceMb, mb) fb.AddMessage(mb) method := builder.NewMethod("Create"+r.Kind, @@ -144,7 +143,7 @@ func AddCreate(r *parser.ParsedResource, resourceMb *builder.MessageBuilder, fb Body: strings.ToLower(r.Kind), }) proto.SetExtension(options, annotations.E_MethodSignature, []string{ - strings.Join([]string{constants.FIELD_PARENT_NAME, constants.FIELD_RESOURCE_NAME}, ","), + strings.Join([]string{constants.FIELD_PARENT_NAME, strings.ToLower(r.Kind)}, ","), }) method.SetOptions(options) sb.AddMethod(method) @@ -173,6 +172,9 @@ func AddGet(r *parser.ParsedResource, resourceMb *builder.MessageBuilder, fb *bu Get: fmt.Sprintf("/{path=%v}", generateHTTPPath(r)), }, }) + proto.SetExtension(options, annotations.E_MethodSignature, []string{ + strings.Join([]string{constants.FIELD_PATH_NAME}, ","), + }) method.SetOptions(options) sb.AddMethod(method) return nil @@ -212,7 +214,7 @@ func AddUpdate(r *parser.ParsedResource, resourceMb *builder.MessageBuilder, fb Body: strings.ToLower(r.Kind), }) proto.SetExtension(options, annotations.E_MethodSignature, []string{ - strings.Join([]string{constants.FIELD_UPDATE_MASK_NAME, constants.FIELD_RESOURCE_NAME}, ","), + strings.Join([]string{strings.ToLower(r.Kind), constants.FIELD_UPDATE_MASK_NAME}, ","), }) method.SetOptions(options) sb.AddMethod(method) @@ -258,7 +260,7 @@ func AddList(r *parser.ParsedResource, resourceMb *builder.MessageBuilder, fb *b // create request messages reqMb := builder.NewMessage("List" + r.Kind + "Request") reqMb.SetComments(builder.Comments{ - LeadingComment: fmt.Sprintf("Request message for the Delete%v method", r.Kind), + LeadingComment: fmt.Sprintf("Request message for the List%v method", r.Kind), }) addParentField(r, reqMb) addPageToken(r, reqMb) @@ -270,7 +272,7 @@ func AddList(r *parser.ParsedResource, resourceMb *builder.MessageBuilder, fb *b fb.AddMessage(reqMb) respMb := builder.NewMessage("List" + r.Kind + "Response") respMb.SetComments(builder.Comments{ - LeadingComment: fmt.Sprintf("Response message for the Delete%v method", r.Kind), + LeadingComment: fmt.Sprintf("Response message for the List%v method", r.Kind), }) addResourcesField(r, resourceMb, respMb) addNextPageToken(r, respMb) @@ -376,14 +378,16 @@ func generateHTTPPath(r *parser.ParsedResource) string { func generateParentHTTPPath(r *parser.ParsedResource) string { parentPath := "" if len(r.Parents) > 0 { - parentPath = fmt.Sprintf("{parent=%v}/", generateHTTPPath(r.Parents[0])) + parentPath = generateHTTPPath(r.Parents[0]) + // parentPath = fmt.Sprintf("{parent=%v/}", generateHTTPPath(r.Parents[0])) } - return fmt.Sprintf("/%v%v", parentPath, strings.ToLower(r.Plural)) + return fmt.Sprintf("/{parent=%v%v}", parentPath, strings.ToLower(r.Plural)) } func addParentField(r *parser.ParsedResource, mb *builder.MessageBuilder) { o := &descriptorpb.FieldOptions{} proto.SetExtension(o, annotations.E_FieldBehavior, []annotations.FieldBehavior{annotations.FieldBehavior_REQUIRED}) + proto.SetExtension(o, annotations.E_ResourceReference, &annotations.ResourceReference{}) f := builder. NewField(constants.FIELD_PARENT_NAME, builder.FieldTypeString()). SetNumber(constants.FIELD_PARENT_NUMBER). @@ -429,9 +433,9 @@ func addResourceField(r *parser.ParsedResource, resourceMb, mb *builder.MessageB } func addResourcesField(r *parser.ParsedResource, resourceMb, mb *builder.MessageBuilder) { - f := builder.NewField(strings.ToLower(r.Plural), builder.FieldTypeMessage(resourceMb)).SetNumber(constants.FIELD_RESOURCES_NUMBER).SetComments(builder.Comments{ + f := builder.NewField("results", builder.FieldTypeMessage(resourceMb)).SetNumber(constants.FIELD_RESOURCES_NUMBER).SetComments(builder.Comments{ LeadingComment: fmt.Sprintf("A list of %v", r.Plural), - }) + }).SetRepeated() mb.AddField(f) }