chore: tweak api definition

This commit is contained in:
Steven
2024-04-27 22:02:15 +08:00
parent 04c78e180c
commit 9b66ef5e26
45 changed files with 1422 additions and 3231 deletions

View File

@@ -11,7 +11,7 @@ option go_package = "gen/api/v2";
service ActivityService {
// GetActivity returns the activity with the given id.
rpc GetActivity(GetActivityRequest) returns (GetActivityResponse) {
rpc GetActivity(GetActivityRequest) returns (Activity) {
option (google.api.http) = {get: "/v2/activities/{id}"};
option (google.api.method_signature) = "id";
}
@@ -54,7 +54,3 @@ message GetActivityRequest {
// The system-generated unique identifier for the activity.
int32 id = 1;
}
message GetActivityResponse {
Activity activity = 1;
}

View File

@@ -4,28 +4,29 @@ package memos.api.v2;
import "api/v2/user_service.proto";
import "google/api/annotations.proto";
import "google/protobuf/empty.proto";
option go_package = "gen/api/v2";
service AuthService {
// GetAuthStatus returns the current auth status of the user.
rpc GetAuthStatus(GetAuthStatusRequest) returns (GetAuthStatusResponse) {
rpc GetAuthStatus(GetAuthStatusRequest) returns (User) {
option (google.api.http) = {post: "/api/v2/auth/status"};
}
// SignIn signs in the user with the given username and password.
rpc SignIn(SignInRequest) returns (SignInResponse) {
rpc SignIn(SignInRequest) returns (User) {
option (google.api.http) = {post: "/api/v2/auth/signin"};
}
// SignInWithSSO signs in the user with the given SSO code.
rpc SignInWithSSO(SignInWithSSORequest) returns (SignInWithSSOResponse) {
rpc SignInWithSSO(SignInWithSSORequest) returns (User) {
option (google.api.http) = {post: "/api/v2/auth/signin/sso"};
}
// SignUp signs up the user with the given username and password.
rpc SignUp(SignUpRequest) returns (SignUpResponse) {
rpc SignUp(SignUpRequest) returns (User) {
option (google.api.http) = {post: "/api/v2/auth/signup"};
}
// SignOut signs out the user.
rpc SignOut(SignOutRequest) returns (SignOutResponse) {
rpc SignOut(SignOutRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {post: "/api/v2/auth/signout"};
}
}
@@ -45,10 +46,6 @@ message SignInRequest {
bool never_expire = 3;
}
message SignInResponse {
User user = 1;
}
message SignInWithSSORequest {
// The ID of the SSO provider.
int32 idp_id = 1;
@@ -58,10 +55,6 @@ message SignInWithSSORequest {
string redirect_uri = 3;
}
message SignInWithSSOResponse {
User user = 1;
}
message SignUpRequest {
// The username to sign up with.
string username = 1;
@@ -69,10 +62,4 @@ message SignUpRequest {
string password = 2;
}
message SignUpResponse {
User user = 1;
}
message SignOutRequest {}
message SignOutResponse {}

View File

@@ -4,6 +4,7 @@ package memos.api.v2;
import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";
option go_package = "gen/api/v2";
@@ -14,19 +15,19 @@ service IdentityProviderService {
option (google.api.http) = {get: "/api/v2/identityProviders"};
}
// GetIdentityProvider gets an identity provider.
rpc GetIdentityProvider(GetIdentityProviderRequest) returns (GetIdentityProviderResponse) {
rpc GetIdentityProvider(GetIdentityProviderRequest) returns (IdentityProvider) {
option (google.api.http) = {get: "/api/v2/{name=identityProviders/*}"};
option (google.api.method_signature) = "name";
}
// CreateIdentityProvider creates an identity provider.
rpc CreateIdentityProvider(CreateIdentityProviderRequest) returns (CreateIdentityProviderResponse) {
rpc CreateIdentityProvider(CreateIdentityProviderRequest) returns (IdentityProvider) {
option (google.api.http) = {
post: "/api/v2/identityProviders",
body: "identity_provider"
};
}
// UpdateIdentityProvider updates an identity provider.
rpc UpdateIdentityProvider(UpdateIdentityProviderRequest) returns (UpdateIdentityProviderResponse) {
rpc UpdateIdentityProvider(UpdateIdentityProviderRequest) returns (IdentityProvider) {
option (google.api.http) = {
patch: "/api/v2/{identity_provider.name=identityProviders/*}"
body: "identity_provider"
@@ -34,7 +35,7 @@ service IdentityProviderService {
option (google.api.method_signature) = "identity_provider,update_mask";
}
// DeleteIdentityProvider deletes an identity provider.
rpc DeleteIdentityProvider(DeleteIdentityProviderRequest) returns (DeleteIdentityProviderResponse) {
rpc DeleteIdentityProvider(DeleteIdentityProviderRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {delete: "/api/v2/{name=identityProviders/*}"};
option (google.api.method_signature) = "name";
}
@@ -92,21 +93,11 @@ message GetIdentityProviderRequest {
string name = 1;
}
message GetIdentityProviderResponse {
// The identityProvider.
IdentityProvider identity_provider = 1;
}
message CreateIdentityProviderRequest {
// The identityProvider to create.
IdentityProvider identity_provider = 1;
}
message CreateIdentityProviderResponse {
// The created identityProvider.
IdentityProvider identity_provider = 1;
}
message UpdateIdentityProviderRequest {
// The identityProvider to update.
IdentityProvider identity_provider = 1;
@@ -116,15 +107,8 @@ message UpdateIdentityProviderRequest {
google.protobuf.FieldMask update_mask = 2;
}
message UpdateIdentityProviderResponse {
// The updated identityProvider.
IdentityProvider identity_provider = 1;
}
message DeleteIdentityProviderRequest {
// The name of the identityProvider to delete.
// Format: identityProviders/{id}
string name = 1;
}
message DeleteIdentityProviderResponse {}

View File

@@ -4,6 +4,7 @@ package memos.api.v2;
import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/timestamp.proto";
@@ -15,7 +16,7 @@ service InboxService {
option (google.api.http) = {get: "/api/v2/inboxes"};
}
// UpdateInbox updates an inbox.
rpc UpdateInbox(UpdateInboxRequest) returns (UpdateInboxResponse) {
rpc UpdateInbox(UpdateInboxRequest) returns (Inbox) {
option (google.api.http) = {
patch: "/api/v2/{inbox.name=inboxes/*}"
body: "inbox"
@@ -23,7 +24,7 @@ service InboxService {
option (google.api.method_signature) = "inbox,update_mask";
}
// DeleteInbox deletes an inbox.
rpc DeleteInbox(DeleteInboxRequest) returns (DeleteInboxResponse) {
rpc DeleteInbox(DeleteInboxRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {delete: "/api/v2/{name=inboxes/*}"};
option (google.api.method_signature) = "name";
}
@@ -72,14 +73,8 @@ message UpdateInboxRequest {
google.protobuf.FieldMask update_mask = 2;
}
message UpdateInboxResponse {
Inbox inbox = 1;
}
message DeleteInboxRequest {
// The name of the inbox to delete.
// Format: inboxes/{id}
string name = 1;
}
message DeleteInboxResponse {}

View File

@@ -9,6 +9,7 @@ import "api/v2/resource_service.proto";
import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/timestamp.proto";
@@ -16,7 +17,7 @@ option go_package = "gen/api/v2";
service MemoService {
// CreateMemo creates a memo.
rpc CreateMemo(CreateMemoRequest) returns (CreateMemoResponse) {
rpc CreateMemo(CreateMemoRequest) returns (Memo) {
option (google.api.http) = {
post: "/api/v2/memos"
body: "*"
@@ -31,12 +32,12 @@ service MemoService {
option (google.api.http) = {get: "/api/v2/memos:search"};
}
// GetMemo gets a memo.
rpc GetMemo(GetMemoRequest) returns (GetMemoResponse) {
rpc GetMemo(GetMemoRequest) returns (Memo) {
option (google.api.http) = {get: "/api/v2/{name=memos/*}"};
option (google.api.method_signature) = "name";
}
// UpdateMemo updates a memo.
rpc UpdateMemo(UpdateMemoRequest) returns (UpdateMemoResponse) {
rpc UpdateMemo(UpdateMemoRequest) returns (Memo) {
option (google.api.http) = {
patch: "/api/v2/{memo.name=memos/*}"
body: "memo"
@@ -44,7 +45,7 @@ service MemoService {
option (google.api.method_signature) = "memo,update_mask";
}
// DeleteMemo deletes a memo.
rpc DeleteMemo(DeleteMemoRequest) returns (DeleteMemoResponse) {
rpc DeleteMemo(DeleteMemoRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {delete: "/api/v2/{name=memos/*}"};
option (google.api.method_signature) = "name";
}
@@ -56,7 +57,7 @@ service MemoService {
};
}
// SetMemoResources sets resources for a memo.
rpc SetMemoResources(SetMemoResourcesRequest) returns (SetMemoResourcesResponse) {
rpc SetMemoResources(SetMemoResourcesRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
patch: "/api/v2/{name=memos/*}/resources"
body: "*"
@@ -69,7 +70,7 @@ service MemoService {
option (google.api.method_signature) = "name";
}
// SetMemoRelations sets relations for a memo.
rpc SetMemoRelations(SetMemoRelationsRequest) returns (SetMemoRelationsResponse) {
rpc SetMemoRelations(SetMemoRelationsRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
patch: "/api/v2/{name=memos/*}/relations"
body: "*"
@@ -82,10 +83,10 @@ service MemoService {
option (google.api.method_signature) = "name";
}
// CreateMemoComment creates a comment for a memo.
rpc CreateMemoComment(CreateMemoCommentRequest) returns (CreateMemoCommentResponse) {
rpc CreateMemoComment(CreateMemoCommentRequest) returns (Memo) {
option (google.api.http) = {
post: "/api/v2/{name=memos/*}/comments",
body: "*"
body: "comment"
};
option (google.api.method_signature) = "name";
}
@@ -105,7 +106,7 @@ service MemoService {
option (google.api.method_signature) = "name";
}
// UpsertMemoReaction upserts a reaction for a memo.
rpc UpsertMemoReaction(UpsertMemoReactionRequest) returns (UpsertMemoReactionResponse) {
rpc UpsertMemoReaction(UpsertMemoReactionRequest) returns (Reaction) {
option (google.api.http) = {
post: "/api/v2/{name=memos/*}/reactions",
body: "*"
@@ -113,7 +114,7 @@ service MemoService {
option (google.api.method_signature) = "name";
}
// DeleteMemoReaction deletes a reaction for a memo.
rpc DeleteMemoReaction(DeleteMemoReactionRequest) returns (DeleteMemoReactionResponse) {
rpc DeleteMemoReaction(DeleteMemoReactionRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {delete: "/api/v2/reactions/{reaction_id}"};
option (google.api.method_signature) = "reaction_id";
}
@@ -168,10 +169,6 @@ message CreateMemoRequest {
Visibility visibility = 2;
}
message CreateMemoResponse {
Memo memo = 1;
}
message ListMemosRequest {
// The maximum number of memos to return.
int32 page_size = 1;
@@ -209,28 +206,18 @@ message GetMemoRequest {
string name = 1;
}
message GetMemoResponse {
Memo memo = 1;
}
message UpdateMemoRequest {
Memo memo = 1;
google.protobuf.FieldMask update_mask = 2;
}
message UpdateMemoResponse {
Memo memo = 1;
}
message DeleteMemoRequest {
// The name of the memo.
// Format: memos/{id}
string name = 1;
}
message DeleteMemoResponse {}
message ExportMemosRequest {
// Same as ListMemosRequest.filter
string filter = 1;
@@ -248,8 +235,6 @@ message SetMemoResourcesRequest {
repeated Resource resources = 2;
}
message SetMemoResourcesResponse {}
message ListMemoResourcesRequest {
// The name of the memo.
// Format: memos/{id}
@@ -268,8 +253,6 @@ message SetMemoRelationsRequest {
repeated MemoRelation relations = 2;
}
message SetMemoRelationsResponse {}
message ListMemoRelationsRequest {
// The name of the memo.
// Format: memos/{id}
@@ -288,10 +271,6 @@ message CreateMemoCommentRequest {
CreateMemoRequest comment = 2;
}
message CreateMemoCommentResponse {
Memo memo = 1;
}
message ListMemoCommentsRequest {
// The name of the memo.
// Format: memos/{id}
@@ -340,12 +319,6 @@ message UpsertMemoReactionRequest {
Reaction reaction = 2;
}
message UpsertMemoReactionResponse {
Reaction reaction = 1;
}
message DeleteMemoReactionRequest {
int32 reaction_id = 1;
}
message DeleteMemoReactionResponse {}

View File

@@ -5,6 +5,7 @@ package memos.api.v2;
import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/timestamp.proto";
@@ -12,7 +13,7 @@ option go_package = "gen/api/v2";
service ResourceService {
// CreateResource creates a new resource.
rpc CreateResource(CreateResourceRequest) returns (CreateResourceResponse) {
rpc CreateResource(CreateResourceRequest) returns (Resource) {
option (google.api.http) = {
post: "/api/v2/resources",
body: "resource"
@@ -27,12 +28,12 @@ service ResourceService {
option (google.api.http) = {get: "/api/v2/resources:search"};
}
// GetResource returns a resource by name.
rpc GetResource(GetResourceRequest) returns (GetResourceResponse) {
rpc GetResource(GetResourceRequest) returns (Resource) {
option (google.api.http) = {get: "/api/v2/{name=resources/*}"};
option (google.api.method_signature) = "name";
}
// UpdateResource updates a resource.
rpc UpdateResource(UpdateResourceRequest) returns (UpdateResourceResponse) {
rpc UpdateResource(UpdateResourceRequest) returns (Resource) {
option (google.api.http) = {
patch: "/api/v2/{resource.name=resources/*}",
body: "resource"
@@ -40,7 +41,7 @@ service ResourceService {
option (google.api.method_signature) = "resource,update_mask";
}
// DeleteResource deletes a resource by name.
rpc DeleteResource(DeleteResourceRequest) returns (DeleteResourceResponse) {
rpc DeleteResource(DeleteResourceRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {delete: "/api/v2/{name=resources/*}"};
option (google.api.method_signature) = "name";
}
@@ -76,10 +77,6 @@ message CreateResourceRequest {
Resource resource = 1;
}
message CreateResourceResponse {
Resource resource = 1;
}
message ListResourcesRequest {}
message ListResourcesResponse {
@@ -101,25 +98,15 @@ message GetResourceRequest {
string name = 1;
}
message GetResourceResponse {
Resource resource = 1;
}
message UpdateResourceRequest {
Resource resource = 1;
google.protobuf.FieldMask update_mask = 2;
}
message UpdateResourceResponse {
Resource resource = 1;
}
message DeleteResourceRequest {
// The name of the resource.
// Format: resources/{id}
// id is the system generated unique identifier.
string name = 1;
}
message DeleteResourceResponse {}

View File

@@ -8,7 +8,7 @@ option go_package = "gen/api/v2";
service WorkspaceService {
// GetWorkspaceProfile returns the workspace profile.
rpc GetWorkspaceProfile(GetWorkspaceProfileRequest) returns (GetWorkspaceProfileResponse) {
rpc GetWorkspaceProfile(GetWorkspaceProfileRequest) returns (WorkspaceProfile) {
option (google.api.http) = {get: "/api/v2/workspace/profile"};
}
}
@@ -24,7 +24,3 @@ message WorkspaceProfile {
}
message GetWorkspaceProfileRequest {}
message GetWorkspaceProfileResponse {
WorkspaceProfile workspace_profile = 1;
}