mirror of https://github.com/apache/jclouds.git
Implements listAll method for LoadBalancersAPI (#32)
This commit is contained in:
parent
0b357adc7b
commit
757d288ae0
|
@ -192,7 +192,7 @@ public interface AzureComputeApi extends Closeable {
|
||||||
* </a>
|
* </a>
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
LoadBalancerApi getLoadBalancerApi(@PathParam("resourcegroup") String resourcegroup);
|
LoadBalancerApi getLoadBalancerApi(@Nullable @PathParam("resourcegroup") String resourcegroup);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The AvailabilitySet API includes operations for managing availability sets
|
* The AvailabilitySet API includes operations for managing availability sets
|
||||||
|
|
|
@ -45,34 +45,44 @@ import org.jclouds.rest.annotations.ResponseParser;
|
||||||
import org.jclouds.rest.annotations.SelectJson;
|
import org.jclouds.rest.annotations.SelectJson;
|
||||||
import org.jclouds.rest.binders.BindToJsonPayload;
|
import org.jclouds.rest.binders.BindToJsonPayload;
|
||||||
|
|
||||||
@Path("/resourcegroups/{resourcegroup}/providers/Microsoft.Network/loadBalancers")
|
/**
|
||||||
|
* The Load Balancer API includes operations for managing the load balancers in your subscription.
|
||||||
|
*
|
||||||
|
* @see <a href="https://docs.microsoft.com/en-us/rest/api/load-balancer/loadbalancers">docs</a>
|
||||||
|
*/
|
||||||
@RequestFilters({ OAuthFilter.class, ApiVersionFilter.class })
|
@RequestFilters({ OAuthFilter.class, ApiVersionFilter.class })
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public interface LoadBalancerApi {
|
public interface LoadBalancerApi {
|
||||||
|
|
||||||
@Named("loadbalancer:list")
|
@Named("loadbalancer:list")
|
||||||
@GET
|
@GET
|
||||||
|
@Path("/resourcegroups/{resourcegroup}/providers/Microsoft.Network/loadBalancers")
|
||||||
@SelectJson("value")
|
@SelectJson("value")
|
||||||
@Fallback(EmptyListOnNotFoundOr404.class)
|
@Fallback(EmptyListOnNotFoundOr404.class)
|
||||||
List<LoadBalancer> list();
|
List<LoadBalancer> list();
|
||||||
|
|
||||||
|
@Named("loadbalancer:listall")
|
||||||
|
@GET
|
||||||
|
@Path("/providers/Microsoft.Network/loadBalancers")
|
||||||
|
@SelectJson("value")
|
||||||
|
@Fallback(EmptyListOnNotFoundOr404.class)
|
||||||
|
List<LoadBalancer> listAll();
|
||||||
|
|
||||||
@Named("loadbalancer:get")
|
@Named("loadbalancer:get")
|
||||||
@Path("/{loadbalancername}")
|
@Path("/resourcegroups/{resourcegroup}/providers/Microsoft.Network/loadBalancers/{loadbalancername}")
|
||||||
@GET
|
@GET
|
||||||
@Fallback(NullOnNotFoundOr404.class)
|
@Fallback(NullOnNotFoundOr404.class)
|
||||||
LoadBalancer get(@PathParam("loadbalancername") String lbName);
|
LoadBalancer get(@PathParam("loadbalancername") String lbName);
|
||||||
|
|
||||||
@Named("loadbalancer:createOrUpdate")
|
@Named("loadbalancer:createOrUpdate")
|
||||||
@Path("/{loadbalancername}")
|
@Path("/resourcegroups/{resourcegroup}/providers/Microsoft.Network/loadBalancers/{loadbalancername}")
|
||||||
@PUT
|
@PUT
|
||||||
@MapBinder(BindToJsonPayload.class)
|
@MapBinder(BindToJsonPayload.class)
|
||||||
LoadBalancer createOrUpdate(@PathParam("loadbalancername") String lbName,
|
LoadBalancer createOrUpdate(@PathParam("loadbalancername") String lbName, @PayloadParam("location") String location, @Nullable @PayloadParam("tags") Map<String, String> tags, @Nullable @PayloadParam("sku") SKU sku,
|
||||||
@PayloadParam("location") String location, @Nullable @PayloadParam("tags") Map<String, String> tags,
|
|
||||||
@Nullable @PayloadParam("sku") SKU sku,
|
|
||||||
@PayloadParam("properties") LoadBalancerProperties properties);
|
@PayloadParam("properties") LoadBalancerProperties properties);
|
||||||
|
|
||||||
@Named("loadbalancer:delete")
|
@Named("loadbalancer:delete")
|
||||||
@Path("/{loadbalancername}")
|
@Path("/resourcegroups/{resourcegroup}/providers/Microsoft.Network/loadBalancers/{loadbalancername}")
|
||||||
@DELETE
|
@DELETE
|
||||||
@ResponseParser(URIParser.class)
|
@ResponseParser(URIParser.class)
|
||||||
@Fallback(NullOnNotFoundOr404.class)
|
@Fallback(NullOnNotFoundOr404.class)
|
||||||
|
|
|
@ -218,6 +218,23 @@ public class LoadBalancerApiLiveTest extends BaseComputeServiceContextLiveTest {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
||||||
|
public void testListAllLoadBalancers() {
|
||||||
|
List<LoadBalancer> result = lbApi.listAll();
|
||||||
|
|
||||||
|
// Verify we have something
|
||||||
|
assertNotNull(result);
|
||||||
|
assertTrue(result.size() > 0);
|
||||||
|
|
||||||
|
// Check that the load balancer matches the one we originally passed in
|
||||||
|
assertTrue(any(result, new Predicate<LoadBalancer>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(LoadBalancer input) {
|
||||||
|
return lb.name().equals(input.name());
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
||||||
public void testGetLoadBalancer() {
|
public void testGetLoadBalancer() {
|
||||||
lb = lbApi.get(lbName);
|
lb = lbApi.get(lbName);
|
||||||
|
@ -324,7 +341,7 @@ public class LoadBalancerApiLiveTest extends BaseComputeServiceContextLiveTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = { "testCreateLoadBalancer", "testListLoadBalancers", "testGetLoadBalancer", "testAddProbe",
|
@Test(dependsOnMethods = { "testCreateLoadBalancer", "testListLoadBalancers", "testListAllLoadBalancers", "testGetLoadBalancer", "testAddProbe",
|
||||||
"testAddLoadBalancingRule", "testAddBackendPool", "testAttachNodesToBackendPool", "testAddInboundNatRule" }, alwaysRun = true)
|
"testAddLoadBalancingRule", "testAddBackendPool", "testAttachNodesToBackendPool", "testAddInboundNatRule" }, alwaysRun = true)
|
||||||
public void deleteLoadBalancer() {
|
public void deleteLoadBalancer() {
|
||||||
URI uri = lbApi.delete(lbName);
|
URI uri = lbApi.delete(lbName);
|
||||||
|
|
|
@ -109,6 +109,19 @@ public class LoadBalancerApiMockTest extends BaseAzureComputeApiMockTest {
|
||||||
assertTrue(result.size() > 0);
|
assertTrue(result.size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void listAllLoadBalancers() throws InterruptedException {
|
||||||
|
server.enqueue(jsonResponse("/loadbalancerlistall.json").setResponseCode(200));
|
||||||
|
|
||||||
|
final LoadBalancerApi nsgApi = api.getLoadBalancerApi(resourcegroup);
|
||||||
|
List<LoadBalancer> result = nsgApi.listAll();
|
||||||
|
|
||||||
|
String path = String.format("/subscriptions/%s/providers/Microsoft.Network/loadBalancers?%s", subscriptionid, apiVersion);
|
||||||
|
assertSent(server, "GET", path);
|
||||||
|
|
||||||
|
assertNotNull(result);
|
||||||
|
assertTrue(result.size() > 0);
|
||||||
|
}
|
||||||
|
|
||||||
public void listLoadBalancersReturns404() throws InterruptedException {
|
public void listLoadBalancersReturns404() throws InterruptedException {
|
||||||
server.enqueue(response404());
|
server.enqueue(response404());
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
{
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"name": "testLoadBalancer",
|
||||||
|
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-loadbalancerapilivetest-nacx/providers/Microsoft.Network/loadBalancers/testLoadBalancer",
|
||||||
|
"etag": "W/\"1107154b-8717-486b-80c1-af99ec62897b\"",
|
||||||
|
"type": "Microsoft.Network/loadBalancers",
|
||||||
|
"location": "westeurope",
|
||||||
|
"properties": {
|
||||||
|
"provisioningState": "Succeeded",
|
||||||
|
"resourceGuid": "383708b3-8d4e-474c-8908-9c4e311ac0bf",
|
||||||
|
"frontendIPConfigurations": [
|
||||||
|
{
|
||||||
|
"name": "ipConfigs",
|
||||||
|
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-loadbalancerapilivetest-nacx/providers/Microsoft.Network/loadBalancers/testLoadBalancer/frontendIPConfigurations/ipConfigs",
|
||||||
|
"etag": "W/\"1107154b-8717-486b-80c1-af99ec62897b\"",
|
||||||
|
"properties": {
|
||||||
|
"provisioningState": "Succeeded",
|
||||||
|
"privateIPAllocationMethod": "Dynamic",
|
||||||
|
"publicIPAddress": {
|
||||||
|
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-loadbalancerapilivetest-nacx/providers/Microsoft.Network/publicIPAddresses/Ip4LoadBalancer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"backendAddressPools": [],
|
||||||
|
"loadBalancingRules": [],
|
||||||
|
"probes": [],
|
||||||
|
"inboundNatRules": [],
|
||||||
|
"outboundNatRules": [],
|
||||||
|
"inboundNatPools": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "testLoadBalancer",
|
||||||
|
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/other-rg/providers/Microsoft.Network/loadBalancers/testLoadBalancer",
|
||||||
|
"etag": "W/\"1107154b-8717-486b-80c1-af99ec62897b\"",
|
||||||
|
"type": "Microsoft.Network/loadBalancers",
|
||||||
|
"location": "westeurope",
|
||||||
|
"properties": {
|
||||||
|
"provisioningState": "Succeeded",
|
||||||
|
"resourceGuid": "383708b3-8d4e-474c-8908-9c4e311ac0bf",
|
||||||
|
"frontendIPConfigurations": [
|
||||||
|
{
|
||||||
|
"name": "ipConfigs",
|
||||||
|
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/other-rg/providers/Microsoft.Network/loadBalancers/testLoadBalancer/frontendIPConfigurations/ipConfigs",
|
||||||
|
"etag": "W/\"1107154b-8717-486b-80c1-af99ec62897b\"",
|
||||||
|
"properties": {
|
||||||
|
"provisioningState": "Succeeded",
|
||||||
|
"privateIPAllocationMethod": "Dynamic",
|
||||||
|
"publicIPAddress": {
|
||||||
|
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/other-rg/providers/Microsoft.Network/publicIPAddresses/Ip4LoadBalancer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"backendAddressPools": [],
|
||||||
|
"loadBalancingRules": [],
|
||||||
|
"probes": [],
|
||||||
|
"inboundNatRules": [],
|
||||||
|
"outboundNatRules": [],
|
||||||
|
"inboundNatPools": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue