diff --git a/plugin/webhook/webhook.go b/plugin/webhook/webhook.go index aadc5344..113fabd8 100644 --- a/plugin/webhook/webhook.go +++ b/plugin/webhook/webhook.go @@ -30,7 +30,8 @@ type Memo struct { } type Resource struct { - ID int32 `json:"id"` + ID int32 `json:"id"` + UID string `json:"uid"` // Standard fields CreatorID int32 `json:"creatorId"` diff --git a/proto/api/v2/memo_service.proto b/proto/api/v2/memo_service.proto index ff09649a..251a0e09 100644 --- a/proto/api/v2/memo_service.proto +++ b/proto/api/v2/memo_service.proto @@ -26,7 +26,7 @@ service MemoService { rpc ListMemos(ListMemosRequest) returns (ListMemosResponse) { option (google.api.http) = {get: "/api/v2/memos"}; } - // SearchMemosRequest searches memos. + // SearchMemos searches memos. rpc SearchMemos(SearchMemosRequest) returns (SearchMemosResponse) { option (google.api.http) = {get: "/api/v2/memos:search"}; } diff --git a/proto/api/v2/resource_service.proto b/proto/api/v2/resource_service.proto index 79198c85..cfac8713 100644 --- a/proto/api/v2/resource_service.proto +++ b/proto/api/v2/resource_service.proto @@ -18,37 +18,38 @@ service ResourceService { rpc ListResources(ListResourcesRequest) returns (ListResourcesResponse) { option (google.api.http) = {get: "/api/v2/resources"}; } - // GetResource returns a resource by id. - rpc GetResource(GetResourceRequest) returns (GetResourceResponse) { - option (google.api.http) = {get: "/api/v2/resources/{id}"}; - option (google.api.method_signature) = "id"; + // SearchResources searches memos. + rpc SearchResources(SearchResourcesRequest) returns (SearchResourcesResponse) { + option (google.api.http) = {get: "/api/v2/resources:search"}; } - // GetResourceByName returns a resource by name. - rpc GetResourceByName(GetResourceByNameRequest) returns (GetResourceByNameResponse) { - option (google.api.http) = {get: "/api/v2/resources/name/{name}"}; + // GetResource returns a resource by name. + rpc GetResource(GetResourceRequest) returns (GetResourceResponse) { + option (google.api.http) = {get: "/api/v2/{name=resources/*}"}; option (google.api.method_signature) = "name"; } // UpdateResource updates a resource. rpc UpdateResource(UpdateResourceRequest) returns (UpdateResourceResponse) { option (google.api.http) = { - patch: "/api/v2/resources/{resource.id}", + patch: "/api/v2/{resource.name=resources/*}", body: "resource" }; option (google.api.method_signature) = "resource,update_mask"; } - // DeleteResource deletes a resource by id. + // DeleteResource deletes a resource by name. rpc DeleteResource(DeleteResourceRequest) returns (DeleteResourceResponse) { - option (google.api.http) = {delete: "/api/v2/resources/{id}"}; - option (google.api.method_signature) = "id"; + option (google.api.http) = {delete: "/api/v2/{name=resources/*}"}; + option (google.api.method_signature) = "name"; } } message Resource { + // The name of the resource. + // Format: resources/{id} // id is the system generated unique identifier. - int32 id = 1; + string name = 1; - // name is the user provided name. - string name = 2; + // The user defined id of the resource. + string uid = 2; google.protobuf.Timestamp create_time = 3; @@ -65,8 +66,11 @@ message Resource { message CreateResourceRequest { string filename = 1; + string external_link = 2; + string type = 3; + optional int32 memo_id = 4; } @@ -80,19 +84,19 @@ message ListResourcesResponse { repeated Resource resources = 1; } -message GetResourceRequest { - int32 id = 1; +message SearchResourcesRequest { + string filter = 1; } -message GetResourceResponse { - Resource resource = 1; +message SearchResourcesResponse { + repeated Resource resources = 1; } -message GetResourceByNameRequest { +message GetResourceRequest { string name = 1; } -message GetResourceByNameResponse { +message GetResourceResponse { Resource resource = 1; } @@ -107,7 +111,7 @@ message UpdateResourceResponse { } message DeleteResourceRequest { - int32 id = 1; + string name = 1; } message DeleteResourceResponse {} diff --git a/proto/gen/api/v2/README.md b/proto/gen/api/v2/README.md index a7ba32fe..79dee724 100644 --- a/proto/gen/api/v2/README.md +++ b/proto/gen/api/v2/README.md @@ -99,13 +99,13 @@ - [CreateResourceResponse](#memos-api-v2-CreateResourceResponse) - [DeleteResourceRequest](#memos-api-v2-DeleteResourceRequest) - [DeleteResourceResponse](#memos-api-v2-DeleteResourceResponse) - - [GetResourceByNameRequest](#memos-api-v2-GetResourceByNameRequest) - - [GetResourceByNameResponse](#memos-api-v2-GetResourceByNameResponse) - [GetResourceRequest](#memos-api-v2-GetResourceRequest) - [GetResourceResponse](#memos-api-v2-GetResourceResponse) - [ListResourcesRequest](#memos-api-v2-ListResourcesRequest) - [ListResourcesResponse](#memos-api-v2-ListResourcesResponse) - [Resource](#memos-api-v2-Resource) + - [SearchResourcesRequest](#memos-api-v2-SearchResourcesRequest) + - [SearchResourcesResponse](#memos-api-v2-SearchResourcesResponse) - [UpdateResourceRequest](#memos-api-v2-UpdateResourceRequest) - [UpdateResourceResponse](#memos-api-v2-UpdateResourceResponse) @@ -1362,7 +1362,7 @@ Used internally for obfuscating the page token. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| id | [int32](#int32) | | | +| name | [string](#string) | | | @@ -1379,9 +1379,9 @@ Used internally for obfuscating the page token. - + -### GetResourceByNameRequest +### GetResourceRequest @@ -1394,9 +1394,9 @@ Used internally for obfuscating the page token. - + -### GetResourceByNameResponse +### GetResourceResponse @@ -1409,77 +1409,77 @@ Used internally for obfuscating the page token. - - -### GetResourceRequest - + +### ListResourcesRequest -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| id | [int32](#int32) | | | - + -### GetResourceResponse +### ListResourcesResponse | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| resource | [Resource](#memos-api-v2-Resource) | | | +| resources | [Resource](#memos-api-v2-Resource) | repeated | | - + + +### Resource -### ListResourcesRequest +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| name | [string](#string) | | The name of the resource. Format: resources/{id} id is the system generated unique identifier. | +| uid | [string](#string) | | The user defined id of the resource. | +| create_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | | +| filename | [string](#string) | | | +| external_link | [string](#string) | | | +| type | [string](#string) | | | +| size | [int64](#int64) | | | +| memo_id | [int32](#int32) | optional | | - -### ListResourcesResponse + + +### SearchResourcesRequest | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| resources | [Resource](#memos-api-v2-Resource) | repeated | | +| filter | [string](#string) | | | - + -### Resource +### SearchResourcesResponse | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| id | [int32](#int32) | | id is the system generated unique identifier. | -| name | [string](#string) | | name is the user provided name. | -| create_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | | -| filename | [string](#string) | | | -| external_link | [string](#string) | | | -| type | [string](#string) | | | -| size | [int64](#int64) | | | -| memo_id | [int32](#int32) | optional | | +| resources | [Resource](#memos-api-v2-Resource) | repeated | | @@ -1532,10 +1532,10 @@ Used internally for obfuscating the page token. | ----------- | ------------ | ------------- | ------------| | CreateResource | [CreateResourceRequest](#memos-api-v2-CreateResourceRequest) | [CreateResourceResponse](#memos-api-v2-CreateResourceResponse) | CreateResource creates a new resource. | | ListResources | [ListResourcesRequest](#memos-api-v2-ListResourcesRequest) | [ListResourcesResponse](#memos-api-v2-ListResourcesResponse) | ListResources lists all resources. | -| GetResource | [GetResourceRequest](#memos-api-v2-GetResourceRequest) | [GetResourceResponse](#memos-api-v2-GetResourceResponse) | GetResource returns a resource by id. | -| GetResourceByName | [GetResourceByNameRequest](#memos-api-v2-GetResourceByNameRequest) | [GetResourceByNameResponse](#memos-api-v2-GetResourceByNameResponse) | GetResourceByName returns a resource by name. | +| SearchResources | [SearchResourcesRequest](#memos-api-v2-SearchResourcesRequest) | [SearchResourcesResponse](#memos-api-v2-SearchResourcesResponse) | SearchResources searches memos. | +| GetResource | [GetResourceRequest](#memos-api-v2-GetResourceRequest) | [GetResourceResponse](#memos-api-v2-GetResourceResponse) | GetResource returns a resource by name. | | UpdateResource | [UpdateResourceRequest](#memos-api-v2-UpdateResourceRequest) | [UpdateResourceResponse](#memos-api-v2-UpdateResourceResponse) | UpdateResource updates a resource. | -| DeleteResource | [DeleteResourceRequest](#memos-api-v2-DeleteResourceRequest) | [DeleteResourceResponse](#memos-api-v2-DeleteResourceResponse) | DeleteResource deletes a resource by id. | +| DeleteResource | [DeleteResourceRequest](#memos-api-v2-DeleteResourceRequest) | [DeleteResourceResponse](#memos-api-v2-DeleteResourceResponse) | DeleteResource deletes a resource by name. | @@ -2123,7 +2123,7 @@ Used internally for obfuscating the page token. | ----------- | ------------ | ------------- | ------------| | CreateMemo | [CreateMemoRequest](#memos-api-v2-CreateMemoRequest) | [CreateMemoResponse](#memos-api-v2-CreateMemoResponse) | CreateMemo creates a memo. | | ListMemos | [ListMemosRequest](#memos-api-v2-ListMemosRequest) | [ListMemosResponse](#memos-api-v2-ListMemosResponse) | ListMemos lists memos with pagination and filter. | -| SearchMemos | [SearchMemosRequest](#memos-api-v2-SearchMemosRequest) | [SearchMemosResponse](#memos-api-v2-SearchMemosResponse) | SearchMemosRequest searches memos. | +| SearchMemos | [SearchMemosRequest](#memos-api-v2-SearchMemosRequest) | [SearchMemosResponse](#memos-api-v2-SearchMemosResponse) | SearchMemos searches memos. | | GetMemo | [GetMemoRequest](#memos-api-v2-GetMemoRequest) | [GetMemoResponse](#memos-api-v2-GetMemoResponse) | GetMemo gets a memo. | | UpdateMemo | [UpdateMemoRequest](#memos-api-v2-UpdateMemoRequest) | [UpdateMemoResponse](#memos-api-v2-UpdateMemoResponse) | UpdateMemo updates a memo. | | DeleteMemo | [DeleteMemoRequest](#memos-api-v2-DeleteMemoRequest) | [DeleteMemoResponse](#memos-api-v2-DeleteMemoResponse) | DeleteMemo deletes a memo. | diff --git a/proto/gen/api/v2/memo_service_grpc.pb.go b/proto/gen/api/v2/memo_service_grpc.pb.go index 41d0c443..4b3412eb 100644 --- a/proto/gen/api/v2/memo_service_grpc.pb.go +++ b/proto/gen/api/v2/memo_service_grpc.pb.go @@ -46,7 +46,7 @@ type MemoServiceClient interface { CreateMemo(ctx context.Context, in *CreateMemoRequest, opts ...grpc.CallOption) (*CreateMemoResponse, error) // ListMemos lists memos with pagination and filter. ListMemos(ctx context.Context, in *ListMemosRequest, opts ...grpc.CallOption) (*ListMemosResponse, error) - // SearchMemosRequest searches memos. + // SearchMemos searches memos. SearchMemos(ctx context.Context, in *SearchMemosRequest, opts ...grpc.CallOption) (*SearchMemosResponse, error) // GetMemo gets a memo. GetMemo(ctx context.Context, in *GetMemoRequest, opts ...grpc.CallOption) (*GetMemoResponse, error) @@ -247,7 +247,7 @@ type MemoServiceServer interface { CreateMemo(context.Context, *CreateMemoRequest) (*CreateMemoResponse, error) // ListMemos lists memos with pagination and filter. ListMemos(context.Context, *ListMemosRequest) (*ListMemosResponse, error) - // SearchMemosRequest searches memos. + // SearchMemos searches memos. SearchMemos(context.Context, *SearchMemosRequest) (*SearchMemosResponse, error) // GetMemo gets a memo. GetMemo(context.Context, *GetMemoRequest) (*GetMemoResponse, error) diff --git a/proto/gen/api/v2/resource_service.pb.go b/proto/gen/api/v2/resource_service.pb.go index 24c5e356..211986f7 100644 --- a/proto/gen/api/v2/resource_service.pb.go +++ b/proto/gen/api/v2/resource_service.pb.go @@ -28,10 +28,12 @@ type Resource struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + // The name of the resource. + // Format: resources/{id} // id is the system generated unique identifier. - Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // name is the user provided name. - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // The user defined id of the resource. + Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid,omitempty"` CreateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty"` Filename string `protobuf:"bytes,4,opt,name=filename,proto3" json:"filename,omitempty"` ExternalLink string `protobuf:"bytes,5,opt,name=external_link,json=externalLink,proto3" json:"external_link,omitempty"` @@ -72,16 +74,16 @@ func (*Resource) Descriptor() ([]byte, []int) { return file_api_v2_resource_service_proto_rawDescGZIP(), []int{0} } -func (x *Resource) GetId() int32 { +func (x *Resource) GetName() string { if x != nil { - return x.Id + return x.Name } - return 0 + return "" } -func (x *Resource) GetName() string { +func (x *Resource) GetUid() string { if x != nil { - return x.Name + return x.Uid } return "" } @@ -331,16 +333,16 @@ func (x *ListResourcesResponse) GetResources() []*Resource { return nil } -type GetResourceRequest struct { +type SearchResourcesRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Filter string `protobuf:"bytes,1,opt,name=filter,proto3" json:"filter,omitempty"` } -func (x *GetResourceRequest) Reset() { - *x = GetResourceRequest{} +func (x *SearchResourcesRequest) Reset() { + *x = SearchResourcesRequest{} if protoimpl.UnsafeEnabled { mi := &file_api_v2_resource_service_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -348,13 +350,13 @@ func (x *GetResourceRequest) Reset() { } } -func (x *GetResourceRequest) String() string { +func (x *SearchResourcesRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetResourceRequest) ProtoMessage() {} +func (*SearchResourcesRequest) ProtoMessage() {} -func (x *GetResourceRequest) ProtoReflect() protoreflect.Message { +func (x *SearchResourcesRequest) ProtoReflect() protoreflect.Message { mi := &file_api_v2_resource_service_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -366,28 +368,28 @@ func (x *GetResourceRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetResourceRequest.ProtoReflect.Descriptor instead. -func (*GetResourceRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use SearchResourcesRequest.ProtoReflect.Descriptor instead. +func (*SearchResourcesRequest) Descriptor() ([]byte, []int) { return file_api_v2_resource_service_proto_rawDescGZIP(), []int{5} } -func (x *GetResourceRequest) GetId() int32 { +func (x *SearchResourcesRequest) GetFilter() string { if x != nil { - return x.Id + return x.Filter } - return 0 + return "" } -type GetResourceResponse struct { +type SearchResourcesResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Resource *Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` + Resources []*Resource `protobuf:"bytes,1,rep,name=resources,proto3" json:"resources,omitempty"` } -func (x *GetResourceResponse) Reset() { - *x = GetResourceResponse{} +func (x *SearchResourcesResponse) Reset() { + *x = SearchResourcesResponse{} if protoimpl.UnsafeEnabled { mi := &file_api_v2_resource_service_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -395,13 +397,13 @@ func (x *GetResourceResponse) Reset() { } } -func (x *GetResourceResponse) String() string { +func (x *SearchResourcesResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetResourceResponse) ProtoMessage() {} +func (*SearchResourcesResponse) ProtoMessage() {} -func (x *GetResourceResponse) ProtoReflect() protoreflect.Message { +func (x *SearchResourcesResponse) ProtoReflect() protoreflect.Message { mi := &file_api_v2_resource_service_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -413,19 +415,19 @@ func (x *GetResourceResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetResourceResponse.ProtoReflect.Descriptor instead. -func (*GetResourceResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use SearchResourcesResponse.ProtoReflect.Descriptor instead. +func (*SearchResourcesResponse) Descriptor() ([]byte, []int) { return file_api_v2_resource_service_proto_rawDescGZIP(), []int{6} } -func (x *GetResourceResponse) GetResource() *Resource { +func (x *SearchResourcesResponse) GetResources() []*Resource { if x != nil { - return x.Resource + return x.Resources } return nil } -type GetResourceByNameRequest struct { +type GetResourceRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -433,8 +435,8 @@ type GetResourceByNameRequest struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` } -func (x *GetResourceByNameRequest) Reset() { - *x = GetResourceByNameRequest{} +func (x *GetResourceRequest) Reset() { + *x = GetResourceRequest{} if protoimpl.UnsafeEnabled { mi := &file_api_v2_resource_service_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -442,13 +444,13 @@ func (x *GetResourceByNameRequest) Reset() { } } -func (x *GetResourceByNameRequest) String() string { +func (x *GetResourceRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetResourceByNameRequest) ProtoMessage() {} +func (*GetResourceRequest) ProtoMessage() {} -func (x *GetResourceByNameRequest) ProtoReflect() protoreflect.Message { +func (x *GetResourceRequest) ProtoReflect() protoreflect.Message { mi := &file_api_v2_resource_service_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -460,19 +462,19 @@ func (x *GetResourceByNameRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetResourceByNameRequest.ProtoReflect.Descriptor instead. -func (*GetResourceByNameRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use GetResourceRequest.ProtoReflect.Descriptor instead. +func (*GetResourceRequest) Descriptor() ([]byte, []int) { return file_api_v2_resource_service_proto_rawDescGZIP(), []int{7} } -func (x *GetResourceByNameRequest) GetName() string { +func (x *GetResourceRequest) GetName() string { if x != nil { return x.Name } return "" } -type GetResourceByNameResponse struct { +type GetResourceResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -480,8 +482,8 @@ type GetResourceByNameResponse struct { Resource *Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` } -func (x *GetResourceByNameResponse) Reset() { - *x = GetResourceByNameResponse{} +func (x *GetResourceResponse) Reset() { + *x = GetResourceResponse{} if protoimpl.UnsafeEnabled { mi := &file_api_v2_resource_service_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -489,13 +491,13 @@ func (x *GetResourceByNameResponse) Reset() { } } -func (x *GetResourceByNameResponse) String() string { +func (x *GetResourceResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetResourceByNameResponse) ProtoMessage() {} +func (*GetResourceResponse) ProtoMessage() {} -func (x *GetResourceByNameResponse) ProtoReflect() protoreflect.Message { +func (x *GetResourceResponse) ProtoReflect() protoreflect.Message { mi := &file_api_v2_resource_service_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -507,12 +509,12 @@ func (x *GetResourceByNameResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetResourceByNameResponse.ProtoReflect.Descriptor instead. -func (*GetResourceByNameResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use GetResourceResponse.ProtoReflect.Descriptor instead. +func (*GetResourceResponse) Descriptor() ([]byte, []int) { return file_api_v2_resource_service_proto_rawDescGZIP(), []int{8} } -func (x *GetResourceByNameResponse) GetResource() *Resource { +func (x *GetResourceResponse) GetResource() *Resource { if x != nil { return x.Resource } @@ -626,7 +628,7 @@ type DeleteResourceRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` } func (x *DeleteResourceRequest) Reset() { @@ -661,11 +663,11 @@ func (*DeleteResourceRequest) Descriptor() ([]byte, []int) { return file_api_v2_resource_service_proto_rawDescGZIP(), []int{11} } -func (x *DeleteResourceRequest) GetId() int32 { +func (x *DeleteResourceRequest) GetName() string { if x != nil { - return x.Id + return x.Name } - return 0 + return "" } type DeleteResourceResponse struct { @@ -719,140 +721,140 @@ var file_api_v2_resource_service_proto_rawDesc = []byte{ 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xfe, 0x01, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x3b, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, - 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x6c, 0x69, - 0x6e, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, - 0x61, 0x6c, 0x4c, 0x69, 0x6e, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, - 0x7a, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x1c, - 0x0a, 0x07, 0x6d, 0x65, 0x6d, 0x6f, 0x5f, 0x69, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x48, - 0x00, 0x52, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x49, 0x64, 0x88, 0x01, 0x01, 0x42, 0x0a, 0x0a, 0x08, - 0x5f, 0x6d, 0x65, 0x6d, 0x6f, 0x5f, 0x69, 0x64, 0x22, 0x96, 0x01, 0x0a, 0x15, 0x43, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x23, - 0x0a, 0x0d, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x6c, 0x69, 0x6e, 0x6b, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x4c, - 0x69, 0x6e, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1c, 0x0a, 0x07, 0x6d, 0x65, 0x6d, 0x6f, 0x5f, - 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x48, 0x00, 0x52, 0x06, 0x6d, 0x65, 0x6d, 0x6f, - 0x49, 0x64, 0x88, 0x01, 0x01, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x6d, 0x65, 0x6d, 0x6f, 0x5f, 0x69, - 0x64, 0x22, 0x4c, 0x0a, 0x16, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x08, 0x72, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, - 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x52, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x22, - 0x16, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x4d, 0x0a, 0x15, 0x4c, 0x69, 0x73, 0x74, 0x52, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x34, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x76, 0x32, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x22, 0x24, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x22, 0x49, 0x0a, 0x13, - 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x08, 0x72, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x22, 0x2e, 0x0a, 0x18, 0x47, 0x65, 0x74, 0x52, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x4f, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x52, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x08, - 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x22, 0x88, 0x01, 0x0a, 0x15, 0x55, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x32, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x32, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x08, 0x72, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x3b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, - 0x65, 0x6c, 0x64, 0x4d, 0x61, 0x73, 0x6b, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, - 0x61, 0x73, 0x6b, 0x22, 0x4c, 0x0a, 0x16, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, + 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x80, 0x02, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x3b, 0x0a, 0x0b, 0x63, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, + 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x78, 0x74, 0x65, + 0x72, 0x6e, 0x61, 0x6c, 0x4c, 0x69, 0x6e, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, + 0x73, 0x69, 0x7a, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, + 0x12, 0x1c, 0x0a, 0x07, 0x6d, 0x65, 0x6d, 0x6f, 0x5f, 0x69, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, + 0x05, 0x48, 0x00, 0x52, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x49, 0x64, 0x88, 0x01, 0x01, 0x42, 0x0a, + 0x0a, 0x08, 0x5f, 0x6d, 0x65, 0x6d, 0x6f, 0x5f, 0x69, 0x64, 0x22, 0x96, 0x01, 0x0a, 0x15, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x6c, 0x69, 0x6e, + 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, + 0x6c, 0x4c, 0x69, 0x6e, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1c, 0x0a, 0x07, 0x6d, 0x65, 0x6d, + 0x6f, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x48, 0x00, 0x52, 0x06, 0x6d, 0x65, + 0x6d, 0x6f, 0x49, 0x64, 0x88, 0x01, 0x01, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x6d, 0x65, 0x6d, 0x6f, + 0x5f, 0x69, 0x64, 0x22, 0x4c, 0x0a, 0x16, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x22, 0x27, 0x0a, 0x15, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x22, 0x18, 0x0a, 0x16, 0x44, 0x65, - 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xb7, 0x06, 0x0a, 0x0f, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x76, 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x23, 0x2e, 0x6d, 0x65, 0x6d, - 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x24, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x43, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x22, 0x11, 0x2f, - 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, - 0x12, 0x73, 0x0a, 0x0d, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x73, 0x12, 0x22, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, + 0x65, 0x22, 0x16, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x4d, 0x0a, 0x15, 0x4c, 0x69, 0x73, + 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x34, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x09, 0x72, + 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x22, 0x30, 0x0a, 0x16, 0x53, 0x65, 0x61, 0x72, + 0x63, 0x68, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x22, 0x4f, 0x0a, 0x17, 0x53, 0x65, + 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x34, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, + 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, + 0x52, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x22, 0x28, 0x0a, 0x12, 0x47, + 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x49, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x08, + 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, + 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x52, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, + 0x22, 0x88, 0x01, 0x0a, 0x15, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x32, 0x0a, 0x08, 0x72, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6d, + 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x52, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x3b, + 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4d, 0x61, 0x73, 0x6b, 0x52, + 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x73, 0x6b, 0x22, 0x4c, 0x0a, 0x16, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, + 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, + 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x22, 0x2b, 0x0a, 0x15, 0x44, 0x65, 0x6c, + 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x18, 0x0a, 0x16, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x32, 0xb5, 0x06, 0x0a, 0x0f, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x12, 0x76, 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x23, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, + 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x6d, 0x65, + 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x22, 0x11, 0x2f, 0x61, 0x70, 0x69, 0x2f, + 0x76, 0x32, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x73, 0x0a, 0x0d, + 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x22, 0x2e, + 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x73, + 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x23, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, - 0x02, 0x13, 0x12, 0x11, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x72, 0x65, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x77, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x12, 0x20, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x32, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x23, 0xda, 0x41, 0x02, 0x69, 0x64, - 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x18, 0x12, 0x16, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, - 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x92, - 0x01, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x42, 0x79, - 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x26, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x32, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x42, - 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x6d, - 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x47, 0x65, 0x74, 0x52, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2c, 0xda, 0x41, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x82, 0xd3, - 0xe4, 0x93, 0x02, 0x1f, 0x12, 0x1d, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x72, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x6e, 0x61, 0x6d, 0x65, 0x2f, 0x7b, 0x6e, 0x61, - 0x6d, 0x65, 0x7d, 0x12, 0xa5, 0x01, 0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x12, 0x11, + 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, + 0x73, 0x12, 0x80, 0x01, 0x0a, 0x0f, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x24, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x6d, 0x65, + 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, + 0x68, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x20, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1a, 0x12, 0x18, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x76, 0x32, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x3a, 0x73, 0x65, + 0x61, 0x72, 0x63, 0x68, 0x12, 0x7d, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x12, 0x20, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, + 0x76, 0x32, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x29, 0xda, 0x41, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1c, 0x12, 0x1a, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, + 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, + 0x2f, 0x2a, 0x7d, 0x12, 0xa9, 0x01, 0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x23, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x48, 0xda, 0x41, 0x14, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2c, 0x75, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2b, - 0x3a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x32, 0x1f, 0x2f, 0x61, 0x70, 0x69, - 0x2f, 0x76, 0x32, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x7b, 0x72, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x69, 0x64, 0x7d, 0x12, 0x80, 0x01, 0x0a, 0x0e, - 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x23, - 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x44, 0x65, - 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x76, 0x32, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x23, 0xda, 0x41, 0x02, 0x69, 0x64, - 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x18, 0x2a, 0x16, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, - 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x42, 0xac, - 0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x32, 0x42, 0x14, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x75, 0x73, 0x65, 0x6d, 0x65, 0x6d, 0x6f, 0x73, - 0x2f, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x65, 0x6e, - 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x3b, 0x61, 0x70, 0x69, 0x76, 0x32, 0xa2, 0x02, 0x03, - 0x4d, 0x41, 0x58, 0xaa, 0x02, 0x0c, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x70, 0x69, 0x2e, - 0x56, 0x32, 0xca, 0x02, 0x0c, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, - 0x32, 0xe2, 0x02, 0x18, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x32, - 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0e, 0x4d, - 0x65, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x22, 0x4c, 0xda, 0x41, 0x14, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2c, 0x75, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2f, + 0x3a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x32, 0x23, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x76, 0x32, 0x2f, 0x7b, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x6e, 0x61, + 0x6d, 0x65, 0x3d, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x2a, 0x7d, 0x12, + 0x86, 0x01, 0x0a, 0x0e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x12, 0x23, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, + 0x32, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, + 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x29, 0xda, + 0x41, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1c, 0x2a, 0x1a, 0x2f, 0x61, + 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x72, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x2a, 0x7d, 0x42, 0xac, 0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, + 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x42, 0x14, 0x52, + 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x72, + 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x75, 0x73, 0x65, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2f, 0x6d, 0x65, 0x6d, 0x6f, 0x73, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, + 0x32, 0x3b, 0x61, 0x70, 0x69, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x4d, 0x41, 0x58, 0xaa, 0x02, 0x0c, + 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x0c, 0x4d, + 0x65, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x18, 0x4d, 0x65, + 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0e, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, + 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -869,41 +871,41 @@ func file_api_v2_resource_service_proto_rawDescGZIP() []byte { var file_api_v2_resource_service_proto_msgTypes = make([]protoimpl.MessageInfo, 13) var file_api_v2_resource_service_proto_goTypes = []interface{}{ - (*Resource)(nil), // 0: memos.api.v2.Resource - (*CreateResourceRequest)(nil), // 1: memos.api.v2.CreateResourceRequest - (*CreateResourceResponse)(nil), // 2: memos.api.v2.CreateResourceResponse - (*ListResourcesRequest)(nil), // 3: memos.api.v2.ListResourcesRequest - (*ListResourcesResponse)(nil), // 4: memos.api.v2.ListResourcesResponse - (*GetResourceRequest)(nil), // 5: memos.api.v2.GetResourceRequest - (*GetResourceResponse)(nil), // 6: memos.api.v2.GetResourceResponse - (*GetResourceByNameRequest)(nil), // 7: memos.api.v2.GetResourceByNameRequest - (*GetResourceByNameResponse)(nil), // 8: memos.api.v2.GetResourceByNameResponse - (*UpdateResourceRequest)(nil), // 9: memos.api.v2.UpdateResourceRequest - (*UpdateResourceResponse)(nil), // 10: memos.api.v2.UpdateResourceResponse - (*DeleteResourceRequest)(nil), // 11: memos.api.v2.DeleteResourceRequest - (*DeleteResourceResponse)(nil), // 12: memos.api.v2.DeleteResourceResponse - (*timestamppb.Timestamp)(nil), // 13: google.protobuf.Timestamp - (*fieldmaskpb.FieldMask)(nil), // 14: google.protobuf.FieldMask + (*Resource)(nil), // 0: memos.api.v2.Resource + (*CreateResourceRequest)(nil), // 1: memos.api.v2.CreateResourceRequest + (*CreateResourceResponse)(nil), // 2: memos.api.v2.CreateResourceResponse + (*ListResourcesRequest)(nil), // 3: memos.api.v2.ListResourcesRequest + (*ListResourcesResponse)(nil), // 4: memos.api.v2.ListResourcesResponse + (*SearchResourcesRequest)(nil), // 5: memos.api.v2.SearchResourcesRequest + (*SearchResourcesResponse)(nil), // 6: memos.api.v2.SearchResourcesResponse + (*GetResourceRequest)(nil), // 7: memos.api.v2.GetResourceRequest + (*GetResourceResponse)(nil), // 8: memos.api.v2.GetResourceResponse + (*UpdateResourceRequest)(nil), // 9: memos.api.v2.UpdateResourceRequest + (*UpdateResourceResponse)(nil), // 10: memos.api.v2.UpdateResourceResponse + (*DeleteResourceRequest)(nil), // 11: memos.api.v2.DeleteResourceRequest + (*DeleteResourceResponse)(nil), // 12: memos.api.v2.DeleteResourceResponse + (*timestamppb.Timestamp)(nil), // 13: google.protobuf.Timestamp + (*fieldmaskpb.FieldMask)(nil), // 14: google.protobuf.FieldMask } var file_api_v2_resource_service_proto_depIdxs = []int32{ 13, // 0: memos.api.v2.Resource.create_time:type_name -> google.protobuf.Timestamp 0, // 1: memos.api.v2.CreateResourceResponse.resource:type_name -> memos.api.v2.Resource 0, // 2: memos.api.v2.ListResourcesResponse.resources:type_name -> memos.api.v2.Resource - 0, // 3: memos.api.v2.GetResourceResponse.resource:type_name -> memos.api.v2.Resource - 0, // 4: memos.api.v2.GetResourceByNameResponse.resource:type_name -> memos.api.v2.Resource + 0, // 3: memos.api.v2.SearchResourcesResponse.resources:type_name -> memos.api.v2.Resource + 0, // 4: memos.api.v2.GetResourceResponse.resource:type_name -> memos.api.v2.Resource 0, // 5: memos.api.v2.UpdateResourceRequest.resource:type_name -> memos.api.v2.Resource 14, // 6: memos.api.v2.UpdateResourceRequest.update_mask:type_name -> google.protobuf.FieldMask 0, // 7: memos.api.v2.UpdateResourceResponse.resource:type_name -> memos.api.v2.Resource 1, // 8: memos.api.v2.ResourceService.CreateResource:input_type -> memos.api.v2.CreateResourceRequest 3, // 9: memos.api.v2.ResourceService.ListResources:input_type -> memos.api.v2.ListResourcesRequest - 5, // 10: memos.api.v2.ResourceService.GetResource:input_type -> memos.api.v2.GetResourceRequest - 7, // 11: memos.api.v2.ResourceService.GetResourceByName:input_type -> memos.api.v2.GetResourceByNameRequest + 5, // 10: memos.api.v2.ResourceService.SearchResources:input_type -> memos.api.v2.SearchResourcesRequest + 7, // 11: memos.api.v2.ResourceService.GetResource:input_type -> memos.api.v2.GetResourceRequest 9, // 12: memos.api.v2.ResourceService.UpdateResource:input_type -> memos.api.v2.UpdateResourceRequest 11, // 13: memos.api.v2.ResourceService.DeleteResource:input_type -> memos.api.v2.DeleteResourceRequest 2, // 14: memos.api.v2.ResourceService.CreateResource:output_type -> memos.api.v2.CreateResourceResponse 4, // 15: memos.api.v2.ResourceService.ListResources:output_type -> memos.api.v2.ListResourcesResponse - 6, // 16: memos.api.v2.ResourceService.GetResource:output_type -> memos.api.v2.GetResourceResponse - 8, // 17: memos.api.v2.ResourceService.GetResourceByName:output_type -> memos.api.v2.GetResourceByNameResponse + 6, // 16: memos.api.v2.ResourceService.SearchResources:output_type -> memos.api.v2.SearchResourcesResponse + 8, // 17: memos.api.v2.ResourceService.GetResource:output_type -> memos.api.v2.GetResourceResponse 10, // 18: memos.api.v2.ResourceService.UpdateResource:output_type -> memos.api.v2.UpdateResourceResponse 12, // 19: memos.api.v2.ResourceService.DeleteResource:output_type -> memos.api.v2.DeleteResourceResponse 14, // [14:20] is the sub-list for method output_type @@ -980,7 +982,7 @@ func file_api_v2_resource_service_proto_init() { } } file_api_v2_resource_service_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetResourceRequest); i { + switch v := v.(*SearchResourcesRequest); i { case 0: return &v.state case 1: @@ -992,7 +994,7 @@ func file_api_v2_resource_service_proto_init() { } } file_api_v2_resource_service_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetResourceResponse); i { + switch v := v.(*SearchResourcesResponse); i { case 0: return &v.state case 1: @@ -1004,7 +1006,7 @@ func file_api_v2_resource_service_proto_init() { } } file_api_v2_resource_service_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetResourceByNameRequest); i { + switch v := v.(*GetResourceRequest); i { case 0: return &v.state case 1: @@ -1016,7 +1018,7 @@ func file_api_v2_resource_service_proto_init() { } } file_api_v2_resource_service_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetResourceByNameResponse); i { + switch v := v.(*GetResourceResponse); i { case 0: return &v.state case 1: diff --git a/proto/gen/api/v2/resource_service.pb.gw.go b/proto/gen/api/v2/resource_service.pb.gw.go index 0e980a9e..9836d31a 100644 --- a/proto/gen/api/v2/resource_service.pb.gw.go +++ b/proto/gen/api/v2/resource_service.pb.gw.go @@ -85,60 +85,44 @@ func local_request_ResourceService_ListResources_0(ctx context.Context, marshale } -func request_ResourceService_GetResource_0(ctx context.Context, marshaler runtime.Marshaler, client ResourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetResourceRequest - var metadata runtime.ServerMetadata +var ( + filter_ResourceService_SearchResources_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) - var ( - val string - ok bool - err error - _ = err - ) +func request_ResourceService_SearchResources_0(ctx context.Context, marshaler runtime.Marshaler, client ResourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq SearchResourcesRequest + var metadata runtime.ServerMetadata - val, ok = pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - - protoReq.Id, err = runtime.Int32(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ResourceService_SearchResources_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.GetResource(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.SearchResources(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_ResourceService_GetResource_0(ctx context.Context, marshaler runtime.Marshaler, server ResourceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetResourceRequest +func local_request_ResourceService_SearchResources_0(ctx context.Context, marshaler runtime.Marshaler, server ResourceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq SearchResourcesRequest var metadata runtime.ServerMetadata - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - - protoReq.Id, err = runtime.Int32(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ResourceService_SearchResources_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.GetResource(ctx, &protoReq) + msg, err := server.SearchResources(ctx, &protoReq) return msg, metadata, err } -func request_ResourceService_GetResourceByName_0(ctx context.Context, marshaler runtime.Marshaler, client ResourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetResourceByNameRequest +func request_ResourceService_GetResource_0(ctx context.Context, marshaler runtime.Marshaler, client ResourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetResourceRequest var metadata runtime.ServerMetadata var ( @@ -158,13 +142,13 @@ func request_ResourceService_GetResourceByName_0(ctx context.Context, marshaler return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) } - msg, err := client.GetResourceByName(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.GetResource(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_ResourceService_GetResourceByName_0(ctx context.Context, marshaler runtime.Marshaler, server ResourceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetResourceByNameRequest +func local_request_ResourceService_GetResource_0(ctx context.Context, marshaler runtime.Marshaler, server ResourceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetResourceRequest var metadata runtime.ServerMetadata var ( @@ -184,13 +168,13 @@ func local_request_ResourceService_GetResourceByName_0(ctx context.Context, mars return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) } - msg, err := server.GetResourceByName(ctx, &protoReq) + msg, err := server.GetResource(ctx, &protoReq) return msg, metadata, err } var ( - filter_ResourceService_UpdateResource_0 = &utilities.DoubleArray{Encoding: map[string]int{"resource": 0, "id": 1}, Base: []int{1, 4, 5, 2, 0, 0, 0, 0}, Check: []int{0, 1, 1, 2, 4, 2, 2, 3}} + filter_ResourceService_UpdateResource_0 = &utilities.DoubleArray{Encoding: map[string]int{"resource": 0, "name": 1}, Base: []int{1, 4, 5, 2, 0, 0, 0, 0}, Check: []int{0, 1, 1, 2, 4, 2, 2, 3}} ) func request_ResourceService_UpdateResource_0(ctx context.Context, marshaler runtime.Marshaler, client ResourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -219,14 +203,14 @@ func request_ResourceService_UpdateResource_0(ctx context.Context, marshaler run _ = err ) - val, ok = pathParams["resource.id"] + val, ok = pathParams["resource.name"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "resource.id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "resource.name") } - err = runtime.PopulateFieldFromPath(&protoReq, "resource.id", val) + err = runtime.PopulateFieldFromPath(&protoReq, "resource.name", val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "resource.id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "resource.name", err) } if err := req.ParseForm(); err != nil { @@ -267,14 +251,14 @@ func local_request_ResourceService_UpdateResource_0(ctx context.Context, marshal _ = err ) - val, ok = pathParams["resource.id"] + val, ok = pathParams["resource.name"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "resource.id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "resource.name") } - err = runtime.PopulateFieldFromPath(&protoReq, "resource.id", val) + err = runtime.PopulateFieldFromPath(&protoReq, "resource.name", val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "resource.id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "resource.name", err) } if err := req.ParseForm(); err != nil { @@ -300,14 +284,14 @@ func request_ResourceService_DeleteResource_0(ctx context.Context, marshaler run _ = err ) - val, ok = pathParams["id"] + val, ok = pathParams["name"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") } - protoReq.Id, err = runtime.Int32(val) + protoReq.Name, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) } msg, err := client.DeleteResource(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) @@ -326,14 +310,14 @@ func local_request_ResourceService_DeleteResource_0(ctx context.Context, marshal _ = err ) - val, ok = pathParams["id"] + val, ok = pathParams["name"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") } - protoReq.Id, err = runtime.Int32(val) + protoReq.Name, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) } msg, err := server.DeleteResource(ctx, &protoReq) @@ -397,7 +381,7 @@ func RegisterResourceServiceHandlerServer(ctx context.Context, mux *runtime.Serv }) - mux.Handle("GET", pattern_ResourceService_GetResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_ResourceService_SearchResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -405,12 +389,12 @@ func RegisterResourceServiceHandlerServer(ctx context.Context, mux *runtime.Serv inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v2.ResourceService/GetResource", runtime.WithHTTPPathPattern("/api/v2/resources/{id}")) + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v2.ResourceService/SearchResources", runtime.WithHTTPPathPattern("/api/v2/resources:search")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_ResourceService_GetResource_0(annotatedContext, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_ResourceService_SearchResources_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 { @@ -418,11 +402,11 @@ func RegisterResourceServiceHandlerServer(ctx context.Context, mux *runtime.Serv return } - forward_ResourceService_GetResource_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_ResourceService_SearchResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_ResourceService_GetResourceByName_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_ResourceService_GetResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -430,12 +414,12 @@ func RegisterResourceServiceHandlerServer(ctx context.Context, mux *runtime.Serv inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v2.ResourceService/GetResourceByName", runtime.WithHTTPPathPattern("/api/v2/resources/name/{name}")) + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v2.ResourceService/GetResource", runtime.WithHTTPPathPattern("/api/v2/{name=resources/*}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_ResourceService_GetResourceByName_0(annotatedContext, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_ResourceService_GetResource_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 { @@ -443,7 +427,7 @@ func RegisterResourceServiceHandlerServer(ctx context.Context, mux *runtime.Serv return } - forward_ResourceService_GetResourceByName_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_ResourceService_GetResource_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -455,7 +439,7 @@ func RegisterResourceServiceHandlerServer(ctx context.Context, mux *runtime.Serv inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v2.ResourceService/UpdateResource", runtime.WithHTTPPathPattern("/api/v2/resources/{resource.id}")) + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v2.ResourceService/UpdateResource", runtime.WithHTTPPathPattern("/api/v2/{resource.name=resources/*}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -480,7 +464,7 @@ func RegisterResourceServiceHandlerServer(ctx context.Context, mux *runtime.Serv inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v2.ResourceService/DeleteResource", runtime.WithHTTPPathPattern("/api/v2/resources/{id}")) + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v2.ResourceService/DeleteResource", runtime.WithHTTPPathPattern("/api/v2/{name=resources/*}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -582,47 +566,47 @@ func RegisterResourceServiceHandlerClient(ctx context.Context, mux *runtime.Serv }) - mux.Handle("GET", pattern_ResourceService_GetResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_ResourceService_SearchResources_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, "/memos.api.v2.ResourceService/GetResource", runtime.WithHTTPPathPattern("/api/v2/resources/{id}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/memos.api.v2.ResourceService/SearchResources", runtime.WithHTTPPathPattern("/api/v2/resources:search")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_ResourceService_GetResource_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_ResourceService_SearchResources_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_ResourceService_GetResource_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_ResourceService_SearchResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_ResourceService_GetResourceByName_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_ResourceService_GetResource_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, "/memos.api.v2.ResourceService/GetResourceByName", runtime.WithHTTPPathPattern("/api/v2/resources/name/{name}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/memos.api.v2.ResourceService/GetResource", runtime.WithHTTPPathPattern("/api/v2/{name=resources/*}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_ResourceService_GetResourceByName_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_ResourceService_GetResource_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_ResourceService_GetResourceByName_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_ResourceService_GetResource_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -632,7 +616,7 @@ func RegisterResourceServiceHandlerClient(ctx context.Context, mux *runtime.Serv inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/memos.api.v2.ResourceService/UpdateResource", runtime.WithHTTPPathPattern("/api/v2/resources/{resource.id}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/memos.api.v2.ResourceService/UpdateResource", runtime.WithHTTPPathPattern("/api/v2/{resource.name=resources/*}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -654,7 +638,7 @@ func RegisterResourceServiceHandlerClient(ctx context.Context, mux *runtime.Serv inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/memos.api.v2.ResourceService/DeleteResource", runtime.WithHTTPPathPattern("/api/v2/resources/{id}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/memos.api.v2.ResourceService/DeleteResource", runtime.WithHTTPPathPattern("/api/v2/{name=resources/*}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -678,13 +662,13 @@ var ( pattern_ResourceService_ListResources_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v2", "resources"}, "")) - pattern_ResourceService_GetResource_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v2", "resources", "id"}, "")) + pattern_ResourceService_SearchResources_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v2", "resources"}, "search")) - pattern_ResourceService_GetResourceByName_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 3}, []string{"api", "v2", "resources", "name"}, "")) + pattern_ResourceService_GetResource_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3}, []string{"api", "v2", "resources", "name"}, "")) - pattern_ResourceService_UpdateResource_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v2", "resources", "resource.id"}, "")) + pattern_ResourceService_UpdateResource_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3}, []string{"api", "v2", "resources", "resource.name"}, "")) - pattern_ResourceService_DeleteResource_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v2", "resources", "id"}, "")) + pattern_ResourceService_DeleteResource_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3}, []string{"api", "v2", "resources", "name"}, "")) ) var ( @@ -692,9 +676,9 @@ var ( forward_ResourceService_ListResources_0 = runtime.ForwardResponseMessage - forward_ResourceService_GetResource_0 = runtime.ForwardResponseMessage + forward_ResourceService_SearchResources_0 = runtime.ForwardResponseMessage - forward_ResourceService_GetResourceByName_0 = runtime.ForwardResponseMessage + forward_ResourceService_GetResource_0 = runtime.ForwardResponseMessage forward_ResourceService_UpdateResource_0 = runtime.ForwardResponseMessage diff --git a/proto/gen/api/v2/resource_service_grpc.pb.go b/proto/gen/api/v2/resource_service_grpc.pb.go index 3cb293ff..77626b50 100644 --- a/proto/gen/api/v2/resource_service_grpc.pb.go +++ b/proto/gen/api/v2/resource_service_grpc.pb.go @@ -19,12 +19,12 @@ import ( const _ = grpc.SupportPackageIsVersion7 const ( - ResourceService_CreateResource_FullMethodName = "/memos.api.v2.ResourceService/CreateResource" - ResourceService_ListResources_FullMethodName = "/memos.api.v2.ResourceService/ListResources" - ResourceService_GetResource_FullMethodName = "/memos.api.v2.ResourceService/GetResource" - ResourceService_GetResourceByName_FullMethodName = "/memos.api.v2.ResourceService/GetResourceByName" - ResourceService_UpdateResource_FullMethodName = "/memos.api.v2.ResourceService/UpdateResource" - ResourceService_DeleteResource_FullMethodName = "/memos.api.v2.ResourceService/DeleteResource" + ResourceService_CreateResource_FullMethodName = "/memos.api.v2.ResourceService/CreateResource" + ResourceService_ListResources_FullMethodName = "/memos.api.v2.ResourceService/ListResources" + ResourceService_SearchResources_FullMethodName = "/memos.api.v2.ResourceService/SearchResources" + ResourceService_GetResource_FullMethodName = "/memos.api.v2.ResourceService/GetResource" + ResourceService_UpdateResource_FullMethodName = "/memos.api.v2.ResourceService/UpdateResource" + ResourceService_DeleteResource_FullMethodName = "/memos.api.v2.ResourceService/DeleteResource" ) // ResourceServiceClient is the client API for ResourceService service. @@ -35,13 +35,13 @@ type ResourceServiceClient interface { CreateResource(ctx context.Context, in *CreateResourceRequest, opts ...grpc.CallOption) (*CreateResourceResponse, error) // ListResources lists all resources. ListResources(ctx context.Context, in *ListResourcesRequest, opts ...grpc.CallOption) (*ListResourcesResponse, error) - // GetResource returns a resource by id. + // SearchResources searches memos. + SearchResources(ctx context.Context, in *SearchResourcesRequest, opts ...grpc.CallOption) (*SearchResourcesResponse, error) + // GetResource returns a resource by name. GetResource(ctx context.Context, in *GetResourceRequest, opts ...grpc.CallOption) (*GetResourceResponse, error) - // GetResourceByName returns a resource by name. - GetResourceByName(ctx context.Context, in *GetResourceByNameRequest, opts ...grpc.CallOption) (*GetResourceByNameResponse, error) // UpdateResource updates a resource. UpdateResource(ctx context.Context, in *UpdateResourceRequest, opts ...grpc.CallOption) (*UpdateResourceResponse, error) - // DeleteResource deletes a resource by id. + // DeleteResource deletes a resource by name. DeleteResource(ctx context.Context, in *DeleteResourceRequest, opts ...grpc.CallOption) (*DeleteResourceResponse, error) } @@ -71,18 +71,18 @@ func (c *resourceServiceClient) ListResources(ctx context.Context, in *ListResou return out, nil } -func (c *resourceServiceClient) GetResource(ctx context.Context, in *GetResourceRequest, opts ...grpc.CallOption) (*GetResourceResponse, error) { - out := new(GetResourceResponse) - err := c.cc.Invoke(ctx, ResourceService_GetResource_FullMethodName, in, out, opts...) +func (c *resourceServiceClient) SearchResources(ctx context.Context, in *SearchResourcesRequest, opts ...grpc.CallOption) (*SearchResourcesResponse, error) { + out := new(SearchResourcesResponse) + err := c.cc.Invoke(ctx, ResourceService_SearchResources_FullMethodName, in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *resourceServiceClient) GetResourceByName(ctx context.Context, in *GetResourceByNameRequest, opts ...grpc.CallOption) (*GetResourceByNameResponse, error) { - out := new(GetResourceByNameResponse) - err := c.cc.Invoke(ctx, ResourceService_GetResourceByName_FullMethodName, in, out, opts...) +func (c *resourceServiceClient) GetResource(ctx context.Context, in *GetResourceRequest, opts ...grpc.CallOption) (*GetResourceResponse, error) { + out := new(GetResourceResponse) + err := c.cc.Invoke(ctx, ResourceService_GetResource_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -115,13 +115,13 @@ type ResourceServiceServer interface { CreateResource(context.Context, *CreateResourceRequest) (*CreateResourceResponse, error) // ListResources lists all resources. ListResources(context.Context, *ListResourcesRequest) (*ListResourcesResponse, error) - // GetResource returns a resource by id. + // SearchResources searches memos. + SearchResources(context.Context, *SearchResourcesRequest) (*SearchResourcesResponse, error) + // GetResource returns a resource by name. GetResource(context.Context, *GetResourceRequest) (*GetResourceResponse, error) - // GetResourceByName returns a resource by name. - GetResourceByName(context.Context, *GetResourceByNameRequest) (*GetResourceByNameResponse, error) // UpdateResource updates a resource. UpdateResource(context.Context, *UpdateResourceRequest) (*UpdateResourceResponse, error) - // DeleteResource deletes a resource by id. + // DeleteResource deletes a resource by name. DeleteResource(context.Context, *DeleteResourceRequest) (*DeleteResourceResponse, error) mustEmbedUnimplementedResourceServiceServer() } @@ -136,12 +136,12 @@ func (UnimplementedResourceServiceServer) CreateResource(context.Context, *Creat func (UnimplementedResourceServiceServer) ListResources(context.Context, *ListResourcesRequest) (*ListResourcesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ListResources not implemented") } +func (UnimplementedResourceServiceServer) SearchResources(context.Context, *SearchResourcesRequest) (*SearchResourcesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SearchResources not implemented") +} func (UnimplementedResourceServiceServer) GetResource(context.Context, *GetResourceRequest) (*GetResourceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetResource not implemented") } -func (UnimplementedResourceServiceServer) GetResourceByName(context.Context, *GetResourceByNameRequest) (*GetResourceByNameResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetResourceByName not implemented") -} func (UnimplementedResourceServiceServer) UpdateResource(context.Context, *UpdateResourceRequest) (*UpdateResourceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateResource not implemented") } @@ -197,38 +197,38 @@ func _ResourceService_ListResources_Handler(srv interface{}, ctx context.Context return interceptor(ctx, in, info, handler) } -func _ResourceService_GetResource_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetResourceRequest) +func _ResourceService_SearchResources_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SearchResourcesRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ResourceServiceServer).GetResource(ctx, in) + return srv.(ResourceServiceServer).SearchResources(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: ResourceService_GetResource_FullMethodName, + FullMethod: ResourceService_SearchResources_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ResourceServiceServer).GetResource(ctx, req.(*GetResourceRequest)) + return srv.(ResourceServiceServer).SearchResources(ctx, req.(*SearchResourcesRequest)) } return interceptor(ctx, in, info, handler) } -func _ResourceService_GetResourceByName_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetResourceByNameRequest) +func _ResourceService_GetResource_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetResourceRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ResourceServiceServer).GetResourceByName(ctx, in) + return srv.(ResourceServiceServer).GetResource(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: ResourceService_GetResourceByName_FullMethodName, + FullMethod: ResourceService_GetResource_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ResourceServiceServer).GetResourceByName(ctx, req.(*GetResourceByNameRequest)) + return srv.(ResourceServiceServer).GetResource(ctx, req.(*GetResourceRequest)) } return interceptor(ctx, in, info, handler) } @@ -285,12 +285,12 @@ var ResourceService_ServiceDesc = grpc.ServiceDesc{ Handler: _ResourceService_ListResources_Handler, }, { - MethodName: "GetResource", - Handler: _ResourceService_GetResource_Handler, + MethodName: "SearchResources", + Handler: _ResourceService_SearchResources_Handler, }, { - MethodName: "GetResourceByName", - Handler: _ResourceService_GetResourceByName_Handler, + MethodName: "GetResource", + Handler: _ResourceService_GetResource_Handler, }, { MethodName: "UpdateResource", diff --git a/server/route/api/v2/apidocs.swagger.md b/server/route/api/v2/apidocs.swagger.md index ef6f955b..5362d67f 100644 --- a/server/route/api/v2/apidocs.swagger.md +++ b/server/route/api/v2/apidocs.swagger.md @@ -146,19 +146,19 @@ UpdateInbox updates an inbox. #### GET ##### Summary -GetMemo gets a memo. +GetResource returns a resource by name. ##### Parameters | Name | Located in | Description | Required | Schema | | ---- | ---------- | ----------- | -------- | ------ | -| name_1 | path | The name of the memo. Format: memos/{id} | Yes | string | +| name_1 | path | | Yes | string | ##### Responses | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | A successful response. | [v2GetMemoResponse](#v2getmemoresponse) | +| 200 | A successful response. | [v2GetResourceResponse](#v2getresourceresponse) | | default | An unexpected error response. | [googlerpcStatus](#googlerpcstatus) | #### DELETE @@ -288,7 +288,7 @@ ExportMemos exports memos. #### GET ##### Summary -SearchMemosRequest searches memos. +SearchMemos searches memos. ##### Parameters @@ -324,7 +324,7 @@ UpdateMemo updates a memo. | 200 | A successful response. | [v2UpdateMemoResponse](#v2updatememoresponse) | | default | An unexpected error response. | [googlerpcStatus](#googlerpcstatus) | -### /api/v2/{name_1} +### /api/v2/{name_2} #### GET ##### Summary @@ -335,7 +335,7 @@ GetMemo gets a memo. | Name | Located in | Description | Required | Schema | | ---- | ---------- | ----------- | -------- | ------ | -| name_1 | path | The name of the memo. Format: memos/{id} | Yes | string | +| name_2 | path | The name of the memo. Format: memos/{id} | Yes | string | ##### Responses @@ -347,22 +347,22 @@ GetMemo gets a memo. #### DELETE ##### Summary -DeleteInbox deletes an inbox. +DeleteResource deletes a resource by name. ##### Parameters | Name | Located in | Description | Required | Schema | | ---- | ---------- | ----------- | -------- | ------ | -| name_1 | path | The name of the inbox to delete. Format: inboxes/{uid} | Yes | string | +| name_2 | path | | Yes | string | ##### Responses | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | A successful response. | [v2DeleteInboxResponse](#v2deleteinboxresponse) | +| 200 | A successful response. | [v2DeleteResourceResponse](#v2deleteresourceresponse) | | default | An unexpected error response. | [googlerpcStatus](#googlerpcstatus) | -### /api/v2/{name_2} +### /api/v2/{name_3} #### DELETE ##### Summary @@ -373,7 +373,7 @@ DeleteMemo deletes a memo. | Name | Located in | Description | Required | Schema | | ---- | ---------- | ----------- | -------- | ------ | -| name_2 | path | The name of the memo. Format: memos/{id} | Yes | string | +| name_3 | path | The name of the memo. Format: memos/{id} | Yes | string | ##### Responses @@ -601,38 +601,38 @@ CreateResource creates a new resource. | 200 | A successful response. | [v2CreateResourceResponse](#v2createresourceresponse) | | default | An unexpected error response. | [googlerpcStatus](#googlerpcstatus) | -### /api/v2/resources/name/{name} +### /api/v2/resources:search #### GET ##### Summary -GetResourceByName returns a resource by name. +SearchResources searches memos. ##### Parameters | Name | Located in | Description | Required | Schema | | ---- | ---------- | ----------- | -------- | ------ | -| name | path | | Yes | string | +| filter | query | | No | string | ##### Responses | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | A successful response. | [v2GetResourceByNameResponse](#v2getresourcebynameresponse) | +| 200 | A successful response. | [v2SearchResourcesResponse](#v2searchresourcesresponse) | | default | An unexpected error response. | [googlerpcStatus](#googlerpcstatus) | -### /api/v2/resources/{id} +### /api/v2/{name_1} #### GET ##### Summary -GetResource returns a resource by id. +GetResource returns a resource by name. ##### Parameters | Name | Located in | Description | Required | Schema | | ---- | ---------- | ----------- | -------- | ------ | -| id | path | | Yes | integer | +| name_1 | path | | Yes | string | ##### Responses @@ -644,13 +644,51 @@ GetResource returns a resource by id. #### DELETE ##### Summary -DeleteResource deletes a resource by id. +DeleteInbox deletes an inbox. ##### Parameters | Name | Located in | Description | Required | Schema | | ---- | ---------- | ----------- | -------- | ------ | -| id | path | | Yes | integer | +| name_1 | path | The name of the inbox to delete. Format: inboxes/{uid} | Yes | string | + +##### Responses + +| Code | Description | Schema | +| ---- | ----------- | ------ | +| 200 | A successful response. | [v2DeleteInboxResponse](#v2deleteinboxresponse) | +| default | An unexpected error response. | [googlerpcStatus](#googlerpcstatus) | + +### /api/v2/{name_2} + +#### GET +##### Summary + +GetMemo gets a memo. + +##### Parameters + +| Name | Located in | Description | Required | Schema | +| ---- | ---------- | ----------- | -------- | ------ | +| name_2 | path | The name of the memo. Format: memos/{id} | Yes | string | + +##### Responses + +| Code | Description | Schema | +| ---- | ----------- | ------ | +| 200 | A successful response. | [v2GetMemoResponse](#v2getmemoresponse) | +| default | An unexpected error response. | [googlerpcStatus](#googlerpcstatus) | + +#### DELETE +##### Summary + +DeleteResource deletes a resource by name. + +##### Parameters + +| Name | Located in | Description | Required | Schema | +| ---- | ---------- | ----------- | -------- | ------ | +| name_2 | path | | Yes | string | ##### Responses @@ -659,7 +697,7 @@ DeleteResource deletes a resource by id. | 200 | A successful response. | [v2DeleteResourceResponse](#v2deleteresourceresponse) | | default | An unexpected error response. | [googlerpcStatus](#googlerpcstatus) | -### /api/v2/resources/{resource.id} +### /api/v2/{resource.name} #### PATCH ##### Summary @@ -670,8 +708,8 @@ UpdateResource updates a resource. | Name | Located in | Description | Required | Schema | | ---- | ---------- | ----------- | -------- | ------ | -| resource.id | path | id is the system generated unique identifier. | Yes | integer | -| resource | body | | Yes | { **"name"**: string, **"createTime"**: dateTime, **"filename"**: string, **"externalLink"**: string, **"type"**: string, **"size"**: string (int64), **"memoId"**: integer } | +| resource.name | path | The name of the resource. Format: resources/{id} id is the system generated unique identifier. | Yes | string | +| resource | body | | Yes | { **"uid"**: string, **"createTime"**: dateTime, **"filename"**: string, **"externalLink"**: string, **"type"**: string, **"size"**: string (int64), **"memoId"**: integer } | ##### Responses @@ -1463,12 +1501,6 @@ GetActivity returns the activity with the given id. | ---- | ---- | ----------- | -------- | | memo | [v2Memo](#v2memo) | | No | -#### v2GetResourceByNameResponse - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| resource | [v2Resource](#v2resource) | | No | - #### v2GetResourceResponse | Name | Type | Description | Required | @@ -1659,8 +1691,8 @@ GetActivity returns the activity with the given id. | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | -| id | integer | id is the system generated unique identifier. | No | -| name | string | name is the user provided name. | No | +| name | string | The name of the resource. Format: resources/{id} id is the system generated unique identifier. | No | +| uid | string | The user defined id of the resource. | No | | createTime | dateTime | | No | | filename | string | | No | | externalLink | string | | No | @@ -1674,6 +1706,12 @@ GetActivity returns the activity with the given id. | ---- | ---- | ----------- | -------- | | memos | [ [v2Memo](#v2memo) ] | | No | +#### v2SearchResourcesResponse + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| resources | [ [v2Resource](#v2resource) ] | | No | + #### v2SearchUsersResponse | Name | Type | Description | Required | diff --git a/server/route/api/v2/apidocs.swagger.yaml b/server/route/api/v2/apidocs.swagger.yaml index 46c4ca03..ab286fbb 100644 --- a/server/route/api/v2/apidocs.swagger.yaml +++ b/server/route/api/v2/apidocs.swagger.yaml @@ -285,7 +285,7 @@ paths: - MemoService /api/v2/memos:search: get: - summary: SearchMemosRequest searches memos. + summary: SearchMemos searches memos. operationId: MemoService_SearchMemos responses: "200": @@ -353,113 +353,26 @@ paths: format: int32 tags: - ResourceService - /api/v2/resources/name/{name}: + /api/v2/resources:search: get: - summary: GetResourceByName returns a resource by name. - operationId: ResourceService_GetResourceByName + summary: SearchResources searches memos. + operationId: ResourceService_SearchResources responses: "200": description: A successful response. schema: - $ref: '#/definitions/v2GetResourceByNameResponse' + $ref: '#/definitions/v2SearchResourcesResponse' default: description: An unexpected error response. schema: $ref: '#/definitions/googlerpcStatus' parameters: - - name: name - in: path - required: true + - name: filter + in: query + required: false type: string tags: - ResourceService - /api/v2/resources/{id}: - get: - summary: GetResource returns a resource by id. - operationId: ResourceService_GetResource - responses: - "200": - description: A successful response. - schema: - $ref: '#/definitions/v2GetResourceResponse' - default: - description: An unexpected error response. - schema: - $ref: '#/definitions/googlerpcStatus' - parameters: - - name: id - in: path - required: true - type: integer - format: int32 - tags: - - ResourceService - delete: - summary: DeleteResource deletes a resource by id. - operationId: ResourceService_DeleteResource - responses: - "200": - description: A successful response. - schema: - $ref: '#/definitions/v2DeleteResourceResponse' - default: - description: An unexpected error response. - schema: - $ref: '#/definitions/googlerpcStatus' - parameters: - - name: id - in: path - required: true - type: integer - format: int32 - tags: - - ResourceService - /api/v2/resources/{resource.id}: - patch: - summary: UpdateResource updates a resource. - operationId: ResourceService_UpdateResource - responses: - "200": - description: A successful response. - schema: - $ref: '#/definitions/v2UpdateResourceResponse' - default: - description: An unexpected error response. - schema: - $ref: '#/definitions/googlerpcStatus' - parameters: - - name: resource.id - description: id is the system generated unique identifier. - in: path - required: true - type: integer - format: int32 - - name: resource - in: body - required: true - schema: - type: object - properties: - name: - type: string - description: name is the user provided name. - createTime: - type: string - format: date-time - filename: - type: string - externalLink: - type: string - type: - type: string - size: - type: string - format: int64 - memoId: - type: integer - format: int32 - tags: - - ResourceService /api/v2/tags: get: summary: ListTags lists tags. @@ -978,28 +891,25 @@ paths: - MemoService /api/v2/{name_1}: get: - summary: GetMemo gets a memo. - operationId: MemoService_GetMemo + summary: GetResource returns a resource by name. + operationId: ResourceService_GetResource responses: "200": description: A successful response. schema: - $ref: '#/definitions/v2GetMemoResponse' + $ref: '#/definitions/v2GetResourceResponse' default: description: An unexpected error response. schema: $ref: '#/definitions/googlerpcStatus' parameters: - name: name_1 - description: |- - The name of the memo. - Format: memos/{id} in: path required: true type: string - pattern: memos/[^/]+ + pattern: resources/[^/]+ tags: - - MemoService + - ResourceService delete: summary: DeleteInbox deletes an inbox. operationId: InboxService_DeleteInbox @@ -1024,6 +934,50 @@ paths: tags: - InboxService /api/v2/{name_2}: + get: + summary: GetMemo gets a memo. + operationId: MemoService_GetMemo + responses: + "200": + description: A successful response. + schema: + $ref: '#/definitions/v2GetMemoResponse' + default: + description: An unexpected error response. + schema: + $ref: '#/definitions/googlerpcStatus' + parameters: + - name: name_2 + description: |- + The name of the memo. + Format: memos/{id} + in: path + required: true + type: string + pattern: memos/[^/]+ + tags: + - MemoService + delete: + summary: DeleteResource deletes a resource by name. + operationId: ResourceService_DeleteResource + responses: + "200": + description: A successful response. + schema: + $ref: '#/definitions/v2DeleteResourceResponse' + default: + description: An unexpected error response. + schema: + $ref: '#/definitions/googlerpcStatus' + parameters: + - name: name_2 + in: path + required: true + type: string + pattern: resources/[^/]+ + tags: + - ResourceService + /api/v2/{name_3}: delete: summary: DeleteMemo deletes a memo. operationId: MemoService_DeleteMemo @@ -1037,7 +991,7 @@ paths: schema: $ref: '#/definitions/googlerpcStatus' parameters: - - name: name_2 + - name: name_3 description: |- The name of the memo. Format: memos/{id} @@ -1475,6 +1429,55 @@ paths: pattern: users/[^/]+ tags: - UserService + /api/v2/{resource.name}: + patch: + summary: UpdateResource updates a resource. + operationId: ResourceService_UpdateResource + responses: + "200": + description: A successful response. + schema: + $ref: '#/definitions/v2UpdateResourceResponse' + default: + description: An unexpected error response. + schema: + $ref: '#/definitions/googlerpcStatus' + parameters: + - name: resource.name + description: |- + The name of the resource. + Format: resources/{id} + id is the system generated unique identifier. + in: path + required: true + type: string + pattern: resources/[^/]+ + - name: resource + in: body + required: true + schema: + type: object + properties: + uid: + type: string + description: The user defined id of the resource. + createTime: + type: string + format: date-time + filename: + type: string + externalLink: + type: string + type: + type: string + size: + type: string + format: int64 + memoId: + type: integer + format: int32 + tags: + - ResourceService /api/v2/{setting.name}: patch: summary: UpdateUserSetting updates the setting of a user. @@ -1882,11 +1885,6 @@ definitions: properties: memo: $ref: '#/definitions/v2Memo' - v2GetResourceByNameResponse: - type: object - properties: - resource: - $ref: '#/definitions/v2Resource' v2GetResourceResponse: type: object properties: @@ -2161,13 +2159,15 @@ definitions: v2Resource: type: object properties: - id: - type: integer - format: int32 - description: id is the system generated unique identifier. name: type: string - description: name is the user provided name. + description: |- + The name of the resource. + Format: resources/{id} + id is the system generated unique identifier. + uid: + type: string + description: The user defined id of the resource. createTime: type: string format: date-time @@ -2191,6 +2191,14 @@ definitions: items: type: object $ref: '#/definitions/v2Memo' + v2SearchResourcesResponse: + type: object + properties: + resources: + type: array + items: + type: object + $ref: '#/definitions/v2Resource' v2SearchUsersResponse: type: object properties: diff --git a/server/route/api/v2/memo_resource_service.go b/server/route/api/v2/memo_resource_service.go index ae5b28ad..42ab0a4b 100644 --- a/server/route/api/v2/memo_resource_service.go +++ b/server/route/api/v2/memo_resource_service.go @@ -13,12 +13,12 @@ import ( ) func (s *APIV2Service) SetMemoResources(ctx context.Context, request *apiv2pb.SetMemoResourcesRequest) (*apiv2pb.SetMemoResourcesResponse, error) { - id, err := ExtractMemoIDFromName(request.Name) + memoID, err := ExtractMemoIDFromName(request.Name) if err != nil { return nil, status.Errorf(codes.InvalidArgument, "invalid memo name: %v", err) } resources, err := s.Store.ListResources(ctx, &store.FindResource{ - MemoID: &id, + MemoID: &memoID, }) if err != nil { return nil, status.Errorf(codes.Internal, "failed to list resources") @@ -28,7 +28,7 @@ func (s *APIV2Service) SetMemoResources(ctx context.Context, request *apiv2pb.Se for _, resource := range resources { found := false for _, requestResource := range request.Resources { - if resource.ID == int32(requestResource.Id) { + if resource.UID == requestResource.Uid { found = true break } @@ -36,7 +36,7 @@ func (s *APIV2Service) SetMemoResources(ctx context.Context, request *apiv2pb.Se if !found { if err = s.Store.DeleteResource(ctx, &store.DeleteResource{ ID: int32(resource.ID), - MemoID: &id, + MemoID: &memoID, }); err != nil { return nil, status.Errorf(codes.Internal, "failed to delete resource") } @@ -46,10 +46,14 @@ func (s *APIV2Service) SetMemoResources(ctx context.Context, request *apiv2pb.Se slices.Reverse(request.Resources) // Update resources' memo_id in the request. for index, resource := range request.Resources { + id, err := ExtractMemoIDFromName(resource.Name) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "invalid resource name: %v", err) + } updatedTs := time.Now().Unix() + int64(index) if _, err := s.Store.UpdateResource(ctx, &store.UpdateResource{ - ID: resource.Id, - MemoID: &id, + ID: id, + MemoID: &memoID, UpdatedTs: &updatedTs, }); err != nil { return nil, status.Errorf(codes.Internal, "failed to update resource: %v", err) diff --git a/server/route/api/v2/memo_service.go b/server/route/api/v2/memo_service.go index 225b5c9c..c9173583 100644 --- a/server/route/api/v2/memo_service.go +++ b/server/route/api/v2/memo_service.go @@ -874,7 +874,7 @@ func convertMemoToWebhookPayload(memo *apiv2pb.Memo) (*webhook.WebhookPayload, e resources := []*webhook.Resource{} for _, resource := range memo.Resources { resources = append(resources, &webhook.Resource{ - ID: resource.Id, + UID: resource.Uid, Filename: resource.Filename, ExternalLink: resource.ExternalLink, Type: resource.Type, diff --git a/server/route/api/v2/resource_name.go b/server/route/api/v2/resource_name.go index 0e9c15d9..0aebea39 100644 --- a/server/route/api/v2/resource_name.go +++ b/server/route/api/v2/resource_name.go @@ -13,6 +13,7 @@ const ( WorkspaceSettingNamePrefix = "settings/" UserNamePrefix = "users/" MemoNamePrefix = "memos/" + ResourceNamePrefix = "resources/" InboxNamePrefix = "inboxes/" ) @@ -70,6 +71,19 @@ func ExtractMemoIDFromName(name string) (int32, error) { return id, nil } +// ExtractResourceIDFromName returns the resource ID from a resource name. +func ExtractResourceIDFromName(name string) (int32, error) { + tokens, err := GetNameParentTokens(name, ResourceNamePrefix) + if err != nil { + return 0, err + } + id, err := util.ConvertStringToInt32(tokens[0]) + if err != nil { + return 0, errors.Errorf("invalid resource ID %q", tokens[0]) + } + return id, nil +} + // ExtractInboxIDFromName returns the inbox ID from a resource name. func ExtractInboxIDFromName(name string) (int32, error) { tokens, err := GetNameParentTokens(name, InboxNamePrefix) diff --git a/server/route/api/v2/resource_service.go b/server/route/api/v2/resource_service.go index 12b01ef5..f27f7212 100644 --- a/server/route/api/v2/resource_service.go +++ b/server/route/api/v2/resource_service.go @@ -2,10 +2,14 @@ package v2 import ( "context" + "fmt" "net/url" "time" + "github.com/google/cel-go/cel" "github.com/lithammer/shortuuid/v4" + "github.com/pkg/errors" + expr "google.golang.org/genproto/googleapis/api/expr/v1alpha1" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/timestamppb" @@ -69,25 +73,42 @@ func (s *APIV2Service) ListResources(ctx context.Context, _ *apiv2pb.ListResourc return response, nil } -func (s *APIV2Service) GetResource(ctx context.Context, request *apiv2pb.GetResourceRequest) (*apiv2pb.GetResourceResponse, error) { - resource, err := s.Store.GetResource(ctx, &store.FindResource{ - ID: &request.Id, - }) +func (s *APIV2Service) SearchResources(ctx context.Context, request *apiv2pb.SearchResourcesRequest) (*apiv2pb.SearchResourcesResponse, error) { + if request.Filter == "" { + return nil, status.Errorf(codes.InvalidArgument, "filter is empty") + } + filter, err := parseSearchResourcesFilter(request.Filter) if err != nil { - return nil, status.Errorf(codes.Internal, "failed to get resource: %v", err) + return nil, status.Errorf(codes.InvalidArgument, "failed to parse filter: %v", err) } - if resource == nil { - return nil, status.Errorf(codes.NotFound, "resource not found") + resourceFind := &store.FindResource{} + if filter.UID != nil { + resourceFind.UID = filter.UID + } + user, err := getCurrentUser(ctx, s.Store) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to get current user: %v", err) + } + resourceFind.CreatorID = &user.ID + resources, err := s.Store.ListResources(ctx, resourceFind) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to search resources: %v", err) } - return &apiv2pb.GetResourceResponse{ - Resource: s.convertResourceFromStore(ctx, resource), - }, nil + response := &apiv2pb.SearchResourcesResponse{} + for _, resource := range resources { + response.Resources = append(response.Resources, s.convertResourceFromStore(ctx, resource)) + } + return response, nil } -func (s *APIV2Service) GetResourceByName(ctx context.Context, request *apiv2pb.GetResourceByNameRequest) (*apiv2pb.GetResourceByNameResponse, error) { +func (s *APIV2Service) GetResource(ctx context.Context, request *apiv2pb.GetResourceRequest) (*apiv2pb.GetResourceResponse, error) { + id, err := ExtractResourceIDFromName(request.Name) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "invalid resource name: %v", err) + } resource, err := s.Store.GetResource(ctx, &store.FindResource{ - UID: &request.Name, + ID: &id, }) if err != nil { return nil, status.Errorf(codes.Internal, "failed to get resource: %v", err) @@ -96,19 +117,23 @@ func (s *APIV2Service) GetResourceByName(ctx context.Context, request *apiv2pb.G return nil, status.Errorf(codes.NotFound, "resource not found") } - return &apiv2pb.GetResourceByNameResponse{ + return &apiv2pb.GetResourceResponse{ Resource: s.convertResourceFromStore(ctx, resource), }, nil } func (s *APIV2Service) UpdateResource(ctx context.Context, request *apiv2pb.UpdateResourceRequest) (*apiv2pb.UpdateResourceResponse, error) { + id, err := ExtractResourceIDFromName(request.Resource.Name) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "invalid resource name: %v", err) + } if request.UpdateMask == nil || len(request.UpdateMask.Paths) == 0 { return nil, status.Errorf(codes.InvalidArgument, "update mask is required") } currentTs := time.Now().Unix() update := &store.UpdateResource{ - ID: request.Resource.Id, + ID: id, UpdatedTs: ¤tTs, } for _, field := range request.UpdateMask.Paths { @@ -129,12 +154,16 @@ func (s *APIV2Service) UpdateResource(ctx context.Context, request *apiv2pb.Upda } func (s *APIV2Service) DeleteResource(ctx context.Context, request *apiv2pb.DeleteResourceRequest) (*apiv2pb.DeleteResourceResponse, error) { + id, err := ExtractResourceIDFromName(request.Name) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "invalid resource name: %v", err) + } user, err := getCurrentUser(ctx, s.Store) if err != nil { return nil, status.Errorf(codes.Internal, "failed to get current user: %v", err) } resource, err := s.Store.GetResource(ctx, &store.FindResource{ - ID: &request.Id, + ID: &id, CreatorID: &user.ID, }) if err != nil { @@ -164,8 +193,8 @@ func (s *APIV2Service) convertResourceFromStore(ctx context.Context, resource *s } return &apiv2pb.Resource{ - Id: resource.ID, - Name: resource.UID, + Name: fmt.Sprintf("%s%d", ResourceNamePrefix, resource.ID), + Uid: resource.UID, CreateTime: timestamppb.New(time.Unix(resource.CreatedTs, 0)), Filename: resource.Filename, ExternalLink: resource.ExternalLink, @@ -174,3 +203,50 @@ func (s *APIV2Service) convertResourceFromStore(ctx context.Context, resource *s MemoId: memoID, } } + +// SearchResourcesFilterCELAttributes are the CEL attributes for SearchResourcesFilter. +var SearchResourcesFilterCELAttributes = []cel.EnvOption{ + cel.Variable("uid", cel.StringType), +} + +type SearchResourcesFilter struct { + UID *string +} + +func parseSearchResourcesFilter(expression string) (*SearchResourcesFilter, error) { + e, err := cel.NewEnv(SearchResourcesFilterCELAttributes...) + if err != nil { + return nil, err + } + ast, issues := e.Compile(expression) + if issues != nil { + return nil, errors.Errorf("found issue %v", issues) + } + filter := &SearchResourcesFilter{} + expr, err := cel.AstToParsedExpr(ast) + if err != nil { + return nil, err + } + callExpr := expr.GetExpr().GetCallExpr() + findSearchResourcesField(callExpr, filter) + return filter, nil +} + +func findSearchResourcesField(callExpr *expr.Expr_Call, filter *SearchResourcesFilter) { + if len(callExpr.Args) == 2 { + idExpr := callExpr.Args[0].GetIdentExpr() + if idExpr != nil { + if idExpr.Name == "uid" { + uid := callExpr.Args[1].GetConstExpr().GetStringValue() + filter.UID = &uid + } + return + } + } + for _, arg := range callExpr.Args { + callExpr := arg.GetCallExpr() + if callExpr != nil { + findSearchResourcesField(callExpr, filter) + } + } +} diff --git a/web/src/components/MemoContent/EmbeddedContent/EmbeddedResource.tsx b/web/src/components/MemoContent/EmbeddedContent/EmbeddedResource.tsx index fe5ba648..e6c6db6d 100644 --- a/web/src/components/MemoContent/EmbeddedContent/EmbeddedResource.tsx +++ b/web/src/components/MemoContent/EmbeddedContent/EmbeddedResource.tsx @@ -42,7 +42,7 @@ const EmbeddedResource = ({ resourceId, params: paramsStr }: Props) => { const params = new URLSearchParams(paramsStr); useEffect(() => { - resourceStore.getOrFetchResourceByName(resourceId).finally(() => loadingState.setFinish()); + resourceStore.searchResources(`uid == ${resourceId}`).finally(() => loadingState.setFinish()); }, [resourceId]); if (loadingState.isLoading) { diff --git a/web/src/components/MemoEditor/ResourceListView.tsx b/web/src/components/MemoEditor/ResourceListView.tsx index 092f4b2b..b6abde5b 100644 --- a/web/src/components/MemoEditor/ResourceListView.tsx +++ b/web/src/components/MemoEditor/ResourceListView.tsx @@ -10,8 +10,8 @@ interface Props { const ResourceListView = (props: Props) => { const { resourceList, setResourceList } = props; - const handleDeleteResource = async (resourceId: ResourceId) => { - setResourceList(resourceList.filter((resource) => resource.id !== resourceId)); + const handleDeleteResource = async (name: string) => { + setResourceList(resourceList.filter((resource) => resource.name !== name)); }; return ( @@ -21,14 +21,14 @@ const ResourceListView = (props: Props) => { {resourceList.map((resource) => { return (
{resource.filename} handleDeleteResource(resource.id)} + onClick={() => handleDeleteResource(resource.name)} />
); diff --git a/web/src/components/MemoEditor/index.tsx b/web/src/components/MemoEditor/index.tsx index b6c6455b..f3d572ab 100644 --- a/web/src/components/MemoEditor/index.tsx +++ b/web/src/components/MemoEditor/index.tsx @@ -229,7 +229,7 @@ const MemoEditor = (props: Props) => { if (memoId) { await resourceStore.updateResource({ resource: Resource.fromPartial({ - id: resource.id, + name: resource.name, memoId, }), updateMask: ["memo_id"], diff --git a/web/src/components/MemoResourceListView.tsx b/web/src/components/MemoResourceListView.tsx index 91b0de6d..9482325e 100644 --- a/web/src/components/MemoResourceListView.tsx +++ b/web/src/components/MemoResourceListView.tsx @@ -70,7 +70,7 @@ const MemoResourceListView = ({ resources = [] }: { resources: Resource[] }) => const cards = resources.map((resource) => ( @@ -90,7 +90,7 @@ const MemoResourceListView = ({ resources = [] }: { resources: Resource[] }) => return (
{otherResources.map((resource) => ( - + ))}
); diff --git a/web/src/pages/Resources.tsx b/web/src/pages/Resources.tsx index c72a449f..a58c8df4 100644 --- a/web/src/pages/Resources.tsx +++ b/web/src/pages/Resources.tsx @@ -70,7 +70,7 @@ const Resources = () => { dialogName: "delete-unused-resources-dialog", onConfirm: async () => { for (const resource of unusedResources) { - await resourceServiceClient.deleteResource({ id: resource.id }); + await resourceServiceClient.deleteResource({ name: resource.name }); } setResources(resources.filter((resource) => resource.memoId)); }, @@ -123,7 +123,7 @@ const Resources = () => { {resources.map((resource) => { const relatedMemo = resource.memoId ? memoStore.getMemoByName(`${MemoNamePrefix}${resource.memoId}`) : null; return ( -
+
@@ -163,7 +163,7 @@ const Resources = () => {
{unusedResources.map((resource) => { return ( -
+
diff --git a/web/src/store/reducer/resource.ts b/web/src/store/reducer/resource.ts index b1709952..102b2b31 100644 --- a/web/src/store/reducer/resource.ts +++ b/web/src/store/reducer/resource.ts @@ -21,14 +21,14 @@ const resourceSlice = createSlice({ upsertResources: (state, action: PayloadAction) => { return { ...state, - resources: uniqBy([...action.payload, ...state.resources], "id"), + resources: uniqBy([...action.payload, ...state.resources], "name"), }; }, patchResource: (state, action: PayloadAction>) => { return { ...state, resources: state.resources.map((resource) => { - if (resource.id === action.payload.id) { + if (resource.name === action.payload.name) { return { ...resource, ...action.payload, diff --git a/web/src/store/v1/resource.ts b/web/src/store/v1/resource.ts index e4aacbbc..91a79a89 100644 --- a/web/src/store/v1/resource.ts +++ b/web/src/store/v1/resource.ts @@ -4,62 +4,30 @@ import { resourceServiceClient } from "@/grpcweb"; import { Resource } from "@/types/proto/api/v2/resource_service"; interface State { - resourceMapById: Record; + resourceMapByName: Record; } const getDefaultState = (): State => ({ - resourceMapById: {}, + resourceMapByName: {}, }); export const useResourceStore = create( combine(getDefaultState(), (set, get) => ({ setState: (state: State) => set(state), getState: () => get(), - getOrFetchResourceById: async (id: number, options?: { skipCache?: boolean; skipStore?: boolean }) => { - const resourceMap = get().resourceMapById; - const resource = resourceMap[id]; - if (resource && !options?.skipCache) { - return resource; - } - - const res = await resourceServiceClient.getResource({ - id, - }); - if (!res.resource) { - throw new Error("Resource not found"); - } - - if (!options?.skipStore) { - resourceMap[id] = res.resource; - set({ resourceMapById: resourceMap }); - } - return res.resource; - }, - getResourceById: (id: number) => { - return get().resourceMapById[id]; - }, - getOrFetchResourceByName: async (name: string, options?: { skipCache?: boolean; skipStore?: boolean }) => { - const resourceMap = get().resourceMapById; - const cachedResource = Object.values(resourceMap).find((r) => r.name === name); - if (cachedResource && !options?.skipCache) { - return cachedResource; - } - - const { resource } = await resourceServiceClient.getResourceByName({ - name, + searchResources: async (filter: string) => { + const { resources } = await resourceServiceClient.searchResources({ + filter, }); - if (!resource) { - throw new Error("Resource not found"); - } - - if (!options?.skipStore) { - resourceMap[resource.id] = resource; - set({ resourceMapById: resourceMap }); + const resourceMap = get().resourceMapByName; + for (const resource of resources) { + resourceMap[resource.name] = resource; } - return resource; + set({ resourceMapByName: resourceMap }); + return resources; }, getResourceByName: (name: string) => { - const resourceMap = get().resourceMapById; + const resourceMap = get().resourceMapByName; return Object.values(resourceMap).find((r) => r.name === name); }, })), diff --git a/web/src/types/modules/resource.d.ts b/web/src/types/modules/resource.d.ts index dc80ed84..8b649d7e 100644 --- a/web/src/types/modules/resource.d.ts +++ b/web/src/types/modules/resource.d.ts @@ -1,5 +1,3 @@ -type ResourceId = number; - interface ResourceCreate { filename: string; externalLink: string; diff --git a/web/src/utils/resource.ts b/web/src/utils/resource.ts index 32bcbf8d..67fdf579 100644 --- a/web/src/utils/resource.ts +++ b/web/src/utils/resource.ts @@ -5,7 +5,7 @@ export const getResourceUrl = (resource: Resource) => { return resource.externalLink; } - return `${import.meta.env.VITE_API_BASE_URL || window.location.origin}/o/r/${resource.name}`; + return `${import.meta.env.VITE_API_BASE_URL || window.location.origin}/o/r/${resource.uid}`; }; export const getResourceType = (resource: Resource) => {