com.amazonaws.services.redshift.AmazonRedshift Java Examples
The following examples show how to use
com.amazonaws.services.redshift.AmazonRedshift.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ResourceTaggingManager.java From pacbot with Apache License 2.0 | 6 votes |
/** * * @param resourceId * @param clientMap * @param pacTag * @return */ private Boolean setRedshiftTag(final String resourceId, final Map<String, Object> clientMap, Map<String, String> pacTag) { com.amazonaws.services.redshift.model.Tag tag = new com.amazonaws.services.redshift.model.Tag(); for (Map.Entry<String, String> tags : pacTag.entrySet()) { tag.setKey(tags.getKey()); tag.setValue(tags.getValue()); } AmazonRedshift amazonRedshift = (AmazonRedshift) clientMap .get("client"); com.amazonaws.services.redshift.model.CreateTagsRequest createTagsRequest = new com.amazonaws.services.redshift.model.CreateTagsRequest(); createTagsRequest.setResourceName(resourceId); createTagsRequest.setTags(Arrays.asList(tag)); try { amazonRedshift.createTags(createTagsRequest); return Boolean.TRUE; } catch (AmazonServiceException ase) { logger.error("error tagging redshift - > " + resourceId, ase); throw ase; } }
Example #2
Source File: InventoryUtilTest.java From pacbot with Apache License 2.0 | 6 votes |
/** * Fetch redshift info test. * * @throws Exception the exception */ @SuppressWarnings("static-access") @Test public void fetchRedshiftInfoTest() throws Exception { mockStatic(AmazonRedshiftClientBuilder.class); AmazonRedshift redshiftClient = PowerMockito.mock(AmazonRedshift.class); AmazonRedshiftClientBuilder amazonRedshiftClientBuilder = PowerMockito.mock(AmazonRedshiftClientBuilder.class); AWSStaticCredentialsProvider awsStaticCredentialsProvider = PowerMockito.mock(AWSStaticCredentialsProvider.class); PowerMockito.whenNew(AWSStaticCredentialsProvider.class).withAnyArguments().thenReturn(awsStaticCredentialsProvider); when(amazonRedshiftClientBuilder.standard()).thenReturn(amazonRedshiftClientBuilder); when(amazonRedshiftClientBuilder.withCredentials(anyObject())).thenReturn(amazonRedshiftClientBuilder); when(amazonRedshiftClientBuilder.withRegion(anyString())).thenReturn(amazonRedshiftClientBuilder); when(amazonRedshiftClientBuilder.build()).thenReturn(redshiftClient); DescribeClustersResult describeClustersResult = new DescribeClustersResult(); List<com.amazonaws.services.redshift.model.Cluster> redshiftList = new ArrayList<>(); redshiftList.add(new com.amazonaws.services.redshift.model.Cluster()); describeClustersResult.setClusters(redshiftList); when(redshiftClient.describeClusters(anyObject())).thenReturn(describeClustersResult); assertThat(inventoryUtil.fetchRedshiftInfo(new BasicSessionCredentials("awsAccessKey", "awsSecretKey", "sessionToken"), "skipRegions", "account","accountName").size(), is(1)); }
Example #3
Source File: AmazonDockerClientsHolder.java From spring-localstack with Apache License 2.0 | 5 votes |
@Override public AmazonRedshift amazonRedshift() { return decorateWithConfigsAndBuild( AmazonRedshiftClientBuilder.standard(), LocalstackDocker::getEndpointRedshift ); }
Example #4
Source File: PublicAccessAutoFix.java From pacbot with Apache License 2.0 | 5 votes |
/** * Gets the cluster for redhift resource. * * @param clientMap the client map * @param resourceId the resource id * @return the cluster for redhift resource * @throws Exception the exception */ public static List<Cluster> getClusterForRedhiftResource(Map<String,Object> clientMap,String resourceId) throws Exception { AmazonRedshift amazonRedshift = (AmazonRedshift) clientMap.get("client"); DescribeClustersRequest describeClustersRequest = new DescribeClustersRequest(); describeClustersRequest.setClusterIdentifier(resourceId); DescribeClustersResult clustersResult = amazonRedshift.describeClusters(describeClustersRequest); return clustersResult.getClusters(); }
Example #5
Source File: PublicAccessAutoFix.java From pacbot with Apache License 2.0 | 5 votes |
/** * Apply security groups to redshift. * * @param amazonRedshift the amazon redshift * @param sgIdToBeAttached the sg id to be attached * @param resourceId the resource id * @return true, if successful * @throws Exception the exception */ public static boolean applySecurityGroupsToRedshift(AmazonRedshift amazonRedshift, Set<String> sgIdToBeAttached, String resourceId) throws Exception { boolean applysgFlg = false; try { ModifyClusterRequest clusterRequest = new ModifyClusterRequest(); clusterRequest.setClusterIdentifier(resourceId); clusterRequest.setVpcSecurityGroupIds(sgIdToBeAttached); amazonRedshift.modifyCluster(clusterRequest); applysgFlg = true; } catch (Exception e) { logger.error("Apply Security Group operation failed for redshift {}" ,resourceId ); throw new Exception(e); } return applysgFlg; }
Example #6
Source File: EveryAwsClientAutoConfiguration.java From spring-localstack with Apache License 2.0 | 4 votes |
@Bean public AmazonRedshift amazonRedshift() { return amazonClientsHolder.amazonRedshift(); }
Example #7
Source File: AmazonClientsHolder.java From spring-localstack with Apache License 2.0 | votes |
AmazonRedshift amazonRedshift();