User management

Add new user

POST /api/mimock/v1/admin/users

Adds a new user to mimock

@AllArgsConstructor
@Builder
@Getter
public class AddUserRequest {
@NotBlank(message = "Name of the user cannot be empty")
@Schema(example = "Gandalf", description = "Name of the user")
@Size(min = 4, max = 24)
@Pattern(regexp = "[a-zA-Z][a-zA-Z0-9 ]{3,24}", message = "Name must contain only alphabets")
private String name;
@NotBlank(message = "Username cannot be empty")
@Schema(example = "mithrandir_69", description = "Unique user name for the user")
@Size(min = 4, message = "User name must be at least 6 characters long")
@Size(max = 24, message = "User name cannot be more than 24 characters")
@Pattern(regexp = "[a-zA-Z][a-zA-Z0-9_]{3,24}", message = "User name must contain only alphanumeric characters")
private String userName;
@NotBlank(message = "Password cannot be empty")
@Schema(
example = "$2a$12$GekvNjpI6TOSDXJRYMNzguU4edoaHaTXs1jvHELi27AW2zsNopTxm",
description = "BCrypt encoded password"
)
@Size(min = 8, message = "Password must be at least 8 characters long")
@Size(max = 128, message = "Password cannot be more than 128 characters long")
@ValidPassword
private String password;
@ValidRole
@Schema(example = "ADMIN", description = "Role of the user")
private String userRole;
}

Validate user auth token

GET /api/mimock/v1/auth-token/validate

Validates if the auth token is valid for use or not.

Delete user based on user name

DELETE /api/mimock/v1/admin/users/delete-user

Delete an existing user

List user info

GET /api/mimock/v1/admin/users/user-info

Returns the user info for an user

List all users

GET /api/mimock/v1/admin/users

Returns all the existing users who are not deleted

Update user activation status

PUT /api/mimock/v1/admin/users/update-activation

To enable or disable a user account

@AllArgsConstructor
@NoArgsConstructor
@Builder
@Getter
public class UserActivationRequest {
@NotNull(message = "User status is mandatory")
@Schema(description = "Activation status for the user", example = "true")
private Boolean isUserActive;
@NotBlank(message = "Username cannot be empty")
@Size(min = 6, message = "User name must be at least 6 characters long")
@Size(max = 128, message = "User name cannot be more than 128 characters")
@Schema(description = "Username for which the activation status need to be set", example = "mimock_admin")
private String userName;
}

Update user password

PUT /api/mimock/v1/admin/users/update-password

Updates the user password

@AllArgsConstructor
@Builder
@Getter
public class UpdatePasswordRequest {
@NotBlank(message = "Username cannot be empty")
@Schema(example = "mimock_admin", description = "Unique user name for the user")
@Size(min = 6, message = "User name must be at least 6 characters long")
@Size(max = 128, message = "User name cannot be more than 128 characters")
private String userName;
@NotBlank(message = "Password cannot be empty")
@Schema(
example = "$2a$12$GekvNjpI6TOSDXJRYMNzguU4edoaHaTXs1jvHELi27AW2zsNopTxm",
description = "BCrypt encoded password"
)
@ValidPassword
private String password;
}

Update user role

PUT /api/mimock/v1/admin/users/update-role

Updates the user role

@AllArgsConstructor
@Builder
@Getter
public class UpdateUserRoleRequest {
@NotBlank(message = "Username cannot be empty")
@Schema(example = "frodo1", description = "Unique user name for the user")
@Size(min = 6, message = "User name must be at least 6 characters long")
@Size(max = 128, message = "User name cannot be more than 128 characters")
private String userName;
@ValidRole
@Schema(example = "ADMIN", description = "Role of the user")
private String userRole;
}