Java Code Examples for com.amazonaws.services.rds.model.DescribeDBInstancesRequest#setDBInstanceIdentifier()

The following examples show how to use com.amazonaws.services.rds.model.DescribeDBInstancesRequest#setDBInstanceIdentifier() . 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: RdsTableProvider.java    From aws-athena-query-federation with Apache License 2.0 6 votes vote down vote up
/**
 * Calls DescribeDBInstances on the AWS RDS Client returning all DB Instances that match the supplied predicate and attempting
 * to push down certain predicates (namely queries for specific DB Instance) to EC2.
 *
 * @See TableProvider
 */
@Override
public void readWithConstraint(BlockSpiller spiller, ReadRecordsRequest recordsRequest, QueryStatusChecker queryStatusChecker)
{
    boolean done = false;
    DescribeDBInstancesRequest request = new DescribeDBInstancesRequest();

    ValueSet idConstraint = recordsRequest.getConstraints().getSummary().get("instance_id");
    if (idConstraint != null && idConstraint.isSingleValue()) {
        request.setDBInstanceIdentifier(idConstraint.getSingleValue().toString());
    }

    while (!done) {
        DescribeDBInstancesResult response = rds.describeDBInstances(request);

        for (DBInstance instance : response.getDBInstances()) {
            instanceToRow(instance, spiller);
        }

        request.setMarker(response.getMarker());

        if (response.getMarker() == null || !queryStatusChecker.isQueryRunning()) {
            done = true;
        }
    }
}
 
Example 2
Source File: PublicAccessAutoFix.java    From pacbot with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the DB instance for rds db resource.
 *
 * @param clientMap the client map
 * @param resourceId the resource id
 * @return the DB instance for rds db resource
 * @throws Exception the exception
 */
public static List<DBInstance> getDBInstanceForRdsDbResource(Map<String,Object> clientMap,String resourceId) throws Exception {
    AmazonRDS amazonRDS = (AmazonRDS) clientMap.get("client");
    DescribeDBInstancesRequest instancesRequest = new DescribeDBInstancesRequest();
    instancesRequest.setDBInstanceIdentifier(resourceId);
    DescribeDBInstancesResult dbInstancesResult = amazonRDS.describeDBInstances(instancesRequest);
    
    return dbInstancesResult.getDBInstances();

}