use of com.amazonaws.services.elasticloadbalancingv2.model.DescribeLoadBalancersRequest in project cloudbreak by hortonworks.
the class AwsNativeMetadataCollector method describeLoadBalancer.
private Optional<CloudLoadBalancerMetadata> describeLoadBalancer(String loadBalancerArn, AmazonElasticLoadBalancingClient loadBalancingClient, List<CloudResource> resources) {
DescribeLoadBalancersRequest describeLoadBalancersRequest = new DescribeLoadBalancersRequest().withLoadBalancerArns(loadBalancerArn);
DescribeLoadBalancersResult describeLoadBalancersResult = loadBalancingClient.describeLoadBalancers(describeLoadBalancersRequest);
return describeLoadBalancersResult.getLoadBalancers().stream().findFirst().map(loadBalancer -> {
LoadBalancerType type = loadBalancerTypeConverter.convert(loadBalancer.getScheme());
Map<String, Object> parameters = awsNativeLbMetadataCollector.getParameters(loadBalancerArn, resources);
CloudLoadBalancerMetadata loadBalancerMetadata = new CloudLoadBalancerMetadata.Builder().withType(type).withCloudDns(loadBalancer.getDNSName()).withHostedZoneId(loadBalancer.getCanonicalHostedZoneId()).withName(loadBalancer.getLoadBalancerName()).withParameters(parameters).build();
LOGGER.info("Saved metadata for load balancer {}: DNS {}, zone ID {}", loadBalancer.getLoadBalancerName(), loadBalancer.getDNSName(), loadBalancer.getCanonicalHostedZoneId());
return loadBalancerMetadata;
});
}
use of com.amazonaws.services.elasticloadbalancingv2.model.DescribeLoadBalancersRequest in project iep by Netflix.
the class PaginationTest method elb.
@Test
public void elb() throws Exception {
SortedSet<String> pages = newPageSet(5);
final Iterator<String> reqIt = pages.iterator();
final Iterator<String> resIt = pages.iterator();
Function<DescribeLoadBalancersRequest, DescribeLoadBalancersResult> f = r -> {
if (r.getMarker() != null) {
Assert.assertEquals(reqIt.next(), r.getMarker());
}
return new DescribeLoadBalancersResult().withNextMarker(resIt.hasNext() ? resIt.next() : null);
};
Publisher<DescribeLoadBalancersResult> publisher = Pagination.createPublisher(new DescribeLoadBalancersRequest(), f);
Iterable<String> iter = Flowable.fromPublisher(publisher).filter(r -> r.getNextMarker() != null).map(DescribeLoadBalancersResult::getNextMarker).blockingIterable();
SortedSet<String> results = new TreeSet<>();
for (String s : iter) {
results.add(s);
}
Assert.assertEquals(pages, results);
Assert.assertFalse(reqIt.hasNext());
}
use of com.amazonaws.services.elasticloadbalancingv2.model.DescribeLoadBalancersRequest in project cloudbreak by hortonworks.
the class CloudFormationStackUtil method getLoadBalancerByLogicalId.
public LoadBalancer getLoadBalancerByLogicalId(AuthenticatedContext ac, String logicalId) {
String region = ac.getCloudContext().getLocation().getRegion().value();
AmazonElasticLoadBalancingClient amazonElbClient = awsClient.createElasticLoadBalancingClient(new AwsCredentialView(ac.getCloudCredential()), region);
String loadBalancerArn = getResourceArnByLogicalId(ac, logicalId, region);
DescribeLoadBalancersResult loadBalancersResult = amazonElbClient.describeLoadBalancers(new DescribeLoadBalancersRequest().withLoadBalancerArns(Collections.singletonList(loadBalancerArn)));
return loadBalancersResult.getLoadBalancers().get(0);
}
Aggregations