Commit 185ec2ad authored by Steven's avatar Steven

chore: update inbox service

parent 6b59c767
......@@ -120,44 +120,81 @@ ListInboxes lists inboxes for a user.
| 200 | A successful response. | [v2ListInboxesResponse](#v2listinboxesresponse) |
| default | An unexpected error response. | [googlerpcStatus](#googlerpcstatus) |
### /v2/inboxes
### /api/v2/{name_1}
#### PATCH
#### DELETE
##### Summary
UpdateInbox updates an inbox.
DeleteInbox deletes an inbox.
##### Parameters
| Name | Located in | Description | Required | Schema |
| ---- | ---------- | ----------- | -------- | ------ |
| inbox | body | | Yes | [v2Inbox](#v2inbox) |
| name_1 | path | The name of the inbox to delete. Format: inboxes/{inbox} | Yes | string |
##### Responses
| Code | Description | Schema |
| ---- | ----------- | ------ |
| 200 | A successful response. | [v2UpdateInboxResponse](#v2updateinboxresponse) |
| 200 | A successful response. | [v2DeleteInboxResponse](#v2deleteinboxresponse) |
| default | An unexpected error response. | [googlerpcStatus](#googlerpcstatus) |
### /v2/{name}
### /api/v2/{name}
#### GET
##### Summary
GetUser gets a user by name.
##### Parameters
| Name | Located in | Description | Required | Schema |
| ---- | ---------- | ----------- | -------- | ------ |
| name | path | The name of the user. Format: users/{username} | Yes | string |
##### Responses
| Code | Description | Schema |
| ---- | ----------- | ------ |
| 200 | A successful response. | [v2GetUserResponse](#v2getuserresponse) |
| default | An unexpected error response. | [googlerpcStatus](#googlerpcstatus) |
#### DELETE
##### Summary
DeleteInbox deletes an inbox.
DeleteUser deletes a user.
##### Parameters
| Name | Located in | Description | Required | Schema |
| ---- | ---------- | ----------- | -------- | ------ |
| name | path | The name of the user. Format: users/{username} | Yes | string |
##### Responses
| Code | Description | Schema |
| ---- | ----------- | ------ |
| 200 | A successful response. | [v2DeleteUserResponse](#v2deleteuserresponse) |
| default | An unexpected error response. | [googlerpcStatus](#googlerpcstatus) |
#### PATCH
##### Summary
UpdateInbox updates an inbox.
##### Parameters
| Name | Located in | Description | Required | Schema |
| ---- | ---------- | ----------- | -------- | ------ |
| name | path | The name of the inbox to delete. Format: inboxes/{inbox} | Yes | string |
| inbox | body | | Yes | [v2Inbox](#v2inbox) |
##### Responses
| Code | Description | Schema |
| ---- | ----------- | ------ |
| 200 | A successful response. | [v2DeleteInboxResponse](#v2deleteinboxresponse) |
| 200 | A successful response. | [v2UpdateInboxResponse](#v2updateinboxresponse) |
| default | An unexpected error response. | [googlerpcStatus](#googlerpcstatus) |
---
......@@ -437,7 +474,7 @@ ExportMemos exports memos.
| Code | Description | Schema |
| ---- | ----------- | ------ |
| 200 | A successful response.(streaming responses) | { **"result"**: [v2ExportMemosResponse](#v2exportmemosresponse), **"error"**: [googlerpcStatus](#googlerpcstatus) } |
| 200 | A successful response. | [v2ExportMemosResponse](#v2exportmemosresponse) |
| default | An unexpected error response. | [googlerpcStatus](#googlerpcstatus) |
---
......@@ -729,6 +766,25 @@ DeleteUser deletes a user.
| 200 | A successful response. | [v2DeleteUserResponse](#v2deleteuserresponse) |
| default | An unexpected error response. | [googlerpcStatus](#googlerpcstatus) |
#### PATCH
##### Summary
UpdateInbox updates an inbox.
##### Parameters
| Name | Located in | Description | Required | Schema |
| ---- | ---------- | ----------- | -------- | ------ |
| name | path | The name of the inbox to delete. Format: inboxes/{inbox} | Yes | string |
| inbox | body | | Yes | [v2Inbox](#v2inbox) |
##### Responses
| Code | Description | Schema |
| ---- | ----------- | ------ |
| 200 | A successful response. | [v2UpdateInboxResponse](#v2updateinboxresponse) |
| default | An unexpected error response. | [googlerpcStatus](#googlerpcstatus) |
### /api/v2/{name}/access_tokens
#### GET
......@@ -1246,7 +1302,7 @@ GetActivity returns the activity with the given id.
| Name | Type | Description | Required |
| ---- | ---- | ----------- | -------- |
| file | byte | | No |
| content | byte | | No |
#### v2GetActivityResponse
......
......@@ -948,6 +948,30 @@ paths:
$ref: '#/definitions/v2WorkspaceProfile'
tags:
- WorkspaceService
/api/v2/{name_1}:
delete:
summary: DeleteInbox deletes an inbox.
operationId: InboxService_DeleteInbox
responses:
"200":
description: A successful response.
schema:
$ref: '#/definitions/v2DeleteInboxResponse'
default:
description: An unexpected error response.
schema:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: name_1
description: |-
The name of the inbox to delete.
Format: inboxes/{inbox}
in: path
required: true
type: string
pattern: inboxes/[^/]+
tags:
- InboxService
/api/v2/{name}:
get:
summary: GetUser gets a user by name.
......@@ -995,6 +1019,34 @@ paths:
pattern: users/[^/]+
tags:
- UserService
patch:
summary: UpdateInbox updates an inbox.
operationId: InboxService_UpdateInbox
responses:
"200":
description: A successful response.
schema:
$ref: '#/definitions/v2UpdateInboxResponse'
default:
description: An unexpected error response.
schema:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: name
description: |-
The name of the inbox to delete.
Format: inboxes/{inbox}
in: path
required: true
type: string
pattern: inboxes/[^/]+
- name: inbox
in: body
required: true
schema:
$ref: '#/definitions/v2Inbox'
tags:
- InboxService
/api/v2/{name}/access_tokens:
get:
summary: ListUserAccessTokens returns a list of access tokens for a user.
......@@ -1237,51 +1289,6 @@ paths:
format: int32
tags:
- ActivityService
/v2/inboxes:
patch:
summary: UpdateInbox updates an inbox.
operationId: InboxService_UpdateInbox
responses:
"200":
description: A successful response.
schema:
$ref: '#/definitions/v2UpdateInboxResponse'
default:
description: An unexpected error response.
schema:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: inbox
in: body
required: true
schema:
$ref: '#/definitions/v2Inbox'
tags:
- InboxService
/v2/{name}:
delete:
summary: DeleteInbox deletes an inbox.
operationId: InboxService_DeleteInbox
responses:
"200":
description: A successful response.
schema:
$ref: '#/definitions/v2DeleteInboxResponse'
default:
description: An unexpected error response.
schema:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: name
description: |-
The name of the inbox to delete.
Format: inboxes/{inbox}
in: path
required: true
type: string
pattern: inboxes/[^/]+
tags:
- InboxService
definitions:
MemoServiceSetMemoRelationsBody:
type: object
......
......@@ -46,7 +46,7 @@ func (s *APIV2Service) UpdateInbox(ctx context.Context, request *apiv2pb.UpdateI
return nil, status.Errorf(codes.InvalidArgument, "update mask is required")
}
inboxID, err := ExtractInboxIDFromName(request.Inbox.Name)
inboxID, err := ExtractInboxIDFromName(request.Name)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "invalid inbox name: %v", err)
}
......
......@@ -17,14 +17,14 @@ service InboxService {
// UpdateInbox updates an inbox.
rpc UpdateInbox(UpdateInboxRequest) returns (UpdateInboxResponse) {
option (google.api.http) = {
patch: "/v2/inboxes"
patch: "/api/v2/{name=inboxes/*}"
body: "inbox"
};
option (google.api.method_signature) = "inbox,update_mask";
option (google.api.method_signature) = "name,inbox,update_mask";
}
// DeleteInbox deletes an inbox.
rpc DeleteInbox(DeleteInboxRequest) returns (DeleteInboxResponse) {
option (google.api.http) = {delete: "/v2/{name=inboxes/*}"};
option (google.api.http) = {delete: "/api/v2/{name=inboxes/*}"};
option (google.api.method_signature) = "name";
}
}
......@@ -67,9 +67,13 @@ message ListInboxesResponse {
}
message UpdateInboxRequest {
Inbox inbox = 1;
// The name of the inbox to delete.
// Format: inboxes/{inbox}
string name = 1;
Inbox inbox = 2;
google.protobuf.FieldMask update_mask = 2;
google.protobuf.FieldMask update_mask = 3;
}
message UpdateInboxResponse {
......
......@@ -1008,6 +1008,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| name | [string](#string) | | The name of the inbox to delete. Format: inboxes/{inbox} |
| inbox | [Inbox](#memos-api-v2-Inbox) | | |
| update_mask | [google.protobuf.FieldMask](#google-protobuf-FieldMask) | | |
......
This diff is collapsed.
......@@ -68,7 +68,7 @@ func local_request_InboxService_ListInboxes_0(ctx context.Context, marshaler run
}
var (
filter_InboxService_UpdateInbox_0 = &utilities.DoubleArray{Encoding: map[string]int{"inbox": 0}, Base: []int{1, 2, 0, 0}, Check: []int{0, 1, 2, 2}}
filter_InboxService_UpdateInbox_0 = &utilities.DoubleArray{Encoding: map[string]int{"inbox": 0, "name": 1}, Base: []int{1, 2, 4, 0, 0, 0, 0}, Check: []int{0, 1, 1, 2, 2, 3, 3}}
)
func request_InboxService_UpdateInbox_0(ctx context.Context, marshaler runtime.Marshaler, client InboxServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
......@@ -90,6 +90,23 @@ func request_InboxService_UpdateInbox_0(ctx context.Context, marshaler runtime.M
}
}
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["name"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
}
protoReq.Name, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
}
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
......@@ -121,6 +138,23 @@ func local_request_InboxService_UpdateInbox_0(ctx context.Context, marshaler run
}
}
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["name"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
}
protoReq.Name, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
}
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
......@@ -224,7 +258,7 @@ func RegisterInboxServiceHandlerServer(ctx context.Context, mux *runtime.ServeMu
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v2.InboxService/UpdateInbox", runtime.WithHTTPPathPattern("/v2/inboxes"))
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v2.InboxService/UpdateInbox", runtime.WithHTTPPathPattern("/api/v2/{name=inboxes/*}"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
......@@ -249,7 +283,7 @@ func RegisterInboxServiceHandlerServer(ctx context.Context, mux *runtime.ServeMu
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v2.InboxService/DeleteInbox", runtime.WithHTTPPathPattern("/v2/{name=inboxes/*}"))
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v2.InboxService/DeleteInbox", runtime.WithHTTPPathPattern("/api/v2/{name=inboxes/*}"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
......@@ -335,7 +369,7 @@ func RegisterInboxServiceHandlerClient(ctx context.Context, mux *runtime.ServeMu
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/memos.api.v2.InboxService/UpdateInbox", runtime.WithHTTPPathPattern("/v2/inboxes"))
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/memos.api.v2.InboxService/UpdateInbox", runtime.WithHTTPPathPattern("/api/v2/{name=inboxes/*}"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
......@@ -357,7 +391,7 @@ func RegisterInboxServiceHandlerClient(ctx context.Context, mux *runtime.ServeMu
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/memos.api.v2.InboxService/DeleteInbox", runtime.WithHTTPPathPattern("/v2/{name=inboxes/*}"))
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/memos.api.v2.InboxService/DeleteInbox", runtime.WithHTTPPathPattern("/api/v2/{name=inboxes/*}"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
......@@ -379,9 +413,9 @@ func RegisterInboxServiceHandlerClient(ctx context.Context, mux *runtime.ServeMu
var (
pattern_InboxService_ListInboxes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v2", "inboxes"}, ""))
pattern_InboxService_UpdateInbox_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v2", "inboxes"}, ""))
pattern_InboxService_UpdateInbox_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3}, []string{"api", "v2", "inboxes", "name"}, ""))
pattern_InboxService_DeleteInbox_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v2", "inboxes", "name"}, ""))
pattern_InboxService_DeleteInbox_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3}, []string{"api", "v2", "inboxes", "name"}, ""))
)
var (
......
......@@ -20,6 +20,7 @@ export const useInboxStore = create(
},
updateInbox: async (inbox: Partial<Inbox>, updateMask: string[]) => {
const { inbox: updatedInbox } = await inboxServiceClient.updateInbox({
name: inbox.name,
inbox,
updateMask,
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment