syntax = "proto3"; package kratos.admin.v1; import "google/protobuf/empty.proto"; import "google/protobuf/timestamp.proto"; import "google/protobuf/field_mask.proto"; import "google/api/annotations.proto"; import "google/api/field_behavior.proto"; option go_package = "kra/api/kratos/admin/v1;v1"; option java_multiple_files = true; option java_package = "api.kratos.admin.v1"; // Admin is the admin message. message Admin { // The unique ID of the user. int64 id = 1; // The name of the user. string name = 2; // The email of the user. string email = 3; // The phone number of the user. string phone = 4; // The avatar URL of the user. string avatar = 5; // The access level of the user. // Possible values are: "admin", "user", etc. string access = 6; // The password of the user. string password = 7; // The timestamp at which the user was created. google.protobuf.Timestamp create_time = 8; // The latest timestamp at which the user was updated. google.protobuf.Timestamp update_time = 9; } // AdminSet is the set of admins. message AdminSet { // The set of admins. repeated Admin admins = 1; // The next page token. string next_page_token = 2; } // AdminService is the admin service definition. service AdminService { // Login a user and return the username. rpc Login (LoginRequest) returns (Admin) { option (google.api.http) = { post: "/v1/admins/login" body: "*" }; } // Logout the currently logged-in user. rpc Logout (google.protobuf.Empty) returns (google.protobuf.Empty) { option (google.api.http) = { post: "/v1/admins/logout" body: "*" }; } // Current returns the currently logged-in user. rpc Current (google.protobuf.Empty) returns (Admin) { option (google.api.http) = { get: "/v1/admins/current" }; } // ListAdmins returns a list of admins. rpc ListAdmins(ListAdminsRequest) returns (AdminSet) { option (google.api.http) = { get: "/v1/admins/list" }; } // CreateAdmin creates a new admin. rpc CreateAdmin(CreateAdminRequest) returns (Admin) { option (google.api.http) = { post: "/v1/admins/create" body: "admin" }; } // UpdateAdmin updates an existing admin. rpc UpdateAdmin(UpdateAdminRequest) returns (Admin) { option (google.api.http) = { put: "/v1/admins/update" body: "admin" }; } // DeleteAdmin deletes an admin by ID. rpc DeleteAdmin(DeleteAdminRequest) returns (google.protobuf.Empty) { option (google.api.http) = { delete: "/v1/admins/{id}" }; } // GetAdmin retrieves an admin by ID. rpc GetAdmin(GetAdminRequest) returns (Admin) { option (google.api.http) = { get: "/v1/admins/{id}" }; } } // LoginRequest is the request message for the Login method. message LoginRequest { // Required. Password of the user. string password = 1 [(google.api.field_behavior) = REQUIRED]; // Required. Exactly one identity must be set. oneof identity { string username = 2; string email = 3; } } // GetAdminRequest is the request message for the GetAdmin method. message GetAdminRequest { // The ID of the admin to retrieve. int64 id = 1 [(google.api.field_behavior) = REQUIRED]; } // ListAdminsResponse is the response message for the ListAdmins method. message ListAdminsRequest { // Optional. The number of admins per page. int32 page_size = 1; // Optional. The page token. string page_token = 2; // Optional. The standard list filter. // Supported fields: // * `name` (i.e. `name="John Doe"`) // * `email` (i.e. `email="admin@go-kratos.dev"`) // * `phone` (i.e. `phone="+1234567890"`) // * `create_time` range (i.e. `timestamp>="2025-01-31T11:30:00-04:00"` where // the timestamp is in RFC 3339 format) // // More detail in [AIP-160](https://google.aip.dev/160). string filter = 3; // Optional. A comma-separated list of fields to order by, sorted in ascending // order. Use "desc" after a field name for descending. Supported fields: // - `create_time` // // Example: `create_time desc`. string order_by = 4; } // CreateAdminRequest is the request message for the CreateAdmin method. message CreateAdminRequest { // Required. The admin to create. Admin admin = 1 [(google.api.field_behavior) = REQUIRED]; } // UpdateAdminRequest is the request message for the UpdateAdmin method. message UpdateAdminRequest { // Required. The admin to update. Admin admin = 1 [(google.api.field_behavior) = REQUIRED]; // Required. Mask of fields to update. google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED]; } // DeleteAdminRequest is the request message for the DeleteAdmin method. message DeleteAdminRequest { // Required. The ID of the admin to delete. int64 id = 1 [(google.api.field_behavior) = REQUIRED]; }