Example usage for com.amazonaws.regions Region isServiceSupported

List of usage examples for com.amazonaws.regions Region isServiceSupported

Introduction

In this page you can find the example usage for com.amazonaws.regions Region isServiceSupported.

Prototype

public boolean isServiceSupported(String serviceName) 

Source Link

Document

Returns whether the given service is supported in this region.

Usage

From source file:com.optimalbi.AmazonAccount.java

License:Apache License

private void populateRedshift() throws AmazonClientException {
    for (Region region : getRegions()) {
        try {/* ww  w .j a  v a  2 s  .  c o  m*/
            if (region.isServiceSupported(ServiceAbbreviations.RedShift)) {
                //                    services.addAll(RedshiftService.populateServices(region, getCredentials(), getLogger()));
                AmazonRedshiftClient redshift = new AmazonRedshiftClient(getCredentials().getCredentials());
                redshift.setRegion(region);

                DescribeClustersResult clusterResult;
                List<Cluster> clusters;
                try {
                    clusterResult = redshift.describeClusters();
                    clusters = clusterResult.getClusters();
                } catch (Exception e) {
                    throw new AmazonClientException("Failed to get clusters " + e.getMessage());
                }

                getLogger().info("Redshift, Adding " + clusters.size() + " clusters from " + region.getName());
                for (Cluster cluster : clusters) {
                    getLogger().info("Cluster: " + cluster.getClusterIdentifier());
                    LocalRedshiftService temp = new LocalRedshiftService(cluster.getDBName(), getCredentials(),
                            region, cluster, getLogger());
                    if (servicePricings != null && servicePricings.size() > 0) {
                        temp.attachPricing(servicePricings.get(region).getRedshiftPricing());
                    }
                    services.add(temp);
                }
            } else {
                getLogger().info("Redshift, NOPE from " + region.getName());
            }
        } catch (AmazonClientException e) {
            throw new AmazonClientException(region.getName() + " " + e.getMessage());
        }
        completed.set(completed.get() + 1);
    }
}

From source file:com.optimalbi.AmazonAccount.java

License:Apache License

private void populateRDS() throws AmazonClientException {
    for (Region region : getRegions()) {
        try {//  w w w . jav  a2 s .  c  o  m
            if (region.isServiceSupported(ServiceAbbreviations.RDS)) {
                AmazonRDSClient rds = new AmazonRDSClient(getCredentials().getCredentials());
                rds.setRegion(region);

                DescribeDBInstancesResult result = rds.describeDBInstances();
                List<DBInstance> instances = result.getDBInstances();

                getLogger().info("RDS, Adding " + instances.size() + " instances from " + region.getName());

                for (DBInstance i : instances) {
                    LocalRDSService temp;
                    if (i.getDBName() != null) {
                        temp = new LocalRDSService(i.getDBName(), getCredentials(), region, i, getLogger());
                    } else {
                        temp = new LocalRDSService(i.getDBInstanceIdentifier(), getCredentials(), region, i,
                                getLogger());
                    }
                    if (servicePricings != null && servicePricings.size() > 0) {
                        if (servicePricings.get(region).getRDSPricing() != null) {
                            temp.attachPricing(servicePricings.get(region).getRDSPricing());
                        }
                    }
                    services.add(temp);
                }
            } else {
                getLogger().info("RDS, NOPE from " + region.getName());
            }
        } catch (AmazonClientException e) {
            throw new AmazonClientException(region.getName() + " " + e.getMessage());
        }
        completed.set(completed.get() + 1);
    }
}

From source file:com.optimalbi.AmazonAccount.java

License:Apache License

private void populateGlacier() throws AmazonClientException {
    for (Region r : regions) {
        if (r.isServiceSupported(ServiceAbbreviations.Glacier)) {
            AmazonGlacierClient glacierClient = new AmazonGlacierClient(credentials.getCredentials());
            glacierClient.setRegion(r);/* w w w .  j  a v a2s  .  c om*/
            ListVaultsResult result = glacierClient.listVaults(new ListVaultsRequest());
            List<DescribeVaultOutput> vaults = result.getVaultList();
            for (DescribeVaultOutput d : vaults) {
                DescribeVaultResult res = glacierClient
                        .describeVault(new DescribeVaultRequest(d.getVaultName()));
                Service temp = new LocalGlacierService(d.getVaultName(), credentials, r, res, logger);
                services.add(temp);
            }
        }
    }
}

