2023-07-30 01:35:00 +08:00
|
|
|
syntax = "proto3";
|
|
|
|
|
2024-04-28 00:44:29 +08:00
|
|
|
package memos.api.v1;
|
2023-07-30 01:35:00 +08:00
|
|
|
|
2024-04-28 00:44:29 +08:00
|
|
|
import "api/v1/common.proto";
|
2023-07-30 01:35:00 +08:00
|
|
|
import "google/api/annotations.proto";
|
|
|
|
import "google/api/client.proto";
|
2023-09-10 18:56:24 +08:00
|
|
|
import "google/api/field_behavior.proto";
|
2024-04-30 22:06:34 +08:00
|
|
|
import "google/api/httpbody.proto";
|
2024-04-27 23:14:58 +08:00
|
|
|
import "google/protobuf/empty.proto";
|
2023-10-21 12:19:06 +08:00
|
|
|
import "google/protobuf/field_mask.proto";
|
2023-09-10 18:56:24 +08:00
|
|
|
import "google/protobuf/timestamp.proto";
|
2023-07-30 01:35:00 +08:00
|
|
|
|
2024-04-28 00:44:29 +08:00
|
|
|
option go_package = "gen/api/v1";
|
2023-07-30 01:35:00 +08:00
|
|
|
|
|
|
|
service UserService {
|
2023-12-23 08:35:54 +08:00
|
|
|
// ListUsers returns a list of users.
|
|
|
|
rpc ListUsers(ListUsersRequest) returns (ListUsersResponse) {
|
2024-04-28 00:44:29 +08:00
|
|
|
option (google.api.http) = {get: "/api/v1/users"};
|
2023-12-23 08:35:54 +08:00
|
|
|
}
|
2024-03-18 12:56:52 +08:00
|
|
|
// SearchUsers searches users by filter.
|
|
|
|
rpc SearchUsers(SearchUsersRequest) returns (SearchUsersResponse) {
|
2024-04-28 00:44:29 +08:00
|
|
|
option (google.api.http) = {get: "/api/v1/users:search"};
|
2024-03-18 12:56:52 +08:00
|
|
|
}
|
2023-11-22 22:52:19 +08:00
|
|
|
// GetUser gets a user by name.
|
2024-04-27 23:14:58 +08:00
|
|
|
rpc GetUser(GetUserRequest) returns (User) {
|
2024-04-28 00:44:29 +08:00
|
|
|
option (google.api.http) = {get: "/api/v1/{name=users/*}"};
|
2023-11-05 23:03:43 +08:00
|
|
|
option (google.api.method_signature) = "name";
|
2023-09-10 18:56:24 +08:00
|
|
|
}
|
2024-05-01 10:23:56 +08:00
|
|
|
// GetUserAvatarBinary gets the avatar of a user.
|
|
|
|
rpc GetUserAvatarBinary(GetUserAvatarBinaryRequest) returns (google.api.HttpBody) {
|
2024-05-02 21:28:06 +08:00
|
|
|
option (google.api.http) = {get: "/file/{name=users/*}/avatar"};
|
2024-04-30 22:06:34 +08:00
|
|
|
option (google.api.method_signature) = "name";
|
|
|
|
}
|
2023-11-22 22:52:19 +08:00
|
|
|
// CreateUser creates a new user.
|
2024-04-27 23:14:58 +08:00
|
|
|
rpc CreateUser(CreateUserRequest) returns (User) {
|
2023-10-21 12:19:06 +08:00
|
|
|
option (google.api.http) = {
|
2024-04-28 00:44:29 +08:00
|
|
|
post: "/api/v1/users"
|
2023-10-21 12:19:06 +08:00
|
|
|
body: "user"
|
|
|
|
};
|
|
|
|
option (google.api.method_signature) = "user";
|
|
|
|
}
|
2023-11-22 22:52:19 +08:00
|
|
|
// UpdateUser updates a user.
|
2024-04-27 23:14:58 +08:00
|
|
|
rpc UpdateUser(UpdateUserRequest) returns (User) {
|
2023-09-10 22:03:12 +08:00
|
|
|
option (google.api.http) = {
|
2024-04-28 00:44:29 +08:00
|
|
|
patch: "/api/v1/{user.name=users/*}"
|
2023-10-21 12:19:06 +08:00
|
|
|
body: "user"
|
2023-09-10 22:03:12 +08:00
|
|
|
};
|
2023-10-21 12:19:06 +08:00
|
|
|
option (google.api.method_signature) = "user,update_mask";
|
2023-07-30 01:35:00 +08:00
|
|
|
}
|
2023-11-22 22:52:19 +08:00
|
|
|
// DeleteUser deletes a user.
|
2024-04-27 23:14:58 +08:00
|
|
|
rpc DeleteUser(DeleteUserRequest) returns (google.protobuf.Empty) {
|
2024-04-28 00:44:29 +08:00
|
|
|
option (google.api.http) = {delete: "/api/v1/{name=users/*}"};
|
2023-11-22 22:52:19 +08:00
|
|
|
option (google.api.method_signature) = "name";
|
|
|
|
}
|
2024-02-01 21:26:09 +08:00
|
|
|
// GetUserSetting gets the setting of a user.
|
2024-04-27 23:14:58 +08:00
|
|
|
rpc GetUserSetting(GetUserSettingRequest) returns (UserSetting) {
|
2024-04-28 00:44:29 +08:00
|
|
|
option (google.api.http) = {get: "/api/v1/{name=users/*}/setting"};
|
2023-11-30 23:08:54 +08:00
|
|
|
option (google.api.method_signature) = "name";
|
|
|
|
}
|
2024-02-01 21:26:09 +08:00
|
|
|
// UpdateUserSetting updates the setting of a user.
|
2024-04-27 23:14:58 +08:00
|
|
|
rpc UpdateUserSetting(UpdateUserSettingRequest) returns (UserSetting) {
|
2023-11-30 23:08:54 +08:00
|
|
|
option (google.api.http) = {
|
2024-04-28 00:44:29 +08:00
|
|
|
patch: "/api/v1/{setting.name=users/*/setting}"
|
2023-12-01 09:03:30 +08:00
|
|
|
body: "setting"
|
2023-11-30 23:08:54 +08:00
|
|
|
};
|
2023-12-01 09:03:30 +08:00
|
|
|
option (google.api.method_signature) = "setting,update_mask";
|
2023-11-30 23:08:54 +08:00
|
|
|
}
|
2023-09-14 19:18:54 +08:00
|
|
|
// ListUserAccessTokens returns a list of access tokens for a user.
|
|
|
|
rpc ListUserAccessTokens(ListUserAccessTokensRequest) returns (ListUserAccessTokensResponse) {
|
2024-04-28 00:44:29 +08:00
|
|
|
option (google.api.http) = {get: "/api/v1/{name=users/*}/access_tokens"};
|
2023-11-05 23:03:43 +08:00
|
|
|
option (google.api.method_signature) = "name";
|
2023-09-14 19:18:54 +08:00
|
|
|
}
|
|
|
|
// CreateUserAccessToken creates a new access token for a user.
|
2024-04-27 23:14:58 +08:00
|
|
|
rpc CreateUserAccessToken(CreateUserAccessTokenRequest) returns (UserAccessToken) {
|
2023-09-14 19:18:54 +08:00
|
|
|
option (google.api.http) = {
|
2024-04-28 00:44:29 +08:00
|
|
|
post: "/api/v1/{name=users/*}/access_tokens"
|
2023-09-20 20:48:34 +08:00
|
|
|
body: "*"
|
2023-09-14 19:18:54 +08:00
|
|
|
};
|
2023-11-05 23:03:43 +08:00
|
|
|
option (google.api.method_signature) = "name";
|
2023-09-14 19:18:54 +08:00
|
|
|
}
|
|
|
|
// DeleteUserAccessToken deletes an access token for a user.
|
2024-04-27 23:14:58 +08:00
|
|
|
rpc DeleteUserAccessToken(DeleteUserAccessTokenRequest) returns (google.protobuf.Empty) {
|
2024-04-28 00:44:29 +08:00
|
|
|
option (google.api.http) = {delete: "/api/v1/{name=users/*}/access_tokens/{access_token}"};
|
2023-11-05 23:03:43 +08:00
|
|
|
option (google.api.method_signature) = "name,access_token";
|
2023-09-14 19:18:54 +08:00
|
|
|
}
|
2023-07-30 01:35:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
message User {
|
2023-11-05 23:03:43 +08:00
|
|
|
// The name of the user.
|
2024-03-20 20:39:16 +08:00
|
|
|
// Format: users/{id}
|
2023-11-05 23:03:43 +08:00
|
|
|
string name = 1;
|
2023-07-30 01:35:00 +08:00
|
|
|
|
2024-03-18 12:56:52 +08:00
|
|
|
// The system generated uid of the user.
|
2023-11-05 23:03:43 +08:00
|
|
|
int32 id = 2;
|
2023-07-30 01:35:00 +08:00
|
|
|
|
2023-09-10 18:56:24 +08:00
|
|
|
enum Role {
|
|
|
|
ROLE_UNSPECIFIED = 0;
|
|
|
|
HOST = 1;
|
|
|
|
ADMIN = 2;
|
|
|
|
USER = 3;
|
|
|
|
}
|
2023-09-14 19:18:54 +08:00
|
|
|
Role role = 3;
|
2023-09-10 18:56:24 +08:00
|
|
|
|
2023-12-23 19:23:39 +08:00
|
|
|
string username = 4;
|
2023-07-30 01:35:00 +08:00
|
|
|
|
2023-12-23 19:23:39 +08:00
|
|
|
string email = 5;
|
2023-07-30 01:35:00 +08:00
|
|
|
|
2023-12-23 19:23:39 +08:00
|
|
|
string nickname = 6;
|
2023-07-30 01:35:00 +08:00
|
|
|
|
2023-12-23 19:23:39 +08:00
|
|
|
string avatar_url = 7;
|
2023-07-30 01:35:00 +08:00
|
|
|
|
2024-03-13 22:30:59 +08:00
|
|
|
string description = 8;
|
2023-09-10 18:56:24 +08:00
|
|
|
|
2024-03-13 22:30:59 +08:00
|
|
|
string password = 9 [(google.api.field_behavior) = INPUT_ONLY];
|
2023-09-14 19:18:54 +08:00
|
|
|
|
2024-03-13 22:30:59 +08:00
|
|
|
RowStatus row_status = 10;
|
2023-12-23 19:23:39 +08:00
|
|
|
|
2024-03-13 22:30:59 +08:00
|
|
|
google.protobuf.Timestamp create_time = 11;
|
|
|
|
|
|
|
|
google.protobuf.Timestamp update_time = 12;
|
2023-07-30 01:35:00 +08:00
|
|
|
}
|
|
|
|
|
2023-12-23 08:35:54 +08:00
|
|
|
message ListUsersRequest {}
|
|
|
|
|
|
|
|
message ListUsersResponse {
|
|
|
|
repeated User users = 1;
|
|
|
|
}
|
|
|
|
|
2024-03-18 12:56:52 +08:00
|
|
|
message SearchUsersRequest {
|
2024-03-29 00:01:45 +08:00
|
|
|
// Filter is used to filter users returned in the list.
|
2024-05-20 22:15:51 +08:00
|
|
|
// Format: "username == 'frank'"
|
2024-03-18 12:56:52 +08:00
|
|
|
string filter = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
message SearchUsersResponse {
|
|
|
|
repeated User users = 1;
|
|
|
|
}
|
|
|
|
|
2023-09-10 18:56:24 +08:00
|
|
|
message GetUserRequest {
|
2023-11-05 23:03:43 +08:00
|
|
|
// The name of the user.
|
2024-03-20 20:39:16 +08:00
|
|
|
// Format: users/{id}
|
2023-11-05 23:03:43 +08:00
|
|
|
string name = 1;
|
2023-09-10 18:56:24 +08:00
|
|
|
}
|
2023-07-30 01:35:00 +08:00
|
|
|
|
2024-05-01 10:23:56 +08:00
|
|
|
message GetUserAvatarBinaryRequest {
|
2024-04-30 22:06:34 +08:00
|
|
|
// The name of the user.
|
|
|
|
// Format: users/{id}
|
|
|
|
string name = 1;
|
|
|
|
|
|
|
|
// The raw HTTP body is bound to this field.
|
|
|
|
google.api.HttpBody http_body = 2;
|
|
|
|
}
|
|
|
|
|
2023-10-21 12:19:06 +08:00
|
|
|
message CreateUserRequest {
|
|
|
|
User user = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
message UpdateUserRequest {
|
|
|
|
User user = 1 [(google.api.field_behavior) = REQUIRED];
|
2023-07-30 01:35:00 +08:00
|
|
|
|
2023-10-21 12:19:06 +08:00
|
|
|
google.protobuf.FieldMask update_mask = 2;
|
2023-07-30 01:35:00 +08:00
|
|
|
}
|
|
|
|
|
2023-11-22 22:52:19 +08:00
|
|
|
message DeleteUserRequest {
|
|
|
|
// The name of the user.
|
2024-03-20 20:39:16 +08:00
|
|
|
// Format: users/{id}
|
2023-11-22 22:52:19 +08:00
|
|
|
string name = 1;
|
|
|
|
}
|
|
|
|
|
2023-11-30 23:08:54 +08:00
|
|
|
message UserSetting {
|
|
|
|
// The name of the user.
|
2024-03-20 20:39:16 +08:00
|
|
|
// Format: users/{id}
|
2023-11-30 23:08:54 +08:00
|
|
|
string name = 1;
|
|
|
|
// The preferred locale of the user.
|
|
|
|
string locale = 2;
|
|
|
|
// The preferred appearance of the user.
|
|
|
|
string appearance = 3;
|
|
|
|
// The default visibility of the memo.
|
|
|
|
string memo_visibility = 4;
|
|
|
|
}
|
|
|
|
|
2023-12-01 09:03:30 +08:00
|
|
|
message GetUserSettingRequest {
|
2023-11-30 23:08:54 +08:00
|
|
|
// The name of the user.
|
2024-03-20 20:39:16 +08:00
|
|
|
// Format: users/{id}
|
2023-11-30 23:08:54 +08:00
|
|
|
string name = 1;
|
|
|
|
}
|
|
|
|
|
2023-12-01 09:03:30 +08:00
|
|
|
message UpdateUserSettingRequest {
|
|
|
|
UserSetting setting = 1 [(google.api.field_behavior) = REQUIRED];
|
2023-11-30 23:08:54 +08:00
|
|
|
|
|
|
|
google.protobuf.FieldMask update_mask = 2;
|
|
|
|
}
|
|
|
|
|
2023-11-06 08:05:07 +08:00
|
|
|
message UserAccessToken {
|
|
|
|
string access_token = 1;
|
|
|
|
string description = 2;
|
|
|
|
google.protobuf.Timestamp issued_at = 3;
|
|
|
|
google.protobuf.Timestamp expires_at = 4;
|
|
|
|
}
|
|
|
|
|
2023-09-14 19:18:54 +08:00
|
|
|
message ListUserAccessTokensRequest {
|
2023-11-05 23:03:43 +08:00
|
|
|
// The name of the user.
|
2024-03-20 20:39:16 +08:00
|
|
|
// Format: users/{id}
|
2023-11-05 23:03:43 +08:00
|
|
|
string name = 1;
|
2023-09-14 19:18:54 +08:00
|
|
|
}
|
2023-07-30 09:53:24 +08:00
|
|
|
|
2023-09-14 19:18:54 +08:00
|
|
|
message ListUserAccessTokensResponse {
|
|
|
|
repeated UserAccessToken access_tokens = 1;
|
2023-07-30 09:53:24 +08:00
|
|
|
}
|
|
|
|
|
2023-09-14 19:18:54 +08:00
|
|
|
message CreateUserAccessTokenRequest {
|
2023-11-05 23:03:43 +08:00
|
|
|
// The name of the user.
|
2024-03-20 20:39:16 +08:00
|
|
|
// Format: users/{id}
|
2023-11-05 23:03:43 +08:00
|
|
|
string name = 1;
|
2023-09-14 19:18:54 +08:00
|
|
|
|
2023-09-20 20:48:34 +08:00
|
|
|
string description = 2;
|
|
|
|
|
|
|
|
optional google.protobuf.Timestamp expires_at = 3;
|
2023-09-14 19:18:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
message DeleteUserAccessTokenRequest {
|
2023-11-05 23:03:43 +08:00
|
|
|
// The name of the user.
|
2024-03-20 20:39:16 +08:00
|
|
|
// Format: users/{id}
|
2023-11-05 23:03:43 +08:00
|
|
|
string name = 1;
|
2023-09-14 19:18:54 +08:00
|
|
|
// access_token is the access token to delete.
|
|
|
|
string access_token = 2;
|
|
|
|
}
|