本文整理汇总了Java中com.amazonaws.services.ec2.model.DescribeTagsResult类的典型用法代码示例。如果您正苦于以下问题:Java DescribeTagsResult类的具体用法?Java DescribeTagsResult怎么用?Java DescribeTagsResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DescribeTagsResult类属于com.amazonaws.services.ec2.model包,在下文中一共展示了DescribeTagsResult类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ElapsedTimeAggregatorTest
import com.amazonaws.services.ec2.model.DescribeTagsResult; //导入依赖的package包/类
/**
* Default constructor
*/
public ElapsedTimeAggregatorTest() {
AmazonEC2 ec2Client = mock(AmazonEC2.class);
AmazonCloudWatch cloudWatchClient = mock(AmazonCloudWatch.class);
Region region = Region.getRegion(Regions.US_WEST_1);
when(ec2Client.describeTags(any(DescribeTagsRequest.class))).
thenReturn(new DescribeTagsResult());
instanceOnlyAggregator = new ElapsedTimeAggregator("TEST", region, "i-500f6ca6", null, ec2Client, cloudWatchClient);
when(ec2Client.describeTags(any(DescribeTagsRequest.class))).
thenReturn(new DescribeTagsResult().withTags(
new TagDescription().
withKey("aws:autoscaling:groupName").
withValue("TEST")
));
asgAggregator = new ElapsedTimeAggregator("TEST", region, "i-500f6ca6", null, ec2Client, cloudWatchClient);
}
示例2: createInstance
import com.amazonaws.services.ec2.model.DescribeTagsResult; //导入依赖的package包/类
@Override
protected Map<String, String> createInstance() throws Exception {
LinkedHashMap<String, String> properties = new LinkedHashMap<>();
DescribeTagsResult tags = this.amazonEc2.describeTags(new DescribeTagsRequest().withFilters(
new Filter("resource-id", Collections.singletonList(this.idProvider.getCurrentInstanceId())),
new Filter("resource-type", Collections.singletonList("instance"))));
for (TagDescription tag : tags.getTags()) {
properties.put(tag.getKey(), tag.getValue());
}
return properties;
}
示例3: autoDetectStackName
import com.amazonaws.services.ec2.model.DescribeTagsResult; //导入依赖的package包/类
private String autoDetectStackName(String instanceId) {
Assert.notNull(instanceId, "No valid instance id defined");
DescribeStackResourcesResult describeStackResourcesResult = this.amazonCloudFormationClient.describeStackResources(new DescribeStackResourcesRequest().withPhysicalResourceId(instanceId));
if (describeStackResourcesResult != null && describeStackResourcesResult.getStackResources() != null &&
!describeStackResourcesResult.getStackResources().isEmpty()) {
return describeStackResourcesResult.getStackResources().get(0).getStackName();
}
if (this.amazonEc2Client != null) {
DescribeTagsResult describeTagsResult = this.amazonEc2Client.describeTags(new DescribeTagsRequest().withFilters(
new Filter("resource-id", Collections.singletonList(instanceId)),
new Filter("resource-type", Collections.singletonList("instance")),
new Filter("key", Collections.singletonList("aws:cloudformation:stack-name"))));
if (describeTagsResult != null && describeTagsResult.getTags() != null && !describeTagsResult.getTags().isEmpty()) {
return describeTagsResult.getTags().get(0).getValue();
}
}
return null;
}
示例4: getResourceTags
import com.amazonaws.services.ec2.model.DescribeTagsResult; //导入依赖的package包/类
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();
}
示例5: getInstanceName
import com.amazonaws.services.ec2.model.DescribeTagsResult; //导入依赖的package包/类
/**
* Fetches and instance's name Tag or null if it does not have one
* @param instanceId
* @param amazonEC2
* @return
*/
public static String getInstanceName(String instanceId, AmazonEC2 amazonEC2){
DescribeTagsResult result = amazonEC2.describeTags(new DescribeTagsRequest().withFilters(
new Filter().withName("resource-id").withValues(instanceId),
new Filter().withName("resource-type").withValues("instance"),
new Filter().withName("key").withValues(TAG_KEY_NAME)));
if(result.getTags().isEmpty()){
return null;
}
String name = result.getTags().get(0).getValue();
return name == null || name.trim().equals("") ? null : name;
}
示例6: getObject_userTagDataAvailable_objectContainsAllAvailableKeys
import com.amazonaws.services.ec2.model.DescribeTagsResult; //导入依赖的package包/类
@Test
public void getObject_userTagDataAvailable_objectContainsAllAvailableKeys() throws Exception {
//Arrange
AmazonEC2 amazonEC2 = mock(AmazonEC2.class);
InstanceIdProvider instanceIdProvider = mock(InstanceIdProvider.class);
when(instanceIdProvider.getCurrentInstanceId()).thenReturn("1234567890");
DescribeTagsRequest describeTagsRequest = new DescribeTagsRequest().withFilters(
new Filter("resource-id", Collections.singletonList("1234567890")),
new Filter("resource-type", Collections.singletonList("instance")));
DescribeTagsResult describeTagsResult = new DescribeTagsResult().withTags(
new TagDescription().withKey("keyA").withResourceType(ResourceType.Instance).withValue("valueA"),
new TagDescription().withKey("keyB").withResourceType(ResourceType.Instance).withValue("valueB")
);
when(amazonEC2.describeTags(describeTagsRequest)).thenReturn(describeTagsResult);
AmazonEc2InstanceUserTagsFactoryBean amazonEc2InstanceUserTagsFactoryBean = new AmazonEc2InstanceUserTagsFactoryBean(amazonEC2, instanceIdProvider);
//Act
amazonEc2InstanceUserTagsFactoryBean.afterPropertiesSet();
Map<String, String> resultMap = amazonEc2InstanceUserTagsFactoryBean.getObject();
//Assert
assertEquals("valueA", resultMap.get("keyA"));
assertEquals("valueB", resultMap.get("keyB"));
assertFalse(resultMap.containsKey("keyC"));
}
示例7: getTags
import com.amazonaws.services.ec2.model.DescribeTagsResult; //导入依赖的package包/类
/**
* Describe Tags.
* @return TagsDescription
*/
protected final List<TagDescription> getTags() {
DescribeTagsResult result = amazonEC2Client.describeTags();
List<TagDescription> tagsDesc = null;
if (result != null) {
tagsDesc = result.getTags();
}
return tagsDesc;
}
示例8: describeTags
import com.amazonaws.services.ec2.model.DescribeTagsResult; //导入依赖的package包/类
@Override
public DescribeTagsResult describeTags(DescribeTagsRequest describeTagsRequest) throws AmazonServiceException, AmazonClientException {
throw new UnsupportedOperationException("Not supported in mock");
}
示例9: getTags
import com.amazonaws.services.ec2.model.DescribeTagsResult; //导入依赖的package包/类
/**
* Gets a map of tags for an AWS EC2 instance
* @param instanceId the EC2 instance ID
* @return Map of AWS tags
*/
public Map<String, String> getTags(String instanceId) {
Filter filter = new Filter("resource-id", Arrays.asList(instanceId));
DescribeTagsResult result = amazonEC2Client.describeTags(new DescribeTagsRequest().withFilters(filter));
return result.getTags().stream().collect(Collectors.toMap(TagDescription::getKey, TagDescription::getValue));
}
示例10: describeTags
import com.amazonaws.services.ec2.model.DescribeTagsResult; //导入依赖的package包/类
public List<TagDescription> describeTags(DescribeTagsRequest request) {
logger.info("describe tags, request={}", request);
DescribeTagsResult result = ec2.describeTags(request);
Asserts.isNull(result.getNextToken(), "tags pagination is not supported yet, token={}", result.getNextToken());
return result.getTags();
}
示例11: load
import com.amazonaws.services.ec2.model.DescribeTagsResult; //导入依赖的package包/类
@Override
public boolean load(DescribeTagsRequest request,
ResultCapture<DescribeTagsResult> extractor) {
return resource.load(request, extractor);
}
示例12: load
import com.amazonaws.services.ec2.model.DescribeTagsResult; //导入依赖的package包/类
/**
* Makes a call to the service to load this resource's attributes if they
* are not loaded yet, and use a ResultCapture to retrieve the low-level
* client response
* The following request parameters will be populated from the data of this
* <code>Tag</code> resource, and any conflicting parameter value set in the
* request will be overridden:
* <ul>
* <li>
* <b><code>Filters[0].Values.0</code></b>
* - mapped from the <code>Key</code> identifier.
* </li>
* <li>
* <b><code>Filters[1].Values.0</code></b>
* - mapped from the <code>Value</code> identifier.
* </li>
* <li>
* <b><code>Filters[0].Name</code></b>
* - constant value <code>key</code>.
* </li>
* <li>
* <b><code>Filters[1].Name</code></b>
* - constant value <code>value</code>.
* </li>
* </ul>
*
* <p>
*
* @return Returns {@code true} if the resource is not yet loaded when this
* method was invoked, which indicates that a service call has been
* made to retrieve the attributes.
* @see DescribeTagsRequest
*/
boolean load(DescribeTagsRequest request, ResultCapture<DescribeTagsResult>
extractor);