Search in sources :

Example 1 with AccountAttribute

use of software.amazon.awssdk.services.ec2.model.AccountAttribute 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]
}
Also used : AccountAttribute(com.amazonaws.services.ec2.model.AccountAttribute) AccountAttributeValue(com.amazonaws.services.ec2.model.AccountAttributeValue) DescribeAccountAttributesResult(com.amazonaws.services.ec2.model.DescribeAccountAttributesResult) AmazonEC2(com.amazonaws.services.ec2.AmazonEC2) ListIterator(java.util.ListIterator)

Example 2 with AccountAttribute

use of software.amazon.awssdk.services.ec2.model.AccountAttribute 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);
    }
}
Also used : AccountAttribute(software.amazon.awssdk.services.ec2.model.AccountAttribute) DescribeAccountAttributesResponse(software.amazon.awssdk.services.ec2.model.DescribeAccountAttributesResponse) AccountAttributeValue(software.amazon.awssdk.services.ec2.model.AccountAttributeValue) Ec2Exception(software.amazon.awssdk.services.ec2.model.Ec2Exception) ListIterator(java.util.ListIterator)

Aggregations

ListIterator (java.util.ListIterator)2 AmazonEC2 (com.amazonaws.services.ec2.AmazonEC2)1 AccountAttribute (com.amazonaws.services.ec2.model.AccountAttribute)1 AccountAttributeValue (com.amazonaws.services.ec2.model.AccountAttributeValue)1 DescribeAccountAttributesResult (com.amazonaws.services.ec2.model.DescribeAccountAttributesResult)1 AccountAttribute (software.amazon.awssdk.services.ec2.model.AccountAttribute)1 AccountAttributeValue (software.amazon.awssdk.services.ec2.model.AccountAttributeValue)1 DescribeAccountAttributesResponse (software.amazon.awssdk.services.ec2.model.DescribeAccountAttributesResponse)1 Ec2Exception (software.amazon.awssdk.services.ec2.model.Ec2Exception)1