Search in sources :

Example 1 with ListAccessKeysRequest

use of com.amazonaws.services.identitymanagement.model.ListAccessKeysRequest in project aws-doc-sdk-examples by awsdocs.

the class ListAccessKeys method main.

public static void main(String[] args) {
    final String USAGE = "To run this example, supply an IAM  username\n" + "Ex: ListAccessKeys <username>\n";
    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String username = args[0];
    final AmazonIdentityManagement iam = AmazonIdentityManagementClientBuilder.defaultClient();
    boolean done = false;
    while (!done) {
        ListAccessKeysRequest request = new ListAccessKeysRequest().withUserName(username);
        ListAccessKeysResult response = iam.listAccessKeys(request);
        for (AccessKeyMetadata metadata : response.getAccessKeyMetadata()) {
            System.out.format("Retrieved access key %s", metadata.getAccessKeyId());
        }
        request.setMarker(response.getMarker());
        if (!response.getIsTruncated()) {
            done = true;
        }
    }
}
Also used : ListAccessKeysResult(com.amazonaws.services.identitymanagement.model.ListAccessKeysResult) AccessKeyMetadata(com.amazonaws.services.identitymanagement.model.AccessKeyMetadata) ListAccessKeysRequest(com.amazonaws.services.identitymanagement.model.ListAccessKeysRequest) AmazonIdentityManagement(com.amazonaws.services.identitymanagement.AmazonIdentityManagement)

Aggregations

AmazonIdentityManagement (com.amazonaws.services.identitymanagement.AmazonIdentityManagement)1 AccessKeyMetadata (com.amazonaws.services.identitymanagement.model.AccessKeyMetadata)1 ListAccessKeysRequest (com.amazonaws.services.identitymanagement.model.ListAccessKeysRequest)1 ListAccessKeysResult (com.amazonaws.services.identitymanagement.model.ListAccessKeysResult)1