From source file:com.optimalbi.Controller.AmazonAccount.java

License:Apache License

private void populateRedshift() throws AmazonClientException {
    for (Region region : getRegions()) {
        try {//from w w w.j  a  va  2s  .  c o  m
            if (region.isServiceSupported(ServiceAbbreviations.RedShift)) {
                //                    services.addAll(RedshiftService.populateServices(region, getCredentials(), getLogger()));
                AmazonRedshiftClient redshift = new AmazonRedshiftClient(getCredentials().getCredentials());
                redshift.setRegion(region);

                DescribeClustersResult clusterResult;
                List<Cluster> clusters;
                try {
                    clusterResult = redshift.describeClusters();
                    clusters = clusterResult.getClusters();
                } catch (Exception e) {
                    throw new AmazonClientException("Failed to get clusters " + e.getMessage());
                }

                getLogger().info("Redshift, Adding " + clusters.size() + " clusters from " + region.getName());
                for (Cluster cluster : clusters) {
                    getLogger().info("Cluster: " + cluster.getClusterIdentifier());
                    services.add(new LocalRedshiftService(cluster.getClusterIdentifier(), getCredentials(),
                            region, cluster, getLogger()));
                }
            } else {
                getLogger().info("Redshift, NOPE from " + region.getName());

            }
        } catch (AmazonClientException e) {
            throw new AmazonClientException(region.getName() + " " + e.getMessage());
        }
        completed.set(completed.get() + 1);
    }
}

From source file:com.optimalbi.Controller.AmazonAccount.java

License:Apache License

private void populateRDS() throws AmazonClientException {
    for (Region region : getRegions()) {
        try {//from   w w w . j  a v a  2s  .c  om
            if (region.isServiceSupported(ServiceAbbreviations.RDS)) {
                //                services.addAll(RDSService.populateServices(region, getCredentials(), getLogger()));
                AmazonRDSClient rds = new AmazonRDSClient(getCredentials().getCredentials());
                rds.setRegion(region);

                DescribeDBInstancesResult result = rds.describeDBInstances();
                List<DBInstance> instances = result.getDBInstances();

                getLogger().info("RDS, Adding " + instances.size() + " instances from " + region.getName());
                services.addAll(
                        instances
                                .stream().map(i -> new LocalRDSService(i.getDBInstanceIdentifier(),
                                        getCredentials(), region, i, getLogger()))
                                .collect(Collectors.toList()));
            } else {
                getLogger().info("RDS, NOPE from " + region.getName());
            }
        } catch (AmazonClientException e) {
            throw new AmazonClientException(region.getName() + " " + e.getMessage());
        }
        completed.set(completed.get() + 1);

    }
}

From source file:com.smoketurner.pipeline.application.config.AwsConfiguration.java

License:Apache License

@JsonIgnore
public AmazonS3Client buildS3(final Environment environment) {
    final Region region = Region.getRegion(this.region);
    Objects.requireNonNull(region);

    Preconditions.checkArgument(region.isServiceSupported("s3"), "S3 is not supported in " + region);

    final ClientConfiguration clientConfig = getClientConfiguration();
    final AmazonS3Client s3 = region.createClient(AmazonS3Client.class, provider, clientConfig);
    environment.lifecycle().manage(new AmazonS3ClientManager(s3));
    return s3;/*from  w  w w.ja v a 2  s.  c o  m*/
}

From source file:com.smoketurner.pipeline.application.config.AwsConfiguration.java

License:Apache License

@JsonIgnore
public AmazonSQSClient buildSQS(final Environment environment) {
    final Region region = Region.getRegion(this.region);
    Objects.requireNonNull(region);

    Preconditions.checkArgument(region.isServiceSupported("sqs"), "SQS is not supported in " + region);

    final ClientConfiguration clientConfig = getClientConfiguration();
    final AmazonSQSClient sqs = region.createClient(AmazonSQSClient.class, provider, clientConfig);
    environment.lifecycle().manage(new AmazonSQSClientManager(sqs));
    return sqs;//from   w  w  w.  j  av a  2s.  co  m
}