2023-07-29 20:35:00 +03:00
|
|
|
syntax = "proto3";
|
|
|
|
|
|
|
|
package memos.api.v2;
|
|
|
|
|
|
|
|
import "api/v2/common.proto";
|
|
|
|
import "google/api/annotations.proto";
|
|
|
|
import "google/api/client.proto";
|
2023-09-10 13:56:24 +03:00
|
|
|
import "google/api/field_behavior.proto";
|
2023-10-21 07:19:06 +03:00
|
|
|
import "google/protobuf/field_mask.proto";
|
2023-09-10 13:56:24 +03:00
|
|
|
import "google/protobuf/timestamp.proto";
|
2023-07-29 20:35:00 +03:00
|
|
|
|
|
|
|
option go_package = "gen/api/v2";
|
|
|
|
|
|
|
|
service UserService {
|
|
|
|
rpc GetUser(GetUserRequest) returns (GetUserResponse) {
|
2023-09-10 13:56:24 +03:00
|
|
|
option (google.api.http) = {get: "/api/v2/users/{username}"};
|
|
|
|
option (google.api.method_signature) = "username";
|
|
|
|
}
|
2023-10-21 07:19:06 +03:00
|
|
|
rpc CreateUser(CreateUserRequest) returns (CreateUserResponse) {
|
|
|
|
option (google.api.http) = {
|
|
|
|
post: "/v1/users"
|
|
|
|
body: "user"
|
|
|
|
};
|
|
|
|
option (google.api.method_signature) = "user";
|
|
|
|
}
|
2023-09-10 13:56:24 +03:00
|
|
|
rpc UpdateUser(UpdateUserRequest) returns (UpdateUserResponse) {
|
2023-09-10 17:03:12 +03:00
|
|
|
option (google.api.http) = {
|
2023-10-21 07:41:55 +03:00
|
|
|
patch: "/api/v2/users/{user.username}"
|
2023-10-21 07:19:06 +03:00
|
|
|
body: "user"
|
2023-09-10 17:03:12 +03:00
|
|
|
};
|
2023-10-21 07:19:06 +03:00
|
|
|
option (google.api.method_signature) = "user,update_mask";
|
2023-07-29 20:35:00 +03:00
|
|
|
}
|
2023-09-14 14:18:54 +03:00
|
|
|
// ListUserAccessTokens returns a list of access tokens for a user.
|
|
|
|
rpc ListUserAccessTokens(ListUserAccessTokensRequest) returns (ListUserAccessTokensResponse) {
|
|
|
|
option (google.api.http) = {get: "/api/v2/users/{username}/access_tokens"};
|
|
|
|
option (google.api.method_signature) = "username";
|
|
|
|
}
|
|
|
|
// CreateUserAccessToken creates a new access token for a user.
|
|
|
|
rpc CreateUserAccessToken(CreateUserAccessTokenRequest) returns (CreateUserAccessTokenResponse) {
|
|
|
|
option (google.api.http) = {
|
|
|
|
post: "/api/v2/users/{username}/access_tokens"
|
2023-09-20 15:48:34 +03:00
|
|
|
body: "*"
|
2023-09-14 14:18:54 +03:00
|
|
|
};
|
|
|
|
option (google.api.method_signature) = "username";
|
|
|
|
}
|
|
|
|
// DeleteUserAccessToken deletes an access token for a user.
|
|
|
|
rpc DeleteUserAccessToken(DeleteUserAccessTokenRequest) returns (DeleteUserAccessTokenResponse) {
|
|
|
|
option (google.api.http) = {delete: "/api/v2/users/{username}/access_tokens/{access_token}"};
|
|
|
|
option (google.api.method_signature) = "username,access_token";
|
|
|
|
}
|
2023-07-29 20:35:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
message User {
|
|
|
|
int32 id = 1;
|
|
|
|
|
2023-09-14 14:18:54 +03:00
|
|
|
string username = 2;
|
2023-07-29 20:35:00 +03:00
|
|
|
|
2023-09-10 13:56:24 +03:00
|
|
|
enum Role {
|
|
|
|
ROLE_UNSPECIFIED = 0;
|
|
|
|
HOST = 1;
|
|
|
|
ADMIN = 2;
|
|
|
|
USER = 3;
|
|
|
|
}
|
2023-09-14 14:18:54 +03:00
|
|
|
Role role = 3;
|
2023-09-10 13:56:24 +03:00
|
|
|
|
2023-09-14 14:18:54 +03:00
|
|
|
string email = 4;
|
2023-07-29 20:35:00 +03:00
|
|
|
|
2023-09-14 14:18:54 +03:00
|
|
|
string nickname = 5;
|
2023-07-29 20:35:00 +03:00
|
|
|
|
2023-09-14 17:57:27 +03:00
|
|
|
string avatar_url = 6;
|
2023-07-29 20:35:00 +03:00
|
|
|
|
2023-09-14 17:57:27 +03:00
|
|
|
string password = 7 [(google.api.field_behavior) = INPUT_ONLY];
|
2023-07-29 20:35:00 +03:00
|
|
|
|
2023-09-14 17:57:27 +03:00
|
|
|
RowStatus row_status = 8;
|
2023-09-10 13:56:24 +03:00
|
|
|
|
2023-09-14 17:57:27 +03:00
|
|
|
google.protobuf.Timestamp create_time = 9;
|
2023-09-14 14:18:54 +03:00
|
|
|
|
2023-09-14 17:57:27 +03:00
|
|
|
google.protobuf.Timestamp update_time = 10;
|
2023-07-29 20:35:00 +03:00
|
|
|
}
|
|
|
|
|
2023-09-10 13:56:24 +03:00
|
|
|
message GetUserRequest {
|
|
|
|
string username = 1;
|
|
|
|
}
|
2023-07-29 20:35:00 +03:00
|
|
|
|
2023-09-10 13:56:24 +03:00
|
|
|
message GetUserResponse {
|
|
|
|
User user = 1;
|
|
|
|
}
|
2023-07-29 20:35:00 +03:00
|
|
|
|
2023-10-21 07:19:06 +03:00
|
|
|
message CreateUserRequest {
|
|
|
|
User user = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
message CreateUserResponse {
|
|
|
|
User user = 1;
|
|
|
|
}
|
2023-07-29 20:35:00 +03:00
|
|
|
|
2023-10-21 07:19:06 +03:00
|
|
|
message UpdateUserRequest {
|
|
|
|
User user = 1 [(google.api.field_behavior) = REQUIRED];
|
2023-07-29 20:35:00 +03:00
|
|
|
|
2023-10-21 07:19:06 +03:00
|
|
|
google.protobuf.FieldMask update_mask = 2;
|
2023-07-29 20:35:00 +03:00
|
|
|
}
|
|
|
|
|
2023-09-10 13:56:24 +03:00
|
|
|
message UpdateUserResponse {
|
2023-07-29 20:35:00 +03:00
|
|
|
User user = 1;
|
|
|
|
}
|
2023-07-30 04:53:24 +03:00
|
|
|
|
2023-09-14 14:18:54 +03:00
|
|
|
message ListUserAccessTokensRequest {
|
|
|
|
string username = 1;
|
|
|
|
}
|
2023-07-30 04:53:24 +03:00
|
|
|
|
2023-09-14 14:18:54 +03:00
|
|
|
message ListUserAccessTokensResponse {
|
|
|
|
repeated UserAccessToken access_tokens = 1;
|
2023-07-30 04:53:24 +03:00
|
|
|
}
|
|
|
|
|
2023-09-14 14:18:54 +03:00
|
|
|
message CreateUserAccessTokenRequest {
|
|
|
|
string username = 1;
|
|
|
|
|
2023-09-20 15:48:34 +03:00
|
|
|
string description = 2;
|
|
|
|
|
|
|
|
optional google.protobuf.Timestamp expires_at = 3;
|
2023-09-14 14:18:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
message CreateUserAccessTokenResponse {
|
|
|
|
UserAccessToken access_token = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
message DeleteUserAccessTokenRequest {
|
|
|
|
string username = 1;
|
|
|
|
// access_token is the access token to delete.
|
|
|
|
string access_token = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
message DeleteUserAccessTokenResponse {}
|
|
|
|
|
|
|
|
message UserAccessToken {
|
|
|
|
string access_token = 1;
|
|
|
|
string description = 2;
|
|
|
|
google.protobuf.Timestamp issued_at = 3;
|
|
|
|
google.protobuf.Timestamp expires_at = 4;
|
2023-07-30 04:53:24 +03:00
|
|
|
}
|