use of software.amazon.awssdk.services.ec2.model.AccountAttributeValue in project aws-doc-sdk-examples by awsdocs.
the class DescribeAccount method main.
public static void main(String[] args) {
// snippet-start:[ec2.java1.describe_account.main]
AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient();
try {
DescribeAccountAttributesResult accountResults = ec2.describeAccountAttributes();
List<AccountAttribute> accountList = accountResults.getAccountAttributes();
for (ListIterator iter = accountList.listIterator(); iter.hasNext(); ) {
AccountAttribute attribute = (AccountAttribute) iter.next();
System.out.print("\n The name of the attribute is " + attribute.getAttributeName());
List<AccountAttributeValue> values = attribute.getAttributeValues();
// iterate through the attribute values
for (ListIterator iterVals = values.listIterator(); iterVals.hasNext(); ) {
AccountAttributeValue myValue = (AccountAttributeValue) iterVals.next();
System.out.print("\n The value of the attribute is " + myValue.getAttributeValue());
}
}
System.out.print("Done");
} catch (Exception e) {
e.getStackTrace();
}
// snippet-end:[ec2.java1.describe_account.main]
}
use of software.amazon.awssdk.services.ec2.model.AccountAttributeValue in project aws-doc-sdk-examples by awsdocs.
the class DescribeAccount method describeEC2Account.
// snippet-start:[ec2.java2.describe_account.main]
public static void describeEC2Account(Ec2Client ec2) {
try {
DescribeAccountAttributesResponse accountResults = ec2.describeAccountAttributes();
List<AccountAttribute> accountList = accountResults.accountAttributes();
for (ListIterator iter = accountList.listIterator(); iter.hasNext(); ) {
AccountAttribute attribute = (AccountAttribute) iter.next();
System.out.print("\n The name of the attribute is " + attribute.attributeName());
List<AccountAttributeValue> values = attribute.attributeValues();
for (ListIterator iterVals = values.listIterator(); iterVals.hasNext(); ) {
AccountAttributeValue myValue = (AccountAttributeValue) iterVals.next();
System.out.print("\n The value of the attribute is " + myValue.attributeValue());
}
}
} catch (Ec2Exception e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
Aggregations