/** * <p> * The name of the IAM role to get information about. * </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 roleName * The name of the IAM role to get information about.</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 GetRoleRequest withRoleName(String roleName) { setRoleName(roleName); return this; }
/** * <p> * The name of the IAM role to get information about. * </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 roleName * The name of the IAM role to get information about.</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 GetRoleRequest withRoleName(String roleName) { setRoleName(roleName); return this; }
AmazonIdentityManagementClient iamClient = new AmazonIdentityManagementClient(); GetRoleRequest getRoleRequest = new GetRoleRequest(); getRoleRequest.setRoleName("roleName"); String accountNumber = iamClient.getRole(getRoleRequest).getRole().getArn().split(":")[4];