User management API
Create User
Support creating IAM users. Please refer to the following codes:
1public void createUser(IamClient client) {
2 CreateUserRequest createUserRequest = new CreateUserRequest();
3 //Set the username, with a length of 1-64 characters and consisting of letters, numbers, or "_"
4 createUserRequest.setName("test_user_name");
5 // Set user description
6 createUserRequest.setDescription("test_user_description");
7
8 client.createUser(createUserRequest);
9}
Query user
Query an IAM user with reference to the following codes:
1public void getUser(IamClient client) {
2 // Set username
3 String userName = "test_user_name";
4
5 client.getUser(userName);
6}
Update user
Support creating IAM users. Please refer to the following codes:
1public void updateUser(IamClient client) {
2 // Current username
3 String userName = "test_user_name";
4 // Set updated user information
5 UpdateUserRequest updateUserRequest = new UpdateUserRequest();
6 // Set updated username
7 updateUserRequest.setName("new_user_name");
8 // Set updated user description
9 updateUserRequest.setDescription("new_user_description");
10
11 client.updateUser(userName, updateUserRequest);
12}
Delete user
Support deleting an IAM user with reference to the following codes:
1public void deleteUser(IamClient client) {
2 // Current username
3 String userName = "test_user_name";
4
5 client.deleteUser(userName);
6}
List users
List users with reference to the following codes:
1public void listUser(IamClient client) {
2 client.listUser();
3}
Configure console login for the user
Configure console login for the user with reference to the following codes:
1public void updateLoginProfile(IamClient client) {
2 // Username
3 String userName = "test_user_name";
4 UpdateLoginProfileRequest updateLoginProfileRequest = new UpdateLoginProfileRequest();
5 // Set user password; not displayed in responses
6 updateLoginProfileRequest.setPassword("new_passwd");
7 // Whether to reset the password at next login
8 updateLoginProfileRequest.setNeedResetPassword(true);
9 // Whether binding a secondary verification device is required
10 updateLoginProfileRequest.setEnabledLoginMfa(true);
11 // Secondary verification type, options: PHONE-mobile phone number, TOTP MFA Device
12 updateLoginProfileRequest.setLoginMfaType("PHONE");
13 // Bound third-party login types, options: UUAP-intranet account, PASSPORT-Baidu account
14 updateLoginProfileRequest.setThirdPartyType("UUAP");
15 // Bound third-party login account. When the binding type is PASSPORT, it can be a mobile phone number, email, or account name
16 updateLoginProfileRequest.setThirdPartyAccount("PASSPORT");
17 client.updateLoginProfile(userName,updateLoginProfileRequest)
18}
Note: 1. Unbinding is performed when
thirdPartyTypeandthirdPartyAccountare both empty strings; 2. IfenabledLoginMfa":trueis set,loginMfaTypemust be specified
Query console login configuration
Query console login configuration for the user with reference to the following codes:
1public void getLoginProfile(IamClient client) {
2 // Username
3 String userName = "test_user_name";
4 client.getLoginProfile(userName);
5}
Disable console login configuration
Disable user's console login configuration, i.e., disable user's console login, with reference to the following codes:
1public void deleteLoginProfile(IamClient client) {
2 // Username
3 String userName = "test_user_name";
4 client.deleteLoginProfile(userName);
5}
Create user's AccessKey
Create a set of AccessKeys for the user with reference to the following codes:
1public void createAccessKey(IamClient client) {
2 // Username
3 String userName = "test_user_name";
4
5 client.createAccessKey(userName);
6}
Disable user's AccessKey
Disable a specified set of AccessKeys for the user with reference to the following codes:
1public void disableAccessKey(IamClient client) {
2 // Username
3 String userName = "test_user_name";
4 // ak
5 String accessKeyId = "test_user_ak";
6
7 client.disableAccessKey(userName, accessKeyId);
8}
Enable user's AccessKey
Recover a specified set of AccessKeys for the user to "Enabled" status with reference to the following codes:
1public void enableAccessKey(IamClient client) {
2 // Username
3 String userName = "test_user_name";
4 // ak
5 String accessKeyId = "test_user_ak";
6
7 client.enableAccessKey(userName, accessKeyId);
8}
Delete user's AccessKey
Delete a specified set of AccessKeys for the user with reference to the following codes:
1public void deleteAccessKey(IamClient client) {
2 // Username
3 String userName = "test_user_name";
4 // ak
5 String accessKeyId = "test_user_ak";
6
7 client.deleteAccessKey(userName, accessKeyId);
8}
List user's AccessKeys
List all AccessKeys for the user with reference to the following codes:
1public void listAccessKey(IamClient client) {
2 // Username
3 String userName = "test_user_name";
4
5 client.listAccessKey(userName);
6}
