/** * <p> * The name of the user. * </p> * <p> * This parameter allows (through its <a href="http://wikipedia.org/wiki/regex">regex pattern</a>) a string of * characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of * the following characters: _+=,.@- * </p> * * @param userName * The name of the user.</p> * <p> * This parameter allows (through its <a href="http://wikipedia.org/wiki/regex">regex pattern</a>) a string * of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also * include any of the following characters: _+=,.@- * @return Returns a reference to this object so that method calls can be chained together. */ public ListAccessKeysRequest withUserName(String userName) { setUserName(userName); return this; }
/** * <p> * The name of the user. * </p> * <p> * This parameter allows (through its <a href="http://wikipedia.org/wiki/regex">regex pattern</a>) a string of * characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of * the following characters: _+=,.@- * </p> * * @param userName * The name of the user.</p> * <p> * This parameter allows (through its <a href="http://wikipedia.org/wiki/regex">regex pattern</a>) a string * of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also * include any of the following characters: _+=,.@- * @return Returns a reference to this object so that method calls can be chained together. */ public ListAccessKeysRequest withUserName(String userName) { setUserName(userName); return this; }
List<AccessKeyMetadata> getAccessKeys(final String accountId, final String userName) { final ListAccessKeysRequest request = new ListAccessKeysRequest(); request.setUserName(userName); return getIAMClient(accountId).listAccessKeys(request).getAccessKeyMetadata(); }
/** * This method will fetch the access key information of a particular user. * * @param userName * @param iamClient * @return list of access key meta data */ public static List<AccessKeyMetadata> getAccessKeyInformationForUser( final String userName, AmazonIdentityManagementClient iamClient) { ListAccessKeysRequest accessKeysRequest = new ListAccessKeysRequest(); accessKeysRequest.setUserName(userName); logger.debug("userName {} ",userName); List<AccessKeyMetadata> accessKeyMetadatas = new ArrayList<>(); ListAccessKeysResult keysResult = null; do { keysResult = iamClient.listAccessKeys(accessKeysRequest); accessKeyMetadatas.addAll(keysResult.getAccessKeyMetadata()); accessKeysRequest.setMarker(keysResult.getMarker()); } while (keysResult.isTruncated()); return accessKeyMetadatas; } }
for (User user : users) { final ListAccessKeysRequest listAccessKeysRequest = new ListAccessKeysRequest(); listAccessKeysRequest.setUserName(user.getUserName()); final List<AccessKeyMetadata> accessKeyMetadata = iamClient.listAccessKeys(listAccessKeysRequest).getAccessKeyMetadata();