mirror of https://github.com/apache/jclouds.git
Added a describeRouteTablesWithFilter so that Route Tables have capability similar to other EC2 objects that have a "describeXXXWithFilter" method along with their base "describeXXX" method.
Also modified the appropriate unit test with a test for this method
This commit is contained in:
parent
de0e3eddd2
commit
77e7c00184
|
@ -33,6 +33,7 @@ import org.jclouds.aws.ec2.xml.CreateRouteTableResponseHandler;
|
||||||
import org.jclouds.aws.ec2.xml.DescribeRouteTablesResponseHandler;
|
import org.jclouds.aws.ec2.xml.DescribeRouteTablesResponseHandler;
|
||||||
import org.jclouds.aws.ec2.xml.ReturnValueHandler;
|
import org.jclouds.aws.ec2.xml.ReturnValueHandler;
|
||||||
import org.jclouds.aws.filters.FormSigner;
|
import org.jclouds.aws.filters.FormSigner;
|
||||||
|
import org.jclouds.ec2.binders.BindFiltersToIndexedFormParams;
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
|
import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
|
||||||
import org.jclouds.rest.annotations.BinderParam;
|
import org.jclouds.rest.annotations.BinderParam;
|
||||||
|
@ -44,6 +45,7 @@ import org.jclouds.rest.annotations.VirtualHost;
|
||||||
import org.jclouds.rest.annotations.XMLResponseParser;
|
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||||
|
|
||||||
import com.google.common.collect.FluentIterable;
|
import com.google.common.collect.FluentIterable;
|
||||||
|
import com.google.common.collect.Multimap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to AWS Route Table services.
|
* Provides access to AWS Route Table services.
|
||||||
|
@ -267,6 +269,10 @@ public interface RouteTableApi {
|
||||||
/**
|
/**
|
||||||
* Describes route tables.
|
* Describes route tables.
|
||||||
* @param region The region to search for route tables.
|
* @param region The region to search for route tables.
|
||||||
|
* @param routeTableIds One or more identifiers for existing RouteTable instances
|
||||||
|
*
|
||||||
|
* @return a set of RouteTable objects that matched the routeTableIds passed
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
@Named("DescribeRouteTables")
|
@Named("DescribeRouteTables")
|
||||||
@POST
|
@POST
|
||||||
|
@ -276,4 +282,21 @@ public interface RouteTableApi {
|
||||||
FluentIterable<RouteTable> describeRouteTables(
|
FluentIterable<RouteTable> describeRouteTables(
|
||||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
|
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
|
||||||
@BinderParam(BindRouteTableIdsToIndexedFormParams.class) String... routeTableIds);
|
@BinderParam(BindRouteTableIdsToIndexedFormParams.class) String... routeTableIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Describes route tables.
|
||||||
|
* @param region The region to search for route tables.
|
||||||
|
* @param filter One or more filters utilized to search for RouteTable instances
|
||||||
|
*
|
||||||
|
* @link <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeRouteTables.html">...</a>
|
||||||
|
*/
|
||||||
|
@Named("DescribeRouteTables")
|
||||||
|
@POST
|
||||||
|
@FormParams(keys = ACTION, values = "DescribeRouteTables")
|
||||||
|
@XMLResponseParser(DescribeRouteTablesResponseHandler.class)
|
||||||
|
@Fallback(Fallbacks.EmptyFluentIterableOnNotFoundOr404.class)
|
||||||
|
FluentIterable<RouteTable> describeRouteTablesWithFilter(
|
||||||
|
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
|
||||||
|
@BinderParam(BindFiltersToIndexedFormParams.class) Multimap<String, String> filter);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ import com.google.common.collect.FluentIterable;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@link RouteTableApi}
|
* Tests behavior of {@link RouteTableApi}
|
||||||
|
@ -106,6 +107,22 @@ public class RouteTableApiLiveTest extends BaseApiLiveTest<AWSEC2Api> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
assertTrue(vpcRT.isPresent(), "Could not find VPC " + vpc.id() + " in described route tables");
|
assertTrue(vpcRT.isPresent(), "Could not find VPC " + vpc.id() + " in described route tables");
|
||||||
|
|
||||||
|
//Now test the Find by Filter version of the describeRouteTables
|
||||||
|
final FluentIterable<RouteTable> routeTablesByFilter = routeTableApi.describeRouteTablesWithFilter(TEST_REGION,
|
||||||
|
ImmutableMultimap.<String, String>builder()
|
||||||
|
.put("vpc-id", vpc.id())
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
assertNotNull(routeTablesByFilter, "Failed to return list of routeTablesByFilter");
|
||||||
|
Optional<RouteTable> vpcRTByFilter = Iterables.tryFind(routeTablesByFilter, new Predicate<RouteTable>() {
|
||||||
|
@Override public boolean apply(RouteTable input) {
|
||||||
|
return vpc.id().equals(input.vpcId());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
assertTrue(vpcRTByFilter.isPresent(), "Could not find VPC " + vpc.id() + " in described route tables");
|
||||||
|
|
||||||
|
|
||||||
RouteTable rt = vpcRT.get();
|
RouteTable rt = vpcRT.get();
|
||||||
assertEquals(rt.associationSet().size(), 1,
|
assertEquals(rt.associationSet().size(), 1,
|
||||||
"Route for test VPC has wrong number of associations, should be 1: " + rt.associationSet());
|
"Route for test VPC has wrong number of associations, should be 1: " + rt.associationSet());
|
||||||
|
|
Loading…
Reference in New Issue