memos/proto/api/v2/user_service.proto

224 lines
5.5 KiB
Protocol Buffer
Raw Normal View History

syntax = "proto3";
package memos.api.v2;
import "api/v2/common.proto";
import "google/api/annotations.proto";
import "google/api/client.proto";
2023-09-10 18:56:24 +08:00
import "google/api/field_behavior.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";
option go_package = "gen/api/v2";
service UserService {
2023-12-23 08:35:54 +08:00
// ListUsers returns a list of users.
rpc ListUsers(ListUsersRequest) returns (ListUsersResponse) {
option (google.api.http) = {get: "/api/v2/users"};
}
2023-11-22 22:52:19 +08:00
// GetUser gets a user by name.
rpc GetUser(GetUserRequest) returns (GetUserResponse) {
2023-11-05 23:03:43 +08:00
option (google.api.http) = {get: "/api/v2/{name=users/*}"};
option (google.api.method_signature) = "name";
2023-09-10 18:56:24 +08:00
}
2023-11-22 22:52:19 +08:00
// CreateUser creates a new user.
2023-10-21 12:19:06 +08:00
rpc CreateUser(CreateUserRequest) returns (CreateUserResponse) {
option (google.api.http) = {
post: "/v1/users"
body: "user"
};
option (google.api.method_signature) = "user";
}
2023-11-22 22:52:19 +08:00
// UpdateUser updates a user.
2023-09-10 18:56:24 +08:00
rpc UpdateUser(UpdateUserRequest) returns (UpdateUserResponse) {
2023-09-10 22:03:12 +08:00
option (google.api.http) = {
2023-11-05 23:03:43 +08:00
patch: "/api/v2/{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-11-22 22:52:19 +08:00
// DeleteUser deletes a user.
rpc DeleteUser(DeleteUserRequest) returns (DeleteUserResponse) {
option (google.api.http) = {delete: "/api/v2/{name=users/*}"};
option (google.api.method_signature) = "name";
}
2023-12-01 09:03:30 +08:00
rpc GetUserSetting(GetUserSettingRequest) returns (GetUserSettingResponse) {
option (google.api.http) = {get: "/api/v2/{name=users/*}/setting"};
2023-11-30 23:08:54 +08:00
option (google.api.method_signature) = "name";
}
2023-12-01 09:03:30 +08:00
rpc UpdateUserSetting(UpdateUserSettingRequest) returns (UpdateUserSettingResponse) {
2023-11-30 23:08:54 +08:00
option (google.api.http) = {
2023-12-01 09:03:30 +08:00
patch: "/api/v2/{setting.name=users/*/setting}"
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
}
// ListUserAccessTokens returns a list of access tokens for a user.
rpc ListUserAccessTokens(ListUserAccessTokensRequest) returns (ListUserAccessTokensResponse) {
2023-11-05 23:03:43 +08:00
option (google.api.http) = {get: "/api/v2/{name=users/*}/access_tokens"};
option (google.api.method_signature) = "name";
}
// CreateUserAccessToken creates a new access token for a user.
rpc CreateUserAccessToken(CreateUserAccessTokenRequest) returns (CreateUserAccessTokenResponse) {
option (google.api.http) = {
2023-11-05 23:03:43 +08:00
post: "/api/v2/{name=users/*}/access_tokens"
2023-09-20 20:48:34 +08:00
body: "*"
};
2023-11-05 23:03:43 +08:00
option (google.api.method_signature) = "name";
}
// DeleteUserAccessToken deletes an access token for a user.
rpc DeleteUserAccessToken(DeleteUserAccessTokenRequest) returns (DeleteUserAccessTokenResponse) {
2023-11-05 23:03:43 +08:00
option (google.api.http) = {delete: "/api/v2/{name=users/*}/access_tokens/{access_token}"};
option (google.api.method_signature) = "name,access_token";
}
}
message User {
2023-11-05 23:03:43 +08:00
// The name of the user.
// Format: users/{username}
string name = 1;
2023-11-05 23:03:43 +08:00
int32 id = 2;
2023-09-10 18:56:24 +08:00
enum Role {
ROLE_UNSPECIFIED = 0;
HOST = 1;
ADMIN = 2;
USER = 3;
}
Role role = 3;
2023-09-10 18:56:24 +08:00
string username = 4;
string email = 5;
string nickname = 6;
string avatar_url = 7;
string password = 8 [(google.api.field_behavior) = INPUT_ONLY];
2023-09-10 18:56:24 +08:00
RowStatus row_status = 9;
google.protobuf.Timestamp create_time = 10;
google.protobuf.Timestamp update_time = 11;
}
2023-12-23 08:35:54 +08:00
message ListUsersRequest {}
message ListUsersResponse {
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.
// Format: users/{username}
string name = 1;
2023-09-10 18:56:24 +08:00
}
2023-09-10 18:56:24 +08:00
message GetUserResponse {
User user = 1;
}
2023-10-21 12:19:06 +08:00
message CreateUserRequest {
User user = 1;
}
message CreateUserResponse {
User user = 1;
}
2023-10-21 12:19:06 +08:00
message UpdateUserRequest {
User user = 1 [(google.api.field_behavior) = REQUIRED];
2023-10-21 12:19:06 +08:00
google.protobuf.FieldMask update_mask = 2;
}
2023-09-10 18:56:24 +08:00
message UpdateUserResponse {
User user = 1;
}
2023-07-30 09:53:24 +08:00
2023-11-22 22:52:19 +08:00
message DeleteUserRequest {
// The name of the user.
// Format: users/{username}
string name = 1;
}
message DeleteUserResponse {}
2023-11-30 23:08:54 +08:00
message UserSetting {
// The name of the user.
// Format: users/{username}
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;
// The telegram user id of the user.
string telegram_user_id = 5;
}
2023-12-01 09:03:30 +08:00
message GetUserSettingRequest {
2023-11-30 23:08:54 +08:00
// The name of the user.
// Format: users/{username}
string name = 1;
}
2023-12-01 09:03:30 +08:00
message GetUserSettingResponse {
UserSetting setting = 1;
2023-11-30 23:08:54 +08:00
}
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-12-01 09:03:30 +08:00
message UpdateUserSettingResponse {
UserSetting setting = 1;
2023-11-30 23:08:54 +08:00
}
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;
}
message ListUserAccessTokensRequest {
2023-11-05 23:03:43 +08:00
// The name of the user.
// Format: users/{username}
string name = 1;
}
2023-07-30 09:53:24 +08:00
message ListUserAccessTokensResponse {
repeated UserAccessToken access_tokens = 1;
2023-07-30 09:53:24 +08:00
}
message CreateUserAccessTokenRequest {
2023-11-05 23:03:43 +08:00
// The name of the user.
// Format: users/{username}
string name = 1;
2023-09-20 20:48:34 +08:00
string description = 2;
optional google.protobuf.Timestamp expires_at = 3;
}
message CreateUserAccessTokenResponse {
UserAccessToken access_token = 1;
}
message DeleteUserAccessTokenRequest {
2023-11-05 23:03:43 +08:00
// The name of the user.
// Format: users/{username}
string name = 1;
// access_token is the access token to delete.
string access_token = 2;
}
message DeleteUserAccessTokenResponse {}