diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeApi.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeApi.java
index 5a5a8587ba..08a6769492 100644
--- a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeApi.java
+++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeApi.java
@@ -106,7 +106,7 @@ public interface AzureComputeApi extends Closeable {
* @see docs
*/
@Delegate
- VirtualNetworkApi getVirtualNetworkApi(@PathParam("resourcegroup") String resourcegroup);
+ VirtualNetworkApi getVirtualNetworkApi(@Nullable @PathParam("resourcegroup") String resourcegroup);
/**
diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApi.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApi.java
index 5190d425d4..a5691740f1 100644
--- a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApi.java
+++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApi.java
@@ -44,40 +44,51 @@ import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.SelectJson;
import org.jclouds.rest.binders.BindToJsonPayload;
-@Path("/resourcegroups/{resourcegroup}/providers/Microsoft.Network/virtualNetworks")
+/**
+ * The Virtual Networks API includes operations for managing Azure virtual networks in your subscription.
+ *
+ * @see docs
+ */
+@Path("")
@RequestFilters({ OAuthFilter.class, ApiVersionFilter.class })
@Consumes(MediaType.APPLICATION_JSON)
public interface VirtualNetworkApi {
@Named("virtualnetwork:list")
+ @Path("/resourcegroups/{resourcegroup}/providers/Microsoft.Network/virtualNetworks")
@SelectJson("value")
@GET
@Fallback(EmptyListOnNotFoundOr404.class)
List list();
+ @Named("loadbalancer:listall")
+ @GET
+ @Path("/providers/Microsoft.Network/virtualNetworks")
+ @SelectJson("value")
+ @Fallback(EmptyListOnNotFoundOr404.class)
+ List listAll();
+
@Named("virtualnetwork:create_or_update")
- @Path("/{virtualnetworkname}")
+ @Path("/resourcegroups/{resourcegroup}/providers/Microsoft.Network/virtualNetworks/{virtualnetworkname}")
@MapBinder(BindToJsonPayload.class)
@PUT
- VirtualNetwork createOrUpdate(@PathParam("virtualnetworkname") String virtualnetworkname,
- @PayloadParam("location") String location, @Nullable @PayloadParam("tags") Map tags,
+ VirtualNetwork createOrUpdate(@PathParam("virtualnetworkname") String virtualnetworkname, @PayloadParam("location") String location, @Nullable @PayloadParam("tags") Map tags,
@PayloadParam("properties") VirtualNetwork.VirtualNetworkProperties properties);
@Named("virtualnetwork:get")
- @Path("/{virtualnetworkname}")
+ @Path("/resourcegroups/{resourcegroup}/providers/Microsoft.Network/virtualNetworks/{virtualnetworkname}")
@GET
@Fallback(NullOnNotFoundOr404.class)
VirtualNetwork get(@PathParam("virtualnetworkname") String virtualnetworkname);
@Named("virtualnetwork:delete")
- @Path("/{virtualnetworkname}")
+ @Path("/resourcegroups/{resourcegroup}/providers/Microsoft.Network/virtualNetworks/{virtualnetworkname}")
@DELETE
@ResponseParser(FalseOn204.class)
boolean delete(@PathParam("virtualnetworkname") String virtualnetworkname);
@Named("virtualnetwork:check_ip_address_availability")
- @Path("/{virtualnetworkname}/CheckIPAddressAvailability")
+ @Path("/resourcegroups/{resourcegroup}/providers/Microsoft.Network/virtualNetworks/{virtualnetworkname}/CheckIPAddressAvailability")
@GET
- IpAddressAvailabilityResult checkIPAddressAvailability(@PathParam("virtualnetworkname") String virtualnetworkname,
- @QueryParam("ipAddress") String ipAddress);
+ IpAddressAvailabilityResult checkIPAddressAvailability(@PathParam("virtualnetworkname") String virtualnetworkname, @QueryParam("ipAddress") String ipAddress);
}
diff --git a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiLiveTest.java b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiLiveTest.java
index 6fde0594ba..fe47074891 100644
--- a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiLiveTest.java
+++ b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiLiveTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.azurecompute.arm.features;
+import static com.google.common.collect.Iterables.any;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
@@ -39,6 +40,7 @@ import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
@Test(groups = "live", singleThreaded = true)
@@ -49,7 +51,7 @@ public class VirtualNetworkApiLiveTest extends BaseAzureComputeApiLiveTest {
private static final String TEST_IP_ADDRESS_USED_IN_PROVIDER = "10.20.0.7";
private String virtualNetworkName;
-
+ private VirtualNetwork vn;
@BeforeClass
@Override
@@ -75,7 +77,7 @@ public class VirtualNetworkApiLiveTest extends BaseAzureComputeApiLiveTest {
.builder().subnets(ImmutableList. of(subnet))
.addressSpace(AddressSpace.create(Arrays.asList(TEST_VIRTUALNETWORK_ADDRESS_PREFIX))).build();
- VirtualNetwork vn = api().createOrUpdate(virtualNetworkName, LOCATION, null, virtualNetworkProperties);
+ vn = api().createOrUpdate(virtualNetworkName, LOCATION, null, virtualNetworkProperties);
networkAvailablePredicate.create(resourceGroupName).apply(virtualNetworkName);
@@ -95,7 +97,31 @@ public class VirtualNetworkApiLiveTest extends BaseAzureComputeApiLiveTest {
@Test(dependsOnMethods = "createVirtualNetwork")
public void listVirtualNetworks() {
List vnList = api().list();
+
+ assertNotNull(vnList);
assertTrue(vnList.size() > 0);
+
+ assertTrue(any(vnList, new Predicate() {
+ @Override
+ public boolean apply(VirtualNetwork input) {
+ return vn.name().equals(input.name());
+ }
+ }));
+ }
+
+ @Test(dependsOnMethods = "createVirtualNetwork")
+ public void listAllVirtualNetworks() {
+ List vnList = api.getVirtualNetworkApi(null).listAll();
+
+ assertNotNull(vnList);
+ assertTrue(vnList.size() > 0);
+
+ assertTrue(any(vnList, new Predicate() {
+ @Override
+ public boolean apply(VirtualNetwork input) {
+ return vn.name().equals(input.name());
+ }
+ }));
}
@Test(dependsOnMethods = "getVirtualNetwork")
@@ -115,7 +141,7 @@ public class VirtualNetworkApiLiveTest extends BaseAzureComputeApiLiveTest {
deleteLoadBalancer(lbCreated);
}
- @Test(dependsOnMethods = { "listVirtualNetworks", "getVirtualNetwork", "checkIpAvailability" }, alwaysRun = true)
+ @Test(dependsOnMethods = { "listVirtualNetworks", "listAllVirtualNetworks", "getVirtualNetwork", "checkIpAvailability" }, alwaysRun = true)
public void deleteVirtualNetwork() {
boolean status = api().delete(virtualNetworkName);
assertTrue(status);
diff --git a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiMockTest.java b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiMockTest.java
index 11f7fe369d..419f86d95b 100644
--- a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiMockTest.java
+++ b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiMockTest.java
@@ -94,6 +94,17 @@ public class VirtualNetworkApiMockTest extends BaseAzureComputeApiMockTest {
assertEquals(vnList.size(), 3);
}
+ public void listAllVirtualNetworks() throws InterruptedException {
+ server.enqueue(jsonResponse("/listvirtualnetworksall.json"));
+
+ final VirtualNetworkApi vnApi = api.getVirtualNetworkApi(null);
+ List vnList = vnApi.listAll();
+ String path = String.format("/subscriptions/%s/providers/Microsoft.Network/virtualNetworks?%s", subscriptionid, apiVersion);
+
+ assertSent(server, "GET", path);
+ assertEquals(vnList.size(), 4);
+ }
+
public void listVirtualNetworkReturns404() throws InterruptedException {
server.enqueue(response404());
diff --git a/providers/azurecompute-arm/src/test/resources/listvirtualnetworksall.json b/providers/azurecompute-arm/src/test/resources/listvirtualnetworksall.json
new file mode 100644
index 0000000000..d0deaddee3
--- /dev/null
+++ b/providers/azurecompute-arm/src/test/resources/listvirtualnetworksall.json
@@ -0,0 +1,99 @@
+{
+ "value": [
+ {
+ "name": "mockvirtualnetwork",
+ "id": "/subscriptions/6b6748c8-3e69-4e27-9b71-df97a81c0bbc/resourceGroups/azurearmtesting/providers/Microsoft.Network/virtualNetworks/mockvirtualnetwork",
+ "etag": "W/\"0dcd223f-670c-49ca-abe7-5978d127c131\"",
+ "type": "Microsoft.Network/virtualNetworks",
+ "location": "westeurope",
+ "tags": {
+ "key": "value"
+ },
+ "properties": {
+ "provisioningState": "Succeeded",
+ "resourceGuid": "1568c76a-73a4-4a60-8dfb-53b823197ccb",
+ "addressSpace": {
+ "addressPrefixes": [
+ "10.2.0.0/16"
+ ]
+ },
+ "subnets": []
+ }
+ },
+ {
+ "name": "anothervirtualnetworks",
+ "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/azurearmtesting/providers/Microsoft.Network/virtualNetworks/anothervirtualnetworks",
+ "etag": "W/\"7604d8fe-f3b8-4fd4-ae52-ab503cc29097\"",
+ "type": "Microsoft.Network/virtualNetworks",
+ "location": "westeurope",
+ "tags": {
+ "key": "value"
+ },
+ "properties": {
+ "provisioningState": "Succeeded",
+ "resourceGuid": "5192bdb3-f6ed-44ad-bf4c-059cff905791",
+ "addressSpace": {
+ "addressPrefixes": [
+ "10.2.0.0/16"
+ ]
+ },
+ "subnets": []
+ }
+ },
+ {
+ "name": "myvirtualnetwork",
+ "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/azurearmtesting/providers/Microsoft.Network/virtualNetworks/myvirtualnetwork",
+ "etag": "W/\"bc7e1d77-eec0-4b91-ae80-afc33cf3c867\"",
+ "type": "Microsoft.Network/virtualNetworks",
+ "location": "westeurope",
+ "tags": {
+ "key": "value"
+ },
+ "properties": {
+ "provisioningState": "Succeeded",
+ "resourceGuid": "8da85637-833c-4445-a681-81ca3fb90044",
+ "addressSpace": {
+ "addressPrefixes": [
+ "10.2.0.0/16"
+ ]
+ },
+ "subnets": [
+ {
+ "name": "mysubnet",
+ "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/azurearmtesting/providers/Microsoft.Network/virtualNetworks/myvirtualnetwork/subnets/mysubnet",
+ "etag": "W/\"bc7e1d77-eec0-4b91-ae80-afc33cf3c867\"",
+ "properties": {
+ "provisioningState": "Succeeded",
+ "addressPrefix": "10.2.0.0/24",
+ "ipConfigurations": [
+ {
+ "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/azurearmtesting/providers/Microsoft.Network/networkInterfaces/myNic/ipConfigurations/myip1"
+ }
+ ]
+ }
+ }
+ ]
+ }
+ },
+ {
+ "name": "mockvirtualnetworkextra",
+ "id": "/subscriptions/6b6748c8-3e69-4e27-9b71-df97a81c0bbc/resourceGroups/other-rg/providers/Microsoft.Network/virtualNetworks/mockvirtualnetwork",
+ "etag": "W/\"0dcd223f-670c-49ca-abe7-5978d127c131\"",
+ "type": "Microsoft.Network/virtualNetworks",
+ "location": "westeurope",
+ "tags": {
+ "key": "value"
+ },
+ "properties": {
+ "provisioningState": "Succeeded",
+ "resourceGuid": "1568c76a-73a4-4a60-8dfb-53b823197ccb",
+ "addressSpace": {
+ "addressPrefixes": [
+ "10.2.0.0/16"
+ ]
+ },
+ "subnets": []
+ }
+ }
+ ]
+}