Skip to content

Commit

Permalink
chore: tweak api definition
Browse files Browse the repository at this point in the history
  • Loading branch information
boojack committed Apr 27, 2024
1 parent 04c78e1 commit 9b66ef5
Show file tree
Hide file tree
Showing 45 changed files with 1,432 additions and 3,241 deletions.
178 changes: 36 additions & 142 deletions docs/apidocs.swagger.yaml

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions proto/api/v2/activity_service.proto
Expand Up @@ -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";
}
Expand Down Expand Up @@ -54,7 +54,3 @@ message GetActivityRequest {
// The system-generated unique identifier for the activity.
int32 id = 1;
}

message GetActivityResponse {
Activity activity = 1;
}
25 changes: 6 additions & 19 deletions proto/api/v2/auth_service.proto
Expand Up @@ -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"};
}
}
Expand All @@ -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;
Expand All @@ -58,21 +55,11 @@ message SignInWithSSORequest {
string redirect_uri = 3;
}

message SignInWithSSOResponse {
User user = 1;
}

message SignUpRequest {
// The username to sign up with.
string username = 1;
// The password to sign up with.
string password = 2;
}

message SignUpResponse {
User user = 1;
}

message SignOutRequest {}

message SignOutResponse {}
26 changes: 5 additions & 21 deletions proto/api/v2/idp_service.proto
Expand Up @@ -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";
Expand All @@ -14,27 +15,27 @@ 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"
};
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";
}
Expand Down Expand Up @@ -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;
Expand All @@ -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 {}
11 changes: 3 additions & 8 deletions proto/api/v2/inbox_service.proto
Expand Up @@ -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";

Expand All @@ -15,15 +16,15 @@ 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"
};
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";
}
Expand Down Expand Up @@ -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 {}
49 changes: 11 additions & 38 deletions proto/api/v2/memo_service.proto
Expand Up @@ -9,14 +9,15 @@ 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";

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: "*"
Expand All @@ -31,20 +32,20 @@ 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"
};
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";
}
Expand All @@ -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: "*"
Expand All @@ -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: "*"
Expand All @@ -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";
}
Expand All @@ -105,15 +106,15 @@ 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: "*"
};
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";
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -248,8 +235,6 @@ message SetMemoResourcesRequest {
repeated Resource resources = 2;
}

message SetMemoResourcesResponse {}

message ListMemoResourcesRequest {
// The name of the memo.
// Format: memos/{id}
Expand All @@ -268,8 +253,6 @@ message SetMemoRelationsRequest {
repeated MemoRelation relations = 2;
}

message SetMemoRelationsResponse {}

message ListMemoRelationsRequest {
// The name of the memo.
// Format: memos/{id}
Expand All @@ -288,10 +271,6 @@ message CreateMemoCommentRequest {
CreateMemoRequest comment = 2;
}

message CreateMemoCommentResponse {
Memo memo = 1;
}

message ListMemoCommentsRequest {
// The name of the memo.
// Format: memos/{id}
Expand Down Expand Up @@ -340,12 +319,6 @@ message UpsertMemoReactionRequest {
Reaction reaction = 2;
}

message UpsertMemoReactionResponse {
Reaction reaction = 1;
}

message DeleteMemoReactionRequest {
int32 reaction_id = 1;
}

message DeleteMemoReactionResponse {}

0 comments on commit 9b66ef5

Please sign in to comment.