From 691707b8481c3b11aff705aac6b3cab9dbe18e09 Mon Sep 17 00:00:00 2001 From: Yusuke Tsutsumi Date: Sun, 20 Oct 2024 20:46:30 -0700 Subject: [PATCH] feat: add parent-child relationships (#35) re-adding the ability for parent-child relationship. This will enable APIs that have nested resources. --- example/bookstore/v1/bookstore.pb.go | 885 ++++++++++++++++++-- example/bookstore/v1/bookstore.pb.gw.go | 770 ++++++++++++++++- example/bookstore/v1/bookstore.proto | 163 +++- example/bookstore/v1/bookstore.swagger.json | 297 ++++++- example/bookstore/v1/bookstore.yaml | 39 +- example/bookstore/v1/bookstore_grpc.pb.go | 246 +++++- example/bookstore/v1/bookstore_openapi.json | 229 ++++- example/service/service.go | 62 +- parser/parser.go | 14 +- scripts/test_http_api.sh | 37 +- writer/openapi/openapi.go | 234 +++--- writer/proto/resource.go | 16 +- 12 files changed, 2713 insertions(+), 279 deletions(-) diff --git a/example/bookstore/v1/bookstore.pb.go b/example/bookstore/v1/bookstore.pb.go index 74527dc..4defd3f 100644 --- a/example/bookstore/v1/bookstore.pb.go +++ b/example/bookstore/v1/bookstore.pb.go @@ -541,6 +541,488 @@ func (x *ApplyBookRequest) GetBook() *Book { return nil } +// A Publisher. +type Publisher struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Field for description. + Description string `protobuf:"bytes,1,opt,name=description,proto3" json:"description,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 *Publisher) Reset() { + *x = Publisher{} + if protoimpl.UnsafeEnabled { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Publisher) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Publisher) ProtoMessage() {} + +func (x *Publisher) ProtoReflect() protoreflect.Message { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[8] + 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 Publisher.ProtoReflect.Descriptor instead. +func (*Publisher) Descriptor() ([]byte, []int) { + return file_example_bookstore_v1_bookstore_proto_rawDescGZIP(), []int{8} +} + +func (x *Publisher) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Publisher) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +func (x *Publisher) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +// A Create request for a Publisher resource. +type CreatePublisherRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // A field for the parent of Publisher + Parent string `protobuf:"bytes,10013,opt,name=parent,proto3" json:"parent,omitempty"` + // An id that uniquely identifies the resource within the collection + Id string `protobuf:"bytes,10014,opt,name=id,proto3" json:"id,omitempty"` + // The resource to perform the operation on. + Publisher *Publisher `protobuf:"bytes,10015,opt,name=publisher,proto3" json:"publisher,omitempty"` +} + +func (x *CreatePublisherRequest) Reset() { + *x = CreatePublisherRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreatePublisherRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreatePublisherRequest) ProtoMessage() {} + +func (x *CreatePublisherRequest) ProtoReflect() protoreflect.Message { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[9] + 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 CreatePublisherRequest.ProtoReflect.Descriptor instead. +func (*CreatePublisherRequest) Descriptor() ([]byte, []int) { + return file_example_bookstore_v1_bookstore_proto_rawDescGZIP(), []int{9} +} + +func (x *CreatePublisherRequest) GetParent() string { + if x != nil { + return x.Parent + } + return "" +} + +func (x *CreatePublisherRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *CreatePublisherRequest) GetPublisher() *Publisher { + if x != nil { + return x.Publisher + } + return nil +} + +// Request message for the GetPublisher method +type GetPublisherRequest 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 *GetPublisherRequest) Reset() { + *x = GetPublisherRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetPublisherRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPublisherRequest) ProtoMessage() {} + +func (x *GetPublisherRequest) ProtoReflect() protoreflect.Message { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[10] + 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 GetPublisherRequest.ProtoReflect.Descriptor instead. +func (*GetPublisherRequest) Descriptor() ([]byte, []int) { + return file_example_bookstore_v1_bookstore_proto_rawDescGZIP(), []int{10} +} + +func (x *GetPublisherRequest) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +// Request message for the UpdatePublisher method +type UpdatePublisherRequest 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. + Publisher *Publisher `protobuf:"bytes,10015,opt,name=publisher,proto3" json:"publisher,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 *UpdatePublisherRequest) Reset() { + *x = UpdatePublisherRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdatePublisherRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePublisherRequest) ProtoMessage() {} + +func (x *UpdatePublisherRequest) ProtoReflect() protoreflect.Message { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[11] + 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 UpdatePublisherRequest.ProtoReflect.Descriptor instead. +func (*UpdatePublisherRequest) Descriptor() ([]byte, []int) { + return file_example_bookstore_v1_bookstore_proto_rawDescGZIP(), []int{11} +} + +func (x *UpdatePublisherRequest) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +func (x *UpdatePublisherRequest) GetPublisher() *Publisher { + if x != nil { + return x.Publisher + } + return nil +} + +func (x *UpdatePublisherRequest) GetUpdateMask() *fieldmaskpb.FieldMask { + if x != nil { + return x.UpdateMask + } + return nil +} + +// Request message for the DeletePublisher method +type DeletePublisherRequest 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 *DeletePublisherRequest) Reset() { + *x = DeletePublisherRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeletePublisherRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeletePublisherRequest) ProtoMessage() {} + +func (x *DeletePublisherRequest) ProtoReflect() protoreflect.Message { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[12] + 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 DeletePublisherRequest.ProtoReflect.Descriptor instead. +func (*DeletePublisherRequest) Descriptor() ([]byte, []int) { + return file_example_bookstore_v1_bookstore_proto_rawDescGZIP(), []int{12} +} + +func (x *DeletePublisherRequest) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +// Request message for the ListPublisher method +type ListPublisherRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // A field for the parent of Publisher + 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 *ListPublisherRequest) Reset() { + *x = ListPublisherRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListPublisherRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPublisherRequest) ProtoMessage() {} + +func (x *ListPublisherRequest) ProtoReflect() protoreflect.Message { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[13] + 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 ListPublisherRequest.ProtoReflect.Descriptor instead. +func (*ListPublisherRequest) Descriptor() ([]byte, []int) { + return file_example_bookstore_v1_bookstore_proto_rawDescGZIP(), []int{13} +} + +func (x *ListPublisherRequest) GetParent() string { + if x != nil { + return x.Parent + } + return "" +} + +func (x *ListPublisherRequest) GetPageToken() string { + if x != nil { + return x.PageToken + } + return "" +} + +func (x *ListPublisherRequest) GetMaxPageSize() int32 { + if x != nil { + return x.MaxPageSize + } + return 0 +} + +// Response message for the ListPublisher method +type ListPublisherResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // A list of publishers + Results []*Publisher `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 *ListPublisherResponse) Reset() { + *x = ListPublisherResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListPublisherResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPublisherResponse) ProtoMessage() {} + +func (x *ListPublisherResponse) ProtoReflect() protoreflect.Message { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[14] + 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 ListPublisherResponse.ProtoReflect.Descriptor instead. +func (*ListPublisherResponse) Descriptor() ([]byte, []int) { + return file_example_bookstore_v1_bookstore_proto_rawDescGZIP(), []int{14} +} + +func (x *ListPublisherResponse) GetResults() []*Publisher { + if x != nil { + return x.Results + } + return nil +} + +func (x *ListPublisherResponse) GetNextPageToken() string { + if x != nil { + return x.NextPageToken + } + return "" +} + +// Request message for the ApplyPublisher method +type ApplyPublisherRequest 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. + Publisher *Publisher `protobuf:"bytes,10015,opt,name=publisher,proto3" json:"publisher,omitempty"` +} + +func (x *ApplyPublisherRequest) Reset() { + *x = ApplyPublisherRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ApplyPublisherRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ApplyPublisherRequest) ProtoMessage() {} + +func (x *ApplyPublisherRequest) ProtoReflect() protoreflect.Message { + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[15] + 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 ApplyPublisherRequest.ProtoReflect.Descriptor instead. +func (*ApplyPublisherRequest) Descriptor() ([]byte, []int) { + return file_example_bookstore_v1_bookstore_proto_rawDescGZIP(), []int{15} +} + +func (x *ApplyPublisherRequest) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +func (x *ApplyPublisherRequest) GetPublisher() *Publisher { + if x != nil { + return x.Publisher + } + return nil +} + // A Author. type Book_Author struct { state protoimpl.MessageState @@ -556,7 +1038,7 @@ type Book_Author struct { func (x *Book_Author) Reset() { *x = Book_Author{} if protoimpl.UnsafeEnabled { - mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[8] + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -569,7 +1051,7 @@ func (x *Book_Author) String() string { func (*Book_Author) ProtoMessage() {} func (x *Book_Author) ProtoReflect() protoreflect.Message { - mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[8] + mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[16] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -687,54 +1169,178 @@ var file_example_bookstore_v1_bookstore_proto_rawDesc = []byte{ 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, 0xda, 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, + 0x02, 0x52, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x22, 0x53, 0x0a, 0x09, 0x50, 0x75, 0x62, 0x6c, 0x69, + 0x73, 0x68, 0x65, 0x72, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, + 0x69, 0x70, 0x74, 0x69, 0x6f, 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, 0x8f, 0x01, 0x0a, + 0x16, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, + 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, 0x43, 0x0a, 0x09, 0x70, 0x75, 0x62, + 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x18, 0x9f, 0x4e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, + 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, + 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x42, 0x03, + 0xe0, 0x41, 0x02, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x22, 0x53, + 0x0a, 0x13, 0x47, 0x65, 0x74, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x3c, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0xa2, 0x4e, + 0x20, 0x01, 0x28, 0x09, 0x42, 0x27, 0xe0, 0x41, 0x02, 0xfa, 0x41, 0x21, 0x0a, 0x1f, 0x62, 0x6f, + 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x52, 0x04, 0x70, + 0x61, 0x74, 0x68, 0x22, 0xd9, 0x01, 0x0a, 0x16, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x75, + 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x3c, + 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0xa2, 0x4e, 0x20, 0x01, 0x28, 0x09, 0x42, 0x27, 0xe0, + 0x41, 0x02, 0xfa, 0x41, 0x21, 0x0a, 0x1f, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, + 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x50, 0x75, 0x62, + 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x43, 0x0a, 0x09, + 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x18, 0x9f, 0x4e, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, 0x73, + 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, + 0x72, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, + 0x72, 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, + 0x56, 0x0a, 0x16, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, + 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x3c, 0x0a, 0x04, 0x70, 0x61, 0x74, + 0x68, 0x18, 0xa2, 0x4e, 0x20, 0x01, 0x28, 0x09, 0x42, 0x27, 0xe0, 0x41, 0x02, 0xfa, 0x41, 0x21, + 0x0a, 0x1f, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x65, 0x78, 0x61, 0x6d, + 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, + 0x72, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x22, 0x7c, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x50, + 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 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, 0x7c, 0x0a, 0x15, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x75, 0x62, + 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3a, + 0x0a, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x18, 0xa0, 0x4e, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x1f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, 0x73, + 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, + 0x72, 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, 0x9a, 0x01, 0x0a, 0x15, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x50, 0x75, 0x62, + 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x3c, 0x0a, + 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0xa2, 0x4e, 0x20, 0x01, 0x28, 0x09, 0x42, 0x27, 0xe0, 0x41, + 0x02, 0xfa, 0x41, 0x21, 0x0a, 0x1f, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, + 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x50, 0x75, 0x62, 0x6c, + 0x69, 0x73, 0x68, 0x65, 0x72, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x43, 0x0a, 0x09, 0x70, + 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x18, 0x9f, 0x4e, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, + 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, + 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, + 0x32, 0x88, 0x0d, 0x0a, 0x09, 0x42, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x12, 0x8b, + 0x01, 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, 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, 0x83, 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, 0x30, 0xda, 0x41, 0x10, 0x62, 0x6f, 0x6f, 0x6b, 0x2c, - 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x82, 0xd3, 0xe4, 0x93, 0x02, - 0x17, 0x3a, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x32, 0x0f, 0x2f, 0x7b, 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, + 0x6f, 0x6b, 0x22, 0x38, 0xda, 0x41, 0x0b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x2c, 0x62, 0x6f, + 0x6f, 0x6b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x24, 0x3a, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x22, 0x1c, + 0x2f, 0x7b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x3d, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, + 0x65, 0x72, 0x73, 0x2f, 0x2a, 0x7d, 0x2f, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x12, 0x78, 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, 0x2b, 0xda, 0x41, 0x04, 0x70, 0x61, + 0x74, 0x68, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1e, 0x12, 0x1c, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, + 0x3d, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x73, 0x2f, 0x2a, 0x2f, 0x62, 0x6f, + 0x6f, 0x6b, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0x90, 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, 0x3d, 0xda, 0x41, 0x10, 0x62, + 0x6f, 0x6f, 0x6b, 0x2c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x82, + 0xd3, 0xe4, 0x93, 0x02, 0x24, 0x3a, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x32, 0x1c, 0x2f, 0x7b, 0x70, + 0x61, 0x74, 0x68, 0x3d, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x73, 0x2f, 0x2a, + 0x2f, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0x7a, 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, 0x2b, 0xda, 0x41, 0x04, 0x70, 0x61, 0x74, + 0x68, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1e, 0x2a, 0x1c, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x3d, + 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x73, 0x2f, 0x2a, 0x2f, 0x62, 0x6f, 0x6f, + 0x6b, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0x88, 0x01, 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, 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, + 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x2d, 0xda, 0x41, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x82, 0xd3, 0xe4, 0x93, + 0x02, 0x1e, 0x12, 0x1c, 0x2f, 0x7b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x3d, 0x70, 0x75, 0x62, + 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x73, 0x2f, 0x2a, 0x7d, 0x2f, 0x62, 0x6f, 0x6f, 0x6b, 0x73, + 0x12, 0x7b, 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, 0x2a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x24, 0x3a, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x1a, + 0x1c, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x3d, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, + 0x72, 0x73, 0x2f, 0x2a, 0x2f, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0x9c, 0x01, + 0x0a, 0x0f, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, + 0x72, 0x12, 0x2c, 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, 0x50, + 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x1f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, + 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, + 0x22, 0x3a, 0xda, 0x41, 0x10, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x2c, 0x70, 0x75, 0x62, 0x6c, + 0x69, 0x73, 0x68, 0x65, 0x72, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x21, 0x3a, 0x09, 0x70, 0x75, 0x62, + 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x22, 0x14, 0x2f, 0x7b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, + 0x3d, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x73, 0x7d, 0x12, 0x7f, 0x0a, 0x0c, + 0x47, 0x65, 0x74, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x12, 0x29, 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, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, + 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, + 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x22, 0x23, 0xda, 0x41, 0x04, 0x70, 0x61, 0x74, + 0x68, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x12, 0x14, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x3d, + 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0xa1, 0x01, + 0x0a, 0x0f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, + 0x72, 0x12, 0x2c, 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, 0x50, + 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x1f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, + 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, + 0x22, 0x3f, 0xda, 0x41, 0x15, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x2c, 0x75, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x21, + 0x3a, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x32, 0x14, 0x2f, 0x7b, 0x70, + 0x61, 0x74, 0x68, 0x3d, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x73, 0x2f, 0x2a, + 0x7d, 0x12, 0x7c, 0x0a, 0x0f, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x75, 0x62, 0x6c, 0x69, + 0x73, 0x68, 0x65, 0x72, 0x12, 0x2c, 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, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 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, 0x23, 0xda, 0x41, 0x04, 0x70, + 0x61, 0x74, 0x68, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x2a, 0x14, 0x2f, 0x7b, 0x70, 0x61, 0x74, + 0x68, 0x3d, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x73, 0x2f, 0x2a, 0x7d, 0x12, + 0x8f, 0x01, 0x0a, 0x0d, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, + 0x72, 0x12, 0x2a, 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, 0x50, 0x75, 0x62, + 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 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, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, + 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x25, 0xda, 0x41, 0x06, 0x70, + 0x61, 0x72, 0x65, 0x6e, 0x74, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x12, 0x14, 0x2f, 0x7b, 0x70, + 0x61, 0x72, 0x65, 0x6e, 0x74, 0x3d, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x73, + 0x7d, 0x12, 0x87, 0x01, 0x0a, 0x0e, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x50, 0x75, 0x62, 0x6c, 0x69, + 0x73, 0x68, 0x65, 0x72, 0x12, 0x2b, 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, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x1f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, + 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, + 0x65, 0x72, 0x22, 0x27, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x21, 0x3a, 0x09, 0x70, 0x75, 0x62, 0x6c, + 0x69, 0x73, 0x68, 0x65, 0x72, 0x1a, 0x14, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x3d, 0x70, 0x75, + 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 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 ( @@ -749,44 +1355,69 @@ func file_example_bookstore_v1_bookstore_proto_rawDescGZIP() []byte { return file_example_bookstore_v1_bookstore_proto_rawDescData } -var file_example_bookstore_v1_bookstore_proto_msgTypes = make([]protoimpl.MessageInfo, 9) +var file_example_bookstore_v1_bookstore_proto_msgTypes = make([]protoimpl.MessageInfo, 17) 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 - (*Book_Author)(nil), // 8: example.bookstore.v1.Book.Author - (*fieldmaskpb.FieldMask)(nil), // 9: google.protobuf.FieldMask - (*emptypb.Empty)(nil), // 10: google.protobuf.Empty + (*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 + (*Publisher)(nil), // 8: example.bookstore.v1.Publisher + (*CreatePublisherRequest)(nil), // 9: example.bookstore.v1.CreatePublisherRequest + (*GetPublisherRequest)(nil), // 10: example.bookstore.v1.GetPublisherRequest + (*UpdatePublisherRequest)(nil), // 11: example.bookstore.v1.UpdatePublisherRequest + (*DeletePublisherRequest)(nil), // 12: example.bookstore.v1.DeletePublisherRequest + (*ListPublisherRequest)(nil), // 13: example.bookstore.v1.ListPublisherRequest + (*ListPublisherResponse)(nil), // 14: example.bookstore.v1.ListPublisherResponse + (*ApplyPublisherRequest)(nil), // 15: example.bookstore.v1.ApplyPublisherRequest + (*Book_Author)(nil), // 16: example.bookstore.v1.Book.Author + (*fieldmaskpb.FieldMask)(nil), // 17: google.protobuf.FieldMask + (*emptypb.Empty)(nil), // 18: google.protobuf.Empty } var file_example_bookstore_v1_bookstore_proto_depIdxs = []int32{ - 8, // 0: example.bookstore.v1.Book.author:type_name -> example.bookstore.v1.Book.Author + 16, // 0: example.bookstore.v1.Book.author:type_name -> example.bookstore.v1.Book.Author 0, // 1: example.bookstore.v1.CreateBookRequest.book:type_name -> example.bookstore.v1.Book 0, // 2: example.bookstore.v1.UpdateBookRequest.book:type_name -> example.bookstore.v1.Book - 9, // 3: example.bookstore.v1.UpdateBookRequest.update_mask:type_name -> google.protobuf.FieldMask + 17, // 3: example.bookstore.v1.UpdateBookRequest.update_mask:type_name -> google.protobuf.FieldMask 0, // 4: example.bookstore.v1.ListBookResponse.results:type_name -> example.bookstore.v1.Book 0, // 5: example.bookstore.v1.ApplyBookRequest.book:type_name -> example.bookstore.v1.Book - 1, // 6: example.bookstore.v1.Bookstore.CreateBook:input_type -> example.bookstore.v1.CreateBookRequest - 2, // 7: example.bookstore.v1.Bookstore.GetBook:input_type -> example.bookstore.v1.GetBookRequest - 3, // 8: example.bookstore.v1.Bookstore.UpdateBook:input_type -> example.bookstore.v1.UpdateBookRequest - 4, // 9: example.bookstore.v1.Bookstore.DeleteBook:input_type -> example.bookstore.v1.DeleteBookRequest - 5, // 10: example.bookstore.v1.Bookstore.ListBook:input_type -> example.bookstore.v1.ListBookRequest - 7, // 11: example.bookstore.v1.Bookstore.ApplyBook:input_type -> example.bookstore.v1.ApplyBookRequest - 0, // 12: example.bookstore.v1.Bookstore.CreateBook:output_type -> example.bookstore.v1.Book - 0, // 13: example.bookstore.v1.Bookstore.GetBook:output_type -> example.bookstore.v1.Book - 0, // 14: example.bookstore.v1.Bookstore.UpdateBook:output_type -> example.bookstore.v1.Book - 10, // 15: example.bookstore.v1.Bookstore.DeleteBook:output_type -> google.protobuf.Empty - 6, // 16: example.bookstore.v1.Bookstore.ListBook:output_type -> example.bookstore.v1.ListBookResponse - 0, // 17: example.bookstore.v1.Bookstore.ApplyBook:output_type -> example.bookstore.v1.Book - 12, // [12:18] is the sub-list for method output_type - 6, // [6:12] is the sub-list for method input_type - 6, // [6:6] is the sub-list for extension type_name - 6, // [6:6] is the sub-list for extension extendee - 0, // [0:6] is the sub-list for field type_name + 8, // 6: example.bookstore.v1.CreatePublisherRequest.publisher:type_name -> example.bookstore.v1.Publisher + 8, // 7: example.bookstore.v1.UpdatePublisherRequest.publisher:type_name -> example.bookstore.v1.Publisher + 17, // 8: example.bookstore.v1.UpdatePublisherRequest.update_mask:type_name -> google.protobuf.FieldMask + 8, // 9: example.bookstore.v1.ListPublisherResponse.results:type_name -> example.bookstore.v1.Publisher + 8, // 10: example.bookstore.v1.ApplyPublisherRequest.publisher:type_name -> example.bookstore.v1.Publisher + 1, // 11: example.bookstore.v1.Bookstore.CreateBook:input_type -> example.bookstore.v1.CreateBookRequest + 2, // 12: example.bookstore.v1.Bookstore.GetBook:input_type -> example.bookstore.v1.GetBookRequest + 3, // 13: example.bookstore.v1.Bookstore.UpdateBook:input_type -> example.bookstore.v1.UpdateBookRequest + 4, // 14: example.bookstore.v1.Bookstore.DeleteBook:input_type -> example.bookstore.v1.DeleteBookRequest + 5, // 15: example.bookstore.v1.Bookstore.ListBook:input_type -> example.bookstore.v1.ListBookRequest + 7, // 16: example.bookstore.v1.Bookstore.ApplyBook:input_type -> example.bookstore.v1.ApplyBookRequest + 9, // 17: example.bookstore.v1.Bookstore.CreatePublisher:input_type -> example.bookstore.v1.CreatePublisherRequest + 10, // 18: example.bookstore.v1.Bookstore.GetPublisher:input_type -> example.bookstore.v1.GetPublisherRequest + 11, // 19: example.bookstore.v1.Bookstore.UpdatePublisher:input_type -> example.bookstore.v1.UpdatePublisherRequest + 12, // 20: example.bookstore.v1.Bookstore.DeletePublisher:input_type -> example.bookstore.v1.DeletePublisherRequest + 13, // 21: example.bookstore.v1.Bookstore.ListPublisher:input_type -> example.bookstore.v1.ListPublisherRequest + 15, // 22: example.bookstore.v1.Bookstore.ApplyPublisher:input_type -> example.bookstore.v1.ApplyPublisherRequest + 0, // 23: example.bookstore.v1.Bookstore.CreateBook:output_type -> example.bookstore.v1.Book + 0, // 24: example.bookstore.v1.Bookstore.GetBook:output_type -> example.bookstore.v1.Book + 0, // 25: example.bookstore.v1.Bookstore.UpdateBook:output_type -> example.bookstore.v1.Book + 18, // 26: example.bookstore.v1.Bookstore.DeleteBook:output_type -> google.protobuf.Empty + 6, // 27: example.bookstore.v1.Bookstore.ListBook:output_type -> example.bookstore.v1.ListBookResponse + 0, // 28: example.bookstore.v1.Bookstore.ApplyBook:output_type -> example.bookstore.v1.Book + 8, // 29: example.bookstore.v1.Bookstore.CreatePublisher:output_type -> example.bookstore.v1.Publisher + 8, // 30: example.bookstore.v1.Bookstore.GetPublisher:output_type -> example.bookstore.v1.Publisher + 8, // 31: example.bookstore.v1.Bookstore.UpdatePublisher:output_type -> example.bookstore.v1.Publisher + 18, // 32: example.bookstore.v1.Bookstore.DeletePublisher:output_type -> google.protobuf.Empty + 14, // 33: example.bookstore.v1.Bookstore.ListPublisher:output_type -> example.bookstore.v1.ListPublisherResponse + 8, // 34: example.bookstore.v1.Bookstore.ApplyPublisher:output_type -> example.bookstore.v1.Publisher + 23, // [23:35] is the sub-list for method output_type + 11, // [11:23] is the sub-list for method input_type + 11, // [11:11] is the sub-list for extension type_name + 11, // [11:11] is the sub-list for extension extendee + 0, // [0:11] is the sub-list for field type_name } func init() { file_example_bookstore_v1_bookstore_proto_init() } @@ -892,6 +1523,102 @@ func file_example_bookstore_v1_bookstore_proto_init() { } } file_example_bookstore_v1_bookstore_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Publisher); 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[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreatePublisherRequest); 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[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetPublisherRequest); 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[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdatePublisherRequest); 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[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeletePublisherRequest); 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[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListPublisherRequest); 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[14].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListPublisherResponse); 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[15].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ApplyPublisherRequest); 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[16].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Book_Author); i { case 0: return &v.state @@ -910,7 +1637,7 @@ func file_example_bookstore_v1_bookstore_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_example_bookstore_v1_bookstore_proto_rawDesc, NumEnums: 0, - NumMessages: 9, + NumMessages: 17, NumExtensions: 0, NumServices: 1, }, diff --git a/example/bookstore/v1/bookstore.pb.gw.go b/example/bookstore/v1/bookstore.pb.gw.go index 8c7679d..05c2ba5 100644 --- a/example/bookstore/v1/bookstore.pb.gw.go +++ b/example/bookstore/v1/bookstore.pb.gw.go @@ -459,6 +459,434 @@ func local_request_Bookstore_ApplyBook_0(ctx context.Context, marshaler runtime. } +var ( + filter_Bookstore_CreatePublisher_0 = &utilities.DoubleArray{Encoding: map[string]int{"publisher": 0, "parent": 1}, Base: []int{1, 2, 4, 0, 0, 0, 0}, Check: []int{0, 1, 1, 2, 2, 3, 3}} +) + +func request_Bookstore_CreatePublisher_0(ctx context.Context, marshaler runtime.Marshaler, client BookstoreClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreatePublisherRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Publisher); err != nil && err != io.EOF { + 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) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Bookstore_CreatePublisher_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.CreatePublisher(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Bookstore_CreatePublisher_0(ctx context.Context, marshaler runtime.Marshaler, server BookstoreServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreatePublisherRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Publisher); err != nil && err != io.EOF { + 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) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Bookstore_CreatePublisher_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.CreatePublisher(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Bookstore_GetPublisher_0(ctx context.Context, marshaler runtime.Marshaler, client BookstoreClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetPublisherRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["path"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path") + } + + protoReq.Path, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path", err) + } + + msg, err := client.GetPublisher(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Bookstore_GetPublisher_0(ctx context.Context, marshaler runtime.Marshaler, server BookstoreServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetPublisherRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["path"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path") + } + + protoReq.Path, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path", err) + } + + msg, err := server.GetPublisher(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Bookstore_UpdatePublisher_0 = &utilities.DoubleArray{Encoding: map[string]int{"publisher": 0, "path": 1}, Base: []int{1, 2, 4, 0, 0, 0, 0}, Check: []int{0, 1, 1, 2, 2, 3, 3}} +) + +func request_Bookstore_UpdatePublisher_0(ctx context.Context, marshaler runtime.Marshaler, client BookstoreClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdatePublisherRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Publisher); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 { + if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Publisher); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } else { + protoReq.UpdateMask = fieldMask + } + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["path"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path") + } + + protoReq.Path, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Bookstore_UpdatePublisher_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.UpdatePublisher(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Bookstore_UpdatePublisher_0(ctx context.Context, marshaler runtime.Marshaler, server BookstoreServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdatePublisherRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Publisher); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 { + if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Publisher); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } else { + protoReq.UpdateMask = fieldMask + } + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["path"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path") + } + + protoReq.Path, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Bookstore_UpdatePublisher_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.UpdatePublisher(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Bookstore_DeletePublisher_0(ctx context.Context, marshaler runtime.Marshaler, client BookstoreClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeletePublisherRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["path"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path") + } + + protoReq.Path, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path", err) + } + + msg, err := client.DeletePublisher(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Bookstore_DeletePublisher_0(ctx context.Context, marshaler runtime.Marshaler, server BookstoreServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeletePublisherRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["path"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path") + } + + protoReq.Path, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path", err) + } + + msg, err := server.DeletePublisher(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Bookstore_ListPublisher_0 = &utilities.DoubleArray{Encoding: map[string]int{"parent": 0}, Base: []int{1, 2, 0, 0}, Check: []int{0, 1, 2, 2}} +) + +func request_Bookstore_ListPublisher_0(ctx context.Context, marshaler runtime.Marshaler, client BookstoreClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListPublisherRequest + 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) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Bookstore_ListPublisher_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ListPublisher(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Bookstore_ListPublisher_0(ctx context.Context, marshaler runtime.Marshaler, server BookstoreServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListPublisherRequest + 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) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Bookstore_ListPublisher_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ListPublisher(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Bookstore_ApplyPublisher_0(ctx context.Context, marshaler runtime.Marshaler, client BookstoreClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ApplyPublisherRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Publisher); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["path"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path") + } + + protoReq.Path, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path", err) + } + + msg, err := client.ApplyPublisher(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Bookstore_ApplyPublisher_0(ctx context.Context, marshaler runtime.Marshaler, server BookstoreServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ApplyPublisherRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Publisher); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["path"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path") + } + + protoReq.Path, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path", err) + } + + msg, err := server.ApplyPublisher(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterBookstoreHandlerServer registers the http handlers for service Bookstore to "mux". // UnaryRPC :call BookstoreServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -473,7 +901,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, "/example.bookstore.v1.Bookstore/CreateBook", runtime.WithHTTPPathPattern("/{parent=books}")) + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/CreateBook", runtime.WithHTTPPathPattern("/{parent=publishers/*}/books")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -498,7 +926,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, "/example.bookstore.v1.Bookstore/GetBook", runtime.WithHTTPPathPattern("/{path=books/*}")) + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/GetBook", runtime.WithHTTPPathPattern("/{path=publishers/*/books/*}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -523,7 +951,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, "/example.bookstore.v1.Bookstore/UpdateBook", runtime.WithHTTPPathPattern("/{path=books/*}")) + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/UpdateBook", runtime.WithHTTPPathPattern("/{path=publishers/*/books/*}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -548,7 +976,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, "/example.bookstore.v1.Bookstore/DeleteBook", runtime.WithHTTPPathPattern("/{path=books/*}")) + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/DeleteBook", runtime.WithHTTPPathPattern("/{path=publishers/*/books/*}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -573,7 +1001,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, "/example.bookstore.v1.Bookstore/ListBook", runtime.WithHTTPPathPattern("/{parent=books}")) + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/ListBook", runtime.WithHTTPPathPattern("/{parent=publishers/*}/books")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -598,7 +1026,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, "/example.bookstore.v1.Bookstore/ApplyBook", runtime.WithHTTPPathPattern("/{path=books/*}")) + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/ApplyBook", runtime.WithHTTPPathPattern("/{path=publishers/*/books/*}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -615,6 +1043,156 @@ func RegisterBookstoreHandlerServer(ctx context.Context, mux *runtime.ServeMux, }) + mux.Handle("POST", pattern_Bookstore_CreatePublisher_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/CreatePublisher", runtime.WithHTTPPathPattern("/{parent=publishers}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Bookstore_CreatePublisher_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Bookstore_CreatePublisher_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Bookstore_GetPublisher_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/GetPublisher", runtime.WithHTTPPathPattern("/{path=publishers/*}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Bookstore_GetPublisher_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Bookstore_GetPublisher_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PATCH", pattern_Bookstore_UpdatePublisher_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/UpdatePublisher", runtime.WithHTTPPathPattern("/{path=publishers/*}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Bookstore_UpdatePublisher_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Bookstore_UpdatePublisher_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("DELETE", pattern_Bookstore_DeletePublisher_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/DeletePublisher", runtime.WithHTTPPathPattern("/{path=publishers/*}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Bookstore_DeletePublisher_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Bookstore_DeletePublisher_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Bookstore_ListPublisher_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/ListPublisher", runtime.WithHTTPPathPattern("/{parent=publishers}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Bookstore_ListPublisher_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Bookstore_ListPublisher_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PUT", pattern_Bookstore_ApplyPublisher_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/ApplyPublisher", runtime.WithHTTPPathPattern("/{path=publishers/*}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Bookstore_ApplyPublisher_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Bookstore_ApplyPublisher_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -662,7 +1240,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, "/example.bookstore.v1.Bookstore/CreateBook", runtime.WithHTTPPathPattern("/{parent=books}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/CreateBook", runtime.WithHTTPPathPattern("/{parent=publishers/*}/books")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -684,7 +1262,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, "/example.bookstore.v1.Bookstore/GetBook", runtime.WithHTTPPathPattern("/{path=books/*}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/GetBook", runtime.WithHTTPPathPattern("/{path=publishers/*/books/*}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -706,7 +1284,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, "/example.bookstore.v1.Bookstore/UpdateBook", runtime.WithHTTPPathPattern("/{path=books/*}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/UpdateBook", runtime.WithHTTPPathPattern("/{path=publishers/*/books/*}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -728,7 +1306,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, "/example.bookstore.v1.Bookstore/DeleteBook", runtime.WithHTTPPathPattern("/{path=books/*}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/DeleteBook", runtime.WithHTTPPathPattern("/{path=publishers/*/books/*}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -750,7 +1328,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, "/example.bookstore.v1.Bookstore/ListBook", runtime.WithHTTPPathPattern("/{parent=books}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/ListBook", runtime.WithHTTPPathPattern("/{parent=publishers/*}/books")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -772,7 +1350,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, "/example.bookstore.v1.Bookstore/ApplyBook", runtime.WithHTTPPathPattern("/{path=books/*}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/ApplyBook", runtime.WithHTTPPathPattern("/{path=publishers/*/books/*}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -788,21 +1366,165 @@ func RegisterBookstoreHandlerClient(ctx context.Context, mux *runtime.ServeMux, }) + mux.Handle("POST", pattern_Bookstore_CreatePublisher_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/CreatePublisher", runtime.WithHTTPPathPattern("/{parent=publishers}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Bookstore_CreatePublisher_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Bookstore_CreatePublisher_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Bookstore_GetPublisher_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/GetPublisher", runtime.WithHTTPPathPattern("/{path=publishers/*}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Bookstore_GetPublisher_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Bookstore_GetPublisher_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PATCH", pattern_Bookstore_UpdatePublisher_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/UpdatePublisher", runtime.WithHTTPPathPattern("/{path=publishers/*}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Bookstore_UpdatePublisher_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Bookstore_UpdatePublisher_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("DELETE", pattern_Bookstore_DeletePublisher_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/DeletePublisher", runtime.WithHTTPPathPattern("/{path=publishers/*}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Bookstore_DeletePublisher_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Bookstore_DeletePublisher_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Bookstore_ListPublisher_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/ListPublisher", runtime.WithHTTPPathPattern("/{parent=publishers}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Bookstore_ListPublisher_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Bookstore_ListPublisher_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PUT", pattern_Bookstore_ApplyPublisher_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/ApplyPublisher", runtime.WithHTTPPathPattern("/{path=publishers/*}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Bookstore_ApplyPublisher_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Bookstore_ApplyPublisher_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } var ( - pattern_Bookstore_CreateBook_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 4, 1, 5, 1}, []string{"books", "parent"}, "")) + pattern_Bookstore_CreateBook_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 2, 5, 1, 2, 2}, []string{"publishers", "parent", "books"}, "")) + + pattern_Bookstore_GetBook_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 2, 1, 1, 0, 4, 4, 5, 2}, []string{"publishers", "books", "path"}, "")) + + pattern_Bookstore_UpdateBook_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 2, 1, 1, 0, 4, 4, 5, 2}, []string{"publishers", "books", "path"}, "")) + + pattern_Bookstore_DeleteBook_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 2, 1, 1, 0, 4, 4, 5, 2}, []string{"publishers", "books", "path"}, "")) + + pattern_Bookstore_ListBook_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 2, 5, 1, 2, 2}, []string{"publishers", "parent", "books"}, "")) - pattern_Bookstore_GetBook_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 2, 5, 1}, []string{"books", "path"}, "")) + pattern_Bookstore_ApplyBook_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 2, 1, 1, 0, 4, 4, 5, 2}, []string{"publishers", "books", "path"}, "")) - pattern_Bookstore_UpdateBook_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 2, 5, 1}, []string{"books", "path"}, "")) + pattern_Bookstore_CreatePublisher_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 4, 1, 5, 1}, []string{"publishers", "parent"}, "")) - pattern_Bookstore_DeleteBook_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 2, 5, 1}, []string{"books", "path"}, "")) + pattern_Bookstore_GetPublisher_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 2, 5, 1}, []string{"publishers", "path"}, "")) - pattern_Bookstore_ListBook_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 4, 1, 5, 1}, []string{"books", "parent"}, "")) + pattern_Bookstore_UpdatePublisher_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 2, 5, 1}, []string{"publishers", "path"}, "")) - pattern_Bookstore_ApplyBook_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 2, 5, 1}, []string{"books", "path"}, "")) + pattern_Bookstore_DeletePublisher_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 2, 5, 1}, []string{"publishers", "path"}, "")) + + pattern_Bookstore_ListPublisher_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 4, 1, 5, 1}, []string{"publishers", "parent"}, "")) + + pattern_Bookstore_ApplyPublisher_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 2, 5, 1}, []string{"publishers", "path"}, "")) ) var ( @@ -817,4 +1539,16 @@ var ( forward_Bookstore_ListBook_0 = runtime.ForwardResponseMessage forward_Bookstore_ApplyBook_0 = runtime.ForwardResponseMessage + + forward_Bookstore_CreatePublisher_0 = runtime.ForwardResponseMessage + + forward_Bookstore_GetPublisher_0 = runtime.ForwardResponseMessage + + forward_Bookstore_UpdatePublisher_0 = runtime.ForwardResponseMessage + + forward_Bookstore_DeletePublisher_0 = runtime.ForwardResponseMessage + + forward_Bookstore_ListPublisher_0 = runtime.ForwardResponseMessage + + forward_Bookstore_ApplyPublisher_0 = runtime.ForwardResponseMessage ) diff --git a/example/bookstore/v1/bookstore.proto b/example/bookstore/v1/bookstore.proto index f9fcdbc..65d404d 100644 --- a/example/bookstore/v1/bookstore.proto +++ b/example/bookstore/v1/bookstore.proto @@ -20,42 +20,97 @@ option go_package = "/bookstore"; 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.http) = { + post: "/{parent=publishers/*}/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.http) = { get: "/{path=publishers/*/books/*}" }; option (google.api.method_signature) = "path"; } // An aep-compliant Update method for Book. rpc UpdateBook ( UpdateBookRequest ) returns ( Book ) { - option (google.api.http) = { patch: "/{path=books/*}", body: "book" }; + option (google.api.http) = { + patch: "/{path=publishers/*/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.http) = { delete: "/{path=publishers/*/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.http) = { get: "/{parent=publishers/*}/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" }; + option (google.api.http) = { + put: "/{path=publishers/*/books/*}", + body: "book" + }; + } + + // An aep-compliant Create method for Publisher. + rpc CreatePublisher ( CreatePublisherRequest ) returns ( Publisher ) { + option (google.api.http) = { + post: "/{parent=publishers}", + body: "publisher" + }; + + option (google.api.method_signature) = "parent,publisher"; + } + + // An aep-compliant Get method for Publisher. + rpc GetPublisher ( GetPublisherRequest ) returns ( Publisher ) { + option (google.api.http) = { get: "/{path=publishers/*}" }; + + option (google.api.method_signature) = "path"; + } + + // An aep-compliant Update method for Publisher. + rpc UpdatePublisher ( UpdatePublisherRequest ) returns ( Publisher ) { + option (google.api.http) = { + patch: "/{path=publishers/*}", + body: "publisher" + }; + + option (google.api.method_signature) = "publisher,update_mask"; + } + + // An aep-compliant Delete method for Publisher. + rpc DeletePublisher ( DeletePublisherRequest ) returns ( google.protobuf.Empty ) { + option (google.api.http) = { delete: "/{path=publishers/*}" }; + + option (google.api.method_signature) = "path"; + } + + // An aep-compliant List method for publishers. + rpc ListPublisher ( ListPublisherRequest ) returns ( ListPublisherResponse ) { + option (google.api.http) = { get: "/{parent=publishers}" }; + + option (google.api.method_signature) = "parent"; + } + + // An aep-compliant Apply method for publishers. + rpc ApplyPublisher ( ApplyPublisherRequest ) returns ( Publisher ) { + option (google.api.http) = { put: "/{path=publishers/*}", body: "publisher" }; } } @@ -175,3 +230,99 @@ message ApplyBookRequest { // The resource to perform the operation on. Book book = 10015 [(google.api.field_behavior) = REQUIRED]; } + +// A Publisher. +message Publisher { + // Field for description. + string description = 1; + + // Field for path. + string path = 10000; + + // Field for id. + string id = 10001; +} + +// A Create request for a Publisher resource. +message CreatePublisherRequest { + // A field for the parent of Publisher + string parent = 10013 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { } + ]; + + // An id that uniquely identifies the resource within the collection + string id = 10014; + + // The resource to perform the operation on. + Publisher publisher = 10015 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for the GetPublisher method +message GetPublisherRequest { + // The globally unique identifier for the resource + string path = 10018 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "bookstore.example.com/Publisher" } + ]; +} + +// Request message for the UpdatePublisher method +message UpdatePublisherRequest { + // The globally unique identifier for the resource + string path = 10018 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "bookstore.example.com/Publisher" } + ]; + + // The resource to perform the operation on. + Publisher publisher = 10015 [(google.api.field_behavior) = REQUIRED]; + + // The update mask for the resource + google.protobuf.FieldMask update_mask = 10012; +} + +// Request message for the DeletePublisher method +message DeletePublisherRequest { + // The globally unique identifier for the resource + string path = 10018 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "bookstore.example.com/Publisher" } + ]; +} + +// Request message for the ListPublisher method +message ListPublisherRequest { + // A field for the parent of Publisher + 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; + + // The maximum number of resources to return in a single page. + int32 max_page_size = 10017; +} + +// Response message for the ListPublisher method +message ListPublisherResponse { + // A list of publishers + repeated Publisher results = 10016; + + // The page token indicating the ending point of this response. + string next_page_token = 10011; +} + +// Request message for the ApplyPublisher method +message ApplyPublisherRequest { + // The globally unique identifier for the resource + string path = 10018 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "bookstore.example.com/Publisher" } + ]; + + // The resource to perform the operation on. + Publisher publisher = 10015 [(google.api.field_behavior) = REQUIRED]; +} diff --git a/example/bookstore/v1/bookstore.swagger.json b/example/bookstore/v1/bookstore.swagger.json index 4053afe..79cee1b 100644 --- a/example/bookstore/v1/bookstore.swagger.json +++ b/example/bookstore/v1/bookstore.swagger.json @@ -17,6 +17,104 @@ ], "paths": { "/{parent}": { + "get": { + "summary": "An aep-compliant List method for publishers.", + "operationId": "Bookstore_ListPublisher", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1ListPublisherResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "parent", + "description": "A field for the parent of Publisher", + "in": "path", + "required": true, + "type": "string", + "pattern": "publishers" + }, + { + "name": "pageToken", + "description": "The page token indicating the starting point of the page", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "maxPageSize", + "description": "The maximum number of resources to return in a single page.", + "in": "query", + "required": false, + "type": "integer", + "format": "int32" + } + ], + "tags": [ + "Bookstore" + ] + }, + "post": { + "summary": "An aep-compliant Create method for Publisher.", + "operationId": "Bookstore_CreatePublisher", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1Publisher" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "parent", + "description": "A field for the parent of Publisher", + "in": "path", + "required": true, + "type": "string", + "pattern": "publishers" + }, + { + "name": "publisher", + "description": "The resource to perform the operation on.", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1Publisher", + "required": [ + "publisher" + ] + } + }, + { + "name": "id", + "description": "An id that uniquely identifies the resource within the collection", + "in": "query", + "required": false, + "type": "string" + } + ], + "tags": [ + "Bookstore" + ] + } + }, + "/{parent}/books": { "get": { "summary": "An aep-compliant List method for books.", "operationId": "Bookstore_ListBook", @@ -41,7 +139,7 @@ "in": "path", "required": true, "type": "string", - "pattern": "books" + "pattern": "publishers/[^/]+" }, { "name": "pageToken", @@ -87,7 +185,7 @@ "in": "path", "required": true, "type": "string", - "pattern": "books" + "pattern": "publishers/[^/]+" }, { "name": "book", @@ -114,6 +212,157 @@ ] } }, + "/{path_1}": { + "get": { + "summary": "An aep-compliant Get method for Publisher.", + "operationId": "Bookstore_GetPublisher", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1Publisher" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "path_1", + "description": "The globally unique identifier for the resource", + "in": "path", + "required": true, + "type": "string", + "pattern": "publishers/[^/]+" + } + ], + "tags": [ + "Bookstore" + ] + }, + "delete": { + "summary": "An aep-compliant Delete method for Publisher.", + "operationId": "Bookstore_DeletePublisher", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "object", + "properties": {} + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "path_1", + "description": "The globally unique identifier for the resource", + "in": "path", + "required": true, + "type": "string", + "pattern": "publishers/[^/]+" + } + ], + "tags": [ + "Bookstore" + ] + }, + "put": { + "summary": "An aep-compliant Apply method for publishers.", + "operationId": "Bookstore_ApplyPublisher", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1Publisher" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "path_1", + "description": "The globally unique identifier for the resource", + "in": "path", + "required": true, + "type": "string", + "pattern": "publishers/[^/]+" + }, + { + "name": "publisher", + "description": "The resource to perform the operation on.", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1Publisher", + "required": [ + "publisher" + ] + } + } + ], + "tags": [ + "Bookstore" + ] + }, + "patch": { + "summary": "An aep-compliant Update method for Publisher.", + "operationId": "Bookstore_UpdatePublisher", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1Publisher" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "path_1", + "description": "The globally unique identifier for the resource", + "in": "path", + "required": true, + "type": "string", + "pattern": "publishers/[^/]+" + }, + { + "name": "publisher", + "description": "The resource to perform the operation on.", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1Publisher", + "required": [ + "publisher" + ] + } + } + ], + "tags": [ + "Bookstore" + ] + } + }, "/{path}": { "get": { "summary": "An aep-compliant Get method for Book.", @@ -139,7 +388,7 @@ "in": "path", "required": true, "type": "string", - "pattern": "books/[^/]+" + "pattern": "publishers/[^/]+/books/[^/]+" } ], "tags": [ @@ -171,7 +420,7 @@ "in": "path", "required": true, "type": "string", - "pattern": "books/[^/]+" + "pattern": "publishers/[^/]+/books/[^/]+" } ], "tags": [ @@ -202,7 +451,7 @@ "in": "path", "required": true, "type": "string", - "pattern": "books/[^/]+" + "pattern": "publishers/[^/]+/books/[^/]+" }, { "name": "book", @@ -245,7 +494,7 @@ "in": "path", "required": true, "type": "string", - "pattern": "books/[^/]+" + "pattern": "publishers/[^/]+/books/[^/]+" }, { "name": "book", @@ -374,6 +623,42 @@ } }, "title": "Response message for the ListBook method" + }, + "v1ListPublisherResponse": { + "type": "object", + "properties": { + "results": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/v1Publisher" + }, + "title": "A list of publishers" + }, + "nextPageToken": { + "type": "string", + "description": "The page token indicating the ending point of this response." + } + }, + "title": "Response message for the ListPublisher method" + }, + "v1Publisher": { + "type": "object", + "properties": { + "description": { + "type": "string", + "description": "Field for description." + }, + "path": { + "type": "string", + "description": "Field for path." + }, + "id": { + "type": "string", + "description": "Field for id." + } + }, + "description": "A Publisher." } } } diff --git a/example/bookstore/v1/bookstore.yaml b/example/bookstore/v1/bookstore.yaml index e4365ed..8f8a1d3 100644 --- a/example/bookstore/v1/bookstore.yaml +++ b/example/bookstore/v1/bookstore.yaml @@ -2,8 +2,27 @@ name: "bookstore.example.com" url: "http://localhost:8081" resources: + # example of a simple resource + - kind: "Publisher" + plural: "publishers" + properties: + description: + type: STRING + number: 1 + methods: + create: {} + read: {} + update: {} + delete: {} + list: {} + apply: {} + # example of a child resource - kind: "Book" plural: "books" + # the parents should specify the parents of the resource. It takes in the + # kind. + parents: + - "Publisher" properties: isbn: array_type: @@ -32,8 +51,6 @@ resources: lastName: type: STRING number: 2 - # parents: - # - "bookstore.example.com/Publisher" methods: create: {} read: {} @@ -41,18 +58,6 @@ resources: delete: {} list: {} apply: {} # do not uncomment until there is an AEP on apply. -# - kind: "Publisher" -# plural: "publishers" -# methods: -# read: {} -# list: {} -# - kind: "Author" -# plural: "authors" -# properties: -# name: -# type: STRING -# number: 1 -# parents: -# - "Publisher" -# methods: -# read: {} + # other example resources that might be interesting to add: + # authors, which could be a reference for book + # authors could have a reference to publishers too diff --git a/example/bookstore/v1/bookstore_grpc.pb.go b/example/bookstore/v1/bookstore_grpc.pb.go index 8fbaba2..5a1ae9a 100644 --- a/example/bookstore/v1/bookstore_grpc.pb.go +++ b/example/bookstore/v1/bookstore_grpc.pb.go @@ -20,12 +20,18 @@ import ( const _ = grpc.SupportPackageIsVersion7 const ( - 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" + 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" + Bookstore_CreatePublisher_FullMethodName = "/example.bookstore.v1.Bookstore/CreatePublisher" + Bookstore_GetPublisher_FullMethodName = "/example.bookstore.v1.Bookstore/GetPublisher" + Bookstore_UpdatePublisher_FullMethodName = "/example.bookstore.v1.Bookstore/UpdatePublisher" + Bookstore_DeletePublisher_FullMethodName = "/example.bookstore.v1.Bookstore/DeletePublisher" + Bookstore_ListPublisher_FullMethodName = "/example.bookstore.v1.Bookstore/ListPublisher" + Bookstore_ApplyPublisher_FullMethodName = "/example.bookstore.v1.Bookstore/ApplyPublisher" ) // BookstoreClient is the client API for Bookstore service. @@ -44,6 +50,18 @@ type BookstoreClient interface { ListBook(ctx context.Context, in *ListBookRequest, opts ...grpc.CallOption) (*ListBookResponse, error) // An aep-compliant Apply method for books. ApplyBook(ctx context.Context, in *ApplyBookRequest, opts ...grpc.CallOption) (*Book, error) + // An aep-compliant Create method for Publisher. + CreatePublisher(ctx context.Context, in *CreatePublisherRequest, opts ...grpc.CallOption) (*Publisher, error) + // An aep-compliant Get method for Publisher. + GetPublisher(ctx context.Context, in *GetPublisherRequest, opts ...grpc.CallOption) (*Publisher, error) + // An aep-compliant Update method for Publisher. + UpdatePublisher(ctx context.Context, in *UpdatePublisherRequest, opts ...grpc.CallOption) (*Publisher, error) + // An aep-compliant Delete method for Publisher. + DeletePublisher(ctx context.Context, in *DeletePublisherRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) + // An aep-compliant List method for publishers. + ListPublisher(ctx context.Context, in *ListPublisherRequest, opts ...grpc.CallOption) (*ListPublisherResponse, error) + // An aep-compliant Apply method for publishers. + ApplyPublisher(ctx context.Context, in *ApplyPublisherRequest, opts ...grpc.CallOption) (*Publisher, error) } type bookstoreClient struct { @@ -108,6 +126,60 @@ func (c *bookstoreClient) ApplyBook(ctx context.Context, in *ApplyBookRequest, o return out, nil } +func (c *bookstoreClient) CreatePublisher(ctx context.Context, in *CreatePublisherRequest, opts ...grpc.CallOption) (*Publisher, error) { + out := new(Publisher) + err := c.cc.Invoke(ctx, Bookstore_CreatePublisher_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *bookstoreClient) GetPublisher(ctx context.Context, in *GetPublisherRequest, opts ...grpc.CallOption) (*Publisher, error) { + out := new(Publisher) + err := c.cc.Invoke(ctx, Bookstore_GetPublisher_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *bookstoreClient) UpdatePublisher(ctx context.Context, in *UpdatePublisherRequest, opts ...grpc.CallOption) (*Publisher, error) { + out := new(Publisher) + err := c.cc.Invoke(ctx, Bookstore_UpdatePublisher_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *bookstoreClient) DeletePublisher(ctx context.Context, in *DeletePublisherRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, Bookstore_DeletePublisher_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *bookstoreClient) ListPublisher(ctx context.Context, in *ListPublisherRequest, opts ...grpc.CallOption) (*ListPublisherResponse, error) { + out := new(ListPublisherResponse) + err := c.cc.Invoke(ctx, Bookstore_ListPublisher_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *bookstoreClient) ApplyPublisher(ctx context.Context, in *ApplyPublisherRequest, opts ...grpc.CallOption) (*Publisher, error) { + out := new(Publisher) + err := c.cc.Invoke(ctx, Bookstore_ApplyPublisher_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // BookstoreServer is the server API for Bookstore service. // All implementations must embed UnimplementedBookstoreServer // for forward compatibility @@ -124,6 +196,18 @@ type BookstoreServer interface { ListBook(context.Context, *ListBookRequest) (*ListBookResponse, error) // An aep-compliant Apply method for books. ApplyBook(context.Context, *ApplyBookRequest) (*Book, error) + // An aep-compliant Create method for Publisher. + CreatePublisher(context.Context, *CreatePublisherRequest) (*Publisher, error) + // An aep-compliant Get method for Publisher. + GetPublisher(context.Context, *GetPublisherRequest) (*Publisher, error) + // An aep-compliant Update method for Publisher. + UpdatePublisher(context.Context, *UpdatePublisherRequest) (*Publisher, error) + // An aep-compliant Delete method for Publisher. + DeletePublisher(context.Context, *DeletePublisherRequest) (*emptypb.Empty, error) + // An aep-compliant List method for publishers. + ListPublisher(context.Context, *ListPublisherRequest) (*ListPublisherResponse, error) + // An aep-compliant Apply method for publishers. + ApplyPublisher(context.Context, *ApplyPublisherRequest) (*Publisher, error) mustEmbedUnimplementedBookstoreServer() } @@ -149,6 +233,24 @@ func (UnimplementedBookstoreServer) ListBook(context.Context, *ListBookRequest) func (UnimplementedBookstoreServer) ApplyBook(context.Context, *ApplyBookRequest) (*Book, error) { return nil, status.Errorf(codes.Unimplemented, "method ApplyBook not implemented") } +func (UnimplementedBookstoreServer) CreatePublisher(context.Context, *CreatePublisherRequest) (*Publisher, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreatePublisher not implemented") +} +func (UnimplementedBookstoreServer) GetPublisher(context.Context, *GetPublisherRequest) (*Publisher, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetPublisher not implemented") +} +func (UnimplementedBookstoreServer) UpdatePublisher(context.Context, *UpdatePublisherRequest) (*Publisher, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdatePublisher not implemented") +} +func (UnimplementedBookstoreServer) DeletePublisher(context.Context, *DeletePublisherRequest) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeletePublisher not implemented") +} +func (UnimplementedBookstoreServer) ListPublisher(context.Context, *ListPublisherRequest) (*ListPublisherResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListPublisher not implemented") +} +func (UnimplementedBookstoreServer) ApplyPublisher(context.Context, *ApplyPublisherRequest) (*Publisher, error) { + return nil, status.Errorf(codes.Unimplemented, "method ApplyPublisher not implemented") +} func (UnimplementedBookstoreServer) mustEmbedUnimplementedBookstoreServer() {} // UnsafeBookstoreServer may be embedded to opt out of forward compatibility for this service. @@ -270,6 +372,114 @@ func _Bookstore_ApplyBook_Handler(srv interface{}, ctx context.Context, dec func return interceptor(ctx, in, info, handler) } +func _Bookstore_CreatePublisher_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreatePublisherRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BookstoreServer).CreatePublisher(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Bookstore_CreatePublisher_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BookstoreServer).CreatePublisher(ctx, req.(*CreatePublisherRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Bookstore_GetPublisher_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetPublisherRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BookstoreServer).GetPublisher(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Bookstore_GetPublisher_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BookstoreServer).GetPublisher(ctx, req.(*GetPublisherRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Bookstore_UpdatePublisher_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdatePublisherRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BookstoreServer).UpdatePublisher(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Bookstore_UpdatePublisher_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BookstoreServer).UpdatePublisher(ctx, req.(*UpdatePublisherRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Bookstore_DeletePublisher_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeletePublisherRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BookstoreServer).DeletePublisher(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Bookstore_DeletePublisher_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BookstoreServer).DeletePublisher(ctx, req.(*DeletePublisherRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Bookstore_ListPublisher_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListPublisherRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BookstoreServer).ListPublisher(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Bookstore_ListPublisher_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BookstoreServer).ListPublisher(ctx, req.(*ListPublisherRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Bookstore_ApplyPublisher_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ApplyPublisherRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BookstoreServer).ApplyPublisher(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Bookstore_ApplyPublisher_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BookstoreServer).ApplyPublisher(ctx, req.(*ApplyPublisherRequest)) + } + return interceptor(ctx, in, info, handler) +} + // Bookstore_ServiceDesc is the grpc.ServiceDesc for Bookstore service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -301,6 +511,30 @@ var Bookstore_ServiceDesc = grpc.ServiceDesc{ MethodName: "ApplyBook", Handler: _Bookstore_ApplyBook_Handler, }, + { + MethodName: "CreatePublisher", + Handler: _Bookstore_CreatePublisher_Handler, + }, + { + MethodName: "GetPublisher", + Handler: _Bookstore_GetPublisher_Handler, + }, + { + MethodName: "UpdatePublisher", + Handler: _Bookstore_UpdatePublisher_Handler, + }, + { + MethodName: "DeletePublisher", + Handler: _Bookstore_DeletePublisher_Handler, + }, + { + MethodName: "ListPublisher", + Handler: _Bookstore_ListPublisher_Handler, + }, + { + MethodName: "ApplyPublisher", + Handler: _Bookstore_ApplyPublisher_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "example/bookstore/v1/bookstore.proto", diff --git a/example/bookstore/v1/bookstore_openapi.json b/example/bookstore/v1/bookstore_openapi.json index 2c36d60..36feca1 100644 --- a/example/bookstore/v1/bookstore_openapi.json +++ b/example/bookstore/v1/bookstore_openapi.json @@ -13,24 +13,24 @@ "http" ], "paths": { - "/books": { + "/publishers": { "get": { "responses": { "200": { "schema": { "items": { - "$ref": "#/components/schemas/Book" + "$ref": "#/components/schemas/Publisher" } } } }, - "parameters": null + "parameters": [] }, "post": { "responses": { "200": { "schema": { - "$ref": "#/components/schemas/Book" + "$ref": "#/components/schemas/Publisher" } } }, @@ -39,11 +39,11 @@ "in": "body", "name": "body", "schema": { - "$ref": "#/components/schemas/Book" + "$ref": "#/components/schemas/Publisher" } }, { - "in": "path", + "in": "query", "name": "id", "schema": {}, "required": true, @@ -52,8 +52,107 @@ ] } }, - "/books/{id}": { + "/publishers/{publisher_id}": { "delete": { + "responses": { + "200": { + "schema": {} + } + }, + "parameters": [ + { + "in": "path", + "name": "publisher_id", + "schema": {}, + "required": true, + "type": "string" + } + ] + }, + "get": { + "responses": { + "200": { + "schema": { + "$ref": "#/components/schemas/Publisher" + } + } + }, + "parameters": [ + { + "in": "path", + "name": "publisher_id", + "schema": {}, + "required": true, + "type": "string" + } + ] + }, + "patch": { + "responses": { + "200": { + "schema": { + "$ref": "#/components/schemas/Publisher" + } + } + }, + "parameters": [ + { + "in": "path", + "name": "publisher_id", + "schema": {}, + "required": true, + "type": "string" + }, + { + "in": "body", + "name": "body", + "schema": { + "$ref": "#/components/schemas/Publisher" + } + } + ] + }, + "put": { + "responses": { + "200": { + "schema": { + "$ref": "#/components/schemas/Publisher" + } + } + }, + "parameters": [ + { + "in": "body", + "name": "body", + "schema": { + "$ref": "#/components/schemas/Publisher" + } + } + ] + } + }, + "/publishers/{publisher_id}/books": { + "get": { + "responses": { + "200": { + "schema": { + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + }, + "parameters": [ + { + "in": "path", + "name": "publisher_id", + "schema": {}, + "required": true, + "type": "string" + } + ] + }, + "post": { "responses": { "200": { "schema": { @@ -61,7 +160,54 @@ } } }, - "parameters": null + "parameters": [ + { + "in": "path", + "name": "publisher_id", + "schema": {}, + "required": true, + "type": "string" + }, + { + "in": "body", + "name": "body", + "schema": { + "$ref": "#/components/schemas/Book" + } + }, + { + "in": "query", + "name": "id", + "schema": {}, + "required": true, + "type": "string" + } + ] + } + }, + "/publishers/{publisher_id}/books/{book_id}": { + "delete": { + "responses": { + "200": { + "schema": {} + } + }, + "parameters": [ + { + "in": "path", + "name": "publisher_id", + "schema": {}, + "required": true, + "type": "string" + }, + { + "in": "path", + "name": "book_id", + "schema": {}, + "required": true, + "type": "string" + } + ] }, "get": { "responses": { @@ -71,7 +217,22 @@ } } }, - "parameters": null + "parameters": [ + { + "in": "path", + "name": "publisher_id", + "schema": {}, + "required": true, + "type": "string" + }, + { + "in": "path", + "name": "book_id", + "schema": {}, + "required": true, + "type": "string" + } + ] }, "patch": { "responses": { @@ -82,6 +243,20 @@ } }, "parameters": [ + { + "in": "path", + "name": "publisher_id", + "schema": {}, + "required": true, + "type": "string" + }, + { + "in": "path", + "name": "book_id", + "schema": {}, + "required": true, + "type": "string" + }, { "in": "body", "name": "body", @@ -100,6 +275,13 @@ } }, "parameters": [ + { + "in": "path", + "name": "publisher_id", + "schema": {}, + "required": true, + "type": "string" + }, { "in": "body", "name": "body", @@ -158,7 +340,34 @@ "singular": "Book", "plural": "books", "patterns": [ - "/books/{book}" + "/publishers/{publisher_id}/books/{book_id}" + ], + "parents": [ + "Publisher" + ] + } + }, + "Publisher": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "id": { + "type": "string", + "readOnly": true, + "x-terraform-id": true + }, + "path": { + "type": "string", + "readOnly": true + } + }, + "x-aep-resource": { + "singular": "Publisher", + "plural": "publishers", + "patterns": [ + "/publishers/{publisher_id}" ] } } diff --git a/example/service/service.go b/example/service/service.go index 2ab2737..d3c998b 100644 --- a/example/service/service.go +++ b/example/service/service.go @@ -16,6 +16,7 @@ import ( ) var bookDatabase map[string]*bpb.Book +var publisherDatabase map[string]*bpb.Publisher type BookstoreServer struct { bpb.UnimplementedBookstoreServer @@ -29,9 +30,9 @@ func (BookstoreServer) CreateBook(_ context.Context, r *bpb.CreateBookRequest) ( book := proto.Clone(r.Book).(*bpb.Book) log.Printf("creating book %q", r) if r.Id == "" { - r.Id = fmt.Sprintf("%v", len(bookDatabase)+1) + r.Id = fmt.Sprintf("%v/books/%v", r.Parent, len(bookDatabase)+1) } - path := fmt.Sprintf("books/%v", r.Id) + path := fmt.Sprintf("%v/books/%v", r.Parent, r.Id) book.Id = r.Id book.Path = path bookDatabase[path] = book @@ -81,8 +82,65 @@ func (BookstoreServer) ListBook(_ context.Context, r *bpb.ListBookRequest) (*bpb }, nil } +func (BookstoreServer) CreatePublisher(_ context.Context, r *bpb.CreatePublisherRequest) (*bpb.Publisher, error) { + publisher := proto.Clone(r.Publisher).(*bpb.Publisher) + log.Printf("creating publisher %q", r) + if r.Id == "" { + r.Id = fmt.Sprintf("%v", len(bookDatabase)+1) + } + path := fmt.Sprintf("publishers/%v", r.Id) + publisher.Id = r.Id + publisher.Path = path + publisherDatabase[path] = publisher + log.Printf("created publisher %q", path) + return publisher, nil +} + +func (BookstoreServer) ApplyPublisher(_ context.Context, r *bpb.ApplyPublisherRequest) (*bpb.Publisher, error) { + log.Printf("applying publisher request: %v", r) + originalResource := bookDatabase[r.Path] + publisher := proto.Clone(r.Publisher).(*bpb.Publisher) + publisher.Id = originalResource.Id + publisher.Path = originalResource.Path + publisherDatabase[r.Path] = publisher + log.Printf("applied publisher %q", publisher.Path) + return publisher, nil +} + +func (BookstoreServer) UpdatePublisher(_ context.Context, r *bpb.UpdatePublisherRequest) (*bpb.Publisher, error) { + publisher := proto.Clone(r.Publisher).(*bpb.Publisher) + publisher.Path = r.Path + publisherDatabase[r.Path] = publisher + log.Printf("updated publisher %q at path %q", publisher, r.Path) + return publisher, nil +} + +func (BookstoreServer) DeletePublisher(_ context.Context, r *bpb.DeletePublisherRequest) (*emptypb.Empty, error) { + delete(publisherDatabase, r.Path) + log.Printf("deleted publisher %q", r.Path) + return &emptypb.Empty{}, nil +} + +func (BookstoreServer) GetPublisher(_ context.Context, r *bpb.GetPublisherRequest) (*bpb.Publisher, error) { + if p, found := publisherDatabase[r.Path]; found { + return p, nil + } + return nil, status.Errorf(codes.NotFound, "publisher %q not found", r.Path) +} + +func (BookstoreServer) ListPublisher(_ context.Context, r *bpb.ListPublisherRequest) (*bpb.ListPublisherResponse, error) { + var publishers []*bpb.Publisher + for _, p := range publisherDatabase { + publishers = append(publishers, p) + } + return &bpb.ListPublisherResponse{ + Results: publishers, + }, nil +} + func StartServer(targetPort int) { bookDatabase = make(map[string]*bpb.Book) + publisherDatabase = make(map[string]*bpb.Publisher) lis, err := net.Listen("tcp", fmt.Sprintf(":%d", targetPort)) if err != nil { log.Fatalf("failed to listen: %v", err) diff --git a/parser/parser.go b/parser/parser.go index efc3c25..51de352 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -27,8 +27,8 @@ func (ps *ParsedService) GetShortName() string { type ParsedResource struct { *schema.Resource - Type string - Parents []*ParsedResource + Type string + ParsedParents []*ParsedResource IsResource bool } @@ -79,10 +79,10 @@ func loadResourceByType(s *schema.Service) (map[string]*ParsedResource, error) { for _, r := range s.Resources { t := fmt.Sprintf("%s/%s", s.Name, r.Kind) resourceByType[t] = &ParsedResource{ - Resource: r, - Type: t, - Parents: []*ParsedResource{}, - IsResource: true, + Resource: r, + Type: t, + ParsedParents: []*ParsedResource{}, + IsResource: true, } } // populate resource parents @@ -97,7 +97,7 @@ func loadResourceByType(s *schema.Service) (map[string]*ParsedResource, error) { if !exists { return nil, fmt.Errorf("parent %q for resource %q not found", p, r.Kind) } - r.Parents = append(r.Parents, parentResource) + r.ParsedParents = append(r.ParsedParents, parentResource) } addGetToResource(r) addCommonFieldsToResource(r) diff --git a/scripts/test_http_api.sh b/scripts/test_http_api.sh index 4bdd224..fa8a909 100755 --- a/scripts/test_http_api.sh +++ b/scripts/test_http_api.sh @@ -4,8 +4,8 @@ set -ex GRPC_GATEWAY_PORT=8081 # Get OpenAPI Json -BOOK_ID="tomorrow-and-tomorrow-and-tomorrow" -ISBN="978-1476788036" +PUBLISHER_ID="orderly-cottage" +DESCRIPTION="very orderly" # start a process and get it's PID go build example/main.go @@ -23,33 +23,32 @@ if ! [[ $OPENAPI_OUTPUT == *"bookstore.example.com"* ]]; then echo "'bookstore.example.com' not found in OPENAPI_OUTPUT" fi -curl "http://localhost:8081/books?id=${BOOK_ID}" -X POST -d "{}" -BOOK=$(curl "http://localhost:8081/books/${BOOK_ID}") +curl "http://localhost:8081/publishers?id=${PUBLISHER_ID}" -X POST -d "{}" +PUBLISHER=$(curl "http://localhost:8081/publishers/${PUBLISHER_ID}") -# check if "tomorrow-and-tomorrow-and-tomorrow" is in BOOK -if ! [[ $BOOK == *"${BOOK_ID}"* ]]; then - echo "'${BOOK_ID}' not found in BOOK" +# check if "tomorrow-and-tomorrow-and-tomorrow" is in PUBLISHER +if ! [[ $PUBLISHER == *"${PUBLISHER_ID}"* ]]; then + echo "'${PUBLISHER_ID}' not found in PUBLISHER" fi # patch -if [[ $BOOK == *"${BOOK_ID}"* ]]; then - echo "Patching book" - curl "http://localhost:8081/books/${BOOK_ID}" -X PATCH -d "{\"isbn\": \"${ISBN}\"}" +if [[ $PUBLISHER == *"${PUBLISHER_ID}"* ]]; then + echo "Patching resource" + curl "http://localhost:8081/publishers/${PUBLISHER_ID}" -X PATCH -d "{\"description\": \"${DESCRIPTION}\"}" fi -# check if "tomorrow-and-tomorrow-and-tomorrow" is in BOOK -BOOK=$(curl "http://localhost:8081/books/${BOOK_ID}") -if ! [[ $BOOK == *"${ISBN}"* ]]; then - echo "'${ISBN}' not found in BOOK" +# check if "tomorrow-and-tomorrow-and-tomorrow" is in PUBLISHER +PUBLISHER=$(curl "http://localhost:8081/publishers/${PUBLISHER_ID}") +if ! [[ $PUBLISHER == *"${DESCRIPTION}"* ]]; then + echo "'${DESCRIPTION}' not found in PUBLISHER" fi # finally, delete the book -curl "http://localhost:8081/books/${BOOK_ID}" -X DELETE +curl "http://localhost:8081/publishers/${PUBLISHER_ID}" -X DELETE # perform a curl, verify we get a 404 not found -if [[ $(curl -s -o /dev/null -w "%{http_code}" "http://localhost:8081/books/${BOOK_ID}") -ne 404 ]]; then - echo "Book not deleted" +if [[ $(curl -s -o /dev/null -w "%{http_code}" "http://localhost:8081/publishers/${PUBLISHER_ID}") -ne 404 ]]; then + echo "resource not deleted" fi -echo "Success! Test Passed" - +echo "Success! Test Passed" \ No newline at end of file diff --git a/writer/openapi/openapi.go b/writer/openapi/openapi.go index 6e6f848..114970b 100644 --- a/writer/openapi/openapi.go +++ b/writer/openapi/openapi.go @@ -3,7 +3,6 @@ package openapi import ( "encoding/json" "fmt" - "log" "github.com/aep-dev/aepc/constants" "github.com/aep-dev/aepc/parser" @@ -41,119 +40,115 @@ func convertToOpenAPI(service *parser.ParsedService) (*OpenAPI, error) { if err != nil { return nil, err } - components.Schemas[r.Kind] = d if !r.IsResource { + components.Schemas[r.Kind] = d continue } - schemaRef := fmt.Sprintf("#/components/schemas/%v", r.Kind) - if r.Methods.List != nil { - log.Printf("resource plural: %s", r.Plural) - listPath := fmt.Sprintf("/%s", lowerizer.String(r.Plural)) - addMethodToPath(paths, listPath, "get", MethodInfo{ - Responses: Responses{ - "200": ResponseInfo{ - Schema: Schema{ - Items: &Schema{ - Ref: schemaRef, - }, - }, - }, - }, + // if it is a resource, add paths + parentPWPS := generateParentPatternsWithParams(r) + // add an empty PathWithParam, if there are no parents. + // This will add paths for the simple resource case. + if len(*parentPWPS) == 0 { + *parentPWPS = append(*parentPWPS, PathWithParams{ + Pattern: "", Params: []ParameterInfo{}, }) } - if r.Methods.Create != nil { - getPath := fmt.Sprintf("/%s", lowerizer.String(r.Plural)) - addMethodToPath(paths, getPath, "post", MethodInfo{ - Parameters: Parameters{ - ParameterInfo{ - In: "body", - Name: "body", - Schema: Schema{ - Ref: schemaRef, + patterns := []string{} + schemaRef := fmt.Sprintf("#/components/schemas/%v", r.Kind) + // declare some commonly used objects, to be used later. + bodyParam := ParameterInfo{ + In: "body", + Name: "body", + Schema: Schema{ + Ref: schemaRef, + }, + } + idParam := ParameterInfo{ + In: "path", + Name: fmt.Sprintf("%s_id", lowerizer.String(r.Kind)), + Required: true, + Type: "string", + } + resourceResponse := ResponseInfo{ + Schema: Schema{ + Ref: schemaRef, + }, + } + for _, pwp := range *parentPWPS { + resourcePath := fmt.Sprintf("%s/%s/{%s_id}", pwp.Pattern, lowerizer.String(r.Plural), lowerizer.String(r.Kind)) + patterns = append(patterns, resourcePath) + if r.Methods.List != nil { + listPath := fmt.Sprintf("%s/%s", pwp.Pattern, lowerizer.String(r.Plural)) + addMethodToPath(paths, listPath, "get", MethodInfo{ + Parameters: pwp.Params, + Responses: Responses{ + "200": ResponseInfo{ + Schema: Schema{ + Items: &Schema{ + Ref: schemaRef, + }, + }, }, }, + }) + } + if r.Methods.Create != nil { + createPath := fmt.Sprintf("%s/%s", pwp.Pattern, lowerizer.String(r.Plural)) + params := append(pwp.Params, bodyParam, ParameterInfo{ - In: "path", + In: "query", Name: "id", Required: true, Type: "string", }, - }, - Responses: Responses{ - "200": ResponseInfo{ - Schema: Schema{ - Ref: schemaRef, - }, + ) + addMethodToPath(paths, createPath, "post", MethodInfo{ + Parameters: params, + Responses: Responses{ + "200": resourceResponse, }, - }, - }) - } - if r.Methods.Read != nil { - getPath := fmt.Sprintf("/%s/{id}", lowerizer.String(r.Plural)) - addMethodToPath(paths, getPath, "get", MethodInfo{ - Responses: Responses{ - "200": ResponseInfo{ - Schema: Schema{ - Ref: schemaRef, - }, + }) + } + if r.Methods.Read != nil { + addMethodToPath(paths, resourcePath, "get", MethodInfo{ + Parameters: append(pwp.Params, idParam), + Responses: Responses{ + "200": resourceResponse, }, - }, - }) - } - if r.Methods.Update != nil { - getPath := fmt.Sprintf("/%s/{id}", lowerizer.String(r.Plural)) - addMethodToPath(paths, getPath, "patch", MethodInfo{ - Parameters: Parameters{ - ParameterInfo{ - In: "body", - Name: "body", - Schema: Schema{ - Ref: schemaRef, - }, + }) + } + if r.Methods.Update != nil { + addMethodToPath(paths, resourcePath, "patch", MethodInfo{ + Parameters: append(pwp.Params, idParam, bodyParam), + Responses: Responses{ + "200": resourceResponse, }, - }, - Responses: Responses{ - "200": ResponseInfo{ - Schema: Schema{ - Ref: schemaRef, - }, + }) + } + if r.Methods.Delete != nil { + addMethodToPath(paths, resourcePath, "delete", MethodInfo{ + Parameters: append(pwp.Params, idParam), + Responses: Responses{ + "200": ResponseInfo{}, }, - }, - }) - } - if r.Methods.Delete != nil { - getPath := fmt.Sprintf("/%s/{id}", lowerizer.String(r.Plural)) - addMethodToPath(paths, getPath, "delete", MethodInfo{ - Responses: Responses{ - "200": ResponseInfo{ - Schema: Schema{ - Ref: schemaRef, - }, + }) + } + if r.Methods.Apply != nil { + addMethodToPath(paths, resourcePath, "put", MethodInfo{ + Parameters: append(pwp.Params, bodyParam), + Responses: Responses{ + "200": resourceResponse, }, - }, - }) + }) + } } - if r.Methods.Apply != nil { - getPath := fmt.Sprintf("/%s/{id}", lowerizer.String(r.Plural)) - addMethodToPath(paths, getPath, "put", MethodInfo{ - Parameters: Parameters{ - ParameterInfo{ - In: "body", - Name: "body", - Schema: Schema{ - Ref: schemaRef, - }, - }, - }, - Responses: Responses{ - "200": ResponseInfo{ - Schema: Schema{ - Ref: schemaRef, - }, - }, - }, - }) + d.XAEPResource = &XAEPResource{ + Singular: r.Kind, + Plural: r.Plural, + Patterns: patterns, + Parents: r.Parents, } + components.Schemas[r.Kind] = d } openAPI := &OpenAPI{ Swagger: "2.0", @@ -235,16 +230,50 @@ func resourceToSchema(r *parser.ParsedResource) (Schema, error) { Type: "object", Properties: &properties, Required: required, - XAEPResource: &XAEPResource{ - Singular: r.Kind, - Plural: r.Plural, - Patterns: []string{ - fmt.Sprintf("/%s/{%s}", lowerizer.String(r.Plural), lowerizer.String(r.Kind)), - }, - }, }, nil } +// PathWithParams passes an http path +// with the OpenAPI parameters it contains. +// helpful to bundle them both when iterating. +type PathWithParams struct { + Pattern string + Params []ParameterInfo +} + +// generate the x-aep-patterns for the parent resources, along with the patterns +// they need. +// +// This is helpful when you're constructing methods on resources with a parent. +func generateParentPatternsWithParams(r *parser.ParsedResource) *[]PathWithParams { + if len(r.ParsedParents) == 0 { + return &[]PathWithParams{} + } + pwps := []PathWithParams{} + for _, parent := range r.ParsedParents { + basePattern := fmt.Sprintf("/%s/{%s_id}", lowerizer.String(parent.Plural), lowerizer.String(parent.Kind)) + baseParam := ParameterInfo{ + In: "path", + Name: fmt.Sprintf("%s_id", lowerizer.String(parent.Kind)), + Required: true, + Type: "string", + } + if len(parent.ParsedParents) == 0 { + pwps = append(pwps, PathWithParams{ + Pattern: basePattern, + Params: []ParameterInfo{baseParam}, + }) + } else { + for _, parentPWP := range *generateParentPatternsWithParams(parent) { + params := append(parentPWP.Params, baseParam) + pattern := fmt.Sprintf("{%s}{%s}", parentPWP.Pattern, basePattern) + pwps = append(pwps, PathWithParams{Pattern: pattern, Params: params}) + } + } + } + return &pwps +} + func addMethodToPath(paths Paths, path, method string, methodInfo MethodInfo) { methods, ok := paths[path] if !ok { @@ -323,4 +352,5 @@ type XAEPResource struct { Singular string `json:"singular,omitempty"` Plural string `json:"plural,omitempty"` Patterns []string `json:"patterns,omitempty"` + Parents []string `json:"parents,omitempty"` } diff --git a/writer/proto/resource.go b/writer/proto/resource.go index 425bd95..4dae03e 100644 --- a/writer/proto/resource.go +++ b/writer/proto/resource.go @@ -458,12 +458,12 @@ func AddApply(r *parser.ParsedResource, resourceMb *builder.MessageBuilder, fb * func generateHTTPPath(r *parser.ParsedResource) string { elements := []string{strings.ToLower(r.Plural)} - if len(r.Parents) > 0 { + if len(r.ParsedParents) > 0 { // TODO: handle multiple parents - p := r.Parents[0] + p := r.ParsedParents[0] for p != nil { elements = append([]string{strings.ToLower(p.Plural)}, elements...) - if len(p.Parents) == 0 { + if len(p.ParsedParents) == 0 { break } } @@ -473,11 +473,13 @@ func generateHTTPPath(r *parser.ParsedResource) string { func generateParentHTTPPath(r *parser.ParsedResource) string { parentPath := "" - if len(r.Parents) > 0 { - parentPath = generateHTTPPath(r.Parents[0]) - // parentPath = fmt.Sprintf("{parent=%v/}", generateHTTPPath(r.Parents[0])) + if len(r.ParsedParents) == 0 { + return fmt.Sprintf("/{parent=%v}", strings.ToLower(r.Plural)) } - return fmt.Sprintf("/{parent=%v%v}", parentPath, strings.ToLower(r.Plural)) + if len(r.ParsedParents) > 0 { + parentPath = fmt.Sprintf("%v", generateHTTPPath(r.ParsedParents[0])) + } + return fmt.Sprintf("/{parent=%v}/%v", parentPath, strings.ToLower(r.Plural)) } func addParentField(r *parser.ParsedResource, mb *builder.MessageBuilder) {