use of com.amazonaws.services.ec2.model.TagDescription in project photon-model by vmware.
the class TestAWSUtils method testResourceNaming.
@Test
public void testResourceNaming() throws Throwable {
boolean tagFound = false;
AmazonEC2AsyncClient client = TestUtils.getClient(this.privateKeyId, this.privateKey, this.region, false);
// create something to name
AWSNetworkClient svc = new AWSNetworkClient(client);
String vpcID = svc.createVPC("10.20.0.0/16");
AWSUtils.tagResourcesWithName(client, TEST_NAME, vpcID);
List<TagDescription> tags = AWSUtils.getResourceTags(vpcID, client);
for (TagDescription tagDesc : tags) {
if (tagDesc.getKey().equalsIgnoreCase(AWS_TAG_NAME)) {
assertTrue(tagDesc.getValue().equalsIgnoreCase(TEST_NAME));
tagFound = true;
break;
}
}
// ensure we found the tag
assertTrue(tagFound);
svc.deleteVPC(vpcID);
}
use of com.amazonaws.services.ec2.model.TagDescription in project photon-model by vmware.
the class AWSUtils method getResourceTags.
/*
* Return the tags for a giving resource
*/
public static List<TagDescription> getResourceTags(String resourceID, AmazonEC2AsyncClient client) {
Filter resource = new Filter().withName(AWS_FILTER_RESOURCE_ID).withValues(resourceID);
DescribeTagsRequest req = new DescribeTagsRequest().withFilters(resource);
DescribeTagsResult result = client.describeTags(req);
return result.getTags();
}
Aggregations