syntax = "proto3";

package identity.v1;

option go_package = "git.dcentral.systems/toolz/goplt/api/proto/generated/identity/v1;identityv1";

// IdentityService provides user management operations.
service IdentityService {
  // GetUser retrieves a user by ID.
  rpc GetUser(GetUserRequest) returns (GetUserResponse);
  
  // GetUserByEmail retrieves a user by email address.
  rpc GetUserByEmail(GetUserByEmailRequest) returns (GetUserByEmailResponse);
  
  // CreateUser creates a new user.
  rpc CreateUser(CreateUserRequest) returns (CreateUserResponse);
  
  // UpdateUser updates an existing user.
  rpc UpdateUser(UpdateUserRequest) returns (UpdateUserResponse);
  
  // DeleteUser deletes a user.
  rpc DeleteUser(DeleteUserRequest) returns (DeleteUserResponse);
  
  // VerifyEmail verifies a user's email address using a verification token.
  rpc VerifyEmail(VerifyEmailRequest) returns (VerifyEmailResponse);
  
  // RequestPasswordReset requests a password reset token.
  rpc RequestPasswordReset(RequestPasswordResetRequest) returns (RequestPasswordResetResponse);
  
  // ResetPassword resets a user's password using a reset token.
  rpc ResetPassword(ResetPasswordRequest) returns (ResetPasswordResponse);
}

// User represents a user in the system.
message User {
  string id = 1;
  string email = 2;
  string username = 3;
  string first_name = 4;
  string last_name = 5;
  bool email_verified = 6;
  int64 created_at = 7;
  int64 updated_at = 8;
}

// GetUserRequest contains a user ID.
message GetUserRequest {
  string id = 1;
}

// GetUserResponse contains a user.
message GetUserResponse {
  User user = 1;
}

// GetUserByEmailRequest contains an email address.
message GetUserByEmailRequest {
  string email = 1;
}

// GetUserByEmailResponse contains a user.
message GetUserByEmailResponse {
  User user = 1;
}

// CreateUserRequest contains user data for creation.
message CreateUserRequest {
  string email = 1;
  string username = 2;
  string password = 3;
  string first_name = 4;
  string last_name = 5;
}

// CreateUserResponse contains the created user.
message CreateUserResponse {
  User user = 1;
}

// UpdateUserRequest contains user data for update.
message UpdateUserRequest {
  string id = 1;
  optional string email = 2;
  optional string username = 3;
  optional string first_name = 4;
  optional string last_name = 5;
}

// UpdateUserResponse contains the updated user.
message UpdateUserResponse {
  User user = 1;
}

// DeleteUserRequest contains a user ID.
message DeleteUserRequest {
  string id = 1;
}

// DeleteUserResponse indicates success.
message DeleteUserResponse {
  bool success = 1;
}

// VerifyEmailRequest contains a verification token.
message VerifyEmailRequest {
  string token = 1;
}

// VerifyEmailResponse indicates success.
message VerifyEmailResponse {
  bool success = 1;
}

// RequestPasswordResetRequest contains an email address.
message RequestPasswordResetRequest {
  string email = 1;
}

// RequestPasswordResetResponse indicates success.
message RequestPasswordResetResponse {
  bool success = 1;
}

// ResetPasswordRequest contains a reset token and new password.
message ResetPasswordRequest {
  string token = 1;
  string new_password = 2;
}

// ResetPasswordResponse indicates success.
message ResetPasswordResponse {
  bool success = 1;
}

