user_service.proto 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. syntax = "proto3";
  2. package memos.api.v1;
  3. import "api/v1/common.proto";
  4. import "google/api/annotations.proto";
  5. import "google/api/client.proto";
  6. import "google/api/field_behavior.proto";
  7. import "google/api/httpbody.proto";
  8. import "google/protobuf/empty.proto";
  9. import "google/protobuf/field_mask.proto";
  10. import "google/protobuf/timestamp.proto";
  11. option go_package = "gen/api/v1";
  12. service UserService {
  13. // ListUsers returns a list of users.
  14. rpc ListUsers(ListUsersRequest) returns (ListUsersResponse) {
  15. option (google.api.http) = {get: "/api/v1/users"};
  16. }
  17. // SearchUsers searches users by filter.
  18. rpc SearchUsers(SearchUsersRequest) returns (SearchUsersResponse) {
  19. option (google.api.http) = {get: "/api/v1/users:search"};
  20. }
  21. // GetUser gets a user by name.
  22. rpc GetUser(GetUserRequest) returns (User) {
  23. option (google.api.http) = {get: "/api/v1/{name=users/*}"};
  24. option (google.api.method_signature) = "name";
  25. }
  26. // GetUserAvatarBinary gets the avatar of a user.
  27. rpc GetUserAvatarBinary(GetUserAvatarBinaryRequest) returns (google.api.HttpBody) {
  28. option (google.api.http) = {get: "/file/{name=users/*}/avatar"};
  29. option (google.api.method_signature) = "name";
  30. }
  31. // CreateUser creates a new user.
  32. rpc CreateUser(CreateUserRequest) returns (User) {
  33. option (google.api.http) = {
  34. post: "/api/v1/users"
  35. body: "user"
  36. };
  37. option (google.api.method_signature) = "user";
  38. }
  39. // UpdateUser updates a user.
  40. rpc UpdateUser(UpdateUserRequest) returns (User) {
  41. option (google.api.http) = {
  42. patch: "/api/v1/{user.name=users/*}"
  43. body: "user"
  44. };
  45. option (google.api.method_signature) = "user,update_mask";
  46. }
  47. // DeleteUser deletes a user.
  48. rpc DeleteUser(DeleteUserRequest) returns (google.protobuf.Empty) {
  49. option (google.api.http) = {delete: "/api/v1/{name=users/*}"};
  50. option (google.api.method_signature) = "name";
  51. }
  52. // GetUserSetting gets the setting of a user.
  53. rpc GetUserSetting(GetUserSettingRequest) returns (UserSetting) {
  54. option (google.api.http) = {get: "/api/v1/{name=users/*}/setting"};
  55. option (google.api.method_signature) = "name";
  56. }
  57. // UpdateUserSetting updates the setting of a user.
  58. rpc UpdateUserSetting(UpdateUserSettingRequest) returns (UserSetting) {
  59. option (google.api.http) = {
  60. patch: "/api/v1/{setting.name=users/*/setting}"
  61. body: "setting"
  62. };
  63. option (google.api.method_signature) = "setting,update_mask";
  64. }
  65. // ListUserAccessTokens returns a list of access tokens for a user.
  66. rpc ListUserAccessTokens(ListUserAccessTokensRequest) returns (ListUserAccessTokensResponse) {
  67. option (google.api.http) = {get: "/api/v1/{name=users/*}/access_tokens"};
  68. option (google.api.method_signature) = "name";
  69. }
  70. // CreateUserAccessToken creates a new access token for a user.
  71. rpc CreateUserAccessToken(CreateUserAccessTokenRequest) returns (UserAccessToken) {
  72. option (google.api.http) = {
  73. post: "/api/v1/{name=users/*}/access_tokens"
  74. body: "*"
  75. };
  76. option (google.api.method_signature) = "name";
  77. }
  78. // DeleteUserAccessToken deletes an access token for a user.
  79. rpc DeleteUserAccessToken(DeleteUserAccessTokenRequest) returns (google.protobuf.Empty) {
  80. option (google.api.http) = {delete: "/api/v1/{name=users/*}/access_tokens/{access_token}"};
  81. option (google.api.method_signature) = "name,access_token";
  82. }
  83. }
  84. message User {
  85. // The name of the user.
  86. // Format: users/{id}
  87. string name = 1;
  88. // The system generated uid of the user.
  89. int32 id = 2;
  90. enum Role {
  91. ROLE_UNSPECIFIED = 0;
  92. HOST = 1;
  93. ADMIN = 2;
  94. USER = 3;
  95. }
  96. Role role = 3;
  97. string username = 4;
  98. string email = 5;
  99. string nickname = 6;
  100. string avatar_url = 7;
  101. string description = 8;
  102. string password = 9 [(google.api.field_behavior) = INPUT_ONLY];
  103. RowStatus row_status = 10;
  104. google.protobuf.Timestamp create_time = 11;
  105. google.protobuf.Timestamp update_time = 12;
  106. }
  107. message ListUsersRequest {}
  108. message ListUsersResponse {
  109. repeated User users = 1;
  110. }
  111. message SearchUsersRequest {
  112. // Filter is used to filter users returned in the list.
  113. // Format: "username == 'frank'"
  114. string filter = 1;
  115. }
  116. message SearchUsersResponse {
  117. repeated User users = 1;
  118. }
  119. message GetUserRequest {
  120. // The name of the user.
  121. // Format: users/{id}
  122. string name = 1;
  123. }
  124. message GetUserAvatarBinaryRequest {
  125. // The name of the user.
  126. // Format: users/{id}
  127. string name = 1;
  128. // The raw HTTP body is bound to this field.
  129. google.api.HttpBody http_body = 2;
  130. }
  131. message CreateUserRequest {
  132. User user = 1;
  133. }
  134. message UpdateUserRequest {
  135. User user = 1 [(google.api.field_behavior) = REQUIRED];
  136. google.protobuf.FieldMask update_mask = 2;
  137. }
  138. message DeleteUserRequest {
  139. // The name of the user.
  140. // Format: users/{id}
  141. string name = 1;
  142. }
  143. message UserSetting {
  144. // The name of the user.
  145. // Format: users/{id}
  146. string name = 1;
  147. // The preferred locale of the user.
  148. string locale = 2;
  149. // The preferred appearance of the user.
  150. string appearance = 3;
  151. // The default visibility of the memo.
  152. string memo_visibility = 4;
  153. }
  154. message GetUserSettingRequest {
  155. // The name of the user.
  156. // Format: users/{id}
  157. string name = 1;
  158. }
  159. message UpdateUserSettingRequest {
  160. UserSetting setting = 1 [(google.api.field_behavior) = REQUIRED];
  161. google.protobuf.FieldMask update_mask = 2;
  162. }
  163. message UserAccessToken {
  164. string access_token = 1;
  165. string description = 2;
  166. google.protobuf.Timestamp issued_at = 3;
  167. google.protobuf.Timestamp expires_at = 4;
  168. }
  169. message ListUserAccessTokensRequest {
  170. // The name of the user.
  171. // Format: users/{id}
  172. string name = 1;
  173. }
  174. message ListUserAccessTokensResponse {
  175. repeated UserAccessToken access_tokens = 1;
  176. }
  177. message CreateUserAccessTokenRequest {
  178. // The name of the user.
  179. // Format: users/{id}
  180. string name = 1;
  181. string description = 2;
  182. optional google.protobuf.Timestamp expires_at = 3;
  183. }
  184. message DeleteUserAccessTokenRequest {
  185. // The name of the user.
  186. // Format: users/{id}
  187. string name = 1;
  188. // access_token is the access token to delete.
  189. string access_token = 2;
  190. }