Search in sources :

Example 6 with ListTagsForResourceRequest

use of com.amazonaws.services.rds.model.ListTagsForResourceRequest in project spring-cloud-aws by awspring.

the class AmazonRdsDataSourceUserTagsFactoryBeanTest method getObject_instanceWithOutTags_emptyMapReturned.

@Test
void getObject_instanceWithOutTags_emptyMapReturned() throws Exception {
    // Arrange
    AmazonRDS amazonRds = mock(AmazonRDS.class);
    ResourceIdResolver resourceIdResolver = mock(ResourceIdResolver.class);
    AmazonIdentityManagement amazonIdentityManagement = mock(AmazonIdentityManagement.class);
    AmazonRdsDataSourceUserTagsFactoryBean factoryBean = new AmazonRdsDataSourceUserTagsFactoryBean(amazonRds, "test", amazonIdentityManagement);
    factoryBean.setResourceIdResolver(resourceIdResolver);
    factoryBean.setResourceIdResolver(resourceIdResolver);
    factoryBean.setRegion(Region.getRegion(Regions.EU_WEST_1));
    when(resourceIdResolver.resolveToPhysicalResourceId("test")).thenReturn("stack-test");
    when(amazonIdentityManagement.getUser()).thenReturn(new GetUserResult().withUser(new User("/", "aemruli", "123456789012", "arn:aws:iam::1234567890:user/aemruli", new Date())));
    when(amazonRds.listTagsForResource(new ListTagsForResourceRequest().withResourceName("arn:aws:rds:eu-west-1:1234567890:db:stack-test"))).thenReturn(new ListTagsForResourceResult());
    // Act
    factoryBean.afterPropertiesSet();
    Map<String, String> userTagMap = factoryBean.getObject();
    // Assert
    assertThat(userTagMap.isEmpty()).isTrue();
}
Also used : GetUserResult(com.amazonaws.services.identitymanagement.model.GetUserResult) User(com.amazonaws.services.identitymanagement.model.User) ResourceIdResolver(io.awspring.cloud.core.env.ResourceIdResolver) AmazonRDS(com.amazonaws.services.rds.AmazonRDS) ListTagsForResourceRequest(com.amazonaws.services.rds.model.ListTagsForResourceRequest) ListTagsForResourceResult(com.amazonaws.services.rds.model.ListTagsForResourceResult) AmazonIdentityManagement(com.amazonaws.services.identitymanagement.AmazonIdentityManagement) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 7 with ListTagsForResourceRequest

use of com.amazonaws.services.rds.model.ListTagsForResourceRequest in project datarouter by hotpads.

the class RdsService method getTags.

public ListTagsForResourceResult getTags(String instance) {
    String instanceArn = getInstance(instance).getDBInstanceArn();
    ListTagsForResourceRequest listTagsRequest = new ListTagsForResourceRequest().withResourceName(instanceArn);
    return getAmazonRdsReadOnlyClient().listTagsForResource(listTagsRequest);
}
Also used : ListTagsForResourceRequest(com.amazonaws.services.rds.model.ListTagsForResourceRequest)

Aggregations

ListTagsForResourceRequest (com.amazonaws.services.rds.model.ListTagsForResourceRequest)7 ListTagsForResourceResult (com.amazonaws.services.rds.model.ListTagsForResourceResult)6 AmazonIdentityManagement (com.amazonaws.services.identitymanagement.AmazonIdentityManagement)5 GetUserResult (com.amazonaws.services.identitymanagement.model.GetUserResult)5 User (com.amazonaws.services.identitymanagement.model.User)5 AmazonRDS (com.amazonaws.services.rds.AmazonRDS)5 Tag (com.amazonaws.services.rds.model.Tag)5 Date (java.util.Date)5 Test (org.junit.jupiter.api.Test)5 ResourceIdResolver (io.awspring.cloud.core.env.ResourceIdResolver)2 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)2 XmlBeanDefinitionReader (org.springframework.beans.factory.xml.XmlBeanDefinitionReader)2 ClassPathResource (org.springframework.core.io.ClassPathResource)2 DBInstance (com.amazonaws.services.rds.model.DBInstance)1 DescribeDBInstancesRequest (com.amazonaws.services.rds.model.DescribeDBInstancesRequest)1 DescribeDBInstancesResult (com.amazonaws.services.rds.model.DescribeDBInstancesResult)1 Endpoint (com.amazonaws.services.rds.model.Endpoint)1 LinkedHashMap (java.util.LinkedHashMap)1 DataSource (javax.sql.DataSource)1 BeanDefinitionBuilder (org.springframework.beans.factory.support.BeanDefinitionBuilder)1