You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by an...@apache.org on 2017/11/22 13:32:55 UTC
jclouds git commit: This is the first commit of for SoftLayer Network
API set
Repository: jclouds
Updated Branches:
refs/heads/master ec03b710a -> a540daf3d
This is the first commit of for SoftLayer Network API set
minor code improvement
Syntax fix with coding standards
- added more test coverage to NetworkApiMockTest class
- minor clean up
- minor code improvement
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/a540daf3
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/a540daf3
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/a540daf3
Branch: refs/heads/master
Commit: a540daf3d67619eb2fb728b40b169d0418f10c2a
Parents: ec03b71
Author: William Chen <wi...@Williams-MacBook-Pro.local>
Authored: Thu Nov 16 16:08:09 2017 +0800
Committer: Andrea Turli <an...@gmail.com>
Committed: Wed Nov 22 14:32:22 2017 +0100
----------------------------------------------------------------------
.../org/jclouds/softlayer/SoftLayerApi.java | 7 +
.../org/jclouds/softlayer/domain/Network.java | 159 ++++++++
.../org/jclouds/softlayer/domain/Subnet.java | 162 ++++++++
.../jclouds/softlayer/features/NetworkApi.java | 185 ++++++++++
.../softlayer/features/NetworkApiLiveTest.java | 207 +++++++++++
.../softlayer/features/NetworkApiMockTest.java | 370 +++++++++++++++++++
.../test/resources/network_createObject.json | 7 +
.../test/resources/network_createSubnet.json | 18 +
.../src/test/resources/network_get_153001.json | 8 +
.../src/test/resources/network_list.json | 41 ++
.../resources/network_subnet_get_1592631.json | 26 ++
11 files changed, 1190 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds/blob/a540daf3/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApi.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApi.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApi.java
index 5c57918..14c0171 100644
--- a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApi.java
+++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApi.java
@@ -19,6 +19,7 @@ package org.jclouds.softlayer;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.softlayer.features.AccountApi;
import org.jclouds.softlayer.features.DatacenterApi;
+import org.jclouds.softlayer.features.NetworkApi;
import org.jclouds.softlayer.features.SoftwareDescriptionApi;
import org.jclouds.softlayer.features.VirtualGuestApi;
import org.jclouds.softlayer.features.VirtualGuestBlockDeviceTemplateGroupApi;
@@ -56,4 +57,10 @@ public interface SoftLayerApi extends Closeable {
*/
@Delegate
AccountApi getAccountApi();
+
+ /**
+ * Provides access to Network features.
+ */
+ @Delegate
+ NetworkApi getNetworkApi();
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/a540daf3/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/Network.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/Network.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/Network.java
new file mode 100644
index 0000000..5be402f
--- /dev/null
+++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/Network.java
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.softlayer.domain;
+
+import com.google.auto.value.AutoValue;
+import com.google.common.collect.ImmutableList;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.json.SerializedNames;
+
+import java.util.List;
+
+/**
+ * Class Network
+ *
+ * @see <a href= "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Network" />
+ */
+
+@AutoValue
+public abstract class Network {
+
+ public abstract long accountId();
+ public abstract long id();
+ public abstract int cidr();
+ public abstract String networkIdentifier();
+ @Nullable
+ public abstract String name();
+ @Nullable
+ public abstract String notes();
+ @Nullable
+ public abstract List<Subnet> subnets();
+
+ @SerializedNames({"accountId", "id", "cidr", "networkIdentifier", "name", "notes", "subnets"})
+ public static Network create(final long id, final long accountId, int cidr, String networkIdentifier, String name,
+ String notes, List<Subnet> subnets) {
+ return new AutoValue_Network(id, accountId, cidr, networkIdentifier, name, notes,
+ subnets == null ? ImmutableList.<Subnet> of() : ImmutableList.copyOf(subnets));
+ }
+
+ Network() {}
+
+ @AutoValue
+ public abstract static class CreateNetwork {
+
+ public abstract String networkIdentifier();
+ public abstract String name();
+ public abstract int cidr();
+ @Nullable
+ public abstract String notes();
+
+ @SerializedNames({"networkIdentifier", "name", "cidr", "notes"})
+ private static CreateNetwork create(final String networkIdentifier, final String name, final int cidr, @Nullable final String notes) {
+ return builder()
+ .networkIdentifier(networkIdentifier)
+ .name(name)
+ .cidr(cidr)
+ .notes(notes)
+ .build();
+ }
+
+ public static Builder builder() {
+ return new AutoValue_Network_CreateNetwork.Builder();
+ }
+
+ @AutoValue.Builder
+ public abstract static class Builder {
+
+ public abstract Builder networkIdentifier(String networkIdentifier);
+ public abstract Builder name(String name);
+ public abstract Builder cidr(int cidr);
+ @Nullable
+ public abstract Builder notes(String notes);
+
+ abstract CreateNetwork autoBuild();
+
+ public CreateNetwork build() {
+ return autoBuild();
+ }
+ }
+ }
+
+ @AutoValue
+ public abstract static class EditNetwork {
+
+ public abstract String name();
+ public abstract String notes();
+ public abstract long id();
+
+ @SerializedNames({"name", "notes", "id"})
+ private static EditNetwork create(final String name, final String notes, final long id) {
+ return builder()
+ .name(name)
+ .notes(notes)
+ .id(id)
+ .build();
+ }
+
+ public static Builder builder() {
+ return new AutoValue_Network_EditNetwork.Builder();
+ }
+
+ @AutoValue.Builder
+ public abstract static class Builder {
+
+ public abstract Builder name(String name);
+ public abstract Builder notes(String notes);
+ public abstract Builder id(long id);
+
+ abstract EditNetwork autoBuild();
+
+ public EditNetwork build() {
+ return autoBuild();
+ }
+ }
+ }
+
+ @AutoValue
+ public abstract static class DeleteNetwork {
+
+ public abstract long id();
+
+ @SerializedNames({"id"})
+ private static DeleteNetwork create(final long id) {
+ return builder()
+ .id(id)
+ .build();
+ }
+
+ public static Builder builder() {
+ return new AutoValue_Network_DeleteNetwork.Builder();
+ }
+
+ @AutoValue.Builder
+ public abstract static class Builder {
+
+ public abstract Builder id(long id);
+
+ abstract DeleteNetwork autoBuild();
+
+ public DeleteNetwork build() {
+ return autoBuild();
+ }
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/jclouds/blob/a540daf3/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/Subnet.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/Subnet.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/Subnet.java
new file mode 100644
index 0000000..598f660
--- /dev/null
+++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/Subnet.java
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.softlayer.domain;
+
+import com.google.auto.value.AutoValue;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.json.SerializedNames;
+
+import java.util.Date;
+
+/**
+ * Class SecurityGroup
+ *
+ * @see <a href= "http://sldn.softlayer.com/reference/datatypes/softlayer_network_subnet" />
+ */
+
+@AutoValue
+public abstract class Subnet {
+
+ public abstract String boradcastAddress();
+ public abstract int cidr();
+ public abstract String gateway();
+ public abstract long id();
+ public abstract boolean isCustomerOwned();
+ public abstract boolean isCustomerRoutable();
+ @Nullable
+ public abstract Date modifyDate();
+ public abstract String netmask();
+ public abstract String networkIdentifier();
+ public abstract long networkVlanId();
+ @Nullable
+ public abstract String note();
+ public abstract String sortOrder();
+ @Nullable
+ public abstract String subnetType();
+ public abstract String totalIpAddresses();
+ public abstract String usableIpAddressCount();
+ public abstract int version();
+ @Nullable
+ public abstract String addressSpace();
+
+ @SerializedNames({"broadcastAddress", "cidr", "gateway", "id", "isCustomerOwned", "isCustomerRoutable", "modifyDate",
+ "netmask", "networkIdentifier", "networkVlanId", "note", "sortOrder", "subnetType", "totalIpAddresses",
+ "usableIpAddressCount", "version", "addressSpace"})
+ public static Subnet create(String broadcastAddress, int cidr, String gateway, final long id, boolean isCustomerOwned, boolean isCustomerRoutable,
+ Date modifyDate, String netmask, String networkIdentifier, long networkVlanId, String note, String sortOrder, String subnetType,
+ String totalIpAddresses, String usableIpAddressCount, int version, String addressSpace) {
+ return new AutoValue_Subnet(broadcastAddress, cidr, gateway, id, isCustomerOwned, isCustomerRoutable, modifyDate, netmask,
+ networkIdentifier, networkVlanId, note, sortOrder, subnetType, totalIpAddresses, usableIpAddressCount, version, addressSpace);
+ }
+
+ Subnet() {}
+
+ @AutoValue
+ public abstract static class CreateSubnet {
+
+ public abstract String networkIdentifier();
+ public abstract String note();
+ public abstract int cidr();
+
+ @SerializedNames({"networkIdentifier", "note", "cidr"})
+ private static CreateSubnet create(final String networkIdentifier, final String note, final int cidr) {
+ return builder()
+ .networkIdentifier(networkIdentifier)
+ .cidr(cidr)
+ .note(note)
+ .build();
+ }
+
+ public static Builder builder() {
+ return new AutoValue_Subnet_CreateSubnet.Builder();
+ }
+
+ @AutoValue.Builder
+ public abstract static class Builder {
+
+ public abstract Builder networkIdentifier(String networkIdentifier);
+ public abstract Builder note(String note);
+ public abstract Builder cidr(int cidr);
+
+ abstract CreateSubnet autoBuild();
+
+ public CreateSubnet build() {
+ return autoBuild();
+ }
+ }
+ }
+
+ @AutoValue
+ public abstract static class DeleteSubnet {
+
+ public abstract long id();
+
+ @SerializedNames({"id"})
+ private static DeleteSubnet create(final long id) {
+ return builder()
+ .id(id)
+ .build();
+ }
+
+ public static Builder builder() {
+ return new AutoValue_Subnet_DeleteSubnet.Builder();
+ }
+
+ @AutoValue.Builder
+ public abstract static class Builder {
+
+ public abstract Builder id(long id);
+
+ abstract DeleteSubnet autoBuild();
+
+ public DeleteSubnet build() {
+ return autoBuild();
+ }
+ }
+ }
+
+ @AutoValue
+ public abstract static class CreateDatacenterName {
+ public abstract String name();
+
+ @SerializedNames({"name"})
+ public static CreateDatacenterName create(String name) {
+ return builder()
+ .name(name)
+ .build();
+ }
+
+ CreateDatacenterName() {}
+
+ public static Builder builder() {
+ return new AutoValue_Subnet_CreateDatacenterName.Builder();
+ }
+
+ @AutoValue.Builder
+ public abstract static class Builder {
+
+ public abstract Builder name(String name);
+
+ abstract CreateDatacenterName autoBuild();
+
+ public CreateDatacenterName build() {
+ return autoBuild();
+ }
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/jclouds/blob/a540daf3/providers/softlayer/src/main/java/org/jclouds/softlayer/features/NetworkApi.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/features/NetworkApi.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/features/NetworkApi.java
new file mode 100644
index 0000000..a05e00e
--- /dev/null
+++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/features/NetworkApi.java
@@ -0,0 +1,185 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.softlayer.features;
+
+import org.jclouds.Fallbacks;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.http.filters.BasicAuthentication;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.QueryParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.WrapWith;
+import org.jclouds.softlayer.domain.Network;
+import org.jclouds.softlayer.domain.Subnet;
+
+import javax.inject.Named;
+import javax.ws.rs.Path;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.Produces;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.DELETE;
+
+import javax.ws.rs.core.MediaType;
+import java.io.Closeable;
+import java.util.List;
+
+/**
+ * Provides access to Network via their REST API.
+ * <p/>
+ * @see <a href="http://sldn.softlayer.com/article/REST" />
+ */
+@RequestFilters(BasicAuthentication.class)
+@Path("/v{jclouds.api-version}")
+@Consumes(MediaType.APPLICATION_JSON)
+public interface NetworkApi extends Closeable {
+
+ String NAME_MASK = "mask.subnets";
+
+ /**
+ * returns a list of networks belong to the account
+ * @return an account's associated network objects.
+ * @see <a href="http://sldn.softlayer.com/reference/services/softlayer_network/getallobjects" />
+ */
+ @GET
+ @Named("Network:getAlllObjects")
+ @Path("/SoftLayer_Network/getAllObjects")
+ @Produces(MediaType.APPLICATION_JSON)
+ @QueryParams(keys = "objectMask", values = NAME_MASK)
+ @Fallback(Fallbacks.EmptyListOnNotFoundOr404.class)
+ List<Network> listNetworks();
+
+ /**
+ * returns the name of the network of the given id
+ * @param id id of the network
+ * @return String or null
+ * @see <a href="http://sldn.softlayer.com/reference/services/softlayer_network/getname" />
+ */
+ @GET
+ @Named("Network:getName")
+ @Path("/SoftLayer_Network/{id}/getName")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Fallback(NullOnNotFoundOr404.class)
+ String getName(@PathParam("id") long id);
+
+ /**
+ * returns the notes of the network of the given id
+ * @param id id of the network
+ * @return String or null
+ * @see <a href="http://sldn.softlayer.com/reference/services/softlayer_network/getnotes" />
+ */
+ @GET
+ @Named("Network:getNotes")
+ @Path("/SoftLayer_Network/{id}/getNotes")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Fallback(NullOnNotFoundOr404.class)
+ String getNotes(@PathParam("id") long id);
+
+ /**
+ * returns the details of the network of the given id
+ * @param id id of the network
+ * @return String or null
+ * @see <a href="http://sldn.softlayer.com/reference/services/softlayer_network/getObject" />
+ */
+ @GET
+ @Named("Network:getObject")
+ @Path("/SoftLayer_Network/{id}/getObject")
+ @Produces(MediaType.APPLICATION_JSON)
+ @QueryParams(keys = "objectMask", values = NAME_MASK)
+ @Fallback(NullOnNotFoundOr404.class)
+ Network getNetwork(@PathParam("id") long id);
+
+ /**
+ * returns the subnets of the network of the given id
+ * @param id id of the network
+ * @return list of subnets under the network or null
+ * @see <a href="http://sldn.softlayer.com/reference/services/softlayer_network/getSubnet" />
+ */
+ @GET
+ @Named("Network:getSubnets")
+ @Path("/SoftLayer_Network/{id}/getSubnets")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.EmptyListOnNotFoundOr404.class)
+ List<Subnet> getSubnets(@PathParam("id") long id);
+
+ /**
+ * creates a network
+ * @param networkToBeCreated the network creation definition of Network.CreateNetwork
+ * @return Network created
+ * @see <a href="http://sldn.softlayer.com/reference/services/SoftLayer_network/createObject" />
+ */
+ @POST
+ @Named("network:createObject")
+ @Path("/SoftLayer_Network/createObject")
+ @Produces(MediaType.APPLICATION_JSON)
+ Network createNetwork(@WrapWith("parameters") List<Network.CreateNetwork> networkToBeCreated);
+
+ /**
+ * modifies a network with the given id
+ * @param id the id of the network to be edited
+ * @param networkToBeEdited the network edition definition of Network.EditNetwork
+ * @return true when edition was successful and false for unsuccessful edition
+ * @see <a href="http://sldn.softlayer.com/reference/services/SoftLayer_network/editObject" />
+ */
+ @PUT
+ @Named("Network:editObject")
+ @Path("/SoftLayer_Network/{id}/editObject")
+ @Fallback(Fallbacks.FalseOnNotFoundOr404.class)
+ boolean editNetwork(@PathParam("id") long id, @WrapWith("parameters") List<Network.EditNetwork> networkToBeEdited);
+
+ /**
+ * deletes a network with the given id
+ * @param id the id of the network to be deleted
+ * @return boolean value true for successful deletion and false for failed deletion
+ * @see <a href="http://sldn.softlayer.com/reference/services/SoftLayer_network/deleteObject" />
+ */
+ @DELETE
+ @Named("network:deleteObject")
+ @Path("/SoftLayer_Network/{id}")
+ @Fallback(Fallbacks.FalseOnNotFoundOr404.class)
+ boolean deleteNetwork(@PathParam("id") long id);
+
+ /**
+ * creates a subnet on the given network
+ * @param id the id of the network to be edited
+ * @param subnetToBeCreated the subnet creation definition of Subnet.CreateSubnet
+ * @return subnet created
+ * @see <a href="http://sldn.softlayer.com/reference/services/softlayer_network/createSubnet" />
+ */
+ @POST
+ @Named("Network:createSubnet")
+ @Path("/SoftLayer_Network/{id}/createSubnet")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Fallback(NullOnNotFoundOr404.class)
+ Subnet createSubnet(@PathParam("id") long id, @WrapWith("parameters") List<Object> subnetToBeCreated);
+
+ /**
+ * removes the subnet of the given network
+ * @param id id of the targeted seurity group
+ * @param subnetToBeDeleted the subnet deletion definition of Subnet.DeleteSubnet
+ * @reutrn boolean value true for successful deletion and false for failed deletion
+ * @see <a href="http://sldn.softlayer.com/reference/services/softlayer_network/deleteSubnet" />
+ */
+ @POST
+ @Named("Network:deleteSubnet")
+ @Path("/SoftLayer_Network/{id}/deleteSubnet")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.FalseOnNotFoundOr404.class)
+ boolean deleteSubnet(@PathParam("id") long id, @WrapWith("parameters") List<Subnet.DeleteSubnet> subnetToBeDeleted);
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/a540daf3/providers/softlayer/src/test/java/org/jclouds/softlayer/features/NetworkApiLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/NetworkApiLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/NetworkApiLiveTest.java
new file mode 100644
index 0000000..638e3ac
--- /dev/null
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/NetworkApiLiveTest.java
@@ -0,0 +1,207 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.softlayer.features;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+import org.jclouds.softlayer.domain.Network;
+import org.jclouds.softlayer.domain.Subnet;
+import org.jclouds.softlayer.domain.Datacenter;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import java.util.List;
+import java.util.ArrayList;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertNull;
+
+/**
+ * Tests behavior of {@code NetworkApi}
+ */
+@Test(groups = "live")
+public class NetworkApiLiveTest extends BaseSoftLayerApiLiveTest {
+
+ private NetworkApi networkApi;
+
+ private Network network = null;
+ private Subnet subnet = null;
+
+ private Datacenter datacenter = null;
+
+ @BeforeClass(groups = {"integration", "live"})
+ @Override
+ public void setup() {
+ super.setup();
+
+ networkApi = api.getNetworkApi();
+
+ datacenter = Iterables.get(api.getDatacenterApi().listDatacenters(), 0);
+ assertNotNull(datacenter, "Datacenter must not be null");
+ }
+
+ @Test
+ public void testCreateNetwork() throws Exception {
+ Network.CreateNetwork createNetwork = Network.CreateNetwork.builder()
+ .networkIdentifier("192.168.253.0")
+ .name("NetworkApiLiveTestNetwork")
+ .cidr(24)
+ .notes("this is a test network from jclouds NetworkApiLiveTest.")
+ .build();
+
+ network = networkApi.createNetwork(ImmutableList.of(createNetwork));
+
+ checkNetwork(network);
+ }
+
+ @Test(dependsOnMethods = "testCreateNetwork")
+ public void testListNetworks() throws Exception {
+ List<Network> response = networkApi.listNetworks();
+ assertNotNull(response, "listNetworks returns null");
+
+ boolean found = false;
+
+ for (Network n : response) {
+ Network newDetails = networkApi.getNetwork(n.id());
+ assertEquals(n.id(), newDetails.id());
+ checkNetwork(newDetails);
+ if (n.id() == network.id()) {
+ found = true;
+ assertEquals(n.cidr(), network.cidr());
+ assertEquals(n.networkIdentifier(), network.networkIdentifier());
+ assertEquals(n.name(), n.name());
+ }
+ }
+
+ assertTrue(found, "List Networks didn't return created network.");
+ }
+
+ @Test(dependsOnMethods = "testCreateNetwork")
+ public void testGetNetwork() throws Exception {
+ Network found = networkApi.getNetwork(network.id());
+ assertEquals(found, network);
+ checkNetwork(found);
+ assertEquals(found.networkIdentifier(), "192.168.253.0");
+ assertEquals(found.name(), "NetworkApiLiveTestNetwork");
+ assertEquals(found.cidr(), 24);
+ assertEquals(found.notes(), "this is a test network from jclouds NetworkApiLiveTest.");
+ }
+
+ @Test(dependsOnMethods = "testCreateNetwork")
+ public void testGetName() throws Exception {
+ String name = networkApi.getName(network.id());
+
+ assertEquals(name, "NetworkApiLiveTestNetwork");
+ }
+
+ @Test(dependsOnMethods = "testCreateNetwork")
+ public void testGetNotes() throws Exception {
+ String notes = networkApi.getNotes(network.id());
+
+ assertEquals(notes, "this is a test network from jclouds NetworkApiLiveTest.");
+ }
+
+ @Test(dependsOnMethods = "testCreateNetwork")
+ public void testCreateSubnet() throws Exception {
+ Subnet.CreateSubnet createSubnet = Subnet.CreateSubnet.builder()
+ .networkIdentifier("192.168.253.0")
+ .cidr(28)
+ .note("This is a test subnet from NetworkApiLiveTest")
+ .build();
+
+ Subnet.CreateDatacenterName createDatacenterName = Subnet.CreateDatacenterName.builder()
+ .name("dal10.pod01")
+ .build();
+
+ List<Object> parameters = new ArrayList<Object>();
+ parameters.add(createSubnet);
+ parameters.add(createDatacenterName);
+
+ subnet = networkApi.createSubnet(network.id(), parameters);
+
+ network = networkApi.getNetwork(network.id());
+ assertEquals(network.subnets().size(), 1);
+ }
+
+ @Test(dependsOnMethods = "testCreateSubnet")
+ public void testGetSubnets() throws Exception {
+ List<Subnet> subnets = networkApi.getSubnets(network.id());
+
+ assertEquals(subnets.size(), 1);
+ assertEquals(subnets.get(0).id(), subnet.id());
+ assertEquals(subnets.get(0).cidr(), subnet.cidr());
+ assertEquals(subnets.get(0).networkIdentifier(), subnet.networkIdentifier());
+ assertEquals(subnets.get(0).note(), subnet.note());
+ }
+
+ @Test(dependsOnMethods = "testGetSubnets")
+ public void testDeleteSubnet() throws Exception {
+ Subnet.DeleteSubnet deleteSubnet = Subnet.DeleteSubnet.builder()
+ .id(subnet.id())
+ .build();
+
+
+ List<Subnet.DeleteSubnet> parameters = new ArrayList<Subnet.DeleteSubnet>();
+ parameters.add(deleteSubnet);
+
+ boolean deletion = networkApi.deleteSubnet(network.id(), parameters);
+
+ assertTrue(deletion, "deletion of subnet failed");
+
+ List<Subnet> subnets = networkApi.getSubnets(network.id());
+ assertEquals(subnets.size(), 0);
+
+ subnet = null;
+ }
+
+ @Test(dependsOnMethods = "testGetNetwork")
+ public void testEditNetwork() throws Exception {
+ Network.EditNetwork editNetwork = Network.EditNetwork.builder()
+ .name("newNetworkApiLiveTestNetwork")
+ .notes("new notes")
+ .id(network.id())
+ .build();
+
+ boolean edit = networkApi.editNetwork(network.id(), ImmutableList.of(editNetwork));
+ assertTrue(edit, "edition failed");
+
+ Network newFound = networkApi.getNetwork(network.id());
+ assertEquals(newFound.name(), "newNetworkApiLiveTestNetwork");
+ assertEquals(newFound.notes(), "new notes");
+
+ network = newFound;
+ }
+
+ @Test(dependsOnMethods = "testDeleteSubnet")
+ public void testDeleteNetwork() throws Exception {
+ boolean deletion = networkApi.deleteNetwork(network.id());
+
+ Network found = networkApi.getNetwork(network.id());
+ assertNull(found, "deletion failed");
+
+ network = null;
+ }
+
+ private void checkNetwork(Network n) {
+ assertNotNull(n.id());
+ assertNotNull(n.name());
+ assertNotNull(n.networkIdentifier());
+ assertNotNull(n.cidr());
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/a540daf3/providers/softlayer/src/test/java/org/jclouds/softlayer/features/NetworkApiMockTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/NetworkApiMockTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/NetworkApiMockTest.java
new file mode 100644
index 0000000..5cf3e26
--- /dev/null
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/NetworkApiMockTest.java
@@ -0,0 +1,370 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.softlayer.features;
+
+import com.google.common.collect.ImmutableList;
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
+import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
+import org.jclouds.softlayer.SoftLayerApi;
+import org.jclouds.softlayer.config.SoftLayerParserModule;
+import org.jclouds.softlayer.domain.Network;
+import org.jclouds.softlayer.domain.Subnet;
+import org.jclouds.softlayer.internal.BaseSoftLayerMockTest;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static com.google.common.collect.Iterables.size;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertFalse;
+/**
+ * Mock tests for the {@link NetworkApi} class.
+ */
+@Test(groups = "unit", testName = "SecurityGroupApiMockTest")
+public class NetworkApiMockTest extends BaseSoftLayerMockTest {
+
+ public void testListNetworks() throws Exception {
+ MockWebServer server = mockWebServer(new MockResponse().setBody(payloadFromResource("/network_list.json")));
+ NetworkApi api = getNetworkApi(server);
+
+ Iterable<Network> networks = api.listNetworks();
+
+ try {
+ assertEquals(size(networks), 5);
+ assertEquals(server.getRequestCount(), 1);
+
+ assertSent(server, "GET", "/SoftLayer_Network/getAllObjects?objectMask=mask.subnets");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testEmptyListNetworks() throws Exception {
+ MockWebServer server = mockWebServer(new MockResponse().setResponseCode(404));
+ NetworkApi api = getNetworkApi(server);
+
+ try {
+ assertTrue(api.listNetworks().isEmpty());
+ assertSent(server, "GET", "/SoftLayer_Network/getAllObjects?objectMask=mask.subnets");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testCreateNetwork() throws Exception {
+ MockWebServer server = mockWebServer(new MockResponse().setBody(payloadFromResource("/network_createObject.json")));
+ NetworkApi api = getNetworkApi(server);
+
+ Network.CreateNetwork createNetwork = Network.CreateNetwork.builder()
+ .networkIdentifier("192.168.0.0")
+ .name("testNet")
+ .cidr(16)
+ .notes("testNotes")
+ .build();
+
+ Network network = api.createNetwork(ImmutableList.of(createNetwork));
+
+ try {
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "POST", "/SoftLayer_Network/createObject");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetNetwork() throws Exception {
+ MockWebServer server = mockWebServer(new MockResponse().setBody(payloadFromResource("/network_get_153001.json")));
+ NetworkApi api = getNetworkApi(server);
+
+ Network network = api.getNetwork(153001);
+
+ try {
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/SoftLayer_Network/153001/getObject?objectMask=mask.subnets");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetNullNetwork() throws Exception {
+ MockWebServer server = mockWebServer(new MockResponse().setResponseCode(404));
+ NetworkApi api = getNetworkApi(server);
+
+ try {
+ assertNull(api.getNetwork(153001));
+ assertSent(server, "GET", "/SoftLayer_Network/153001/getObject?objectMask=mask.subnets");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetName() throws Exception {
+ MockWebServer server = mockWebServer(new MockResponse().setBody("testNet"));
+ NetworkApi api = getNetworkApi(server);
+
+ String name = api.getName(153001);
+
+ try {
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/SoftLayer_Network/153001/getName");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetNullName() throws Exception {
+ MockWebServer server = mockWebServer(new MockResponse().setResponseCode(404));
+ NetworkApi api = getNetworkApi(server);
+
+ try {
+ assertNull(api.getName(153001));
+ assertSent(server, "GET", "/SoftLayer_Network/153001/getName");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetNotes() throws Exception {
+ MockWebServer server = mockWebServer(new MockResponse().setBody("testNotes"));
+ NetworkApi api = getNetworkApi(server);
+
+ String notes = api.getNotes(153001);
+
+ try {
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/SoftLayer_Network/153001/getNotes");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetNullNotes() throws Exception {
+ MockWebServer server = mockWebServer(new MockResponse().setResponseCode(404));
+ NetworkApi api = getNetworkApi(server);
+
+ try {
+ assertNull(api.getNotes(153001));
+ assertSent(server, "GET", "/SoftLayer_Network/153001/getNotes");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testCreateSubnet() throws Exception {
+ MockWebServer server = mockWebServer(new MockResponse().setBody(payloadFromResource("/network_createSubnet.json")));
+ NetworkApi api = getNetworkApi(server);
+
+ Subnet.CreateSubnet createSubnet = Subnet.CreateSubnet.builder()
+ .networkIdentifier("192.168.1.0")
+ .cidr(24)
+ .note("testNet test create subnet")
+ .build();
+
+ Subnet.CreateDatacenterName createDatacenterName = Subnet.CreateDatacenterName.builder()
+ .name("dal10.pod01")
+ .build();
+
+ List<Object> parameters = new ArrayList<Object>();
+ parameters.add(createSubnet);
+ parameters.add(createDatacenterName);
+
+ Subnet subnet = api.createSubnet(153001, parameters);
+
+ try {
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "POST", "/SoftLayer_Network/153001/createSubnet");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testCreateSubnetOnNonExistingNetwork() throws Exception {
+ MockWebServer server = mockWebServer(new MockResponse().setResponseCode(404));
+ NetworkApi api = getNetworkApi(server);
+
+ Subnet.CreateSubnet createSubnet = Subnet.CreateSubnet.builder()
+ .networkIdentifier("192.168.1.0")
+ .cidr(24)
+ .note("testNet test create subnet")
+ .build();
+
+ Subnet.CreateDatacenterName createDatacenterName = Subnet.CreateDatacenterName.builder()
+ .name("dal10.pod01")
+ .build();
+
+ List<Object> parameters = new ArrayList<Object>();
+ parameters.add(createSubnet);
+ parameters.add(createDatacenterName);
+
+ Subnet subnet = api.createSubnet(153001, parameters);
+
+ try {
+ assertNull(subnet);
+ assertSent(server, "POST", "/SoftLayer_Network/153001/createSubnet");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetSubnets() throws Exception {
+ MockWebServer server = mockWebServer(new MockResponse().setBody(payloadFromResource("/network_subnet_get_1592631.json")));
+ NetworkApi api = getNetworkApi(server);
+
+ List<Subnet> subnets = api.getSubnets(153001);
+
+ try {
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/SoftLayer_Network/153001/getSubnets");
+ assertEquals(subnets.size(), 1);
+ assertEquals(subnets.get(0).id(), 1592631);
+ assertEquals(subnets.get(0).cidr(), 28);
+ assertEquals(subnets.get(0).networkIdentifier(), "192.168.253.0");
+ assertEquals(subnets.get(0).note(), "This is a test subnet from NetworkApiMockTest");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetSubnetsOnNonExistingNetwork() throws Exception {
+ MockWebServer server = mockWebServer(new MockResponse().setResponseCode(404));
+ NetworkApi api = getNetworkApi(server);
+
+ try {
+ assertTrue(api.getSubnets(153001).isEmpty());
+ assertSent(server, "GET", "/SoftLayer_Network/153001/getSubnets");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeleteSubnet() throws Exception {
+ MockWebServer server = mockWebServer(new MockResponse().setBody("true"));
+ NetworkApi api = getNetworkApi(server);
+
+ Subnet.DeleteSubnet deleteSubnet = Subnet.DeleteSubnet.builder()
+ .id(1592631)
+ .build();
+
+ List<Subnet.DeleteSubnet> parameters = new ArrayList<Subnet.DeleteSubnet>();
+ parameters.add(deleteSubnet);
+ boolean deletion = api.deleteSubnet(153001, parameters);
+
+ try {
+ assertTrue(deletion, "deletion failed");
+
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "POST", "/SoftLayer_Network/153001/deleteSubnet");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeleteNonExistingSubnet() throws Exception {
+ MockWebServer server = mockWebServer(new MockResponse().setResponseCode(404));
+ NetworkApi api = getNetworkApi(server);
+
+ Subnet.DeleteSubnet deleteSubnet = Subnet.DeleteSubnet.builder()
+ .id(1592631)
+ .build();
+
+ List<Subnet.DeleteSubnet> parameters = new ArrayList<Subnet.DeleteSubnet>();
+ parameters.add(deleteSubnet);
+ boolean deletion = api.deleteSubnet(153001, parameters);
+
+ try {
+ assertFalse(deletion);
+ assertSent(server, "POST", "/SoftLayer_Network/153001/deleteSubnet");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testEditNetwork() throws Exception {
+ MockWebServer server = mockWebServer(new MockResponse().setBody("true"));
+ NetworkApi api = getNetworkApi(server);
+
+ Network.EditNetwork editNetwork = Network.EditNetwork.builder()
+ .name("newNetworkApiLiveTestNetwork")
+ .notes("new notes")
+ .id(153001)
+ .build();
+
+ boolean edit = api.editNetwork(153001, ImmutableList.of(editNetwork));
+
+ try {
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "PUT", "/SoftLayer_Network/153001/editObject");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testEditNullNetwork() throws Exception {
+ MockWebServer server = mockWebServer(new MockResponse().setResponseCode(404));
+ NetworkApi api = getNetworkApi(server);
+
+ Network.EditNetwork editNetwork = Network.EditNetwork.builder()
+ .name("newNetworkApiLiveTestNetwork")
+ .notes("new notes")
+ .id(153001)
+ .build();
+
+ boolean edit = api.editNetwork(153001, ImmutableList.of(editNetwork));
+
+ try {
+ assertFalse(edit);
+ assertSent(server, "PUT", "/SoftLayer_Network/153001/editObject");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeleteNetwork() throws Exception {
+ MockWebServer server = mockWebServer(new MockResponse().setBody("true"));
+ NetworkApi api = getNetworkApi(server);
+
+ boolean deletion = api.deleteNetwork(153001);
+
+ try {
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "DELETE", "/SoftLayer_Network/153001");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeleteNonExistingNetwork() throws Exception {
+ MockWebServer server = mockWebServer(new MockResponse().setResponseCode(404));
+ NetworkApi api = getNetworkApi(server);
+
+ try {
+ assertFalse(api.deleteNetwork(153001));
+ assertSent(server, "DELETE", "/SoftLayer_Network/153001");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ private NetworkApi getNetworkApi(MockWebServer server) {
+ return api(SoftLayerApi.class, server.getUrl("/").toString(), new
+ JavaUrlHttpCommandExecutorServiceModule(), new SoftLayerParserModule()).getNetworkApi();
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/a540daf3/providers/softlayer/src/test/resources/network_createObject.json
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/resources/network_createObject.json b/providers/softlayer/src/test/resources/network_createObject.json
new file mode 100644
index 0000000..8138bbe
--- /dev/null
+++ b/providers/softlayer/src/test/resources/network_createObject.json
@@ -0,0 +1,7 @@
+{
+ "accountId": 1186236,
+ "id": 153001,
+ "cidr": 16,
+ "name": "testNet",
+ "networkIdentifier": "192.168.0.0"
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/a540daf3/providers/softlayer/src/test/resources/network_createSubnet.json
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/resources/network_createSubnet.json b/providers/softlayer/src/test/resources/network_createSubnet.json
new file mode 100644
index 0000000..212e320
--- /dev/null
+++ b/providers/softlayer/src/test/resources/network_createSubnet.json
@@ -0,0 +1,18 @@
+{
+ "broadcastAddress": "192.168.1.255",
+ "cidr": 24,
+ "gateway": "192.168.1.1",
+ "id": 1581517,
+ "isCustomerOwned": true,
+ "isCustomerRoutable": false,
+ "modifyDate": null,
+ "netmask": "255.255.255.0",
+ "networkIdentifier": "192.168.1.0",
+ "networkVlanId": null,
+ "note": "testNet test create subnet",
+ "sortOrder": "4",
+ "totalIpAddresses": "256",
+ "usableIpAddressCount": "253",
+ "version": 4,
+ "addressSpace": "PRIVATE"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds/blob/a540daf3/providers/softlayer/src/test/resources/network_get_153001.json
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/resources/network_get_153001.json b/providers/softlayer/src/test/resources/network_get_153001.json
new file mode 100644
index 0000000..831fa0f
--- /dev/null
+++ b/providers/softlayer/src/test/resources/network_get_153001.json
@@ -0,0 +1,8 @@
+{
+ "accountId": 1186236,
+ "id": 153503,
+ "cidr": 16,
+ "name": "testNet",
+ "networkIdentifier": "192.168.0.0",
+ "notes": "this is a test network from JClouds NetworkApiMockTest."
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds/blob/a540daf3/providers/softlayer/src/test/resources/network_list.json
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/resources/network_list.json b/providers/softlayer/src/test/resources/network_list.json
new file mode 100644
index 0000000..596cb5c
--- /dev/null
+++ b/providers/softlayer/src/test/resources/network_list.json
@@ -0,0 +1,41 @@
+[
+ {
+ "accountId": 1186236,
+ "id": 153602,
+ "cidr": 24,
+ "name": "newNetworkApiLiveTestNetwork",
+ "networkIdentifier": "192.168.253.0",
+ "notes": "new notes"
+ },
+ {
+ "accountId": 1186236,
+ "id": 7505,
+ "cidr": 16,
+ "name": "ADN-public",
+ "networkIdentifier": "10.0.0.0",
+ "notes": "This network is available for testing and demo purposes. Anything here will be automatically removed periodically"
+ },
+ {
+ "accountId": 1186236,
+ "id": 12202,
+ "cidr": 24,
+ "name": "testNet",
+ "networkIdentifier": "10.0.0.0"
+ },
+ {
+ "accountId": 1186236,
+ "id": 6802,
+ "cidr": 24,
+ "name": "mcltn-172-31-1",
+ "networkIdentifier": "172.31.1.0",
+ "notes": "mcltn network"
+ },
+ {
+ "accountId": 1186236,
+ "id": 6932,
+ "cidr": 16,
+ "name": "khoa_network",
+ "networkIdentifier": "10.0.0.0",
+ "notes": "Khoa's first test network"
+ }
+]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds/blob/a540daf3/providers/softlayer/src/test/resources/network_subnet_get_1592631.json
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/resources/network_subnet_get_1592631.json b/providers/softlayer/src/test/resources/network_subnet_get_1592631.json
new file mode 100644
index 0000000..ee44bd5
--- /dev/null
+++ b/providers/softlayer/src/test/resources/network_subnet_get_1592631.json
@@ -0,0 +1,26 @@
+[
+ {
+ "broadcastAddress": "192.168.253.15",
+ "cidr": 28,
+ "gateway": "192.168.253.1",
+ "id": 1592631,
+ "isCustomerOwned": true,
+ "isCustomerRoutable": false,
+ "modifyDate": "2017-11-09T08:07:22-06:00",
+ "netmask": "255.255.255.240",
+ "networkIdentifier": "192.168.253.0",
+ "networkVlanId": 2188589,
+ "note": "This is a test subnet from NetworkApiMockTest",
+ "sortOrder": "1",
+ "subnetType": "ADDITIONAL_PRIMARY",
+ "totalIpAddresses": "16",
+ "usableIpAddressCount": "13",
+ "version": 4,
+ "datacenter": {
+ "id": 1441195,
+ "longName": "Dallas 10",
+ "name": "dal10",
+ "statusId": 2
+ }
+ }
+]
\ No newline at end of file