Search in sources :

Example 1 with User

use of software.amazon.awssdk.services.iam.model.User in project aws-doc-sdk-examples by awsdocs.

the class ListUsers method listAllUsers.

// snippet-start:[iam.java2.list_users.main]
public static void listAllUsers(IamClient iam) {
    try {
        boolean done = false;
        String newMarker = null;
        while (!done) {
            ListUsersResponse response;
            if (newMarker == null) {
                ListUsersRequest request = ListUsersRequest.builder().build();
                response = iam.listUsers(request);
            } else {
                ListUsersRequest request = ListUsersRequest.builder().marker(newMarker).build();
                response = iam.listUsers(request);
            }
            for (User user : response.users()) {
                System.out.format("\n Retrieved user %s", user.userName());
            }
            if (!response.isTruncated()) {
                done = true;
            } else {
                newMarker = response.marker();
            }
        }
    } catch (IamException e) {
        System.err.println(e.awsErrorDetails().errorMessage());
        System.exit(1);
    }
}
Also used : ListUsersRequest(software.amazon.awssdk.services.iam.model.ListUsersRequest) User(software.amazon.awssdk.services.iam.model.User) ListUsersResponse(software.amazon.awssdk.services.iam.model.ListUsersResponse) IamException(software.amazon.awssdk.services.iam.model.IamException)

Aggregations

IamException (software.amazon.awssdk.services.iam.model.IamException)1 ListUsersRequest (software.amazon.awssdk.services.iam.model.ListUsersRequest)1 ListUsersResponse (software.amazon.awssdk.services.iam.model.ListUsersResponse)1 User (software.amazon.awssdk.services.iam.model.User)1