当前位置: 首页>>代码示例>>Java>>正文


Java DescribeTagsResult类代码示例

本文整理汇总了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);
}
 
开发者ID:web-online,项目名称:cloudwatch-tomcat-valve,代码行数:22,代码来源:ElapsedTimeAggregatorTest.java

示例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;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:12,代码来源:AmazonEc2InstanceUserTagsFactoryBean.java

示例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;
    }
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:24,代码来源:AutoDetectingStackNameProvider.java

示例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();
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:10,代码来源:AWSUtils.java

示例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;
}
 
开发者ID:Kixeye,项目名称:chassis,代码行数:18,代码来源:AwsUtils.java

示例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"));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:31,代码来源:AmazonEc2InstanceUserTagsFactoryBeanTest.java

示例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;
}
 
开发者ID:treelogic-swe,项目名称:aws-mock,代码行数:16,代码来源:BaseTest.java

示例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");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AmazonEC2Mock.java

示例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));
}
 
开发者ID:shinesolutions,项目名称:aem-orchestrator,代码行数:11,代码来源:AwsHelperService.java

示例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();
}
 
开发者ID:neowu,项目名称:cmn-project,代码行数:7,代码来源:EC2.java

示例11: load

import com.amazonaws.services.ec2.model.DescribeTagsResult; //导入依赖的package包/类
@Override
public boolean load(DescribeTagsRequest request,
        ResultCapture<DescribeTagsResult> extractor) {

    return resource.load(request, extractor);
}
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:7,代码来源:TagImpl.java

示例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);
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:36,代码来源:Tag.java


注:本文中的com.amazonaws.services.ec2.model.DescribeTagsResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。