Download User List - Amazon Chime

Download User List

The following example shows how to download a list of users associated with your Amazon Chime administrative account in .csv format.

BufferedWriter writer = Files.newBufferedWriter(Paths.get("/path/to/csv")); CSVPrinter printer = new CSVPrinter(writer, CSVFormat.DEFAULT.withHeader("userId", "email")); ListUsersRequest listUsersRequest = new ListUsersRequest() .withAccountId(accountId) .withMaxResults(1); boolean done = false; while (!done) { ListUsersResult listUsersResult = chime.listUsers(listUsersRequest); for (User user: listUsersResult.getUsers()) { printer.printRecord(user.getUserId(), user.getPrimaryEmail()); } if (listUsersResult.getNextToken() == null) { done = true; } listUsersRequest = new ListUsersRequest() .withAccountId(accountId) .withNextToken(listUsersResult.getNextToken()); } printer.close();