diff --git a/.github/workflows/test_runner.yml b/.github/workflows/test_runner.yml index 2e941fda..ceabd447 100644 --- a/.github/workflows/test_runner.yml +++ b/.github/workflows/test_runner.yml @@ -24,21 +24,18 @@ jobs: - name: Tests shell: bash run: |- - cd equinix-openapi-fabric mvn clean test -DenvUrl=${{ env.TEST_HOST_URL }} - name: Generate report if: always() shell: bash run: |- - cd equinix-openapi-fabric + cd equinix-openapi-fabric-tests mvn surefire-report:report -DskipTests - ls - find . - name: attach report as attachment if: always() uses: actions/upload-artifact@v4 with: name: test report - path: ./equinix-openapi-fabric/target/reports + path: ./equinix-openapi-fabric-tests/target/reports diff --git a/.gitignore b/.gitignore index 7c2c284c..e49868d2 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,5 @@ hs_err_pid* # JetBrains project directory files *.idea *.idea/ +equinix-openapi-fabric/target +equinix-openapi-fabric-tests/target diff --git a/Makefile b/Makefile index 7dbc3ff7..93230c4d 100644 --- a/Makefile +++ b/Makefile @@ -66,4 +66,4 @@ docker_generate: --git-user-id ${GIT_ORG} build_client: - rm -rf ${OPENAPI_GENERATED_CLIENT}${TESTS_PATH}v4; cp -r v4 ${OPENAPI_GENERATED_CLIENT}${TESTS_PATH} + rm -rf ${OPENAPI_GENERATED_CLIENT}${TESTS_PATH}v4; diff --git a/equinix-openapi-fabric-tests/README.md b/equinix-openapi-fabric-tests/README.md new file mode 100644 index 00000000..8c6a25a8 --- /dev/null +++ b/equinix-openapi-fabric-tests/README.md @@ -0,0 +1,16 @@ +# equinix-openapi-fabric-tests + +## Requirements + +Building the API client library requires: + +1. Java 1.8+ +2. Maven (3.8.3+) + +## Installation + +To install the API client library to your local Maven repository, simply execute: + +```shell +mvn clean install +``` diff --git a/equinix-openapi-fabric-tests/equinix-openapi-fabric-tests.iml b/equinix-openapi-fabric-tests/equinix-openapi-fabric-tests.iml new file mode 100644 index 00000000..2feb230e --- /dev/null +++ b/equinix-openapi-fabric-tests/equinix-openapi-fabric-tests.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/equinix-openapi-fabric-tests/pom.xml b/equinix-openapi-fabric-tests/pom.xml new file mode 100644 index 00000000..33445bd3 --- /dev/null +++ b/equinix-openapi-fabric-tests/pom.xml @@ -0,0 +1,42 @@ + + 4.0.0 + + com.equinix + openapi-fabric-tests + equinix-openapi-fabric-tests + 0.5.0 + + + com.equinix + equinix-openapi-fabric-core + 0.0.1 + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + **Test.java + + + + + + + + junit + junit + 4.13.2 + + + com.equinix + equinix-openapi-fabric + 0.5.0 + + + diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/CloudRoutersApiTest.java b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/CloudRoutersApiTest.java similarity index 94% rename from equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/CloudRoutersApiTest.java rename to equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/CloudRoutersApiTest.java index cd2891d1..38708a67 100644 --- a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/CloudRoutersApiTest.java +++ b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/CloudRoutersApiTest.java @@ -8,22 +8,22 @@ * Do not edit the class manually. */ -package com.equinix.openapi.fabric.v4.api; +package com.equinix.openapi.fabric.tests; import com.equinix.openapi.fabric.ApiException; -import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem; -import com.equinix.openapi.fabric.v4.api.helpers.Utils; +import com.equinix.openapi.fabric.tests.dto.users.UsersItem; +import com.equinix.openapi.fabric.tests.helpers.Utils; import com.equinix.openapi.fabric.v4.model.*; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; import java.util.UUID; -import static com.equinix.openapi.fabric.v4.api.helpers.Apis.*; -import static com.equinix.openapi.fabric.v4.api.helpers.TokenGenerator.users; +import static com.equinix.openapi.fabric.tests.helpers.Apis.*; +import static com.equinix.openapi.fabric.tests.helpers.TokenGenerator.users; import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.Assert.*; /** * API tests for CloudRoutersApi @@ -40,12 +40,12 @@ public static void removeCloudRouters(UsersItem.UserName userName) { }); } - @BeforeAll + @BeforeClass public static void setUp() { setUserName(userName); } - @AfterAll + @AfterClass public static void removeResources() { removeCloudRouters(userName); } @@ -273,7 +273,6 @@ private static void waitForCloudRouterIsProvisioned(UUID cloudRouterUuid) { } } - assertTrue(result, - "Cloud Router has not reached the expected state: " + CloudRouterAccessPointState.PROVISIONED + " current state: " + currentState.getValue()); + assertTrue("Cloud Router has not reached the expected state: " + CloudRouterAccessPointState.PROVISIONED + " current state: " + currentState.getValue(), result); } } diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/ConnectionsApiTest.java b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/ConnectionsApiTest.java similarity index 95% rename from equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/ConnectionsApiTest.java rename to equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/ConnectionsApiTest.java index ec09cdf2..1f238c72 100644 --- a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/ConnectionsApiTest.java +++ b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/ConnectionsApiTest.java @@ -8,29 +8,29 @@ * Do not edit the class manually. */ -package com.equinix.openapi.fabric.v4.api; +package com.equinix.openapi.fabric.tests; import com.equinix.openapi.fabric.ApiException; -import com.equinix.openapi.fabric.v4.api.dto.port.PortDto; -import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem; -import com.equinix.openapi.fabric.v4.api.helpers.Utils; +import com.equinix.openapi.fabric.tests.dto.port.PortDto; +import com.equinix.openapi.fabric.tests.dto.users.UsersItem; +import com.equinix.openapi.fabric.tests.helpers.Utils; import com.equinix.openapi.fabric.v4.model.*; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; import java.util.List; import java.util.Random; import java.util.UUID; import java.util.stream.Collectors; -import static com.equinix.openapi.fabric.v4.api.CloudRoutersApiTest.createRouter; -import static com.equinix.openapi.fabric.v4.api.PortsApiTest.getPorts; -import static com.equinix.openapi.fabric.v4.api.helpers.Apis.*; -import static com.equinix.openapi.fabric.v4.api.helpers.TokenGenerator.users; -import static com.equinix.openapi.fabric.v4.api.helpers.Utils.getRandomVlanNumber; +import static com.equinix.openapi.fabric.tests.CloudRoutersApiTest.createRouter; +import static com.equinix.openapi.fabric.tests.PortsApiTest.getPorts; +import static com.equinix.openapi.fabric.tests.helpers.Apis.*; +import static com.equinix.openapi.fabric.tests.helpers.TokenGenerator.users; +import static com.equinix.openapi.fabric.tests.helpers.Utils.getRandomVlanNumber; import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.Assert.assertEquals; public class ConnectionsApiTest { private static final UsersItem.UserName userName = UsersItem.UserName.PANTHERS_FCR; @@ -50,12 +50,12 @@ public static void removeConnections(UsersItem.UserName userName) { }); } - @BeforeAll + @BeforeClass public static void setUp() { setUserName(userName); } - @AfterAll + @AfterClass public static void removeResources() { removeConnections(userName); CloudRoutersApiTest.removeCloudRouters(userName); diff --git a/v4/api/MetrosApiTest.java b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/MetrosApiTest.java similarity index 81% rename from v4/api/MetrosApiTest.java rename to equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/MetrosApiTest.java index 1bc32c29..e21e939d 100644 --- a/v4/api/MetrosApiTest.java +++ b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/MetrosApiTest.java @@ -8,17 +8,17 @@ * Do not edit the class manually. */ -package com.equinix.openapi.fabric.v4.api; +package com.equinix.openapi.fabric.tests; import com.equinix.openapi.fabric.ApiException; import com.equinix.openapi.fabric.v4.model.Metro; import com.equinix.openapi.fabric.v4.model.MetroResponse; import com.equinix.openapi.fabric.v4.model.Presence; -import org.junit.jupiter.api.Test; +import org.junit.Test; -import static com.equinix.openapi.fabric.v4.api.helpers.Apis.metrosApi; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static com.equinix.openapi.fabric.tests.helpers.Apis.metrosApi; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; /** * API tests for MetrosApi diff --git a/v4/api/NetworksApiTest.java b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/NetworksApiTest.java similarity index 87% rename from v4/api/NetworksApiTest.java rename to equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/NetworksApiTest.java index b74fef68..f1960881 100644 --- a/v4/api/NetworksApiTest.java +++ b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/NetworksApiTest.java @@ -8,41 +8,41 @@ * Do not edit the class manually. */ -package com.equinix.openapi.fabric.v4.api; +package com.equinix.openapi.fabric.tests; import com.equinix.openapi.fabric.ApiException; -import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem; -import com.equinix.openapi.fabric.v4.api.helpers.Utils; +import com.equinix.openapi.fabric.tests.dto.users.UsersItem; +import com.equinix.openapi.fabric.tests.helpers.Utils; import com.equinix.openapi.fabric.v4.model.*; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; import java.util.UUID; -import static com.equinix.openapi.fabric.v4.api.helpers.TokenGenerator.users; -import static com.equinix.openapi.fabric.v4.api.helpers.Apis.networksApi; -import static com.equinix.openapi.fabric.v4.api.helpers.Apis.setUserName; +import static com.equinix.openapi.fabric.tests.helpers.Apis.networksApi; +import static com.equinix.openapi.fabric.tests.helpers.Apis.setUserName; +import static com.equinix.openapi.fabric.tests.helpers.TokenGenerator.users; import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; /** * API tests for NetworksApi */ -class NetworksApiTest { +public class NetworksApiTest { private static final UsersItem.UserName userName = UsersItem.UserName.PANTHERS_FNV; public static void removeNetworks(UsersItem.UserName userName) { - users.get(userName).getUserResources().getNetworksUuid().forEach(com.equinix.openapi.fabric.v4.api.NetworksApiTest::deleteNetwork); + users.get(userName).getUserResources().getNetworksUuid().forEach(NetworksApiTest::deleteNetwork); } - @BeforeAll + @BeforeClass public static void setUp() { setUserName(userName); } - @AfterAll + @AfterClass public static void removeResources() { removeNetworks(userName); } diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/PortsApiTest.java b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/PortsApiTest.java similarity index 83% rename from equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/PortsApiTest.java rename to equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/PortsApiTest.java index cef2dd76..de534eb0 100644 --- a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/PortsApiTest.java +++ b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/PortsApiTest.java @@ -8,23 +8,23 @@ * Do not edit the class manually. */ -package com.equinix.openapi.fabric.v4.api; +package com.equinix.openapi.fabric.tests; import com.equinix.openapi.fabric.ApiException; -import com.equinix.openapi.fabric.v4.api.dto.port.PortDto; -import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem; -import com.equinix.openapi.fabric.v4.api.helpers.Utils; +import com.equinix.openapi.fabric.tests.dto.port.PortDto; +import com.equinix.openapi.fabric.tests.dto.users.UsersItem; +import com.equinix.openapi.fabric.tests.helpers.Utils; import com.equinix.openapi.fabric.v4.model.*; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; +import org.junit.BeforeClass; +import org.junit.Test; import java.util.List; -import static com.equinix.openapi.fabric.v4.api.helpers.Apis.portsApi; -import static com.equinix.openapi.fabric.v4.api.helpers.Apis.setUserName; +import static com.equinix.openapi.fabric.tests.helpers.Apis.portsApi; +import static com.equinix.openapi.fabric.tests.helpers.Apis.setUserName; import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; /** * API tests for PortsApi @@ -32,7 +32,7 @@ public class PortsApiTest { private static final UsersItem.UserName userName = UsersItem.UserName.PANTHERS_FCR; - @BeforeAll + @BeforeClass public static void setUp() { setUserName(userName); } diff --git a/v4/api/PricesApiTest.java b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/PricesApiTest.java similarity index 82% rename from v4/api/PricesApiTest.java rename to equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/PricesApiTest.java index 5960228f..5f322f82 100644 --- a/v4/api/PricesApiTest.java +++ b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/PricesApiTest.java @@ -8,30 +8,31 @@ * Do not edit the class manually. */ -package com.equinix.openapi.fabric.v4.api; +package com.equinix.openapi.fabric.tests; import com.equinix.openapi.fabric.ApiException; -import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem; import com.equinix.openapi.fabric.v4.model.FilterBody; import com.equinix.openapi.fabric.v4.model.PriceSearchResponse; import com.equinix.openapi.fabric.v4.model.SearchExpression; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; + +import com.equinix.openapi.fabric.tests.dto.users.UsersItem; +import org.junit.BeforeClass; +import org.junit.Test; import java.util.Arrays; import java.util.Collections; -import static com.equinix.openapi.fabric.v4.api.helpers.Apis.pricesApi; -import static com.equinix.openapi.fabric.v4.api.helpers.Apis.setUserName; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static com.equinix.openapi.fabric.tests.helpers.Apis.pricesApi; +import static com.equinix.openapi.fabric.tests.helpers.Apis.setUserName; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; /** * API tests for PricesApi */ public class PricesApiTest { - @BeforeAll + @BeforeClass public static void setUp() { setUserName(UsersItem.UserName.PANTHERS_FCR); } diff --git a/v4/api/RoutingProtocolsApiTest.java b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/RoutingProtocolsApiTest.java similarity index 78% rename from v4/api/RoutingProtocolsApiTest.java rename to equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/RoutingProtocolsApiTest.java index 06ae9bc8..fc47ec09 100644 --- a/v4/api/RoutingProtocolsApiTest.java +++ b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/RoutingProtocolsApiTest.java @@ -8,25 +8,25 @@ * Do not edit the class manually. */ -package com.equinix.openapi.fabric.v4.api; +package com.equinix.openapi.fabric.tests; import com.equinix.openapi.fabric.ApiException; -import com.equinix.openapi.fabric.v4.api.dto.users.UserResources; -import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem; +import com.equinix.openapi.fabric.tests.dto.users.UserResources; +import com.equinix.openapi.fabric.tests.dto.users.UsersItem; import com.equinix.openapi.fabric.v4.model.*; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; import java.util.UUID; -import static com.equinix.openapi.fabric.v4.api.CloudRoutersApiTest.removeCloudRouters; -import static com.equinix.openapi.fabric.v4.api.ConnectionsApiTest.createConnectionFCR2ToPort; -import static com.equinix.openapi.fabric.v4.api.ConnectionsApiTest.removeConnections; -import static com.equinix.openapi.fabric.v4.api.helpers.Apis.*; -import static com.equinix.openapi.fabric.v4.api.helpers.TokenGenerator.users; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static com.equinix.openapi.fabric.tests.CloudRoutersApiTest.removeCloudRouters; +import static com.equinix.openapi.fabric.tests.ConnectionsApiTest.createConnectionFCR2ToPort; +import static com.equinix.openapi.fabric.tests.ConnectionsApiTest.removeConnections; +import static com.equinix.openapi.fabric.tests.helpers.Apis.*; +import static com.equinix.openapi.fabric.tests.helpers.TokenGenerator.users; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; /** * API tests for RoutingProtocolsApi @@ -38,12 +38,12 @@ public static void removeRoutingInstances(UsersItem.UserName userName) { users.get(userName).getUserResources().getRoutingProtocolsUuid().forEach(RoutingProtocolsApiTest::deleteRoutingProtocol); } - @BeforeAll + @BeforeClass public static void setUp() { setUserName(userName); } - @AfterAll + @AfterClass public static void removeResources() { try { Thread.sleep(15000); @@ -115,7 +115,7 @@ private static void waitForDirectTypeIsProvisioned(UUID routingProtocolUuid, Str } } - assertTrue(result, "Routing Protocol has not reached the expected state: " + RoutingProtocolDirectData.StateEnum.PROVISIONED + " current state: " + currentState.getValue() + " for connection " + "uuid " + connectionUuid); + assertTrue("Routing Protocol has not reached the expected state: " + RoutingProtocolDirectData.StateEnum.PROVISIONED + " current state: " + currentState.getValue() + " for connection " + "uuid " + connectionUuid, result); } private static void waitForBGPTypeIsProvisioned(UUID routingProtocolUuid, String connectionUuid) throws ApiException { @@ -136,6 +136,6 @@ private static void waitForBGPTypeIsProvisioned(UUID routingProtocolUuid, String } } - assertTrue(result, "Routing Protocol has not reached the expected state: " + RoutingProtocolBGPData.StateEnum.PROVISIONED + " current state: " + currentState.getValue() + " for connection " + "uuid " + connectionUuid); + assertTrue("Routing Protocol has not reached the expected state: " + RoutingProtocolBGPData.StateEnum.PROVISIONED + " current state: " + currentState.getValue() + " for connection " + "uuid " + connectionUuid, result); } } diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/ServiceProfilesApiTest.java b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/ServiceProfilesApiTest.java similarity index 93% rename from equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/ServiceProfilesApiTest.java rename to equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/ServiceProfilesApiTest.java index e6629514..25181c69 100644 --- a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/ServiceProfilesApiTest.java +++ b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/ServiceProfilesApiTest.java @@ -8,34 +8,34 @@ * Do not edit the class manually. */ -package com.equinix.openapi.fabric.v4.api; +package com.equinix.openapi.fabric.tests; import com.equinix.openapi.fabric.ApiException; -import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem; -import com.equinix.openapi.fabric.v4.api.helpers.Utils; +import com.equinix.openapi.fabric.tests.dto.users.UsersItem; +import com.equinix.openapi.fabric.tests.helpers.Utils; import com.equinix.openapi.fabric.v4.model.*; import org.apache.commons.lang3.RandomStringUtils; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.UUID; -import static com.equinix.openapi.fabric.v4.api.PortsApiTest.getPorts; -import static com.equinix.openapi.fabric.v4.api.helpers.Apis.serviceProfilesApi; -import static com.equinix.openapi.fabric.v4.api.helpers.Apis.setUserName; -import static com.equinix.openapi.fabric.v4.api.helpers.TokenGenerator.users; +import static com.equinix.openapi.fabric.tests.PortsApiTest.getPorts; +import static com.equinix.openapi.fabric.tests.helpers.Apis.serviceProfilesApi; +import static com.equinix.openapi.fabric.tests.helpers.Apis.setUserName; +import static com.equinix.openapi.fabric.tests.helpers.TokenGenerator.users; import static com.equinix.openapi.fabric.v4.model.Expression.OperatorEnum.EQUAL; import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.Assert.*; /** * API tests for ServiceProfilesApi */ -class ServiceProfilesApiTest { +public class ServiceProfilesApiTest { private static final UsersItem.UserName userName = UsersItem.UserName.PANTHERS_FCR; public static void removeServiceProfiles(UsersItem.UserName userName) { @@ -50,12 +50,12 @@ public static void removeServiceProfiles(UsersItem.UserName userName) { }); } - @BeforeAll + @BeforeClass public static void setUp() { setUserName(userName); } - @AfterAll + @AfterClass public static void removeResources() { removeServiceProfiles(userName); try { @@ -191,7 +191,7 @@ private static void waitForSpIsInState(UUID uuid, ServiceProfileStateEnum state) } } - assertTrue(result, "Service profile has not reached the expected state: " + state + " current state: " + currentState.getValue()); + assertTrue("Service profile has not reached the expected state: " + state + " current state: " + currentState.getValue(), result); } private ServiceProfile createServiceProfile() throws ApiException { diff --git a/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/TokenRequestDto.java b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/TokenRequestDto.java new file mode 100644 index 00000000..0395b6cf --- /dev/null +++ b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/TokenRequestDto.java @@ -0,0 +1,39 @@ +package com.equinix.openapi.fabric.tests.dto; + +import com.google.gson.annotations.SerializedName; + +public class TokenRequestDto { + + @SerializedName("grant_type") + private String grantType; + + @SerializedName("client_secret") + private String clientSecret; + + @SerializedName("client_id") + private String clientId; + + public void setGrantType(String grantType) { + this.grantType = grantType; + } + + public String getGrantType() { + return grantType; + } + + public void setClientSecret(String clientSecret) { + this.clientSecret = clientSecret; + } + + public String getClientSecret() { + return clientSecret; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getClientId() { + return clientId; + } +} diff --git a/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/TokenResponseDto.java b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/TokenResponseDto.java new file mode 100644 index 00000000..ef90cccd --- /dev/null +++ b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/TokenResponseDto.java @@ -0,0 +1,34 @@ +package com.equinix.openapi.fabric.tests.dto; + +import com.google.gson.annotations.SerializedName; + +public class TokenResponseDto { + + @SerializedName("access_token") + private String accessToken; + + @SerializedName("user_name") + private String userName; + + @SerializedName("token_timeout") + private String tokenTimeout; + + @SerializedName("token_type") + private String tokenType; + + public String getAccessToken() { + return accessToken; + } + + public String getUserName() { + return userName; + } + + public String getTokenTimeout() { + return tokenTimeout; + } + + public String getTokenType() { + return tokenType; + } +} diff --git a/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/port/Location.java b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/port/Location.java new file mode 100644 index 00000000..0669348c --- /dev/null +++ b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/port/Location.java @@ -0,0 +1,34 @@ +package com.equinix.openapi.fabric.tests.dto.port; + +import com.google.gson.annotations.SerializedName; + +public class Location { + + @SerializedName("metroName") + private String metroName; + + @SerializedName("metroCode") + private String metroCode; + + @SerializedName("region") + private String region; + + @SerializedName("ibx") + private String ibx; + + public String getMetroName() { + return metroName; + } + + public String getMetroCode() { + return metroCode; + } + + public String getRegion() { + return region; + } + + public String getIbx() { + return ibx; + } +} diff --git a/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/port/PortDto.java b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/port/PortDto.java new file mode 100644 index 00000000..44db24e5 --- /dev/null +++ b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/port/PortDto.java @@ -0,0 +1,41 @@ +package com.equinix.openapi.fabric.tests.dto.port; + +import com.google.gson.annotations.SerializedName; + +public class PortDto { + + @SerializedName("encapsulation") + private String encapsulation; + + @SerializedName("name") + private String name; + + @SerializedName("location") + private Location location; + + @SerializedName("type") + private String type; + + @SerializedName("uuid") + private String uuid; + + public String getEncapsulation() { + return encapsulation; + } + + public String getName() { + return name; + } + + public Location getLocation() { + return location; + } + + public String getType() { + return type; + } + + public String getUuid() { + return uuid; + } +} diff --git a/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/port/UsersItem.java b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/port/UsersItem.java new file mode 100644 index 00000000..55ee2bb5 --- /dev/null +++ b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/port/UsersItem.java @@ -0,0 +1,57 @@ +package com.equinix.openapi.fabric.tests.dto.port; + +import java.util.List; + +import com.google.gson.annotations.SerializedName; + +public class UsersItem { + + @SerializedName("virtualDevices") + private List virtualDevices; + + @SerializedName("name") + private String name; + + @SerializedName("client_secret") + private String clientSecret; + + @SerializedName("accountNumber") + private String accountNumber; + + @SerializedName("ports") + private List ports; + + @SerializedName("projectId") + private String projectId; + + @SerializedName("client_id") + private String clientId; + + public List getVirtualDevices() { + return virtualDevices; + } + + public String getName() { + return name; + } + + public String getClientSecret() { + return clientSecret; + } + + public String getAccountNumber() { + return accountNumber; + } + + public List getPorts() { + return ports; + } + + public String getProjectId() { + return projectId; + } + + public String getClientId() { + return clientId; + } +} diff --git a/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/port/VirtualDevicesItem.java b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/port/VirtualDevicesItem.java new file mode 100644 index 00000000..ccae2959 --- /dev/null +++ b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/port/VirtualDevicesItem.java @@ -0,0 +1,29 @@ +package com.equinix.openapi.fabric.tests.dto.port; + +import com.google.gson.annotations.SerializedName; + +import java.util.UUID; + +public class VirtualDevicesItem { + + @SerializedName("orderNumber") + private String orderNumber; + + @SerializedName("name") + private String name; + + @SerializedName("uuid") + private UUID uuid; + + public String getOrderNumber() { + return orderNumber; + } + + public String getName() { + return name; + } + + public UUID getUuid() { + return uuid; + } +} diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/users/UserResources.java b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/users/UserResources.java similarity index 97% rename from equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/users/UserResources.java rename to equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/users/UserResources.java index ed5a81c5..9078e600 100644 --- a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/users/UserResources.java +++ b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/users/UserResources.java @@ -1,4 +1,4 @@ -package com.equinix.openapi.fabric.v4.api.dto.users; +package com.equinix.openapi.fabric.tests.dto.users; import java.util.ArrayList; import java.util.List; diff --git a/v4/api/dto/users/UserUsedDto.java b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/users/UserUsedDto.java similarity index 93% rename from v4/api/dto/users/UserUsedDto.java rename to equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/users/UserUsedDto.java index 165f7e6d..7f872d01 100644 --- a/v4/api/dto/users/UserUsedDto.java +++ b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/users/UserUsedDto.java @@ -1,4 +1,4 @@ -package com.equinix.openapi.fabric.v4.api.dto.users; +package com.equinix.openapi.fabric.tests.dto.users; import com.equinix.openapi.fabric.ApiClient; diff --git a/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/users/UsersDto.java b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/users/UsersDto.java new file mode 100644 index 00000000..eb86e0a5 --- /dev/null +++ b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/users/UsersDto.java @@ -0,0 +1,19 @@ +package com.equinix.openapi.fabric.tests.dto.users; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +public class UsersDto { + + @JsonProperty("users") + private List users; + + public void setUsers(List users) { + this.users = users; + } + + public List getUsers() { + return users; + } +} diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/users/UsersItem.java b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/users/UsersItem.java similarity index 91% rename from equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/users/UsersItem.java rename to equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/users/UsersItem.java index 6b7f1740..0a90439e 100644 --- a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/users/UsersItem.java +++ b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/users/UsersItem.java @@ -1,7 +1,8 @@ -package com.equinix.openapi.fabric.v4.api.dto.users; +package com.equinix.openapi.fabric.tests.dto.users; -import com.equinix.openapi.fabric.v4.api.dto.port.PortDto; import com.fasterxml.jackson.annotation.JsonProperty; +import com.equinix.openapi.fabric.tests.dto.port.PortDto; +import com.equinix.openapi.fabric.tests.dto.port.VirtualDevicesItem; import java.util.List; diff --git a/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/users/VirtualDevicesItem.java b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/users/VirtualDevicesItem.java new file mode 100644 index 00000000..ebc6ee73 --- /dev/null +++ b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/dto/users/VirtualDevicesItem.java @@ -0,0 +1,41 @@ +package com.equinix.openapi.fabric.tests.dto.users; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.UUID; + +public class VirtualDevicesItem { + + @JsonProperty("orderNumber") + private String orderNumber; + + @JsonProperty("name") + private String name; + + @JsonProperty("uuid") + private UUID uuid; + + public void setOrderNumber(String orderNumber) { + this.orderNumber = orderNumber; + } + + public String getOrderNumber() { + return orderNumber; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + public UUID getUuid() { + return uuid; + } +} diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/helpers/Apis.java b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/helpers/Apis.java similarity index 92% rename from equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/helpers/Apis.java rename to equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/helpers/Apis.java index 23e4069f..b8e1b725 100644 --- a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/helpers/Apis.java +++ b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/helpers/Apis.java @@ -1,9 +1,9 @@ -package com.equinix.openapi.fabric.v4.api.helpers; +package com.equinix.openapi.fabric.tests.helpers; import com.equinix.openapi.fabric.v4.api.*; -import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem; +import com.equinix.openapi.fabric.tests.dto.users.UsersItem; -import static com.equinix.openapi.fabric.v4.api.helpers.TokenGenerator.generate; +import static com.equinix.openapi.fabric.tests.helpers.TokenGenerator.generate; public class Apis { public static CloudRoutersApi cloudRoutersApi; diff --git a/v4/api/helpers/TokenGenerator.java b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/helpers/TokenGenerator.java similarity index 91% rename from v4/api/helpers/TokenGenerator.java rename to equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/helpers/TokenGenerator.java index 258c3c71..ef4879d0 100644 --- a/v4/api/helpers/TokenGenerator.java +++ b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/helpers/TokenGenerator.java @@ -8,17 +8,18 @@ * Do not edit the class manually. */ -package com.equinix.openapi.fabric.v4.api.helpers; +package com.equinix.openapi.fabric.tests.helpers; import com.equinix.openapi.fabric.ApiClient; import com.equinix.openapi.fabric.ApiException; import com.equinix.openapi.fabric.Configuration; import com.equinix.openapi.fabric.Pair; -import com.equinix.openapi.fabric.v4.api.dto.TokenRequestDto; -import com.equinix.openapi.fabric.v4.api.dto.TokenResponseDto; -import com.equinix.openapi.fabric.v4.api.dto.users.UserUsedDto; -import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem; + import com.google.gson.reflect.TypeToken; +import com.equinix.openapi.fabric.tests.dto.TokenRequestDto; +import com.equinix.openapi.fabric.tests.dto.TokenResponseDto; +import com.equinix.openapi.fabric.tests.dto.users.UserUsedDto; +import com.equinix.openapi.fabric.tests.dto.users.UsersItem; import java.lang.reflect.Type; import java.util.ArrayList; diff --git a/v4/api/helpers/Utils.java b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/helpers/Utils.java similarity index 89% rename from v4/api/helpers/Utils.java rename to equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/helpers/Utils.java index 947b8488..53d32a23 100644 --- a/v4/api/helpers/Utils.java +++ b/equinix-openapi-fabric-tests/src/test/java/com/equinix/openapi/fabric/tests/helpers/Utils.java @@ -1,9 +1,9 @@ -package com.equinix.openapi.fabric.v4.api.helpers; +package com.equinix.openapi.fabric.tests.helpers; import com.equinix.openapi.fabric.JSON; -import com.equinix.openapi.fabric.v4.api.dto.users.UsersDto; -import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem; import com.fasterxml.jackson.databind.ObjectMapper; +import com.equinix.openapi.fabric.tests.dto.users.UsersDto; +import com.equinix.openapi.fabric.tests.dto.users.UsersItem; import java.io.IOException; import java.util.NoSuchElementException; diff --git a/equinix-openapi-fabric/api/openapi.yaml b/equinix-openapi-fabric/api/openapi.yaml index 8bf7460c..2022db26 100644 --- a/equinix-openapi-fabric/api/openapi.yaml +++ b/equinix-openapi-fabric/api/openapi.yaml @@ -32586,7 +32586,6 @@ components: - encapsulation - location - settings - - type type: object PhysicalPort: description: Physical Port specification diff --git a/equinix-openapi-fabric/docs/Port.md b/equinix-openapi-fabric/docs/Port.md index 8f5d7074..add8711c 100644 --- a/equinix-openapi-fabric/docs/Port.md +++ b/equinix-openapi-fabric/docs/Port.md @@ -8,7 +8,7 @@ Port specification | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**type** | **PortType** | | | +|**type** | **PortType** | | [optional] | |**id** | **Integer** | Equinix assigned response attribute for Port Id | [optional] | |**href** | **URI** | Equinix assigned response attribute for an absolute URL that is the subject of the link's context. | [optional] [readonly] | |**uuid** | **UUID** | Equinix assigned response attribute for port identifier | [optional] | diff --git a/equinix-openapi-fabric/pom.xml b/equinix-openapi-fabric/pom.xml index 1484171d..4d59c1f4 100644 --- a/equinix-openapi-fabric/pom.xml +++ b/equinix-openapi-fabric/pom.xml @@ -14,6 +14,12 @@ https://github.com/openapitools/openapi-generator + + com.equinix + equinix-openapi-fabric-core + 0.0.1 + + Unlicense @@ -300,7 +306,6 @@ jackson-databind-nullable ${jackson-databind-nullable-version} - javax.ws.rs jsr311-api @@ -324,27 +329,19 @@ ${junit-platform-runner.version} test - - org.mockito - mockito-core - ${mockito-core-version} - test - 1.8 ${java.version} ${java.version} - 1.8.5 - 1.6.6 - 4.10.0 - 2.9.1 - 3.12.0 - 0.2.4 + 1.9.0 + 4.11.0 + 2.10.1 + 3.13.0 + 0.2.6 1.3.5 - 5.9.1 - 1.9.1 - 3.12.4 + 5.10.0 + 1.10.0 2.1.1 1.1.1 UTF-8 diff --git a/equinix-openapi-fabric/src/main/java/com/equinix/openapi/fabric/JSON.java b/equinix-openapi-fabric/src/main/java/com/equinix/openapi/fabric/JSON.java index acbdf512..6bacc54d 100644 --- a/equinix-openapi-fabric/src/main/java/com/equinix/openapi/fabric/JSON.java +++ b/equinix-openapi-fabric/src/main/java/com/equinix/openapi/fabric/JSON.java @@ -13,10 +13,19 @@ import com.equinix.openapi.fabric.v4.model.PortDeviceRedundancy; import com.equinix.openapi.fabric.v4.model.PortEncapsulation; -import com.google.gson.*; -import com.google.gson.internal.bind.util.ISO8601Utils; +import com.fasterxml.jackson.databind.util.StdDateFormat; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonElement; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonArray; import io.gsonfire.GsonFireBuilder; import io.gsonfire.TypeSelector; @@ -27,712 +36,721 @@ import java.lang.reflect.Type; import java.text.DateFormat; import java.text.ParseException; -import java.text.ParsePosition; import java.time.LocalDate; import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; +import java.util.Collection; import java.util.Date; import java.util.Locale; import java.util.Map; import java.util.HashMap; -import java.util.Collection; +import java.util.TimeZone; + /* -* A JSON utility class -* -* NOTE: in the future, this class may be converted to static, which may break -* backward-compatibility -*/ + * A JSON utility class + * + * NOTE: in the future, this class may be converted to static, which may break + * backward-compatibility + */ public class JSON { -private static Gson gson; -private static boolean isLenientOnJson = false; -private static DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); -private static SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter(); + private static Gson gson; + private static boolean isLenientOnJson = false; + private static DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); + private static SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter(); private static OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter(); private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); -private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); - -@SuppressWarnings("unchecked") -public static GsonBuilder createGson() { -GsonFireBuilder fireBuilder = new GsonFireBuilder() - .registerTypeSelector(com.equinix.openapi.fabric.v4.model.LinkProtocol.class, new TypeSelector() { - @Override - public Class getClassForElement(JsonElement readElement) { - Map classByDiscriminatorValue = new HashMap(); - classByDiscriminatorValue.put("DOT1Q", com.equinix.openapi.fabric.v4.model.LinkProtocolDot1q.class); - classByDiscriminatorValue.put("EVPN_VXLAN", com.equinix.openapi.fabric.v4.model.LinkProtocolEvpnVxlan.class); - classByDiscriminatorValue.put("QINQ", com.equinix.openapi.fabric.v4.model.LinkProtocolQinq.class); - classByDiscriminatorValue.put("UNTAGGED", com.equinix.openapi.fabric.v4.model.LinkProtocolUntagged.class); - classByDiscriminatorValue.put("VXLAN", com.equinix.openapi.fabric.v4.model.LinkProtocolVxlan.class); - classByDiscriminatorValue.put("LinkProtocol", com.equinix.openapi.fabric.v4.model.LinkProtocol.class); - return getClassByDiscriminator(classByDiscriminatorValue, - getDiscriminatorValue(readElement, "type")); - } - }) - .registerTypeSelector(com.equinix.openapi.fabric.v4.model.MetroError.class, new TypeSelector() { - @Override - public Class getClassForElement(JsonElement readElement) { - Map classByDiscriminatorValue = new HashMap(); - classByDiscriminatorValue.put("MetroError", com.equinix.openapi.fabric.v4.model.MetroError.class); - return getClassByDiscriminator(classByDiscriminatorValue, - getDiscriminatorValue(readElement, "errorCode")); - } - }) - .registerTypeSelector(com.equinix.openapi.fabric.v4.model.PriceError.class, new TypeSelector() { - @Override - public Class getClassForElement(JsonElement readElement) { - Map classByDiscriminatorValue = new HashMap(); - classByDiscriminatorValue.put("PriceError", com.equinix.openapi.fabric.v4.model.PriceError.class); - return getClassByDiscriminator(classByDiscriminatorValue, - getDiscriminatorValue(readElement, "errorCode")); - } - }) -; -GsonBuilder builder = fireBuilder.createGsonBuilder(); -return builder; -} - -private static String getDiscriminatorValue(JsonElement readElement, String discriminatorField) { -JsonElement element = readElement.getAsJsonObject().get(discriminatorField); -if (null == element) { -throw new IllegalArgumentException("missing discriminator field: <" + discriminatorField + ">"); -} -return element.getAsString(); -} - -/** -* Returns the Java class that implements the OpenAPI schema for the specified discriminator value. -* -* @param classByDiscriminatorValue The map of discriminator values to Java classes. -* @param discriminatorValue The value of the OpenAPI discriminator in the input data. -* @return The Java class that implements the OpenAPI schema -*/ -private static Class getClassByDiscriminator(Map classByDiscriminatorValue, String discriminatorValue) { -Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue); -if (null == clazz) { -throw new IllegalArgumentException("cannot determine model class of name: <" + discriminatorValue + ">"); -} -return clazz; -} + private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); -static { -GsonBuilder gsonBuilder = createGson(); -gsonBuilder.registerTypeHierarchyAdapter(Collection.class, new CollectionAdapter()); -gsonBuilder.registerTypeAdapter(Date.class, dateTypeAdapter); -gsonBuilder.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter); - gsonBuilder.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter); - gsonBuilder.registerTypeAdapter(LocalDate.class, localDateTypeAdapter); -gsonBuilder.registerTypeAdapter(byte[].class, byteArrayAdapter); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.AccessPoint.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.AccessPointSelector.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Account.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.AddOperation.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.AdvanceConfiguration.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.AllPhysicalPortsResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.AllPortsResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ApiConfig.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ApiServices.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.AuthenticationKey.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.BGPActionData.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.BGPActionRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.BGPActionsBulkData.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.BGPConnectionIpv4.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.BGPConnectionIpv6.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.BGPConnectionOperation.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.BandwidthUtilization.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.BulkPhysicalPort.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.BulkPort.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Change.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Changelog.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CloudRouter.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CloudRouterActionRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CloudRouterActionResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CloudRouterChange.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CloudRouterChangeOperation.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CloudRouterFilter.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CloudRouterFilters.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CloudRouterOrFilter.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CloudRouterPackage.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CloudRouterPostRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CloudRouterPostRequestPackage.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CloudRouterSearchRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CloudRouterSimpleExpression.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CloudRouterSortCriteria.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectedMetro.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Connection.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionAcceptanceData.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionAction.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionActionRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionChangeOperation.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionCompanyProfile.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionInvitation.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionLink.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionOperation.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionPostRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionRedundancy.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionRouteFilterData.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionRouteFiltersBase.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionRoutingProtocolPostRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionSearchResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionSide.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionSideAdditionalInfo.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectivitySource.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CustomField.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.DirectConnectionIpv4.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.DirectConnectionIpv6.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Direction.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Error.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Expression.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.FabricCloudRouterPackages.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.FabricCloudRouterPrice.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.FabricConnectionUuid.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.FilterBody.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.GeoCoordinates.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.GetAllConnectionRouteFiltersResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.GetResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.GetRouteFilterGetConnectionsResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.GetRouteFilterRulesResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.HealthResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.InternetAccess.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.IpBlockPrice.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Ipv4.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.JsonPatchOperation.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Link.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.LinkAggregationGroup.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.LinkProtocol.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.LinkProtocolConnection.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.LinkProtocolDot1q.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.LinkProtocolEvpnVxlan.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.LinkProtocolGetResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.LinkProtocolIpv4Ipv6Config.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.LinkProtocolQinq.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.LinkProtocolResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.LinkProtocolServiceToken.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.LinkProtocolUntagged.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.LinkProtocolVxlan.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.MarketingInfo.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.MarketplaceSubscription.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Md5.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.MetalInterconnection.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Metrics.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Metro.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.MetroError.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.MetroResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ModelInterface.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Network.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.NetworkAllOf.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.NetworkChange.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.NetworkChangeOperation.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.NetworkChangeResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.NetworkConnections.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.NetworkFilter.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.NetworkOperation.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.NetworkPostRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.NetworkSearchRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.NetworkSearchResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.NetworkSortCriteria.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.NetworkSortCriteriaResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Order.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PackageChangeLog.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PackageResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Pagination.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PaginationRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PhysicalPort.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Port.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortAdditionalInfo.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortDemarcationPoint.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortDevice.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortDeviceRedundancy.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortEncapsulation.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortExpression.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortInterface.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortLag.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortLoa.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortNotification.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortOperation.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortOrder.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortOrderPurchaseOrder.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortOrderSignature.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortOrderSignatureDelegate.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortRedundancy.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortSettings.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortSortCriteria.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortTether.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortV4SearchRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PrecisionTimeChangeOperation.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PrecisionTimePackageRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PrecisionTimePackageResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PrecisionTimeServiceConnectionsResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PrecisionTimeServiceCreateResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PrecisionTimeServicePackagesResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PrecisionTimeServiceRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PrecisionTimeServiceResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Price.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PriceCharge.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PriceError.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PriceErrorAdditionalInfo.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PriceLocation.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PriceSearchResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ProcessStep.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Project.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PtpAdvanceConfiguration.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RemoveOperation.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ReplaceOperation.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFilterChangeData.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFilterChangeDataResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFilterConnectionsData.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFilterRulesBase.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFilterRulesChange.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFilterRulesChangeData.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFilterRulesChangeDataResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFilterRulesChangeOperation.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFilterRulesData.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFilterRulesPatchRequestItem.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFilterRulesPostRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFiltersBase.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFiltersChange.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFiltersChangeOperation.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFiltersData.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFiltersDataProject.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFiltersPatchRequestItem.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFiltersSearchBase.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFiltersSearchBaseFilter.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFiltersSearchFilterItem.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFiltersSearchResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteTableEntry.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteTableEntryConnection.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteTableEntryFilter.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteTableEntryFilters.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteTableEntryOrFilter.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteTableEntrySearchRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteTableEntrySearchResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteTableEntrySimpleExpression.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteTableEntrySortCriteria.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RoutingProtocolBFD.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RoutingProtocolBGPData.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RoutingProtocolBGPType.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RoutingProtocolBase.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RoutingProtocolChange.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RoutingProtocolChangeData.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RoutingProtocolChangeDataResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RoutingProtocolChangeOperation.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RoutingProtocolData.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RoutingProtocolDirectData.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RoutingProtocolDirectType.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RoutingProtocolOperation.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SearchExpression.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SearchRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SearchResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceMetro.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceMetros.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfile.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfileAccessPointCOLO.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfileAccessPointType.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfileAccessPointTypeCOLO.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfileAccessPointTypeVD.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfileAccessPointVD.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfileAndFilter.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfileFilter.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfileLinkProtocolConfig.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfileMetadata.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfileRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfileSearchRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfileSimpleExpression.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfileSortCriteria.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfiles.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceSearchResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceToken.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceTokenActionRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceTokenChangeOperation.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceTokenConnection.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceTokenSearchExpression.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceTokenSearchRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceTokenSide.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceTokens.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SimplifiedAccount.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SimplifiedLinkProtocol.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SimplifiedLocation.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SimplifiedLocationWithoutIBX.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SimplifiedMetadataEntity.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SimplifiedNetwork.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SimplifiedNetworkChange.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SimplifiedNotification.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SimplifiedPort.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SimplifiedServiceProfile.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SortCriteria.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SortCriteriaResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SortItem.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Statistics.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SubInterface.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SubscriptionAsset.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SubscriptionEntitlementResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SubscriptionResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SubscriptionRouterPackageType.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SubscriptionTrial.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.TimeServiceFilter.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.TimeServiceFilters.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.TimeServiceOrFilter.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.TimeServiceSimpleExpression.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.TimeServiceSortCriteria.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.TimeServicesSearchRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.TopUtilizedStatistics.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ValidateRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ValidateRequestFilter.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ValidateRequestFilterAnd.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ValidateSubnetResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualConnectionPrice.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualConnectionPriceASide.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualConnectionPriceASideAccessPoint.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualConnectionPriceASideAccessPointPort.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualConnectionPriceASideAccessPointPortSettings.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualConnectionPriceZSide.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualConnectionPriceZSideAccessPoint.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualConnectionPriceZSideAccessPointBridge.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualConnectionPriceZSideAccessPointBridgePackage.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualConnectionPriceZSideAccessPointProfile.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualDevice.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualNetwork.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualPortConfiguration.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualPortLocation.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualPortPrice.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualPortRedundancy.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VpicInterface.CustomTypeAdapterFactory()); -gsonBuilder.registerTypeAdapter(PortEncapsulation.TypeEnum.class,new UppercaseEnumAdapter()); -gsonBuilder.registerTypeAdapter(PortDeviceRedundancy.PriorityEnum.class,new UppercaseEnumAdapter()); -gson = gsonBuilder.setPrettyPrinting().create(); -} + private static final StdDateFormat sdf = new StdDateFormat() + .withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault())) + .withColonInTimeZone(true); + private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME; -public static class UppercaseEnumAdapter implements JsonDeserializer { - @Override - public Enum deserialize(JsonElement json, java.lang.reflect.Type type, JsonDeserializationContext context) - throws JsonParseException { - try { - if(type instanceof Class && ((Class) type).isEnum()) - return Enum.valueOf((Class) type, json.getAsString().toUpperCase()); - return null; - } catch (Exception e) { - e.printStackTrace(); - return null; - } + @SuppressWarnings("unchecked") + public static GsonBuilder createGson() { + GsonFireBuilder fireBuilder = new GsonFireBuilder() + .registerTypeSelector(com.equinix.openapi.fabric.v4.model.LinkProtocol.class, new TypeSelector() { + @Override + public Class getClassForElement(JsonElement readElement) { + Map classByDiscriminatorValue = new HashMap(); + classByDiscriminatorValue.put("DOT1Q", com.equinix.openapi.fabric.v4.model.LinkProtocolDot1q.class); + classByDiscriminatorValue.put("EVPN_VXLAN", com.equinix.openapi.fabric.v4.model.LinkProtocolEvpnVxlan.class); + classByDiscriminatorValue.put("QINQ", com.equinix.openapi.fabric.v4.model.LinkProtocolQinq.class); + classByDiscriminatorValue.put("UNTAGGED", com.equinix.openapi.fabric.v4.model.LinkProtocolUntagged.class); + classByDiscriminatorValue.put("VXLAN", com.equinix.openapi.fabric.v4.model.LinkProtocolVxlan.class); + classByDiscriminatorValue.put("LinkProtocol", com.equinix.openapi.fabric.v4.model.LinkProtocol.class); + return getClassByDiscriminator(classByDiscriminatorValue, + getDiscriminatorValue(readElement, "type")); + } + }) + .registerTypeSelector(com.equinix.openapi.fabric.v4.model.MetroError.class, new TypeSelector() { + @Override + public Class getClassForElement(JsonElement readElement) { + Map classByDiscriminatorValue = new HashMap(); + classByDiscriminatorValue.put("MetroError", com.equinix.openapi.fabric.v4.model.MetroError.class); + return getClassByDiscriminator(classByDiscriminatorValue, + getDiscriminatorValue(readElement, "errorCode")); + } + }) + .registerTypeSelector(com.equinix.openapi.fabric.v4.model.PriceError.class, new TypeSelector() { + @Override + public Class getClassForElement(JsonElement readElement) { + Map classByDiscriminatorValue = new HashMap(); + classByDiscriminatorValue.put("PriceError", com.equinix.openapi.fabric.v4.model.PriceError.class); + return getClassByDiscriminator(classByDiscriminatorValue, + getDiscriminatorValue(readElement, "errorCode")); + } + }) + ; + GsonBuilder builder = fireBuilder.createGsonBuilder(); + return builder; + } + + private static String getDiscriminatorValue(JsonElement readElement, String discriminatorField) { + JsonElement element = readElement.getAsJsonObject().get(discriminatorField); + if (null == element) { + throw new IllegalArgumentException("missing discriminator field: <" + discriminatorField + ">"); } + return element.getAsString(); + } + + /** + * Returns the Java class that implements the OpenAPI schema for the specified discriminator value. + * + * @param classByDiscriminatorValue The map of discriminator values to Java classes. + * @param discriminatorValue The value of the OpenAPI discriminator in the input data. + * @return The Java class that implements the OpenAPI schema + */ + private static Class getClassByDiscriminator(Map classByDiscriminatorValue, String discriminatorValue) { + Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue); + if (null == clazz) { + throw new IllegalArgumentException("cannot determine model class of name: <" + discriminatorValue + ">"); } + return clazz; + } -/** -* Get Gson. -* -* @return Gson -*/ -public static Gson getGson() { -return gson; -} - -/** -* Set Gson. -* -* @param gson Gson -*/ -public static void setGson(Gson gson) { -JSON.gson = gson; -} - -public static void setLenientOnJson(boolean lenientOnJson) { -isLenientOnJson = lenientOnJson; -} - -/** -* Serialize the given Java object into JSON string. -* -* @param obj Object -* @return String representation of the JSON -*/ -public static String serialize(Object obj) { -return gson.toJson(obj); -} - -/** -* Deserialize the given JSON string to Java object. -* -* @param Type - * @param body The JSON string - * @param returnType The type to deserialize into - * @return The deserialized Java object - */ + public static class UppercaseEnumAdapter implements JsonDeserializer { + @Override + public Enum deserialize(JsonElement json, java.lang.reflect.Type type, JsonDeserializationContext context) + throws JsonParseException { + try { + if (type instanceof Class && ((Class) type).isEnum()) + return Enum.valueOf((Class) type, json.getAsString().toUpperCase()); + return null; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + } + + static { + GsonBuilder gsonBuilder = createGson(); + gsonBuilder.registerTypeHierarchyAdapter(Collection.class, new CollectionAdapter()); + gsonBuilder.registerTypeAdapter(Date.class, dateTypeAdapter); + gsonBuilder.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter); + gsonBuilder.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter); + gsonBuilder.registerTypeAdapter(LocalDate.class, localDateTypeAdapter); + gsonBuilder.registerTypeAdapter(byte[].class, byteArrayAdapter); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.AccessPoint.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.AccessPointSelector.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Account.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.AddOperation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.AdvanceConfiguration.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.AllPhysicalPortsResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.AllPortsResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ApiConfig.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ApiServices.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.AuthenticationKey.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.BGPActionData.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.BGPActionRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.BGPActionsBulkData.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.BGPConnectionIpv4.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.BGPConnectionIpv6.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.BGPConnectionOperation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.BandwidthUtilization.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.BulkPhysicalPort.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.BulkPort.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Change.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Changelog.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CloudRouter.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CloudRouterActionRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CloudRouterActionResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CloudRouterChange.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CloudRouterChangeOperation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CloudRouterFilter.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CloudRouterFilters.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CloudRouterOrFilter.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CloudRouterPackage.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CloudRouterPostRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CloudRouterPostRequestPackage.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CloudRouterSearchRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CloudRouterSimpleExpression.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CloudRouterSortCriteria.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectedMetro.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Connection.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionAcceptanceData.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionAction.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionActionRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionChangeOperation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionCompanyProfile.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionInvitation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionLink.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionOperation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionPostRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionRedundancy.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionRouteFilterData.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionRouteFiltersBase.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionRoutingProtocolPostRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionSearchResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionSide.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectionSideAdditionalInfo.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ConnectivitySource.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.CustomField.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.DirectConnectionIpv4.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.DirectConnectionIpv6.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Direction.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Error.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Expression.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.FabricCloudRouterPackages.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.FabricCloudRouterPrice.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.FabricConnectionUuid.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.FilterBody.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.GeoCoordinates.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.GetAllConnectionRouteFiltersResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.GetResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.GetRouteFilterGetConnectionsResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.GetRouteFilterRulesResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.HealthResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.InternetAccess.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.IpBlockPrice.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Ipv4.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.JsonPatchOperation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Link.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.LinkAggregationGroup.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.LinkProtocol.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.LinkProtocolConnection.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.LinkProtocolDot1q.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.LinkProtocolEvpnVxlan.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.LinkProtocolGetResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.LinkProtocolIpv4Ipv6Config.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.LinkProtocolQinq.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.LinkProtocolResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.LinkProtocolServiceToken.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.LinkProtocolUntagged.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.LinkProtocolVxlan.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.MarketingInfo.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.MarketplaceSubscription.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Md5.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.MetalInterconnection.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Metrics.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Metro.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.MetroError.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.MetroResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ModelInterface.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Network.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.NetworkAllOf.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.NetworkChange.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.NetworkChangeOperation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.NetworkChangeResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.NetworkConnections.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.NetworkFilter.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.NetworkOperation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.NetworkPostRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.NetworkSearchRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.NetworkSearchResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.NetworkSortCriteria.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.NetworkSortCriteriaResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Order.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PackageChangeLog.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PackageResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Pagination.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PaginationRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PhysicalPort.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Port.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortAdditionalInfo.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortDemarcationPoint.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortDevice.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortDeviceRedundancy.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortEncapsulation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortExpression.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortInterface.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortLag.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortLoa.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortNotification.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortOperation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortOrder.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortOrderPurchaseOrder.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortOrderSignature.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortOrderSignatureDelegate.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortRedundancy.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortSettings.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortSortCriteria.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortTether.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PortV4SearchRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PrecisionTimeChangeOperation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PrecisionTimePackageRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PrecisionTimePackageResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PrecisionTimeServiceConnectionsResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PrecisionTimeServiceCreateResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PrecisionTimeServicePackagesResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PrecisionTimeServiceRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PrecisionTimeServiceResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Price.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PriceCharge.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PriceError.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PriceErrorAdditionalInfo.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PriceLocation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PriceSearchResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ProcessStep.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Project.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.PtpAdvanceConfiguration.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RemoveOperation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ReplaceOperation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFilterChangeData.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFilterChangeDataResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFilterConnectionsData.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFilterRulesBase.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFilterRulesChange.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFilterRulesChangeData.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFilterRulesChangeDataResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFilterRulesChangeOperation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFilterRulesData.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFilterRulesPatchRequestItem.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFilterRulesPostRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFiltersBase.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFiltersChange.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFiltersChangeOperation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFiltersData.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFiltersDataProject.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFiltersPatchRequestItem.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFiltersSearchBase.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFiltersSearchBaseFilter.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFiltersSearchFilterItem.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteFiltersSearchResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteTableEntry.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteTableEntryConnection.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteTableEntryFilter.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteTableEntryFilters.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteTableEntryOrFilter.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteTableEntrySearchRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteTableEntrySearchResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteTableEntrySimpleExpression.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RouteTableEntrySortCriteria.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RoutingProtocolBFD.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RoutingProtocolBGPData.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RoutingProtocolBGPType.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RoutingProtocolBase.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RoutingProtocolChange.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RoutingProtocolChangeData.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RoutingProtocolChangeDataResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RoutingProtocolChangeOperation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RoutingProtocolData.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RoutingProtocolDirectData.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RoutingProtocolDirectType.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.RoutingProtocolOperation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SearchExpression.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SearchRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SearchResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceMetro.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceMetros.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfile.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfileAccessPointCOLO.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfileAccessPointType.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfileAccessPointTypeCOLO.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfileAccessPointTypeVD.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfileAccessPointVD.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfileAndFilter.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfileFilter.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfileLinkProtocolConfig.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfileMetadata.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfileRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfileSearchRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfileSimpleExpression.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfileSortCriteria.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceProfiles.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceSearchResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceToken.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceTokenActionRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceTokenChangeOperation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceTokenConnection.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceTokenSearchExpression.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceTokenSearchRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceTokenSide.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ServiceTokens.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SimplifiedAccount.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SimplifiedLinkProtocol.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SimplifiedLocation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SimplifiedLocationWithoutIBX.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SimplifiedMetadataEntity.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SimplifiedNetwork.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SimplifiedNetworkChange.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SimplifiedNotification.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SimplifiedPort.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SimplifiedServiceProfile.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SortCriteria.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SortCriteriaResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SortItem.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.Statistics.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SubInterface.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SubscriptionAsset.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SubscriptionEntitlementResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SubscriptionResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SubscriptionRouterPackageType.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.SubscriptionTrial.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.TimeServiceFilter.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.TimeServiceFilters.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.TimeServiceOrFilter.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.TimeServiceSimpleExpression.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.TimeServiceSortCriteria.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.TimeServicesSearchRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.TopUtilizedStatistics.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ValidateRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ValidateRequestFilter.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ValidateRequestFilterAnd.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.ValidateSubnetResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualConnectionPrice.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualConnectionPriceASide.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualConnectionPriceASideAccessPoint.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualConnectionPriceASideAccessPointPort.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualConnectionPriceASideAccessPointPortSettings.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualConnectionPriceZSide.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualConnectionPriceZSideAccessPoint.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualConnectionPriceZSideAccessPointBridge.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualConnectionPriceZSideAccessPointBridgePackage.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualConnectionPriceZSideAccessPointProfile.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualDevice.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualNetwork.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualPortConfiguration.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualPortLocation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualPortPrice.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VirtualPortRedundancy.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.openapi.fabric.v4.model.VpicInterface.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapter(PortEncapsulation.TypeEnum.class,new UppercaseEnumAdapter()); + gsonBuilder.registerTypeAdapter(PortDeviceRedundancy.PriorityEnum.class,new UppercaseEnumAdapter()); + gson = gsonBuilder.setPrettyPrinting().create(); + } + + /** + * Get Gson. + * + * @return Gson + */ + public static Gson getGson() { + return gson; + } + + /** + * Set Gson. + * + * @param gson Gson + */ + public static void setGson(Gson gson) { + JSON.gson = gson; + } + + public static void setLenientOnJson(boolean lenientOnJson) { + isLenientOnJson = lenientOnJson; + } + + /** + * Serialize the given Java object into JSON string. + * + * @param obj Object + * @return String representation of the JSON + */ + public static String serialize(Object obj) { + return gson.toJson(obj); + } + + /** + * Deserialize the given JSON string to Java object. + * + * @param Type + * @param body The JSON string + * @param returnType The type to deserialize into + * @return The deserialized Java object + */ @SuppressWarnings("unchecked") public static T deserialize(String body, Type returnType) { try { - if (isLenientOnJson) { - JsonReader jsonReader = new JsonReader(new StringReader(body)); - // see https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean) - jsonReader.setLenient(true); - return gson.fromJson(jsonReader, returnType); - } else { - return gson.fromJson(body, returnType); - } + if (isLenientOnJson) { + JsonReader jsonReader = new JsonReader(new StringReader(body)); + // see https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean) + jsonReader.setLenient(true); + return gson.fromJson(jsonReader, returnType); + } else { + return gson.fromJson(body, returnType); + } } catch (JsonParseException e) { - // Fallback processing when failed to parse JSON form response body: - // return the response body string directly for the String return type; - if (returnType.equals(String.class)) { - return (T) body; - } else { - throw (e); - } - } + // Fallback processing when failed to parse JSON form response body: + // return the response body string directly for the String return type; + if (returnType.equals(String.class)) { + return (T) body; + } else { + throw (e); + } } + } - /** - * Gson TypeAdapter for Byte Array type - */ - public static class ByteArrayAdapter extends TypeAdapter { + /** + * Gson TypeAdapter for Byte Array type + */ + public static class ByteArrayAdapter extends TypeAdapter { @Override public void write(JsonWriter out, byte[] value) throws IOException { - if (value == null) { - out.nullValue(); - } else { - out.value(ByteString.of(value).base64()); - } + if (value == null) { + out.nullValue(); + } else { + out.value(ByteString.of(value).base64()); + } } @Override public byte[] read(JsonReader in) throws IOException { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String bytesAsBase64 = in.nextString(); - ByteString byteString = ByteString.decodeBase64(bytesAsBase64); - return byteString.toByteArray(); - } - } + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String bytesAsBase64 = in.nextString(); + ByteString byteString = ByteString.decodeBase64(bytesAsBase64); + return byteString.toByteArray(); + } } + } - /** - * Gson TypeAdapter for JSR310 OffsetDateTime type - */ - public static class OffsetDateTimeTypeAdapter extends TypeAdapter { + /** + * Gson TypeAdapter for JSR310 OffsetDateTime type + */ + public static class OffsetDateTimeTypeAdapter extends TypeAdapter { - private DateTimeFormatter formatter; + private DateTimeFormatter formatter; - public OffsetDateTimeTypeAdapter() { + public OffsetDateTimeTypeAdapter() { this(DateTimeFormatter.ISO_OFFSET_DATE_TIME); - } + } - public OffsetDateTimeTypeAdapter(DateTimeFormatter formatter) { + public OffsetDateTimeTypeAdapter(DateTimeFormatter formatter) { this.formatter = formatter; - } + } - public void setFormat(DateTimeFormatter dateFormat) { + public void setFormat(DateTimeFormatter dateFormat) { this.formatter = dateFormat; - } + } - @Override - public void write(JsonWriter out, OffsetDateTime date) throws IOException { + @Override + public void write(JsonWriter out, OffsetDateTime date) throws IOException { if (date == null) { - out.nullValue(); + out.nullValue(); } else { - out.value(formatter.format(date)); - } + out.value(formatter.format(date)); } + } - @Override - public OffsetDateTime read(JsonReader in) throws IOException { + @Override + public OffsetDateTime read(JsonReader in) throws IOException { switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - if (date.endsWith("+0000")) { - date = date.substring(0, date.length()-5) + "Z"; - } - return OffsetDateTime.parse(date, formatter); - } - } + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + if (date.endsWith("+0000")) { + date = date.substring(0, date.length()-5) + "Z"; + } + return OffsetDateTime.parse(date, formatter); } + } + } - /** - * Gson TypeAdapter for JSR310 LocalDate type - */ - public static class LocalDateTypeAdapter extends TypeAdapter { + /** + * Gson TypeAdapter for JSR310 LocalDate type + */ + public static class LocalDateTypeAdapter extends TypeAdapter { - private DateTimeFormatter formatter; + private DateTimeFormatter formatter; - public LocalDateTypeAdapter() { + public LocalDateTypeAdapter() { this(DateTimeFormatter.ISO_LOCAL_DATE); - } + } - public LocalDateTypeAdapter(DateTimeFormatter formatter) { + public LocalDateTypeAdapter(DateTimeFormatter formatter) { this.formatter = formatter; - } + } - public void setFormat(DateTimeFormatter dateFormat) { + public void setFormat(DateTimeFormatter dateFormat) { this.formatter = dateFormat; - } + } - @Override - public void write(JsonWriter out, LocalDate date) throws IOException { + @Override + public void write(JsonWriter out, LocalDate date) throws IOException { if (date == null) { - out.nullValue(); + out.nullValue(); } else { - out.value(formatter.format(date)); - } + out.value(formatter.format(date)); } + } - @Override - public LocalDate read(JsonReader in) throws IOException { + @Override + public LocalDate read(JsonReader in) throws IOException { switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - return LocalDate.parse(date, formatter); - } - } + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + return LocalDate.parse(date, formatter); } + } + } - public static void setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { - offsetDateTimeTypeAdapter.setFormat(dateFormat); - } + public static void setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { + offsetDateTimeTypeAdapter.setFormat(dateFormat); + } - public static void setLocalDateFormat(DateTimeFormatter dateFormat) { - localDateTypeAdapter.setFormat(dateFormat); - } + public static void setLocalDateFormat(DateTimeFormatter dateFormat) { + localDateTypeAdapter.setFormat(dateFormat); + } - /** - * Gson TypeAdapter for java.sql.Date type - * If the dateFormat is null, a simple "yyyy-MM-dd" format will be used - * (more efficient than SimpleDateFormat). - */ - public static class SqlDateTypeAdapter extends TypeAdapter { + /** + * Gson TypeAdapter for java.sql.Date type + * If the dateFormat is null, a simple "yyyy-MM-dd" format will be used + * (more efficient than SimpleDateFormat). + */ + public static class SqlDateTypeAdapter extends TypeAdapter { - private DateFormat dateFormat; + private DateFormat dateFormat; - public SqlDateTypeAdapter() {} + public SqlDateTypeAdapter() {} - public SqlDateTypeAdapter(DateFormat dateFormat) { + public SqlDateTypeAdapter(DateFormat dateFormat) { this.dateFormat = dateFormat; - } + } - public void setFormat(DateFormat dateFormat) { + public void setFormat(DateFormat dateFormat) { this.dateFormat = dateFormat; - } + } - @Override - public void write(JsonWriter out, java.sql.Date date) throws IOException { + @Override + public void write(JsonWriter out, java.sql.Date date) throws IOException { if (date == null) { - out.nullValue(); - } else { - String value; - if (dateFormat != null) { - value = dateFormat.format(date); + out.nullValue(); } else { - value = date.toString(); - } - out.value(value); - } + String value; + if (dateFormat != null) { + value = dateFormat.format(date); + } else { + value = date.toString(); + } + out.value(value); } + } - @Override - public java.sql.Date read(JsonReader in) throws IOException { + @Override + public java.sql.Date read(JsonReader in) throws IOException { switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - try { - if (dateFormat != null) { - return new java.sql.Date(dateFormat.parse(date).getTime()); - } - return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime()); - } catch (ParseException e) { - throw new JsonParseException(e); - } - } - } + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return new java.sql.Date(dateFormat.parse(date).getTime()); + } + return new java.sql.Date(sdf.parse(date).getTime()); + } catch (ParseException e) { + throw new JsonParseException(e); + } } + } + } - /** - * Gson TypeAdapter for java.util.Date type - * If the dateFormat is null, ISO8601Utils will be used. - */ - public static class DateTypeAdapter extends TypeAdapter { + /** + * Gson TypeAdapter for java.util.Date type + * If the dateFormat is null, DateTimeFormatter will be used. + */ + public static class DateTypeAdapter extends TypeAdapter { - private DateFormat dateFormat; + private DateFormat dateFormat; - public DateTypeAdapter() {} + public DateTypeAdapter() {} - public DateTypeAdapter(DateFormat dateFormat) { - this.dateFormat = dateFormat; - } + public DateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } - public void setFormat(DateFormat dateFormat) { - this.dateFormat = dateFormat; - } + public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } - @Override - public void write(JsonWriter out, Date date) throws IOException { - if (date == null) { + @Override + public void write(JsonWriter out, Date date) throws IOException { + if (date == null) { out.nullValue(); - } else { + } else { String value; if (dateFormat != null) { - value = dateFormat.format(date); + value = dateFormat.format(date); } else { - value = ISO8601Utils.format(date, true); + value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf); } out.value(value); - } - } + } + } - @Override - public Date read(JsonReader in) throws IOException { - try { + @Override + public Date read(JsonReader in) throws IOException { + try { switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - try { - if (dateFormat != null) { - return dateFormat.parse(date); - } - return ISO8601Utils.parse(date, new ParsePosition(0)); - } catch (ParseException e) { - throw new JsonParseException(e); + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return dateFormat.parse(date); + } + return sdf.parse(date); + } catch (ParseException e) { + throw new JsonParseException(e); + } } - } - } catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { throw new JsonParseException(e); - } - } - } + } + } + } - public static void setDateFormat(DateFormat dateFormat) { - dateTypeAdapter.setFormat(dateFormat); - } + public static void setDateFormat(DateFormat dateFormat) { + dateTypeAdapter.setFormat(dateFormat); + } - public static void setSqlDateFormat(DateFormat dateFormat) { - sqlDateTypeAdapter.setFormat(dateFormat); - } - } - class CollectionAdapter implements JsonSerializer> { + public static void setSqlDateFormat(DateFormat dateFormat) { + sqlDateTypeAdapter.setFormat(dateFormat); + } +} - @Override - public JsonElement serialize(Collection src, Type typeOfSrc, JsonSerializationContext context) { - if (src == null || src.isEmpty()) // exclusion is made here - return null; +class CollectionAdapter implements JsonSerializer> { - JsonArray array = new JsonArray(); + @Override + public JsonElement serialize(Collection src, Type typeOfSrc, JsonSerializationContext context) { + if (src == null || src.isEmpty()) // exclusion is made here + return null; - for (Object child : src) { - JsonElement element = context.serialize(child); - array.add(element); - } + JsonArray array = new JsonArray(); - return array; - } - } + for (Object child : src) { + JsonElement element = context.serialize(child); + array.add(element); + } + + return array; + } +} diff --git a/equinix-openapi-fabric/src/main/java/com/equinix/openapi/fabric/v4/model/Port.java b/equinix-openapi-fabric/src/main/java/com/equinix/openapi/fabric/v4/model/Port.java index f7ad39ee..d9e50a24 100644 --- a/equinix-openapi-fabric/src/main/java/com/equinix/openapi/fabric/v4/model/Port.java +++ b/equinix-openapi-fabric/src/main/java/com/equinix/openapi/fabric/v4/model/Port.java @@ -446,7 +446,7 @@ public Port type(PortType type) { * Get type * @return type **/ - @javax.annotation.Nonnull + @javax.annotation.Nullable public PortType getType() { return type; @@ -1556,7 +1556,6 @@ private String toIndentedString(Object o) { // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("type"); openapiRequiredFields.add("account"); openapiRequiredFields.add("location"); openapiRequiredFields.add("encapsulation"); diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/MetrosApiTest.java b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/MetrosApiTest.java deleted file mode 100644 index 1bc32c29..00000000 --- a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/MetrosApiTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Equinix Fabric API v4 - * - * Contact: api-support@equinix.com - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.equinix.openapi.fabric.v4.api; - -import com.equinix.openapi.fabric.ApiException; -import com.equinix.openapi.fabric.v4.model.Metro; -import com.equinix.openapi.fabric.v4.model.MetroResponse; -import com.equinix.openapi.fabric.v4.model.Presence; -import org.junit.jupiter.api.Test; - -import static com.equinix.openapi.fabric.v4.api.helpers.Apis.metrosApi; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * API tests for MetrosApi - */ -public class MetrosApiTest { - private final String metroCode = "DC"; - - @Test - public void getMetroByCode() throws ApiException { - Metro metro = metrosApi.getMetroByCode(metroCode); - assertEquals(200, metrosApi.getApiClient().getStatusCode()); - assertEquals(metroCode, metro.getCode()); - } - - @Test - public void getMetros() throws ApiException { - MetroResponse metroResponse = metrosApi.getMetros(Presence.MY_PORTS, 1, 10); - assertEquals(200, metrosApi.getApiClient().getStatusCode()); - boolean metroFound = metroResponse.getData().stream().anyMatch(metro -> metro.getCode().equals(metroCode)); - assertTrue(metroFound); - } -} diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/NetworksApiTest.java b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/NetworksApiTest.java deleted file mode 100644 index b74fef68..00000000 --- a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/NetworksApiTest.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Equinix Fabric API v4 - * - * Contact: api-support@equinix.com - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.equinix.openapi.fabric.v4.api; - -import com.equinix.openapi.fabric.ApiException; -import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem; -import com.equinix.openapi.fabric.v4.api.helpers.Utils; -import com.equinix.openapi.fabric.v4.model.*; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -import java.util.UUID; - -import static com.equinix.openapi.fabric.v4.api.helpers.TokenGenerator.users; -import static com.equinix.openapi.fabric.v4.api.helpers.Apis.networksApi; -import static com.equinix.openapi.fabric.v4.api.helpers.Apis.setUserName; -import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; - -/** - * API tests for NetworksApi - */ -class NetworksApiTest { - private static final UsersItem.UserName userName = UsersItem.UserName.PANTHERS_FNV; - - public static void removeNetworks(UsersItem.UserName userName) { - users.get(userName).getUserResources().getNetworksUuid().forEach(com.equinix.openapi.fabric.v4.api.NetworksApiTest::deleteNetwork); - } - - @BeforeAll - public static void setUp() { - setUserName(userName); - } - - @AfterAll - public static void removeResources() { - removeNetworks(userName); - } - - public Network createNetwork() throws ApiException { - UsersItem user = Utils.getUserData(userName); - NetworkPostRequest networkPostRequest = new NetworkPostRequest() - .name("network_panthers_test") - .type(NetworkType.EVPLAN) - .scope(NetworkScope.LOCAL) - .project(new Project().projectId(user.getProjectId())) - .notifications(singletonList(new SimplifiedNotification() - .type(SimplifiedNotification.TypeEnum.ALL).emails(singletonList("test@equinix.com")))); - - Network network = networksApi.createNetwork(networkPostRequest); - assertEquals(201, networksApi.getApiClient().getStatusCode()); - - for (int i = 0; i < 5; i++) { - Network networkGet = networksApi.getNetworkByUuid(network.getUuid()); - - if (networkGet.getState().equals(NetworkState.ACTIVE)) { - break; - } - try { - Thread.sleep(2000); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - - users.get(userName).getUserResources().addNetworkUuid(network.getUuid()); - return network; - } - - /** - * Fabric Network Access point object - */ - @Test - public void validateNetworkCreation() throws ApiException { - createNetwork(); - } - - public static void deleteNetwork(UUID uuid) { - - try { - Network network = networksApi.getNetworkByUuid(uuid); - if (!network.getState().equals(NetworkState.DELETED)) { - networksApi.deleteNetworkByUuid(uuid); - assertEquals(202, networksApi.getApiClient().getStatusCode()); - } - } catch (ApiException e) { - throw new RuntimeException(e); - } - } - - /** - * Fabric Network Access point object - */ - @Test - public void deleteNetworkByUuid() throws ApiException { - Network network = createNetwork(); - deleteNetwork(network.getUuid()); - } - - /** - * Fabric Network Access point object - */ - @Test - public void getNetworkByUuid() throws ApiException { - Network network = createNetwork(); - Network networkGetResponse = networksApi.getNetworkByUuid(network.getUuid()); - assertEquals(200, networksApi.getApiClient().getStatusCode()); - assertEquals(network.getUuid(), networkGetResponse.getUuid()); - assertEquals(network.getName(), networkGetResponse.getName()); - } - - /** - * Fabric Network Access point object - */ - @Test - public void updateNetwork() throws ApiException { - String updatedName = "network_new_updatedName"; - Network network = createNetwork(); - NetworkChangeOperation changeOperation = new NetworkChangeOperation() - .op(NetworkChangeOperation.OpEnum.REPLACE) - .path(NetworkSearchFieldName.NAME.getValue()) - .value(updatedName); - - Network networkPutResponse = networksApi.updateNetworkByUuid(network.getUuid(), singletonList(changeOperation)); - assertEquals(200, networksApi.getApiClient().getStatusCode()); - assertEquals(updatedName, networkPutResponse.getName()); - } - - /** - * Fabric Network Access point object - */ - @Test - public void searchNetwork() throws ApiException { - Network network = createNetwork(); - NetworkSearchRequest networkSearchRequest = new NetworkSearchRequest() - .filter(new NetworkFilter().addAndItem(new NetworkFilter() - .property(NetworkSearchFieldName.UUID) - .operator(NetworkFilter.OperatorEnum.EQUAL) - .values(singletonList(String.valueOf(network.getUuid()))))) - .sort(singletonList(new NetworkSortCriteria().direction(NetworkSortDirection.DESC).property(NetworkSortBy.CHANGELOG_CREATEDDATETIME))) - .pagination(new PaginationRequest().offset(0).limit(20)); - - NetworkSearchResponse networkSearchResponse = networksApi.searchNetworks(networkSearchRequest); - - assertEquals(200, networksApi.getApiClient().getStatusCode()); - assertFalse(networkSearchResponse.getData().isEmpty()); - } -} diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/PricesApiTest.java b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/PricesApiTest.java deleted file mode 100644 index 5960228f..00000000 --- a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/PricesApiTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Equinix Fabric API v4 - * - * Contact: api-support@equinix.com - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.equinix.openapi.fabric.v4.api; - -import com.equinix.openapi.fabric.ApiException; -import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem; -import com.equinix.openapi.fabric.v4.model.FilterBody; -import com.equinix.openapi.fabric.v4.model.PriceSearchResponse; -import com.equinix.openapi.fabric.v4.model.SearchExpression; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -import java.util.Arrays; -import java.util.Collections; - -import static com.equinix.openapi.fabric.v4.api.helpers.Apis.pricesApi; -import static com.equinix.openapi.fabric.v4.api.helpers.Apis.setUserName; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; - -/** - * API tests for PricesApi - */ -public class PricesApiTest { - - @BeforeAll - public static void setUp() { - setUserName(UsersItem.UserName.PANTHERS_FCR); - } - - @Test - public void searchPrices() throws ApiException { - SearchExpression itemProperty1 = new SearchExpression() - .property("/type") - .operator(SearchExpression.OperatorEnum.EQUAL) - .values(Collections.singletonList("IP_BLOCK_PRODUCT")); - SearchExpression itemProperty2 = new SearchExpression() - .property("/ipBlock/type") - .operator(SearchExpression.OperatorEnum.EQUAL) - .values(Collections.singletonList("IPv4")); - SearchExpression itemProperty3 = new SearchExpression() - .property("/ipBlock/prefixLength") - .operator(SearchExpression.OperatorEnum.EQUAL) - .values(Collections.singletonList("29")); - SearchExpression itemProperty4 = new SearchExpression(). - property("/ipBlock/location/metroCode") - .operator(SearchExpression.OperatorEnum.IN) - .values(Arrays.asList("SV", "WA")); - - SearchExpression item = new SearchExpression().and(Arrays.asList(itemProperty1, itemProperty2, itemProperty3, itemProperty4)); - - FilterBody filterBody = new FilterBody(); - filterBody.setFilter(item); - - PriceSearchResponse priceSearchResponse = pricesApi.searchPrices(filterBody); - assertEquals(200, pricesApi.getApiClient().getStatusCode()); - assertNotEquals(null, priceSearchResponse.getData().get(0).getType()); - } -} diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/RoutingProtocolsApiTest.java b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/RoutingProtocolsApiTest.java deleted file mode 100644 index 06ae9bc8..00000000 --- a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/RoutingProtocolsApiTest.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Equinix Fabric API v4 - * - * Contact: api-support@equinix.com - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.equinix.openapi.fabric.v4.api; - -import com.equinix.openapi.fabric.ApiException; -import com.equinix.openapi.fabric.v4.api.dto.users.UserResources; -import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem; -import com.equinix.openapi.fabric.v4.model.*; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -import java.util.UUID; - -import static com.equinix.openapi.fabric.v4.api.CloudRoutersApiTest.removeCloudRouters; -import static com.equinix.openapi.fabric.v4.api.ConnectionsApiTest.createConnectionFCR2ToPort; -import static com.equinix.openapi.fabric.v4.api.ConnectionsApiTest.removeConnections; -import static com.equinix.openapi.fabric.v4.api.helpers.Apis.*; -import static com.equinix.openapi.fabric.v4.api.helpers.TokenGenerator.users; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * API tests for RoutingProtocolsApi - */ -public class RoutingProtocolsApiTest { - private static final UsersItem.UserName userName = UsersItem.UserName.PANTHERS_FCR; - - public static void removeRoutingInstances(UsersItem.UserName userName) { - users.get(userName).getUserResources().getRoutingProtocolsUuid().forEach(RoutingProtocolsApiTest::deleteRoutingProtocol); - } - - @BeforeAll - public static void setUp() { - setUserName(userName); - } - - @AfterAll - public static void removeResources() { - try { - Thread.sleep(15000); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - removeRoutingInstances(userName); - removeConnections(userName); - removeCloudRouters(userName); - } - - /** - * Successful operation - */ - @Test - public void createConnectionRoutingProtocol() throws ApiException { - Connection connection = createConnectionFCR2ToPort(); - String ipDirect = "192.68.100.1/20"; - - RoutingProtocolBase routingProtocolBaseDIRECT = new RoutingProtocolBase(new RoutingProtocolDirectType().type(RoutingProtocolDirectType.TypeEnum.DIRECT).directIpv4(new DirectConnectionIpv4().equinixIfaceIp(ipDirect))); - - try { - RoutingProtocolData response = routingProtocolsApi.createConnectionRoutingProtocol(connection.getUuid(), routingProtocolBaseDIRECT); - waitForDirectTypeIsProvisioned(response.getRoutingProtocolDirectData().getUuid(), connection.getUuid()); - } catch (Exception e) { - - } - - assertEquals(202, connectionsApi.getApiClient().getStatusCode()); - - String ipBGP = "192.68.100.105"; - - RoutingProtocolBase routingProtocolBaseBGP = new RoutingProtocolBase(new RoutingProtocolBGPType().type(RoutingProtocolBGPType.TypeEnum.BGP).bgpIpv4(new BGPConnectionIpv4().customerPeerIp(ipBGP).enabled(true).outboundASPrependCount(0L)).customerAsn(1245L).asOverrideEnabled(false).bfd(new RoutingProtocolBFD().enabled(false))); - - try { - RoutingProtocolData response = routingProtocolsApi.createConnectionRoutingProtocol(connection.getUuid(), routingProtocolBaseBGP); - waitForBGPTypeIsProvisioned(response.getRoutingProtocolBGPData().getUuid(), connection.getUuid()); - } catch (Exception e) { - - } - - assertEquals(202, connectionsApi.getApiClient().getStatusCode()); - } - - public static void deleteRoutingProtocol(UserResources.RoutingProtocolDto routingProtocolDto) { - try { - routingProtocolsApi.deleteConnectionRoutingProtocolByUuid(routingProtocolDto.getRoutingInstanceUuid(), String.valueOf(routingProtocolDto.getConnectionUuid())); - assertEquals(202, routingProtocolsApi.getApiClient().getStatusCode()); - } catch (ApiException e) { - throw new RuntimeException(e); - } - } - - private static void waitForDirectTypeIsProvisioned(UUID routingProtocolUuid, String connectionUuid) throws ApiException { - boolean result = false; - RoutingProtocolDirectData.StateEnum currentState = null; - for (int i = 0; i < 5; i++) { - RoutingProtocolData routingProtocolData = routingProtocolsApi.getConnectionRoutingProtocolByUuid(routingProtocolUuid, connectionUuid); - currentState = routingProtocolData.getRoutingProtocolDirectData().getState(); - - if (currentState.equals(RoutingProtocolDirectData.StateEnum.PROVISIONED)) { - result = true; - break; - } - try { - Thread.sleep(3000); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - - assertTrue(result, "Routing Protocol has not reached the expected state: " + RoutingProtocolDirectData.StateEnum.PROVISIONED + " current state: " + currentState.getValue() + " for connection " + "uuid " + connectionUuid); - } - - private static void waitForBGPTypeIsProvisioned(UUID routingProtocolUuid, String connectionUuid) throws ApiException { - boolean result = false; - RoutingProtocolBGPData.StateEnum currentState = null; - for (int i = 0; i < 5; i++) { - RoutingProtocolData routingProtocolData = routingProtocolsApi.getConnectionRoutingProtocolByUuid(routingProtocolUuid, connectionUuid); - currentState = routingProtocolData.getRoutingProtocolBGPData().getState(); - - if (currentState.equals(RoutingProtocolBGPData.StateEnum.PROVISIONED)) { - result = true; - break; - } - try { - Thread.sleep(3000); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - - assertTrue(result, "Routing Protocol has not reached the expected state: " + RoutingProtocolBGPData.StateEnum.PROVISIONED + " current state: " + currentState.getValue() + " for connection " + "uuid " + connectionUuid); - } -} diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/TokenGenerator.java b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/TokenGenerator.java deleted file mode 100644 index 00438502..00000000 --- a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/TokenGenerator.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Equinix Fabric API v4 - * - * Contact: api-support@equinix.com - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.equinix.openapi.fabric.v4.api; - -import com.equinix.openapi.fabric.ApiClient; -import com.equinix.openapi.fabric.ApiException; -import com.equinix.openapi.fabric.Configuration; -import com.equinix.openapi.fabric.Pair; -import com.equinix.openapi.fabric.v4.api.dto.TokenRequestDto; -import com.equinix.openapi.fabric.v4.api.dto.TokenResponseDto; -import com.equinix.openapi.fabric.v4.api.dto.users.UserUsedDto; -import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class TokenGenerator { - - public static Map users = new HashMap<>(); - - public static ApiClient getApiClient(UsersItem.UserName userName) { - if (users.containsKey(userName)) { - return users.get(userName).getApiClient(); - } else { - return generate(userName); - } - } - - private static ApiClient generate(UsersItem.UserName userName) { - String baseUrl = System.getProperty("envUrl"); - UsersItem user = Utils.getUserData(userName); - - ApiClient apiTokeClient = Configuration.getDefaultApiClient(); - TokenRequestDto tokenRequestDto = new TokenRequestDto(); - tokenRequestDto.setClientId(user.getClientId()); - tokenRequestDto.setClientSecret(user.getClientSecret()); - tokenRequestDto.setGrantType("client_credentials"); - - String localVarPath = "/oauth2/v1/token"; - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarCookieParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - localVarHeaderParams.put("Content-Type", "application/json"); - String[] localVarAuthNames = new String[]{"BearerAuth"}; - - okhttp3.Call call; - TokenResponseDto tokenResponseDto = null; - - try { - call = apiTokeClient.buildCall(baseUrl, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, tokenRequestDto, localVarHeaderParams - , localVarCookieParams, localVarFormParams, localVarAuthNames, null); - - Type localVarReturnType = new TypeToken() { - }.getType(); - tokenResponseDto = (TokenResponseDto) apiTokeClient.execute(call, localVarReturnType).getData(); - } catch (ApiException e) { - throw new RuntimeException(e); - } - - ApiClient apiClient = Configuration.getDefaultApiClient().setBasePath(baseUrl); - apiClient.addDefaultHeader("Authorization", String.format("Bearer %s", tokenResponseDto.getAccessToken())); - users.put(userName, new UserUsedDto(userName, apiClient)); - return users.get(userName).getApiClient(); - } -} diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/Utils.java b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/Utils.java deleted file mode 100644 index b3e7c452..00000000 --- a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/Utils.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.equinix.openapi.fabric.v4.api; - -import com.equinix.openapi.fabric.JSON; -import com.equinix.openapi.fabric.v4.api.dto.users.UsersDto; -import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem; -import com.fasterxml.jackson.databind.ObjectMapper; - -import java.io.IOException; -import java.util.NoSuchElementException; - -public class Utils { - - public static Object getEnvData(EnvVariable envVariable) { - ObjectMapper mapper = new ObjectMapper(); - String json = System.getenv(envVariable.value); - try { - return mapper.readValue(json, envVariable.clazz); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - public static UsersItem getUserData(UsersItem.UserName userName) { - return ((UsersDto) getEnvData(EnvVariable.TEST_DATA_UAT_USERS)).getUsers().stream() - .filter(usersItem -> usersItem.getName().equals(userName.getValue())) - .findFirst().orElseThrow(() -> new NoSuchElementException("User not found")); - } - - public static void printJson(Object object) { - System.out.println(JSON.getGson().toJson(object)); - } - - public enum EnvVariable { - TEST_DATA_UAT_USERS("TEST_DATA_UAT_USERS", UsersDto.class); - - private String value; - private Class clazz; - - EnvVariable(String value, Class clazz) { - this.value = value; - this.clazz = clazz; - } - - @Override - public String toString() { - return String.valueOf(value); - } - } -} diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/TokenRequestDto.java b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/TokenRequestDto.java deleted file mode 100644 index 87f247c3..00000000 --- a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/TokenRequestDto.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.equinix.openapi.fabric.v4.api.dto; - -import com.google.gson.annotations.SerializedName; - -public class TokenRequestDto{ - - @SerializedName("grant_type") - private String grantType; - - @SerializedName("client_secret") - private String clientSecret; - - @SerializedName("client_id") - private String clientId; - - public void setGrantType(String grantType){ - this.grantType = grantType; - } - - public String getGrantType(){ - return grantType; - } - - public void setClientSecret(String clientSecret){ - this.clientSecret = clientSecret; - } - - public String getClientSecret(){ - return clientSecret; - } - - public void setClientId(String clientId){ - this.clientId = clientId; - } - - public String getClientId(){ - return clientId; - } -} \ No newline at end of file diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/TokenResponseDto.java b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/TokenResponseDto.java deleted file mode 100644 index 81a5664f..00000000 --- a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/TokenResponseDto.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.equinix.openapi.fabric.v4.api.dto; - -import com.google.gson.annotations.SerializedName; - -public class TokenResponseDto{ - - @SerializedName("access_token") - private String accessToken; - - @SerializedName("user_name") - private String userName; - - @SerializedName("token_timeout") - private String tokenTimeout; - - @SerializedName("token_type") - private String tokenType; - - public String getAccessToken(){ - return accessToken; - } - - public String getUserName(){ - return userName; - } - - public String getTokenTimeout(){ - return tokenTimeout; - } - - public String getTokenType(){ - return tokenType; - } -} \ No newline at end of file diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/Location.java b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/Location.java deleted file mode 100644 index 77ed7113..00000000 --- a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/Location.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.equinix.openapi.fabric.v4.api.dto.port; - -import com.google.gson.annotations.SerializedName; - -public class Location{ - - @SerializedName("metroName") - private String metroName; - - @SerializedName("metroCode") - private String metroCode; - - @SerializedName("region") - private String region; - - @SerializedName("ibx") - private String ibx; - - public String getMetroName(){ - return metroName; - } - - public String getMetroCode(){ - return metroCode; - } - - public String getRegion(){ - return region; - } - - public String getIbx(){ - return ibx; - } -} \ No newline at end of file diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/PortDto.java b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/PortDto.java deleted file mode 100644 index 3c82647f..00000000 --- a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/PortDto.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.equinix.openapi.fabric.v4.api.dto.port; - -import com.google.gson.annotations.SerializedName; - -public class PortDto { - - @SerializedName("encapsulation") - private String encapsulation; - - @SerializedName("name") - private String name; - - @SerializedName("location") - private Location location; - - @SerializedName("type") - private String type; - - @SerializedName("uuid") - private String uuid; - - public String getEncapsulation(){ - return encapsulation; - } - - public String getName(){ - return name; - } - - public Location getLocation(){ - return location; - } - - public String getType(){ - return type; - } - - public String getUuid(){ - return uuid; - } -} diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/UsersItem.java b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/UsersItem.java deleted file mode 100644 index 6df62bc0..00000000 --- a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/UsersItem.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.equinix.openapi.fabric.v4.api.dto.port; - -import java.util.List; -import com.google.gson.annotations.SerializedName; - -public class UsersItem{ - - @SerializedName("virtualDevices") - private List virtualDevices; - - @SerializedName("name") - private String name; - - @SerializedName("client_secret") - private String clientSecret; - - @SerializedName("accountNumber") - private String accountNumber; - - @SerializedName("ports") - private List ports; - - @SerializedName("projectId") - private String projectId; - - @SerializedName("client_id") - private String clientId; - - public List getVirtualDevices(){ - return virtualDevices; - } - - public String getName(){ - return name; - } - - public String getClientSecret(){ - return clientSecret; - } - - public String getAccountNumber(){ - return accountNumber; - } - - public List getPorts(){ - return ports; - } - - public String getProjectId(){ - return projectId; - } - - public String getClientId(){ - return clientId; - } -} diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/VirtualDevicesItem.java b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/VirtualDevicesItem.java deleted file mode 100644 index 0d99c686..00000000 --- a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/VirtualDevicesItem.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.equinix.openapi.fabric.v4.api.dto.port; - -import com.google.gson.annotations.SerializedName; - -public class VirtualDevicesItem{ - - @SerializedName("orderNumber") - private String orderNumber; - - @SerializedName("name") - private String name; - - @SerializedName("uuid") - private String uuid; - - public String getOrderNumber(){ - return orderNumber; - } - - public String getName(){ - return name; - } - - public String getUuid(){ - return uuid; - } -} \ No newline at end of file diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/users/UserUsedDto.java b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/users/UserUsedDto.java deleted file mode 100644 index 165f7e6d..00000000 --- a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/users/UserUsedDto.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.equinix.openapi.fabric.v4.api.dto.users; - -import com.equinix.openapi.fabric.ApiClient; - -public class UserUsedDto { - - private final UserResources userResources = new UserResources(); - private UsersItem.UserName userName; - - private ApiClient apiClient; - - public UserUsedDto(UsersItem.UserName userName, ApiClient apiClient) { - this.userName = userName; - this.apiClient = apiClient; - } - - public UserResources getUserResources() { - return userResources; - } - - public ApiClient getApiClient() { - return apiClient; - } - - public UsersItem.UserName getUserName() { - return userName; - } - - public UserUsedDto setUserName(UsersItem.UserName userName) { - this.userName = userName; - return this; - } -} diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/users/UsersDto.java b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/users/UsersDto.java deleted file mode 100644 index c216e574..00000000 --- a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/users/UsersDto.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.equinix.openapi.fabric.v4.api.dto.users; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class UsersDto { - - @JsonProperty("users") - private List users; - - public void setUsers(List users){ - this.users = users; - } - - public List getUsers(){ - return users; - } -} diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/users/VirtualDevicesItem.java b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/users/VirtualDevicesItem.java deleted file mode 100644 index 67887207..00000000 --- a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/users/VirtualDevicesItem.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.equinix.openapi.fabric.v4.api.dto.users; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.UUID; - -public class VirtualDevicesItem{ - - @JsonProperty("orderNumber") - private String orderNumber; - - @JsonProperty("name") - private String name; - - @JsonProperty("uuid") - private UUID uuid; - - public void setOrderNumber(String orderNumber){ - this.orderNumber = orderNumber; - } - - public String getOrderNumber(){ - return orderNumber; - } - - public void setName(String name){ - this.name = name; - } - - public String getName(){ - return name; - } - - public void setUuid(UUID uuid){ - this.uuid = uuid; - } - - public UUID getUuid(){ - return uuid; - } -} diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/helpers/TokenGenerator.java b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/helpers/TokenGenerator.java deleted file mode 100644 index 258c3c71..00000000 --- a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/helpers/TokenGenerator.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Equinix Fabric API v4 - * - * Contact: api-support@equinix.com - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.equinix.openapi.fabric.v4.api.helpers; - -import com.equinix.openapi.fabric.ApiClient; -import com.equinix.openapi.fabric.ApiException; -import com.equinix.openapi.fabric.Configuration; -import com.equinix.openapi.fabric.Pair; -import com.equinix.openapi.fabric.v4.api.dto.TokenRequestDto; -import com.equinix.openapi.fabric.v4.api.dto.TokenResponseDto; -import com.equinix.openapi.fabric.v4.api.dto.users.UserUsedDto; -import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class TokenGenerator { - - public static Map users = new HashMap<>(); - - public static ApiClient getApiClient(UsersItem.UserName userName) { - if (users.containsKey(userName)) { - return users.get(userName).getApiClient(); - } else { - return generate(userName); - } - } - - public static ApiClient generate(UsersItem.UserName userName) { - if (users.containsKey(userName)) { - users.remove(userName); - } - - String baseUrl = System.getProperty("envUrl"); - UsersItem user = Utils.getUserData(userName); - - ApiClient apiTokeClient = Configuration.getDefaultApiClient(); - TokenRequestDto tokenRequestDto = new TokenRequestDto(); - tokenRequestDto.setClientId(user.getClientId()); - tokenRequestDto.setClientSecret(user.getClientSecret()); - tokenRequestDto.setGrantType("client_credentials"); - - String localVarPath = "/oauth2/v1/token"; - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarCookieParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - localVarHeaderParams.put("Content-Type", "application/json"); - String[] localVarAuthNames = new String[]{"BearerAuth"}; - - okhttp3.Call call; - TokenResponseDto tokenResponseDto = null; - - try { - call = apiTokeClient.buildCall(baseUrl, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, tokenRequestDto, localVarHeaderParams - , localVarCookieParams, localVarFormParams, localVarAuthNames, null); - - Type localVarReturnType = new TypeToken() { - }.getType(); - tokenResponseDto = (TokenResponseDto) apiTokeClient.execute(call, localVarReturnType).getData(); - } catch (ApiException e) { - throw new RuntimeException(e); - } - - ApiClient apiClient = Configuration.getDefaultApiClient().setBasePath(baseUrl); - apiClient.addDefaultHeader("Authorization", String.format("Bearer %s", tokenResponseDto.getAccessToken())); - users.put(userName, new UserUsedDto(userName, apiClient)); - return users.get(userName).getApiClient(); - } -} diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/helpers/Utils.java b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/helpers/Utils.java deleted file mode 100644 index 947b8488..00000000 --- a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/helpers/Utils.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.equinix.openapi.fabric.v4.api.helpers; - -import com.equinix.openapi.fabric.JSON; -import com.equinix.openapi.fabric.v4.api.dto.users.UsersDto; -import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem; -import com.fasterxml.jackson.databind.ObjectMapper; - -import java.io.IOException; -import java.util.NoSuchElementException; -import java.util.Random; - -public class Utils { - - public static Object getEnvData(EnvVariable envVariable) { - ObjectMapper mapper = new ObjectMapper(); - String json = System.getenv(envVariable.value); - try { - return mapper.readValue(json, envVariable.clazz); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - public static UsersItem getUserData(UsersItem.UserName userName) { - return ((UsersDto) getEnvData(EnvVariable.TEST_DATA_UAT_USERS)).getUsers().stream() - .filter(usersItem -> usersItem.getName().equals(userName.getValue())) - .findFirst().orElseThrow(() -> new NoSuchElementException("User not found")); - } - - public static void printJson(Object object) { - System.out.println(JSON.getGson().toJson(object)); - } - - public static int getRandomVlanNumber() { - Random r = new Random(); - return r.ints(1, 4000).findFirst().getAsInt(); - } - - public enum EnvVariable { - TEST_DATA_UAT_USERS("TEST_DATA_UAT_USERS", UsersDto.class); - - private String value; - private Class clazz; - - EnvVariable(String value, Class clazz) { - this.value = value; - this.clazz = clazz; - } - - @Override - public String toString() { - return String.valueOf(value); - } - } -} diff --git a/patches/spec.fetched.json/20240909-port-required-field-skip.patch b/patches/spec.fetched.json/20240909-port-required-field-skip.patch index 741d8d1e..45af3cec 100644 --- a/patches/spec.fetched.json/20240909-port-required-field-skip.patch +++ b/patches/spec.fetched.json/20240909-port-required-field-skip.patch @@ -1,8 +1,8 @@ diff --git a/spec/oas3.fabric.fetched.json b/spec/oas3.fabric.fetched.json -index 36eeef9..2f694fe 100644 +index 36eeef9..192026c 100644 --- a/spec/oas3.fabric.fetched.json +++ b/spec/oas3.fabric.fetched.json -@@ -14537,11 +14537,8 @@ +@@ -14537,13 +14537,9 @@ "Port": { "required": [ "account", @@ -11,6 +11,9 @@ index 36eeef9..2f694fe 100644 "location", - "physicalPortsSpeed", - "physicalPortsType", - "settings", - "type" +- "settings", +- "type" ++ "settings" ], + "type": "object", + "properties": { diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000..95d49e07 --- /dev/null +++ b/pom.xml @@ -0,0 +1,14 @@ + + 4.0.0 + com.equinix + equinix-openapi-fabric-core + pom + equinix-openapi-fabric-core + 0.0.1 + + + equinix-openapi-fabric + equinix-openapi-fabric-tests + + diff --git a/spec/oas3.fabric.patched.json b/spec/oas3.fabric.patched.json index 8f0f9048..ee1725ee 100644 --- a/spec/oas3.fabric.patched.json +++ b/spec/oas3.fabric.patched.json @@ -14537,8 +14537,7 @@ "account", "encapsulation", "location", - "settings", - "type" + "settings" ], "type": "object", "properties": { diff --git a/templates/Java/libraries/okhttp-gson/JSON.mustache b/templates/Java/libraries/okhttp-gson/JSON.mustache index 8a7d91bf..c0141b33 100644 --- a/templates/Java/libraries/okhttp-gson/JSON.mustache +++ b/templates/Java/libraries/okhttp-gson/JSON.mustache @@ -4,18 +4,27 @@ package {{invokerPackage}}; import com.equinix.openapi.fabric.v4.model.PortDeviceRedundancy; import com.equinix.openapi.fabric.v4.model.PortEncapsulation; -import com.google.gson.*; -import com.google.gson.internal.bind.util.ISO8601Utils; +import com.fasterxml.jackson.databind.util.StdDateFormat; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonElement; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonArray; import io.gsonfire.GsonFireBuilder; import io.gsonfire.TypeSelector; {{#joda}} - import org.joda.time.DateTime; - import org.joda.time.LocalDate; - import org.joda.time.format.DateTimeFormatter; - import org.joda.time.format.DateTimeFormatterBuilder; - import org.joda.time.format.ISODateTimeFormat; +import org.joda.time.DateTime; +import org.joda.time.LocalDate; +import org.joda.time.format.DateTimeFormatter; +import org.joda.time.format.DateTimeFormatterBuilder; +import org.joda.time.format.ISODateTimeFormat; {{/joda}} import okio.ByteString; @@ -25,543 +34,552 @@ import java.io.StringReader; import java.lang.reflect.Type; import java.text.DateFormat; import java.text.ParseException; -import java.text.ParsePosition; import java.time.LocalDate; import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; +import java.util.Collection; import java.util.Date; import java.util.Locale; import java.util.Map; import java.util.HashMap; -import java.util.Collection; +import java.util.TimeZone; + /* -* A JSON utility class -* -* NOTE: in the future, this class may be converted to static, which may break -* backward-compatibility -*/ + * A JSON utility class + * + * NOTE: in the future, this class may be converted to static, which may break + * backward-compatibility + */ public class JSON { -private static Gson gson; -private static boolean isLenientOnJson = false; -private static DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); -private static SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter(); -{{#joda}} + private static Gson gson; + private static boolean isLenientOnJson = false; + private static DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); + private static SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter(); + {{#joda}} private static DateTimeTypeAdapter dateTimeTypeAdapter = new DateTimeTypeAdapter(); private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); -{{/joda}} -{{#jsr310}} + {{/joda}} + {{#jsr310}} private static OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter(); private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); -{{/jsr310}} -private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); - -@SuppressWarnings("unchecked") -public static GsonBuilder createGson() { -GsonFireBuilder fireBuilder = new GsonFireBuilder() -{{#models}} - {{#model}} + {{/jsr310}} + private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); + + private static final StdDateFormat sdf = new StdDateFormat() + .withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault())) + .withColonInTimeZone(true); + private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME; + + @SuppressWarnings("unchecked") + public static GsonBuilder createGson() { + GsonFireBuilder fireBuilder = new GsonFireBuilder() + {{#models}} + {{#model}} {{#discriminator}} - .registerTypeSelector({{modelPackage}}.{{classname}}.class, new TypeSelector<{{modelPackage}}.{{classname}}>() { - @Override - public Class getClassForElement(JsonElement readElement) { - Map classByDiscriminatorValue = new HashMap(); - {{#mappedModels}} - classByDiscriminatorValue.put("{{mappingName}}"{{^discriminatorCaseSensitive}}.toUpperCase(Locale.ROOT){{/discriminatorCaseSensitive}}, {{modelPackage}}.{{modelName}}.class); - {{/mappedModels}} - classByDiscriminatorValue.put("{{name}}"{{^discriminatorCaseSensitive}}.toUpperCase(Locale.ROOT){{/discriminatorCaseSensitive}}, {{modelPackage}}.{{classname}}.class); - return getClassByDiscriminator(classByDiscriminatorValue, - getDiscriminatorValue(readElement, "{{{propertyBaseName}}}")); - } - }) + .registerTypeSelector({{modelPackage}}.{{classname}}.class, new TypeSelector<{{modelPackage}}.{{classname}}>() { + @Override + public Class getClassForElement(JsonElement readElement) { + Map classByDiscriminatorValue = new HashMap(); + {{#mappedModels}} + classByDiscriminatorValue.put("{{mappingName}}"{{^discriminatorCaseSensitive}}.toUpperCase(Locale.ROOT){{/discriminatorCaseSensitive}}, {{modelPackage}}.{{modelName}}.class); + {{/mappedModels}} + classByDiscriminatorValue.put("{{name}}"{{^discriminatorCaseSensitive}}.toUpperCase(Locale.ROOT){{/discriminatorCaseSensitive}}, {{modelPackage}}.{{classname}}.class); + return getClassByDiscriminator(classByDiscriminatorValue, + getDiscriminatorValue(readElement, "{{{propertyBaseName}}}")); + } + }) {{/discriminator}} - {{/model}} -{{/models}} -; -GsonBuilder builder = fireBuilder.createGsonBuilder(); -{{#disableHtmlEscaping}} - builder.disableHtmlEscaping(); -{{/disableHtmlEscaping}} -return builder; -} - -private static String getDiscriminatorValue(JsonElement readElement, String discriminatorField) { -JsonElement element = readElement.getAsJsonObject().get(discriminatorField); -if (null == element) { -throw new IllegalArgumentException("missing discriminator field: <" + discriminatorField + ">"); -} -return element.getAsString(); -} + {{/model}} + {{/models}} + ; + GsonBuilder builder = fireBuilder.createGsonBuilder(); + {{#disableHtmlEscaping}} + builder.disableHtmlEscaping(); + {{/disableHtmlEscaping}} + return builder; + } + + private static String getDiscriminatorValue(JsonElement readElement, String discriminatorField) { + JsonElement element = readElement.getAsJsonObject().get(discriminatorField); + if (null == element) { + throw new IllegalArgumentException("missing discriminator field: <" + discriminatorField + ">"); + } + return element.getAsString(); + } + + /** + * Returns the Java class that implements the OpenAPI schema for the specified discriminator value. + * + * @param classByDiscriminatorValue The map of discriminator values to Java classes. + * @param discriminatorValue The value of the OpenAPI discriminator in the input data. + * @return The Java class that implements the OpenAPI schema + */ + private static Class getClassByDiscriminator(Map classByDiscriminatorValue, String discriminatorValue) { + Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue{{^discriminatorCaseSensitive}}.toUpperCase(Locale.ROOT){{/discriminatorCaseSensitive}}); + if (null == clazz) { + throw new IllegalArgumentException("cannot determine model class of name: <" + discriminatorValue + ">"); + } + return clazz; + } -/** -* Returns the Java class that implements the OpenAPI schema for the specified discriminator value. -* -* @param classByDiscriminatorValue The map of discriminator values to Java classes. -* @param discriminatorValue The value of the OpenAPI discriminator in the input data. -* @return The Java class that implements the OpenAPI schema -*/ -private static Class getClassByDiscriminator(Map classByDiscriminatorValue, String discriminatorValue) { -Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue{{^discriminatorCaseSensitive}}.toUpperCase(Locale.ROOT){{/discriminatorCaseSensitive}}); -if (null == clazz) { -throw new IllegalArgumentException("cannot determine model class of name: <" + discriminatorValue + ">"); -} -return clazz; -} + public static class UppercaseEnumAdapter implements JsonDeserializer { + @Override + public Enum deserialize(JsonElement json, java.lang.reflect.Type type, JsonDeserializationContext context) + throws JsonParseException { + try { + if (type instanceof Class && ((Class) type).isEnum()) + return Enum.valueOf((Class) type, json.getAsString().toUpperCase()); + return null; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + } -static { -GsonBuilder gsonBuilder = createGson(); -gsonBuilder.registerTypeHierarchyAdapter(Collection.class, new CollectionAdapter()); -gsonBuilder.registerTypeAdapter(Date.class, dateTypeAdapter); -gsonBuilder.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter); -{{#joda}} - gsonBuilder.registerTypeAdapter(DateTime.class, dateTimeTypeAdapter); - gsonBuilder.registerTypeAdapter(LocalDate.class, localDateTypeAdapter); -{{/joda}} -{{#jsr310}} - gsonBuilder.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter); - gsonBuilder.registerTypeAdapter(LocalDate.class, localDateTypeAdapter); -{{/jsr310}} -gsonBuilder.registerTypeAdapter(byte[].class, byteArrayAdapter); -{{#models}} - {{#model}} + static { + GsonBuilder gsonBuilder = createGson(); + gsonBuilder.registerTypeHierarchyAdapter(Collection.class, new CollectionAdapter()); + gsonBuilder.registerTypeAdapter(Date.class, dateTypeAdapter); + gsonBuilder.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter); + {{#joda}} + gsonBuilder.registerTypeAdapter(DateTime.class, dateTimeTypeAdapter); + gsonBuilder.registerTypeAdapter(LocalDate.class, localDateTypeAdapter); + {{/joda}} + {{#jsr310}} + gsonBuilder.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter); + gsonBuilder.registerTypeAdapter(LocalDate.class, localDateTypeAdapter); + {{/jsr310}} + gsonBuilder.registerTypeAdapter(byte[].class, byteArrayAdapter); + {{#models}} + {{#model}} {{^isEnum}} - {{^hasChildren}} - gsonBuilder.registerTypeAdapterFactory(new {{modelPackage}}.{{{classname}}}.CustomTypeAdapterFactory()); - {{/hasChildren}} + {{^hasChildren}} + gsonBuilder.registerTypeAdapterFactory(new {{modelPackage}}.{{{classname}}}.CustomTypeAdapterFactory()); + {{/hasChildren}} {{/isEnum}} - {{/model}} -{{/models}} -gsonBuilder.registerTypeAdapter(PortEncapsulation.TypeEnum.class,new UppercaseEnumAdapter()); -gsonBuilder.registerTypeAdapter(PortDeviceRedundancy.PriorityEnum.class,new UppercaseEnumAdapter()); -gson = gsonBuilder.setPrettyPrinting().create(); -} - -public static class UppercaseEnumAdapter implements JsonDeserializer { - @Override - public Enum deserialize(JsonElement json, java.lang.reflect.Type type, JsonDeserializationContext context) - throws JsonParseException { - try { - if(type instanceof Class && ((Class) type).isEnum()) - return Enum.valueOf((Class) type, json.getAsString().toUpperCase()); - return null; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - } - -/** -* Get Gson. -* -* @return Gson -*/ -public static Gson getGson() { -return gson; -} - -/** -* Set Gson. -* -* @param gson Gson -*/ -public static void setGson(Gson gson) { -JSON.gson = gson; -} - -public static void setLenientOnJson(boolean lenientOnJson) { -isLenientOnJson = lenientOnJson; -} - -/** -* Serialize the given Java object into JSON string. -* -* @param obj Object -* @return String representation of the JSON -*/ -public static String serialize(Object obj) { -return gson.toJson(obj); -} - -/** -* Deserialize the given JSON string to Java object. -* -* @param Type - * @param body The JSON string - * @param returnType The type to deserialize into - * @return The deserialized Java object - */ + {{/model}} + {{/models}} + gsonBuilder.registerTypeAdapter(PortEncapsulation.TypeEnum.class,new UppercaseEnumAdapter()); + gsonBuilder.registerTypeAdapter(PortDeviceRedundancy.PriorityEnum.class,new UppercaseEnumAdapter()); + gson = gsonBuilder.setPrettyPrinting().create(); + } + + /** + * Get Gson. + * + * @return Gson + */ + public static Gson getGson() { + return gson; + } + + /** + * Set Gson. + * + * @param gson Gson + */ + public static void setGson(Gson gson) { + JSON.gson = gson; + } + + public static void setLenientOnJson(boolean lenientOnJson) { + isLenientOnJson = lenientOnJson; + } + + /** + * Serialize the given Java object into JSON string. + * + * @param obj Object + * @return String representation of the JSON + */ + public static String serialize(Object obj) { + return gson.toJson(obj); + } + + /** + * Deserialize the given JSON string to Java object. + * + * @param Type + * @param body The JSON string + * @param returnType The type to deserialize into + * @return The deserialized Java object + */ @SuppressWarnings("unchecked") public static T deserialize(String body, Type returnType) { try { - if (isLenientOnJson) { - JsonReader jsonReader = new JsonReader(new StringReader(body)); - // see https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean) - jsonReader.setLenient(true); - return gson.fromJson(jsonReader, returnType); - } else { - return gson.fromJson(body, returnType); - } + if (isLenientOnJson) { + JsonReader jsonReader = new JsonReader(new StringReader(body)); + // see https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean) + jsonReader.setLenient(true); + return gson.fromJson(jsonReader, returnType); + } else { + return gson.fromJson(body, returnType); + } } catch (JsonParseException e) { - // Fallback processing when failed to parse JSON form response body: - // return the response body string directly for the String return type; - if (returnType.equals(String.class)) { - return (T) body; - } else { - throw (e); - } - } + // Fallback processing when failed to parse JSON form response body: + // return the response body string directly for the String return type; + if (returnType.equals(String.class)) { + return (T) body; + } else { + throw (e); + } } + } - /** - * Gson TypeAdapter for Byte Array type - */ - public static class ByteArrayAdapter extends TypeAdapter { + /** + * Gson TypeAdapter for Byte Array type + */ + public static class ByteArrayAdapter extends TypeAdapter { @Override public void write(JsonWriter out, byte[] value) throws IOException { - if (value == null) { - out.nullValue(); - } else { - out.value(ByteString.of(value).base64()); - } + if (value == null) { + out.nullValue(); + } else { + out.value(ByteString.of(value).base64()); + } } @Override public byte[] read(JsonReader in) throws IOException { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String bytesAsBase64 = in.nextString(); - ByteString byteString = ByteString.decodeBase64(bytesAsBase64); - return byteString.toByteArray(); - } - } + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String bytesAsBase64 = in.nextString(); + ByteString byteString = ByteString.decodeBase64(bytesAsBase64); + return byteString.toByteArray(); + } } + } - {{#joda}} - /** - * Gson TypeAdapter for Joda DateTime type - */ - public static class DateTimeTypeAdapter extends TypeAdapter { + {{#joda}} + /** + * Gson TypeAdapter for Joda DateTime type + */ + public static class DateTimeTypeAdapter extends TypeAdapter { - private DateTimeFormatter formatter; + private DateTimeFormatter formatter; - public DateTimeTypeAdapter() { + public DateTimeTypeAdapter() { this(new DateTimeFormatterBuilder() - .append(ISODateTimeFormat.dateTime().getPrinter(), ISODateTimeFormat.dateOptionalTimeParser().getParser()) - .toFormatter()); - } + .append(ISODateTimeFormat.dateTime().getPrinter(), ISODateTimeFormat.dateOptionalTimeParser().getParser()) + .toFormatter()); + } - public DateTimeTypeAdapter(DateTimeFormatter formatter) { + public DateTimeTypeAdapter(DateTimeFormatter formatter) { this.formatter = formatter; - } + } - public void setFormat(DateTimeFormatter dateFormat) { + public void setFormat(DateTimeFormatter dateFormat) { this.formatter = dateFormat; - } + } - @Override - public void write(JsonWriter out, DateTime date) throws IOException { + @Override + public void write(JsonWriter out, DateTime date) throws IOException { if (date == null) { - out.nullValue(); + out.nullValue(); } else { - out.value(formatter.print(date)); - } + out.value(formatter.print(date)); } + } - @Override - public DateTime read(JsonReader in) throws IOException { + @Override + public DateTime read(JsonReader in) throws IOException { switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - return formatter.parseDateTime(date); - } - } + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + return formatter.parseDateTime(date); } + } + } - /** - * Gson TypeAdapter for Joda LocalDate type - */ - public static class LocalDateTypeAdapter extends TypeAdapter { + /** + * Gson TypeAdapter for Joda LocalDate type + */ + public static class LocalDateTypeAdapter extends TypeAdapter { - private DateTimeFormatter formatter; + private DateTimeFormatter formatter; - public LocalDateTypeAdapter() { + public LocalDateTypeAdapter() { this(ISODateTimeFormat.date()); - } + } - public LocalDateTypeAdapter(DateTimeFormatter formatter) { + public LocalDateTypeAdapter(DateTimeFormatter formatter) { this.formatter = formatter; - } + } - public void setFormat(DateTimeFormatter dateFormat) { + public void setFormat(DateTimeFormatter dateFormat) { this.formatter = dateFormat; - } + } - @Override - public void write(JsonWriter out, LocalDate date) throws IOException { + @Override + public void write(JsonWriter out, LocalDate date) throws IOException { if (date == null) { - out.nullValue(); + out.nullValue(); } else { - out.value(formatter.print(date)); - } + out.value(formatter.print(date)); } + } - @Override - public LocalDate read(JsonReader in) throws IOException { + @Override + public LocalDate read(JsonReader in) throws IOException { switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - return formatter.parseLocalDate(date); - } - } + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + return formatter.parseLocalDate(date); } + } + } - public static void setDateTimeFormat(DateTimeFormatter dateFormat) { - dateTimeTypeAdapter.setFormat(dateFormat); - } + public static void setDateTimeFormat(DateTimeFormatter dateFormat) { + dateTimeTypeAdapter.setFormat(dateFormat); + } - public static void setLocalDateFormat(DateTimeFormatter dateFormat) { - localDateTypeAdapter.setFormat(dateFormat); - } + public static void setLocalDateFormat(DateTimeFormatter dateFormat) { + localDateTypeAdapter.setFormat(dateFormat); + } - {{/joda}} - {{#jsr310}} - /** - * Gson TypeAdapter for JSR310 OffsetDateTime type - */ - public static class OffsetDateTimeTypeAdapter extends TypeAdapter { + {{/joda}} + {{#jsr310}} + /** + * Gson TypeAdapter for JSR310 OffsetDateTime type + */ + public static class OffsetDateTimeTypeAdapter extends TypeAdapter { - private DateTimeFormatter formatter; + private DateTimeFormatter formatter; - public OffsetDateTimeTypeAdapter() { + public OffsetDateTimeTypeAdapter() { this(DateTimeFormatter.ISO_OFFSET_DATE_TIME); - } + } - public OffsetDateTimeTypeAdapter(DateTimeFormatter formatter) { + public OffsetDateTimeTypeAdapter(DateTimeFormatter formatter) { this.formatter = formatter; - } + } - public void setFormat(DateTimeFormatter dateFormat) { + public void setFormat(DateTimeFormatter dateFormat) { this.formatter = dateFormat; - } + } - @Override - public void write(JsonWriter out, OffsetDateTime date) throws IOException { + @Override + public void write(JsonWriter out, OffsetDateTime date) throws IOException { if (date == null) { - out.nullValue(); + out.nullValue(); } else { - out.value(formatter.format(date)); - } + out.value(formatter.format(date)); } + } - @Override - public OffsetDateTime read(JsonReader in) throws IOException { + @Override + public OffsetDateTime read(JsonReader in) throws IOException { switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - if (date.endsWith("+0000")) { - date = date.substring(0, date.length()-5) + "Z"; - } - return OffsetDateTime.parse(date, formatter); - } - } + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + if (date.endsWith("+0000")) { + date = date.substring(0, date.length()-5) + "Z"; + } + return OffsetDateTime.parse(date, formatter); } + } + } - /** - * Gson TypeAdapter for JSR310 LocalDate type - */ - public static class LocalDateTypeAdapter extends TypeAdapter { + /** + * Gson TypeAdapter for JSR310 LocalDate type + */ + public static class LocalDateTypeAdapter extends TypeAdapter { - private DateTimeFormatter formatter; + private DateTimeFormatter formatter; - public LocalDateTypeAdapter() { + public LocalDateTypeAdapter() { this(DateTimeFormatter.ISO_LOCAL_DATE); - } + } - public LocalDateTypeAdapter(DateTimeFormatter formatter) { + public LocalDateTypeAdapter(DateTimeFormatter formatter) { this.formatter = formatter; - } + } - public void setFormat(DateTimeFormatter dateFormat) { + public void setFormat(DateTimeFormatter dateFormat) { this.formatter = dateFormat; - } + } - @Override - public void write(JsonWriter out, LocalDate date) throws IOException { + @Override + public void write(JsonWriter out, LocalDate date) throws IOException { if (date == null) { - out.nullValue(); + out.nullValue(); } else { - out.value(formatter.format(date)); - } + out.value(formatter.format(date)); } + } - @Override - public LocalDate read(JsonReader in) throws IOException { + @Override + public LocalDate read(JsonReader in) throws IOException { switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - return LocalDate.parse(date, formatter); - } - } + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + return LocalDate.parse(date, formatter); } + } + } - public static void setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { - offsetDateTimeTypeAdapter.setFormat(dateFormat); - } + public static void setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { + offsetDateTimeTypeAdapter.setFormat(dateFormat); + } - public static void setLocalDateFormat(DateTimeFormatter dateFormat) { - localDateTypeAdapter.setFormat(dateFormat); - } + public static void setLocalDateFormat(DateTimeFormatter dateFormat) { + localDateTypeAdapter.setFormat(dateFormat); + } - {{/jsr310}} - /** - * Gson TypeAdapter for java.sql.Date type - * If the dateFormat is null, a simple "yyyy-MM-dd" format will be used - * (more efficient than SimpleDateFormat). - */ - public static class SqlDateTypeAdapter extends TypeAdapter { + {{/jsr310}} + /** + * Gson TypeAdapter for java.sql.Date type + * If the dateFormat is null, a simple "yyyy-MM-dd" format will be used + * (more efficient than SimpleDateFormat). + */ + public static class SqlDateTypeAdapter extends TypeAdapter { - private DateFormat dateFormat; + private DateFormat dateFormat; - public SqlDateTypeAdapter() {} + public SqlDateTypeAdapter() {} - public SqlDateTypeAdapter(DateFormat dateFormat) { + public SqlDateTypeAdapter(DateFormat dateFormat) { this.dateFormat = dateFormat; - } + } - public void setFormat(DateFormat dateFormat) { + public void setFormat(DateFormat dateFormat) { this.dateFormat = dateFormat; - } + } - @Override - public void write(JsonWriter out, java.sql.Date date) throws IOException { + @Override + public void write(JsonWriter out, java.sql.Date date) throws IOException { if (date == null) { - out.nullValue(); - } else { - String value; - if (dateFormat != null) { - value = dateFormat.format(date); + out.nullValue(); } else { - value = date.toString(); - } - out.value(value); - } + String value; + if (dateFormat != null) { + value = dateFormat.format(date); + } else { + value = date.toString(); + } + out.value(value); } + } - @Override - public java.sql.Date read(JsonReader in) throws IOException { + @Override + public java.sql.Date read(JsonReader in) throws IOException { switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - try { - if (dateFormat != null) { - return new java.sql.Date(dateFormat.parse(date).getTime()); - } - return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime()); - } catch (ParseException e) { - throw new JsonParseException(e); - } - } - } + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return new java.sql.Date(dateFormat.parse(date).getTime()); + } + return new java.sql.Date(sdf.parse(date).getTime()); + } catch (ParseException e) { + throw new JsonParseException(e); + } } + } + } - /** - * Gson TypeAdapter for java.util.Date type - * If the dateFormat is null, ISO8601Utils will be used. - */ - public static class DateTypeAdapter extends TypeAdapter { + /** + * Gson TypeAdapter for java.util.Date type + * If the dateFormat is null, DateTimeFormatter will be used. + */ + public static class DateTypeAdapter extends TypeAdapter { - private DateFormat dateFormat; + private DateFormat dateFormat; - public DateTypeAdapter() {} + public DateTypeAdapter() {} - public DateTypeAdapter(DateFormat dateFormat) { - this.dateFormat = dateFormat; - } + public DateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } - public void setFormat(DateFormat dateFormat) { - this.dateFormat = dateFormat; - } + public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } - @Override - public void write(JsonWriter out, Date date) throws IOException { - if (date == null) { + @Override + public void write(JsonWriter out, Date date) throws IOException { + if (date == null) { out.nullValue(); - } else { + } else { String value; if (dateFormat != null) { - value = dateFormat.format(date); + value = dateFormat.format(date); } else { - value = ISO8601Utils.format(date, true); + value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf); } out.value(value); - } - } + } + } - @Override - public Date read(JsonReader in) throws IOException { - try { + @Override + public Date read(JsonReader in) throws IOException { + try { switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - try { - if (dateFormat != null) { - return dateFormat.parse(date); - } - return ISO8601Utils.parse(date, new ParsePosition(0)); - } catch (ParseException e) { - throw new JsonParseException(e); - } + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return dateFormat.parse(date); + } + return sdf.parse(date); + } catch (ParseException e) { + throw new JsonParseException(e); + } } - } catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { throw new JsonParseException(e); - } - } - } + } + } + } - public static void setDateFormat(DateFormat dateFormat) { - dateTypeAdapter.setFormat(dateFormat); - } + public static void setDateFormat(DateFormat dateFormat) { + dateTypeAdapter.setFormat(dateFormat); + } - public static void setSqlDateFormat(DateFormat dateFormat) { - sqlDateTypeAdapter.setFormat(dateFormat); - } - } - class CollectionAdapter implements JsonSerializer> { + public static void setSqlDateFormat(DateFormat dateFormat) { + sqlDateTypeAdapter.setFormat(dateFormat); + } +} - @Override - public JsonElement serialize(Collection src, Type typeOfSrc, JsonSerializationContext context) { - if (src == null || src.isEmpty()) // exclusion is made here - return null; +class CollectionAdapter implements JsonSerializer> { + + @Override + public JsonElement serialize(Collection src, Type typeOfSrc, JsonSerializationContext context) { + if (src == null || src.isEmpty()) // exclusion is made here + return null; - JsonArray array = new JsonArray(); + JsonArray array = new JsonArray(); - for (Object child : src) { - JsonElement element = context.serialize(child); - array.add(element); - } + for (Object child : src) { + JsonElement element = context.serialize(child); + array.add(element); + } - return array; - } - } + return array; + } +} diff --git a/templates/Java/libraries/okhttp-gson/pom.mustache b/templates/Java/libraries/okhttp-gson/pom.mustache new file mode 100644 index 00000000..df7ec646 --- /dev/null +++ b/templates/Java/libraries/okhttp-gson/pom.mustache @@ -0,0 +1,454 @@ + + 4.0.0 + {{groupId}} + {{artifactId}} + jar + {{artifactId}} + {{artifactVersion}} + {{artifactUrl}} + {{artifactDescription}} + + {{scmConnection}} + {{scmDeveloperConnection}} + {{scmUrl}} + +{{#parentOverridden}} + + {{{parentGroupId}}} + {{{parentArtifactId}}} + {{{parentVersion}}} + +{{/parentOverridden}} + + + com.equinix + equinix-openapi-fabric-core + 0.0.1 + + + + + {{licenseName}} + {{licenseUrl}} + repo + + + + + + {{developerName}} + {{developerEmail}} + {{developerOrganization}} + {{developerOrganizationUrl}} + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + true + 128m + 512m + + -Xlint:all + -J-Xss4m + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.1.0 + + + enforce-maven + + enforce + + + + + 2.2.0 + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + + loggerPath + conf/log4j.properties + + + -Xms512m -Xmx1500m + methods + 10 + + + + + org.junit.jupiter + junit-jupiter-engine + ${junit-version} + + + + + maven-dependency-plugin + 3.3.0 + + + package + + copy-dependencies + + + ${project.build.directory}/lib + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.3.0 + + + + test-jar + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.3.0 + + + add_sources + generate-sources + + add-source + + + + {{{sourceFolder}}} + + + + + add_test_sources + generate-test-sources + + add-test-source + + + + src/test/java + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.4.1 + + + attach-javadocs + + jar + + + + + none + + + http.response.details + a + Http Response Details: + + + + + + org.apache.maven.plugins + maven-source-plugin + 3.2.1 + + + attach-sources + + jar-no-fork + + + + + + + com.diffplug.spotless + spotless-maven-plugin + ${spotless.version} + + + + + + + .gitignore + + + + + + true + 4 + + + + + + + + + + 1.8 + + true + + + + + + + + + + + + + + sign-artifacts + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.0.1 + + + sign-artifacts + verify + + sign + + + + + + + + + + + {{#swagger1AnnotationLibrary}} + + io.swagger + swagger-annotations + ${swagger-annotations-version} + + {{/swagger1AnnotationLibrary}} + {{#swagger2AnnotationLibrary}} + + io.swagger.core.v3 + swagger-annotations + ${swagger-annotations-version} + + {{/swagger2AnnotationLibrary}} + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + com.squareup.okhttp3 + okhttp + ${okhttp-version} + + + com.squareup.okhttp3 + logging-interceptor + ${okhttp-version} + + + com.google.code.gson + gson + ${gson-version} + + + io.gsonfire + gson-fire + ${gson-fire-version} + + {{#hasOAuthMethods}} + + org.apache.oltu.oauth2 + org.apache.oltu.oauth2.client + 1.0.2 + + {{/hasOAuthMethods}} + + org.apache.commons + commons-lang3 + ${commons-lang3-version} + + {{#joda}} + + joda-time + joda-time + ${jodatime-version} + + {{/joda}} + {{#dynamicOperations}} + + io.swagger.parser.v3 + swagger-parser-v3 + 2.0.30 + + {{/dynamicOperations}} + {{#useBeanValidation}} + + + jakarta.validation + jakarta.validation-api + ${beanvalidation-version} + provided + + {{/useBeanValidation}} + {{#performBeanValidation}} + + + org.hibernate + hibernate-validator + 5.4.3.Final + + + jakarta.el + jakarta.el-api + ${jakarta.el-version} + + {{/performBeanValidation}} + {{#parcelableModel}} + + + com.google.android + android + 4.1.1.4 + provided + + {{/parcelableModel}} + + jakarta.annotation + jakarta.annotation-api + ${jakarta-annotation-version} + provided + + {{#openApiNullable}} + + org.openapitools + jackson-databind-nullable + ${jackson-databind-nullable-version} + + {{/openApiNullable}} + {{#withAWSV4Signature}} + + software.amazon.awssdk + auth + 2.20.157 + + {{/withAWSV4Signature}} + + javax.ws.rs + jsr311-api + ${jsr311-api-version} + + + javax.ws.rs + javax.ws.rs-api + ${javax.ws.rs-api-version} + + + + org.junit.jupiter + junit-jupiter-engine + ${junit-version} + test + + + org.junit.platform + junit-platform-runner + ${junit-platform-runner.version} + test + + + + 1.8 + ${java.version} + ${java.version} + 1.9.0 + {{#swagger1AnnotationLibrary}} + 1.6.6 + {{/swagger1AnnotationLibrary}} + {{#swagger2AnnotationLibrary}} + 2.2.15 + {{/swagger2AnnotationLibrary}} + 4.11.0 + 2.10.1 + 3.13.0 + {{#openApiNullable}} + 0.2.6 + {{/openApiNullable}} + {{#joda}} + 2.12.0 + {{/joda}} + {{#useJakartaEe}} + 2.1.1 + {{/useJakartaEe}} + {{^useJakartaEe}} + 1.3.5 + {{/useJakartaEe}} +{{#performBeanValidation}} + 3.0.3 +{{/performBeanValidation}} +{{#useBeanValidation}} + 2.0.2 +{{/useBeanValidation}} + 5.10.0 + 1.10.0 + 2.1.1 + 1.1.1 + UTF-8 + 2.27.2 + + diff --git a/v4/api/CloudRoutersApiTest.java b/v4/api/CloudRoutersApiTest.java deleted file mode 100644 index cd2891d1..00000000 --- a/v4/api/CloudRoutersApiTest.java +++ /dev/null @@ -1,279 +0,0 @@ -/* - * Equinix Fabric API v4 - * - * Contact: api-support@equinix.com - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.equinix.openapi.fabric.v4.api; - -import com.equinix.openapi.fabric.ApiException; -import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem; -import com.equinix.openapi.fabric.v4.api.helpers.Utils; -import com.equinix.openapi.fabric.v4.model.*; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -import java.util.UUID; - -import static com.equinix.openapi.fabric.v4.api.helpers.Apis.*; -import static com.equinix.openapi.fabric.v4.api.helpers.TokenGenerator.users; -import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.*; - -/** - * API tests for CloudRoutersApi - */ -public class CloudRoutersApiTest { - - private static final UsersItem.UserName userName = UsersItem.UserName.PANTHERS_FNV; - - public static void removeCloudRouters(UsersItem.UserName userName) { - users.get(userName).getUserResources().getCloudRoutersUuid().forEach(uuid -> { - if (getCloudRouterStatus(uuid) == CloudRouterAccessPointState.PROVISIONED) { - deleteCloudRouter(uuid); - } - }); - } - - @BeforeAll - public static void setUp() { - setUserName(userName); - } - - @AfterAll - public static void removeResources() { - removeCloudRouters(userName); - } - - /** - * Fabric Cloud Router object - */ - @Test - public void createCloudRouter() throws ApiException { - createRouter(); - } - - /** - * Successful operation - */ - @Test - public void createCloudRouterAction() throws ApiException { - cloudRoutersApi.createCloudRouterAction(createRouter().getUuid(), - new CloudRouterActionRequest().type(CloudRouterActionType.ROUTE_TABLE_ENTRY_UPDATE)); - assertEquals(202, cloudRoutersApi.getApiClient().getStatusCode()); - } - - /** - * Deleted Cloud Router Successfully - */ - @Test - public void deleteCloudRouterByUuid() throws ApiException { - deleteCloudRouter(createRouter().getUuid()); - } - - /** - * Successful operation - */ - @Test - public void getCloudRouterActions() throws ApiException { - CloudRouter cloudRouter = createRouter(); - cloudRoutersApi.createCloudRouterAction(cloudRouter.getUuid(), new CloudRouterActionRequest().type(CloudRouterActionType.ROUTE_TABLE_ENTRY_UPDATE)); - CloudRouterActionResponse cloudRouterActionResponse = cloudRoutersApi.getCloudRouterActions(cloudRouter.getUuid(), CloudRouterActionState.DONE); - assertEquals(200, cloudRoutersApi.getApiClient().getStatusCode()); - assertEquals(cloudRouterActionResponse.getType(), CloudRouterActionType.ROUTE_TABLE_ENTRY_UPDATE); - } - - /** - * Fabric Cloud Router object - */ - @Test - public void getCloudRouterByUuid() throws ApiException { - CloudRouter cloudRouter = createRouter(); - CloudRouter cloudRouterRead = cloudRoutersApi.getCloudRouterByUuid(cloudRouter.getUuid()); - - assertEquals(200, cloudRoutersApi.getApiClient().getStatusCode()); - assertEquals(cloudRouter.getUuid(), cloudRouterRead.getUuid()); - assertEquals(cloudRouter.getName(), cloudRouterRead.getName()); - assertEquals(cloudRouter.getState(), cloudRouterRead.getState()); - } - - /** - * Fabric Cloud Router Package details - */ - @Test - public void getCloudRouterPackageByCode() throws ApiException { - Code routerPackageCode = Code.STANDARD; - CloudRouterPackage cloudRouterPackage = cloudRoutersApi.getCloudRouterPackageByCode(RouterPackageCode.STANDARD); - assertEquals(200, cloudRoutersApi.getApiClient().getStatusCode()); - assertEquals(cloudRouterPackage.getCode(), routerPackageCode); - } - - /** - * Fabric Cloud Router Packages - */ - @Test - public void getCloudRouterPackages() throws ApiException { - PackageResponse packageResponse = cloudRoutersApi.getCloudRouterPackages(10, 10); - assertEquals(200, cloudRoutersApi.getApiClient().getStatusCode()); - assertNotNull(packageResponse.getData()); - } - - /** - * Successful operation - */ - @Test - public void searchCloudRouterRoutes() throws ApiException { - RouteTableEntrySimpleExpression routeTableEntrySimpleExpression = new RouteTableEntrySimpleExpression(); - routeTableEntrySimpleExpression.setProperty(SortItem.PropertyEnum.STATE.getValue()); - routeTableEntrySimpleExpression.setOperator(SearchExpression.OperatorEnum.NOT_EQUAL.getValue()); - routeTableEntrySimpleExpression.setValues(singletonList("ACTIVE")); - - RouteTableEntryFilter routeTableEntryFilter = new RouteTableEntryFilter(routeTableEntrySimpleExpression); - - RouteTableEntryFilters routeTableEntryFilters = new RouteTableEntryFilters(); - routeTableEntryFilters.addAndItem(routeTableEntryFilter); - - RouteTableEntrySearchRequest routeTableEntrySearchRequest = new RouteTableEntrySearchRequest() - .filter(routeTableEntryFilters) - .pagination(new PaginationRequest().offset(10).limit(20)) - .sort(singletonList(new RouteTableEntrySortCriteria() - .direction(RouteTableEntrySortDirection.DESC) - .property(RouteTableEntrySortBy.CHANGELOG_CREATEDDATETIME))); - - cloudRoutersApi.searchCloudRouterRoutes(createRouter().getUuid(), routeTableEntrySearchRequest); - assertEquals(200, cloudRoutersApi.getApiClient().getStatusCode()); - } - - /** - * Successful operation - */ - @Test - public void searchCloudRouters() throws ApiException { - CloudRouter cloudRouter = createRouter(); - - CloudRouterSimpleExpression cloudRouterSimpleExpression = new CloudRouterSimpleExpression(); - cloudRouterSimpleExpression.setOperator(SearchExpression.OperatorEnum.EQUAL.getValue()); - cloudRouterSimpleExpression.setProperty(SortItem.PropertyEnum.NAME.getValue()); - cloudRouterSimpleExpression.values(singletonList(cloudRouter.getName())); - - CloudRouterSimpleExpression cloudRouterSimpleExpression2 = new CloudRouterSimpleExpression(); - cloudRouterSimpleExpression2.setOperator(SearchExpression.OperatorEnum.EQUAL.getValue()); - cloudRouterSimpleExpression2.setProperty(SortItem.PropertyEnum.STATE.getValue()); - cloudRouterSimpleExpression2.values(singletonList(cloudRouter.getState().getValue())); - - CloudRouterFilters cloudRouterFilters = new CloudRouterFilters(); - CloudRouterFilter cloudRouterFilter = new CloudRouterFilter(cloudRouterSimpleExpression); - CloudRouterFilter cloudRouterFilter2 = new CloudRouterFilter(cloudRouterSimpleExpression2); - cloudRouterFilters.addAndItem(cloudRouterFilter); - cloudRouterFilters.addAndItem(cloudRouterFilter2); - - CloudRouterSearchRequest cloudRouterSearchRequest = new CloudRouterSearchRequest() - .filter(cloudRouterFilters) - .pagination(new PaginationRequest().offset(10).limit(20)) - .sort(singletonList(new CloudRouterSortCriteria() - .direction(CloudRouterSortDirection.DESC) - .property(CloudRouterSortBy.CHANGELOG_CREATEDDATETIME))); - - SearchResponse searchResponse = cloudRoutersApi.searchCloudRouters(cloudRouterSearchRequest); - assertEquals(200, cloudRoutersApi.getApiClient().getStatusCode()); - - boolean found = searchResponse.getData().stream().anyMatch(router -> router.getName().equals(cloudRouter.getName())); - assertTrue(found); - } - - /** - * Fabric Cloud Router object - */ - @Test - public void updateCloudRouterByUuid() throws ApiException { - CloudRouter cloudRouter = createRouter(); - String updatedName = "panthers_new_fcr_name"; - - CloudRouterChangeOperation cloudRouterChangeOperation = new CloudRouterChangeOperation() - .op(CloudRouterChangeOperation.OpEnum.REPLACE) - .path(CloudRouterSortBy.NAME.getValue()) - .value(updatedName); - - CloudRouter updatedCloudRouter = cloudRoutersApi.updateCloudRouterByUuid(cloudRouter.getUuid(), singletonList(cloudRouterChangeOperation)); - assertEquals(200, cloudRoutersApi.getApiClient().getStatusCode()); - assertEquals(updatedName, updatedCloudRouter.getName()); - } - - public static void deleteCloudRouter(UUID uuid) { - try { - waitForCloudRouterIsProvisioned(uuid); - cloudRoutersApi.deleteCloudRouterByUuid(uuid); - } catch (ApiException e) { - throw new RuntimeException(e); - } - assertEquals(204, cloudRoutersApi.getApiClient().getStatusCode()); - } - - public static CloudRouterAccessPointState getCloudRouterStatus(UUID cloudRouterUuid) { - try { - return cloudRoutersApi.getCloudRouterByUuid(cloudRouterUuid).getState(); - } catch (ApiException e) { - throw new RuntimeException(e); - } - } - - public static CloudRouter createRouter() throws ApiException { - UsersItem user = Utils.getUserData(getCurrentUser()); - - String cloudRouterName = "panthers-test-java-sdk"; - CloudRouterPostRequest cloudRouterPostRequest = new CloudRouterPostRequest(); - cloudRouterPostRequest.type(CloudRouterPostRequest.TypeEnum.XF_ROUTER) - .name(cloudRouterName) - .location(new SimplifiedLocationWithoutIBX().metroCode("DC")) - ._package(new CloudRouterPostRequestPackage().code(CloudRouterPostRequestPackage.CodeEnum.STANDARD)) - .notifications(singletonList(new SimplifiedNotification().type(SimplifiedNotification.TypeEnum.ALL).emails(singletonList("test@test.com")))) - .project(new Project().projectId(user.getProjectId())) - .account(new SimplifiedAccount().accountNumber(Long.valueOf(user.getAccountNumber()))); - - CloudRouter cloudRouter = cloudRoutersApi.createCloudRouter(cloudRouterPostRequest); - - users.get(getCurrentUser()).getUserResources().addCloudRouterUuid(cloudRouter.getUuid()); - assertEquals(200, cloudRoutersApi.getApiClient().getStatusCode()); - - UUID cloudRouterUuid = cloudRouter.getUuid(); - - for (int i = 0; i < 5; i++) { - cloudRouter = cloudRoutersApi.getCloudRouterByUuid(cloudRouterUuid); - - if (cloudRouter.getState().equals(CloudRouterAccessPointState.PROVISIONED)) { - break; - } - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - return cloudRouter; - } - - private static void waitForCloudRouterIsProvisioned(UUID cloudRouterUuid) { - boolean result = false; - CloudRouterAccessPointState currentState = null; - for (int i = 0; i < 5; i++) { - currentState = getCloudRouterStatus(cloudRouterUuid); - if (currentState.equals(CloudRouterAccessPointState.PROVISIONED)) { - result = true; - break; - } - try { - Thread.sleep(3000); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - - assertTrue(result, - "Cloud Router has not reached the expected state: " + CloudRouterAccessPointState.PROVISIONED + " current state: " + currentState.getValue()); - } -} diff --git a/v4/api/ConnectionsApiTest.java b/v4/api/ConnectionsApiTest.java deleted file mode 100644 index ec09cdf2..00000000 --- a/v4/api/ConnectionsApiTest.java +++ /dev/null @@ -1,400 +0,0 @@ -/* - * Equinix Fabric API v4 - * - * Contact: api-support@equinix.com - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.equinix.openapi.fabric.v4.api; - -import com.equinix.openapi.fabric.ApiException; -import com.equinix.openapi.fabric.v4.api.dto.port.PortDto; -import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem; -import com.equinix.openapi.fabric.v4.api.helpers.Utils; -import com.equinix.openapi.fabric.v4.model.*; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -import java.util.List; -import java.util.Random; -import java.util.UUID; -import java.util.stream.Collectors; - -import static com.equinix.openapi.fabric.v4.api.CloudRoutersApiTest.createRouter; -import static com.equinix.openapi.fabric.v4.api.PortsApiTest.getPorts; -import static com.equinix.openapi.fabric.v4.api.helpers.Apis.*; -import static com.equinix.openapi.fabric.v4.api.helpers.TokenGenerator.users; -import static com.equinix.openapi.fabric.v4.api.helpers.Utils.getRandomVlanNumber; -import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class ConnectionsApiTest { - private static final UsersItem.UserName userName = UsersItem.UserName.PANTHERS_FCR; - - public static void removeConnections(UsersItem.UserName userName) { - try { - Thread.sleep(20000); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - users.get(userName).getUserResources().getConnectionsUuid().forEach(uuid -> { - try { - deleteConnection(uuid); - } catch (ApiException e) { - throw new RuntimeException(e); - } - }); - } - - @BeforeAll - public static void setUp() { - setUserName(userName); - } - - @AfterAll - public static void removeResources() { - removeConnections(userName); - CloudRoutersApiTest.removeCloudRouters(userName); - } - - @Test - public void createConnectionVdColo() throws ApiException { - UsersItem usersItem = Utils.getUserData(getCurrentUser()); - - UUID portUuid = UUID.fromString(usersItem.getPorts().stream() - .filter(port -> port.getEncapsulation().equals(LinkProtocolType.DOT1Q.getValue())) - .findFirst().get().getUuid()); - - ConnectionPostRequest connectionPostRequest = getDefaultConnectionRequest("panthers-con-vd-2-colo") - .bandwidth(1000) - .type(ConnectionType.EVPL_VC) - .order(new Order().purchaseOrderNumber("pol123")) - .aSide(new ConnectionSide().accessPoint(new AccessPoint() - .type(AccessPointType.VD) - .virtualDevice(new VirtualDevice() - .type(VirtualDevice.TypeEnum.EDGE) - .uuid(usersItem.getVirtualDevices().get(0).getUuid())))); - - Connection connection = null; - - for (int i = 0; i < 3; i++) { - int vlanTag = getRandomVlanNumber(); - connectionPostRequest.zSide(new ConnectionSide().accessPoint( - new AccessPoint() - .type(AccessPointType.COLO) - .port(new SimplifiedPort() -// .uuid(port.getUuid())) - .uuid(portUuid)) - .linkProtocol(new SimplifiedLinkProtocol() - .type(LinkProtocolType.DOT1Q) - .vlanTag(vlanTag)))); - - connection = connectionsApi.createConnection(connectionPostRequest); - - if (connectionsApi.getApiClient().getStatusCode() == 201) { - break; - } - } - - assertEquals(201, connectionsApi.getApiClient().getStatusCode()); - users.get(userName).getUserResources().addConnectionUuid(connection.getUuid()); - waitForConnectionIsInState(connection.getUuid(), EquinixStatus.PROVISIONED); - try { - Thread.sleep(10000); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - - @Test - public void createConnectionPort2SP() throws ApiException { - Connection connection = createPort2SpConnection(); - users.get(userName).getUserResources().addConnectionUuid(connection.getUuid()); - waitForConnectionIsInState(connection.getUuid(), EquinixStatus.PENDING_APPROVAL); - } - - @Test - public void createConnectionFCR2Port() throws ApiException { - Connection connection = createConnectionFCR2ToPort(); - waitForConnectionIsInState(connection.getUuid(), EquinixStatus.PENDING_INTERFACE_CONFIGURATION); - } - - @Test - public void createConnectionPort2Port() throws ApiException { - createPort2Port(); - } - - /** - * Successful operation - */ - @Test - public void searchConnections() throws ApiException { - ConnectionSearchResponse connectionSearchResponse = getConnections(); - assertEquals(200, connectionsApi.getApiClient().getStatusCode()); - connectionSearchResponse.getData().forEach(connection -> assertEquals(connection.getOperation().getProviderStatus(), ProviderStatus.AVAILABLE)); - } - - /** - * Successful operation - */ - @Test - public void getConnectionByUuid() throws ApiException { - ConnectionSearchResponse connectionSearchResponse = getConnections(); - Connection randomConnection = connectionSearchResponse.getData().get(new Random().nextInt(connectionSearchResponse.getData().size())); - - Connection connection = connectionsApi.getConnectionByUuid(randomConnection.getUuid(), null); - - assertEquals(200, connectionsApi.getApiClient().getStatusCode()); - assertEquals(randomConnection.getUuid(), connection.getUuid()); - assertEquals(randomConnection.getName(), connection.getName()); - } - - /** - * Delete Connection Request - */ - @Test - public void deleteConnectionByUuid() throws ApiException { - Connection connection = createPort2SpConnection(); - connectionsApi.deleteConnectionByUuid(connection.getUuid()); - waitForConnectionIsInState(connection.getUuid(), EquinixStatus.DELETED); - assertEquals(200, connectionsApi.getApiClient().getStatusCode()); - } - - public static Connection createConnectionFCR2ToPort() throws ApiException { - CloudRouter cloudRouter = createRouter(); - - UsersItem userDto = Utils.getUserData(getCurrentUser()); - - Random r = new Random(); - List portList = getPorts(userName).getData().stream() - .filter(p -> p.getName().contains("Dot1q")) - .filter(p -> p.getLocation().getMetroCode().equals(cloudRouter.getLocation().getMetroCode())) - .collect(Collectors.toList()); - - Port port = portList.get(r.nextInt(portList.size())); - - ConnectionPostRequest connectionPostRequest = getDefaultConnectionRequest("panthers-con-fcr-2-port") - .type(ConnectionType.IP_VC) - .bandwidth(1000) - .project(new Project().projectId(userDto.getProjectId())) - .aSide(new ConnectionSide().accessPoint( - new AccessPoint() - .type(AccessPointType.CLOUD_ROUTER) - .router(new CloudRouter().uuid(cloudRouter.getUuid())))); - - Connection connection = null; - for (int i = 0; i < 3; i++) { - int tag = getRandomVlanNumber(); - connectionPostRequest.zSide(new ConnectionSide().accessPoint( - new AccessPoint() - .type(AccessPointType.COLO) - .port(new SimplifiedPort().uuid(port.getUuid())) - .linkProtocol(new SimplifiedLinkProtocol() - .type(LinkProtocolType.DOT1Q) - .vlanTag(tag)))); - - connection = connectionsApi.createConnection(connectionPostRequest); - - if (connectionsApi.getApiClient().getStatusCode() == 201) { - break; - } - } - - assertEquals(201, connectionsApi.getApiClient().getStatusCode()); - - users.get(userName).getUserResources().addConnectionUuid(connection.getUuid()); - return connection; - } - - public static ConnectionPostRequest getDefaultConnectionRequest(String name) { - return new ConnectionPostRequest() - .name(name) - .notifications(singletonList(new SimplifiedNotification() - .type(SimplifiedNotification.TypeEnum.ALL) - .emails(singletonList("test@test.com")))); - } - - public static Connection createPort2SpConnection() throws ApiException { - ServiceProfile serviceProfile = new ServiceProfilesApiTest().getServiceProfilesByQueryResponse("zSide") - .getData().stream() - .filter(sp -> sp.getState().equals(ServiceProfileStateEnum.ACTIVE)) - .filter(sp -> sp.getVisibility().equals(ServiceProfileVisibilityEnum.PUBLIC)) - .findAny().get(); - - UsersItem usersItem = Utils.getUserData(getCurrentUser()); - PortDto portDto = usersItem.getPorts().get(0); - - ConnectionPostRequest connectionPostRequest = getDefaultConnectionRequest("panthers-con-port-2-sp") - .bandwidth(serviceProfile.getAccessPointTypeConfigs().get(0).getServiceProfileAccessPointTypeCOLO().getSupportedBandwidths().get(0)) - .type(ConnectionType.EVPL_VC) - .redundancy(new ConnectionRedundancy().priority(ConnectionPriority.PRIMARY)) - .order(new Order().purchaseOrderNumber("pol123")) - .zSide(new ConnectionSide().accessPoint( - new AccessPoint() - .type(AccessPointType.SP) - .profile(new SimplifiedServiceProfile() - .type(ServiceProfileTypeEnum.L2_PROFILE) - .uuid(serviceProfile.getUuid())) - .location(new SimplifiedLocation() - .metroCode(serviceProfile.getMetros().get(0).getCode())))); - - Connection connection = null; - - for (int i = 0; i < 3; i++) { - int sTag = getRandomVlanNumber(); - int cTag = getRandomVlanNumber(); - connectionPostRequest.aSide(new ConnectionSide().accessPoint( - new AccessPoint() - .type(AccessPointType.COLO) - .port(new SimplifiedPort().uuid(UUID.fromString(portDto.getUuid()))) - .linkProtocol(new SimplifiedLinkProtocol() - .type(LinkProtocolType.QINQ) - .vlanSTag(sTag) - .vlanCTag(cTag)))); - - connection = connectionsApi.createConnection(connectionPostRequest); - - if (connectionsApi.getApiClient().getStatusCode() == 201) { - break; - } - } - - assertEquals(201, connectionsApi.getApiClient().getStatusCode()); - - return connection; - } - - /** - * Successful operation - */ - @Test - public void updateConnectionByUuid() throws ApiException { - Connection connection = createPort2Port(); - String updatedName = "updated_p2p_connection"; - - ConnectionChangeOperation connectionChangeOperation = new ConnectionChangeOperation() - .op(OpEnum.REPLACE.getValue()) - .path("/name") - .value(updatedName); - - Connection updatedConnection = connectionsApi.updateConnectionByUuid(connection.getUuid(), singletonList(connectionChangeOperation)); - - assertEquals(202, connectionsApi.getApiClient().getStatusCode()); - - for (int i = 0; i < 5; i++) { - updatedConnection = connectionsApi.getConnectionByUuid(connection.getUuid(), null); - - if (updatedConnection.getName().equals(updatedName)) { - break; - } - try { - Thread.sleep(8000); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - assertEquals(updatedConnection.getName(), updatedName); - } - - public static Connection createPort2Port() throws ApiException { - List port = getPorts(userName).getData().stream() - .filter(p -> p.getName().contains("Dot1q")) - .collect(Collectors.toList()); - - Connection connection = null; - - for (int i = 0; i < 3; i++) { - int tagAside = getRandomVlanNumber(); - int tagZside = getRandomVlanNumber(); - - ConnectionPostRequest connectionPostRequest = getDefaultConnectionRequest("panthers-con-port-2-port") - .bandwidth(1000) - .type(ConnectionType.EVPL_VC) - .redundancy(new ConnectionRedundancy().priority(ConnectionPriority.PRIMARY)) - .aSide(new ConnectionSide().accessPoint( - new AccessPoint() - .type(AccessPointType.COLO) - .port(new SimplifiedPort() - .uuid(port.get(0).getUuid())) - .linkProtocol(new SimplifiedLinkProtocol() - .type(LinkProtocolType.DOT1Q).vlanTag(tagAside)))) - .zSide(new ConnectionSide().accessPoint( - new AccessPoint() - .type(AccessPointType.COLO) - .port(new SimplifiedPort() - .uuid(port.get(1).getUuid())) - .linkProtocol(new SimplifiedLinkProtocol() - .type(LinkProtocolType.DOT1Q) - .vlanTag(tagZside)))); - - connection = connectionsApi.createConnection(connectionPostRequest); - - if (connectionsApi.getApiClient().getStatusCode() == 201) { - break; - } - } - - assertEquals(201, connectionsApi.getApiClient().getStatusCode()); - users.get(userName).getUserResources().addConnectionUuid(connection.getUuid()); - waitForConnectionIsInState(connection.getUuid(), EquinixStatus.PROVISIONED); - return connection; - } - - public static boolean waitForConnectionIsInState(String connectionUuid, EquinixStatus... connectionState) throws ApiException { - boolean result = false; - EquinixStatus currentState = null; - for (int i = 0; i < 3; i++) { - Connection connection = connectionsApi.getConnectionByUuid(connectionUuid, null); - currentState = connection.getOperation().getEquinixStatus(); - - if (connectionState.length > 1) { - if (currentState.equals(connectionState[0]) || currentState.equals(connectionState[1])) { - result = true; - break; - } - } else { - if (currentState.equals(connectionState[0])) { - result = true; - break; - } - } - try { - Thread.sleep(15000); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - - if (!result) { - System.out.println(result + " Connection has not reached the expected state: " + connectionState[0].getValue() + " current state: " + currentState.getValue()); - } - return result; - } - - private static void deleteConnection(String uuid) throws ApiException { - for (int i = 0; i < 3; i++) { - connectionsApi.deleteConnectionByUuid(uuid); - boolean isDeleted = waitForConnectionIsInState(uuid, EquinixStatus.DELETED, EquinixStatus.DEPROVISIONED); - if (isDeleted) { - break; - } - } - } - - private ConnectionSearchResponse getConnections() throws ApiException { - SearchRequest searchRequest = new SearchRequest() - .filter(new Expression() - .addAndItem(new Expression() - .property(SearchFieldName._OPERATION_PROVIDERSTATUS) - .operator(Expression.OperatorEnum.EQUAL) - .values(singletonList(ProviderStatus.AVAILABLE.getValue())))) - .pagination(new PaginationRequest().limit(5).offset(10)) - .sort(singletonList(new SortCriteria().property(SortBy.CHANGELOG_UPDATEDDATETIME).direction(SortDirection.DESC))); - - return connectionsApi.searchConnections(searchRequest); - } -} diff --git a/v4/api/PortsApiTest.java b/v4/api/PortsApiTest.java deleted file mode 100644 index cef2dd76..00000000 --- a/v4/api/PortsApiTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Equinix Fabric API v4 - * - * Contact: api-support@equinix.com - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.equinix.openapi.fabric.v4.api; - -import com.equinix.openapi.fabric.ApiException; -import com.equinix.openapi.fabric.v4.api.dto.port.PortDto; -import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem; -import com.equinix.openapi.fabric.v4.api.helpers.Utils; -import com.equinix.openapi.fabric.v4.model.*; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -import java.util.List; - -import static com.equinix.openapi.fabric.v4.api.helpers.Apis.portsApi; -import static com.equinix.openapi.fabric.v4.api.helpers.Apis.setUserName; -import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * API tests for PortsApi - */ -public class PortsApiTest { - private static final UsersItem.UserName userName = UsersItem.UserName.PANTHERS_FCR; - - @BeforeAll - public static void setUp() { - setUserName(userName); - } - - /** - * Successful operation - */ - @Test - public void getPort() throws ApiException { - UsersItem usersItem = Utils.getUserData(userName); - PortDto portDto = usersItem.getPorts().get(0); - Port port = portsApi.getPorts(portDto.getName()).getData().get(0); - assertEquals(200, portsApi.getApiClient().getStatusCode()); - assertEquals(port.getName(), portDto.getName()); - assertEquals(port.getUuid().toString(), portDto.getUuid()); - } - - @Test - public void searchPorts() throws ApiException { - List ports = getPorts(userName).getData(); - assertEquals(200, portsApi.getApiClient().getStatusCode()); - assertTrue(!ports.isEmpty()); - } - - public static AllPortsResponse getPorts(UsersItem.UserName userName) throws ApiException { - UsersItem user = Utils.getUserData(userName); - - PortV4SearchRequest portV4SearchRequest = new PortV4SearchRequest() - .filter(new PortExpression().addOrItem(new PortExpression() - .addAndItem(new PortExpression() - .operator(PortExpression.OperatorEnum.EQUAL) - .property(PortSearchFieldName.STATE) - .values(singletonList("ACTIVE"))) - .addAndItem(new PortExpression() - .operator(PortExpression.OperatorEnum.EQUAL) - .property(PortSearchFieldName.PROJECT_PROJECTID) - .values(singletonList(user.getProjectId()))) - .addAndItem(new PortExpression() - .operator(PortExpression.OperatorEnum.EQUAL) - .property(PortSearchFieldName.SETTINGS_PRODUCTCODE) - .values(singletonList("CX")) - ))) - .pagination(new PaginationRequest() - .offset(0) - .limit(100)) - .sort(singletonList(new PortSortCriteria().property(PortSortBy._DEVICE_NAME).direction(PortSortDirection.DESC))); - - return portsApi.searchPorts(portV4SearchRequest); - } -} diff --git a/v4/api/ServiceProfilesApiTest.java b/v4/api/ServiceProfilesApiTest.java deleted file mode 100644 index e6629514..00000000 --- a/v4/api/ServiceProfilesApiTest.java +++ /dev/null @@ -1,248 +0,0 @@ -/* - * Equinix Fabric API v4 - * - * Contact: api-support@equinix.com - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.equinix.openapi.fabric.v4.api; - -import com.equinix.openapi.fabric.ApiException; -import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem; -import com.equinix.openapi.fabric.v4.api.helpers.Utils; -import com.equinix.openapi.fabric.v4.model.*; -import org.apache.commons.lang3.RandomStringUtils; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.UUID; - -import static com.equinix.openapi.fabric.v4.api.PortsApiTest.getPorts; -import static com.equinix.openapi.fabric.v4.api.helpers.Apis.serviceProfilesApi; -import static com.equinix.openapi.fabric.v4.api.helpers.Apis.setUserName; -import static com.equinix.openapi.fabric.v4.api.helpers.TokenGenerator.users; -import static com.equinix.openapi.fabric.v4.model.Expression.OperatorEnum.EQUAL; -import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.*; - -/** - * API tests for ServiceProfilesApi - */ -class ServiceProfilesApiTest { - private static final UsersItem.UserName userName = UsersItem.UserName.PANTHERS_FCR; - - public static void removeServiceProfiles(UsersItem.UserName userName) { - users.get(userName).getUserResources().getServiceProfilesUuid().forEach(uuid -> { - try { - if (!serviceProfilesApi.getServiceProfileByUuid(uuid, null).getState().equals(ServiceProfileStateEnum.DELETED)) { - deleteServiceProfile(uuid); - } - } catch (ApiException e) { - throw new RuntimeException(e); - } - }); - } - - @BeforeAll - public static void setUp() { - setUserName(userName); - } - - @AfterAll - public static void removeResources() { - removeServiceProfiles(userName); - try { - Thread.sleep(30000); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - - /** - * Successful Create operation - */ - @Test - public void createServiceProfileSp2() throws ApiException { - createServiceProfile(); - assertEquals(201, serviceProfilesApi.getApiClient().getStatusCode()); - } - - /** - * Successful operation - */ - @Test - public void getServiceProfileMetrosByUuid() throws ApiException { - ServiceProfiles serviceProfiles = getServiceProfilesByQueryResponse("aSide"); - ServiceProfile serviceProfileToCheck = serviceProfiles.getData().get(0); - ServiceMetros serviceMetros = serviceProfilesApi.getServiceProfileMetrosByUuid(serviceProfileToCheck.getUuid(), 0, 10); - assertEquals(200, serviceProfilesApi.getApiClient().getStatusCode()); - assertFalse(serviceMetros.getData().isEmpty()); - boolean isFound = serviceMetros.getData().stream().anyMatch(metro -> metro.getCode().equals(serviceProfileToCheck.getMetros().get(0).getCode())); - assertTrue(isFound); - } - - /** - * Successful operation - */ - @Test - public void getServiceProfiles() throws ApiException { - ServiceProfiles serviceProfiles = getServiceProfilesByQueryResponse("aSide"); - assertEquals(200, serviceProfilesApi.getApiClient().getStatusCode()); - assertFalse(serviceProfiles.getData().isEmpty()); - } - - /** - * Successful operation - */ - @Test - public void getServiceProfile() throws ApiException { - ServiceProfiles serviceProfiles = getServiceProfilesByQueryResponse("aSide"); - ServiceProfile serviceProfileToCheck = serviceProfiles.getData().get(0); - ServiceProfile serviceProfile = serviceProfilesApi.getServiceProfileByUuid(serviceProfileToCheck.getUuid(), "aSide"); - assertEquals(200, serviceProfilesApi.getApiClient().getStatusCode()); - assertEquals(serviceProfileToCheck.getUuid(), serviceProfile.getUuid()); - assertEquals(serviceProfileToCheck.getName(), serviceProfile.getName()); - } - - /** - * Successful Delete operation - */ - @Test - public void deleteServiceProfileByUuid() throws ApiException { - ServiceProfile serviceProfile = createServiceProfile(); - serviceProfilesApi.deleteServiceProfileByUuid(serviceProfile.getUuid()); - assertEquals(200, serviceProfilesApi.getApiClient().getStatusCode()); - } - - /** - * Successful operation - */ - @Test - public void searchServiceProfiles() throws ApiException { - ServiceProfileSearchRequest serviceProfileSearchRequest = new ServiceProfileSearchRequest(); - ServiceProfileSimpleExpression serviceProfileSimpleExpression = new ServiceProfileSimpleExpression(); - serviceProfileSimpleExpression.setProperty(ServiceProfileSortBy.STATE.getValue()); - serviceProfileSimpleExpression.setOperator(EQUAL.getValue()); - serviceProfileSimpleExpression.setValues(singletonList("ACTIVE")); - serviceProfileSearchRequest - .filter(new ServiceProfileFilter(serviceProfileSimpleExpression)) - .sort(singletonList(new ServiceProfileSortCriteria() - .direction(ServiceProfileSortDirection.DESC) - .property(ServiceProfileSortBy.CHANGELOG_UPDATEDDATETIME))) - .pagination(new PaginationRequest(). - limit(20).offset(00)); - ServiceProfiles serviceProfiles = serviceProfilesApi.searchServiceProfiles(serviceProfileSearchRequest, "aSide"); - assertEquals(200, serviceProfilesApi.getApiClient().getStatusCode()); - assertFalse(serviceProfiles.getData().isEmpty()); - } - - public ServiceProfiles getServiceProfilesByQueryResponse(String viewPointQuery) throws ApiException { - return serviceProfilesApi.getServiceProfiles(1, 10, viewPointQuery); - } - - /** - * Successful Patch operation - */ - @Test - public void updateServiceProfileByUuid() throws ApiException { - ServiceProfile serviceProfile = createServiceProfile(); - - String updatedServiceName = "panthers updated sp2" + RandomStringUtils.randomAlphabetic(5); - String updatedDescription = "updated description"; - - ServiceProfileRequest serviceProfileRequest = getServiceProfileRequest() - .name(updatedServiceName) - .description(updatedDescription); - - ServiceProfile updatedServiceProfile = serviceProfilesApi.putServiceProfileByUuid(serviceProfile.getUuid(), "1", serviceProfileRequest); - - assertEquals(202, serviceProfilesApi.getApiClient().getStatusCode()); - assertEquals(updatedServiceName, updatedServiceProfile.getName()); - assertEquals(updatedDescription, updatedServiceProfile.getDescription()); - } - - private static void deleteServiceProfile(UUID uuid) throws ApiException { - serviceProfilesApi.deleteServiceProfileByUuid(uuid); - assertEquals(200, serviceProfilesApi.getApiClient().getStatusCode()); - waitForSpIsInState(uuid, ServiceProfileStateEnum.DELETED); - } - - private static void waitForSpIsInState(UUID uuid, ServiceProfileStateEnum state) throws ApiException { - boolean result = false; - ServiceProfileStateEnum currentState = null; - for (int i = 0; i < 5; i++) { - ServiceProfile serviceProfile = serviceProfilesApi.getServiceProfileByUuid(uuid, null); - currentState = serviceProfile.getState(); - if (serviceProfile.getState().equals(state)) { - result = true; - break; - } - try { - Thread.sleep(3000); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - - assertTrue(result, "Service profile has not reached the expected state: " + state + " current state: " + currentState.getValue()); - } - - private ServiceProfile createServiceProfile() throws ApiException { - ServiceProfile serviceProfile = serviceProfilesApi.createServiceProfile(getServiceProfileRequest()); - users.get(userName).getUserResources().addServiceProfileUuid(serviceProfile.getUuid()); - return serviceProfile; - } - - private ServiceProfileRequest getServiceProfileRequest() throws ApiException { - UsersItem usersItem = Utils.getUserData(userName); - List email = singletonList("panthersfcr@test.com"); - - Port port = getPorts(userName).getData().stream() - .filter(p -> p.getName().contains("Dot1q")) - .findFirst().get(); - return new ServiceProfileRequest() - .name("panthers-sp2-test" + RandomStringUtils.randomAlphabetic(5)) - .description("desc") - .type(ServiceProfileTypeEnum.L2_PROFILE) - .notifications( - Arrays.asList(new SimplifiedNotification().emails(email).type(SimplifiedNotification.TypeEnum.BANDWIDTH_ALERT), - new SimplifiedNotification().emails(email).type(SimplifiedNotification.TypeEnum.CONNECTION_APPROVAL), - new SimplifiedNotification().emails(email).type(SimplifiedNotification.TypeEnum.PROFILE_LIFECYCLE))) - .tags(Arrays.asList("SaaS", "VoIP")) - .project(new Project().projectId(usersItem.getProjectId())) - .visibility(ServiceProfileVisibilityEnum.PRIVATE) - .ports(singletonList(new ServiceProfileAccessPointCOLO() - .type(ServiceProfileAccessPointCOLO.TypeEnum.XF_PORT) - .uuid(port.getUuid()) - .location(new SimplifiedLocation().metroCode(port.getLocation().getMetroCode())))) - .accessPointTypeConfigs(singletonList(new ServiceProfileAccessPointType(new ServiceProfileAccessPointTypeCOLO() - .type(ServiceProfileAccessPointTypeEnum.COLO) - .linkProtocolConfig(new ServiceProfileLinkProtocolConfig() - .encapsulationStrategy(null) - .reuseVlanSTag(false)) - .enableAutoGenerateServiceKey(false) - .connectionRedundancyRequired(false) - .apiConfig(new ApiConfig() - .equinixManagedPort(false) - .equinixManagedVlan(false) - .allowOverSubscription(false) - .overSubscriptionLimit(1) - .apiAvailable(false) - .bandwidthFromApi(false)) - .authenticationKey(new AuthenticationKey().required(false)) - .allowRemoteConnections(true) - .supportedBandwidths(Arrays.asList(10, 50, 200, 500, 1000)) - .allowCustomBandwidth(false) - .connectionLabel("Connection") - .allowBandwidthAutoApproval(false) - ))) - .marketingInfo(new MarketingInfo().promotion(false).processSteps(new ArrayList<>())); - } -} diff --git a/v4/api/TokenGenerator.java b/v4/api/TokenGenerator.java deleted file mode 100644 index 00438502..00000000 --- a/v4/api/TokenGenerator.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Equinix Fabric API v4 - * - * Contact: api-support@equinix.com - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.equinix.openapi.fabric.v4.api; - -import com.equinix.openapi.fabric.ApiClient; -import com.equinix.openapi.fabric.ApiException; -import com.equinix.openapi.fabric.Configuration; -import com.equinix.openapi.fabric.Pair; -import com.equinix.openapi.fabric.v4.api.dto.TokenRequestDto; -import com.equinix.openapi.fabric.v4.api.dto.TokenResponseDto; -import com.equinix.openapi.fabric.v4.api.dto.users.UserUsedDto; -import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class TokenGenerator { - - public static Map users = new HashMap<>(); - - public static ApiClient getApiClient(UsersItem.UserName userName) { - if (users.containsKey(userName)) { - return users.get(userName).getApiClient(); - } else { - return generate(userName); - } - } - - private static ApiClient generate(UsersItem.UserName userName) { - String baseUrl = System.getProperty("envUrl"); - UsersItem user = Utils.getUserData(userName); - - ApiClient apiTokeClient = Configuration.getDefaultApiClient(); - TokenRequestDto tokenRequestDto = new TokenRequestDto(); - tokenRequestDto.setClientId(user.getClientId()); - tokenRequestDto.setClientSecret(user.getClientSecret()); - tokenRequestDto.setGrantType("client_credentials"); - - String localVarPath = "/oauth2/v1/token"; - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarCookieParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - localVarHeaderParams.put("Content-Type", "application/json"); - String[] localVarAuthNames = new String[]{"BearerAuth"}; - - okhttp3.Call call; - TokenResponseDto tokenResponseDto = null; - - try { - call = apiTokeClient.buildCall(baseUrl, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, tokenRequestDto, localVarHeaderParams - , localVarCookieParams, localVarFormParams, localVarAuthNames, null); - - Type localVarReturnType = new TypeToken() { - }.getType(); - tokenResponseDto = (TokenResponseDto) apiTokeClient.execute(call, localVarReturnType).getData(); - } catch (ApiException e) { - throw new RuntimeException(e); - } - - ApiClient apiClient = Configuration.getDefaultApiClient().setBasePath(baseUrl); - apiClient.addDefaultHeader("Authorization", String.format("Bearer %s", tokenResponseDto.getAccessToken())); - users.put(userName, new UserUsedDto(userName, apiClient)); - return users.get(userName).getApiClient(); - } -} diff --git a/v4/api/Utils.java b/v4/api/Utils.java deleted file mode 100644 index b3e7c452..00000000 --- a/v4/api/Utils.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.equinix.openapi.fabric.v4.api; - -import com.equinix.openapi.fabric.JSON; -import com.equinix.openapi.fabric.v4.api.dto.users.UsersDto; -import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem; -import com.fasterxml.jackson.databind.ObjectMapper; - -import java.io.IOException; -import java.util.NoSuchElementException; - -public class Utils { - - public static Object getEnvData(EnvVariable envVariable) { - ObjectMapper mapper = new ObjectMapper(); - String json = System.getenv(envVariable.value); - try { - return mapper.readValue(json, envVariable.clazz); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - public static UsersItem getUserData(UsersItem.UserName userName) { - return ((UsersDto) getEnvData(EnvVariable.TEST_DATA_UAT_USERS)).getUsers().stream() - .filter(usersItem -> usersItem.getName().equals(userName.getValue())) - .findFirst().orElseThrow(() -> new NoSuchElementException("User not found")); - } - - public static void printJson(Object object) { - System.out.println(JSON.getGson().toJson(object)); - } - - public enum EnvVariable { - TEST_DATA_UAT_USERS("TEST_DATA_UAT_USERS", UsersDto.class); - - private String value; - private Class clazz; - - EnvVariable(String value, Class clazz) { - this.value = value; - this.clazz = clazz; - } - - @Override - public String toString() { - return String.valueOf(value); - } - } -} diff --git a/v4/api/dto/TokenRequestDto.java b/v4/api/dto/TokenRequestDto.java deleted file mode 100644 index 87f247c3..00000000 --- a/v4/api/dto/TokenRequestDto.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.equinix.openapi.fabric.v4.api.dto; - -import com.google.gson.annotations.SerializedName; - -public class TokenRequestDto{ - - @SerializedName("grant_type") - private String grantType; - - @SerializedName("client_secret") - private String clientSecret; - - @SerializedName("client_id") - private String clientId; - - public void setGrantType(String grantType){ - this.grantType = grantType; - } - - public String getGrantType(){ - return grantType; - } - - public void setClientSecret(String clientSecret){ - this.clientSecret = clientSecret; - } - - public String getClientSecret(){ - return clientSecret; - } - - public void setClientId(String clientId){ - this.clientId = clientId; - } - - public String getClientId(){ - return clientId; - } -} \ No newline at end of file diff --git a/v4/api/dto/TokenResponseDto.java b/v4/api/dto/TokenResponseDto.java deleted file mode 100644 index 81a5664f..00000000 --- a/v4/api/dto/TokenResponseDto.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.equinix.openapi.fabric.v4.api.dto; - -import com.google.gson.annotations.SerializedName; - -public class TokenResponseDto{ - - @SerializedName("access_token") - private String accessToken; - - @SerializedName("user_name") - private String userName; - - @SerializedName("token_timeout") - private String tokenTimeout; - - @SerializedName("token_type") - private String tokenType; - - public String getAccessToken(){ - return accessToken; - } - - public String getUserName(){ - return userName; - } - - public String getTokenTimeout(){ - return tokenTimeout; - } - - public String getTokenType(){ - return tokenType; - } -} \ No newline at end of file diff --git a/v4/api/dto/port/Location.java b/v4/api/dto/port/Location.java deleted file mode 100644 index 77ed7113..00000000 --- a/v4/api/dto/port/Location.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.equinix.openapi.fabric.v4.api.dto.port; - -import com.google.gson.annotations.SerializedName; - -public class Location{ - - @SerializedName("metroName") - private String metroName; - - @SerializedName("metroCode") - private String metroCode; - - @SerializedName("region") - private String region; - - @SerializedName("ibx") - private String ibx; - - public String getMetroName(){ - return metroName; - } - - public String getMetroCode(){ - return metroCode; - } - - public String getRegion(){ - return region; - } - - public String getIbx(){ - return ibx; - } -} \ No newline at end of file diff --git a/v4/api/dto/port/PortDto.java b/v4/api/dto/port/PortDto.java deleted file mode 100644 index 3c82647f..00000000 --- a/v4/api/dto/port/PortDto.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.equinix.openapi.fabric.v4.api.dto.port; - -import com.google.gson.annotations.SerializedName; - -public class PortDto { - - @SerializedName("encapsulation") - private String encapsulation; - - @SerializedName("name") - private String name; - - @SerializedName("location") - private Location location; - - @SerializedName("type") - private String type; - - @SerializedName("uuid") - private String uuid; - - public String getEncapsulation(){ - return encapsulation; - } - - public String getName(){ - return name; - } - - public Location getLocation(){ - return location; - } - - public String getType(){ - return type; - } - - public String getUuid(){ - return uuid; - } -} diff --git a/v4/api/dto/port/UsersItem.java b/v4/api/dto/port/UsersItem.java deleted file mode 100644 index 6df62bc0..00000000 --- a/v4/api/dto/port/UsersItem.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.equinix.openapi.fabric.v4.api.dto.port; - -import java.util.List; -import com.google.gson.annotations.SerializedName; - -public class UsersItem{ - - @SerializedName("virtualDevices") - private List virtualDevices; - - @SerializedName("name") - private String name; - - @SerializedName("client_secret") - private String clientSecret; - - @SerializedName("accountNumber") - private String accountNumber; - - @SerializedName("ports") - private List ports; - - @SerializedName("projectId") - private String projectId; - - @SerializedName("client_id") - private String clientId; - - public List getVirtualDevices(){ - return virtualDevices; - } - - public String getName(){ - return name; - } - - public String getClientSecret(){ - return clientSecret; - } - - public String getAccountNumber(){ - return accountNumber; - } - - public List getPorts(){ - return ports; - } - - public String getProjectId(){ - return projectId; - } - - public String getClientId(){ - return clientId; - } -} diff --git a/v4/api/dto/port/VirtualDevicesItem.java b/v4/api/dto/port/VirtualDevicesItem.java deleted file mode 100644 index 0d99c686..00000000 --- a/v4/api/dto/port/VirtualDevicesItem.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.equinix.openapi.fabric.v4.api.dto.port; - -import com.google.gson.annotations.SerializedName; - -public class VirtualDevicesItem{ - - @SerializedName("orderNumber") - private String orderNumber; - - @SerializedName("name") - private String name; - - @SerializedName("uuid") - private String uuid; - - public String getOrderNumber(){ - return orderNumber; - } - - public String getName(){ - return name; - } - - public String getUuid(){ - return uuid; - } -} \ No newline at end of file diff --git a/v4/api/dto/users/UserResources.java b/v4/api/dto/users/UserResources.java deleted file mode 100644 index ed5a81c5..00000000 --- a/v4/api/dto/users/UserResources.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.equinix.openapi.fabric.v4.api.dto.users; - -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -public class UserResources { - private final List cloudRoutersUuid = new ArrayList<>(); - private final List connectionsUuid = new ArrayList<>(); - private final List routingProtocolsUuid = new ArrayList<>(); - private final List networksUuid = new ArrayList<>(); - private final List serviceProfilesUuid = new ArrayList<>(); - - public List getCloudRoutersUuid() { - return cloudRoutersUuid; - } - - public void addCloudRouterUuid(UUID cloudRouterUuid) { - this.cloudRoutersUuid.add(cloudRouterUuid); - } - - public List getConnectionsUuid() { - return connectionsUuid; - } - - public void addConnectionUuid(String connectionsUuid) { - this.connectionsUuid.add(connectionsUuid); - } - - public List getRoutingProtocolsUuid() { - return routingProtocolsUuid; - } - - public UserResources addRoutingProtocolUuid(RoutingProtocolDto routingProtocolsUuid) { - this.routingProtocolsUuid.add(routingProtocolsUuid); - return this; - } - - public List getNetworksUuid() { - return networksUuid; - } - - public void addNetworkUuid(UUID networkUuid) { - this.networksUuid.add(networkUuid); - } - - public List getServiceProfilesUuid() { - return serviceProfilesUuid; - } - - public void addServiceProfileUuid(UUID serviceProfilesUuid) { - this.serviceProfilesUuid.add(serviceProfilesUuid); - } - - public class RoutingProtocolDto { - private UUID routingInstanceUuid; - private UUID connectionUuid; - - public RoutingProtocolDto(UUID routingInstanceUuid, UUID connectionUuid) { - this.routingInstanceUuid = routingInstanceUuid; - this.connectionUuid = connectionUuid; - } - - public UUID getRoutingInstanceUuid() { - return routingInstanceUuid; - } - - public UUID getConnectionUuid() { - return connectionUuid; - } - } -} diff --git a/v4/api/dto/users/UsersDto.java b/v4/api/dto/users/UsersDto.java deleted file mode 100644 index c216e574..00000000 --- a/v4/api/dto/users/UsersDto.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.equinix.openapi.fabric.v4.api.dto.users; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class UsersDto { - - @JsonProperty("users") - private List users; - - public void setUsers(List users){ - this.users = users; - } - - public List getUsers(){ - return users; - } -} diff --git a/v4/api/dto/users/UsersItem.java b/v4/api/dto/users/UsersItem.java deleted file mode 100644 index 6b7f1740..00000000 --- a/v4/api/dto/users/UsersItem.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.equinix.openapi.fabric.v4.api.dto.users; - -import com.equinix.openapi.fabric.v4.api.dto.port.PortDto; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class UsersItem { - - @JsonProperty("virtualDevices") - private List virtualDevices; - - @JsonProperty("ports") - private List ports; - - @JsonProperty("name") - private String name; - - @JsonProperty("client_secret") - private String clientSecret; - - @JsonProperty("accountNumber") - private String accountNumber; - - @JsonProperty("projectId") - private String projectId; - - @JsonProperty("client_id") - private String clientId; - - public List getPorts() { - return ports; - } - - public void setPorts(List ports) { - this.ports = ports; - } - - public List getVirtualDevices() { - return virtualDevices; - } - - public void setVirtualDevices(List virtualDevices) { - this.virtualDevices = virtualDevices; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getClientSecret() { - return clientSecret; - } - - public void setClientSecret(String clientSecret) { - this.clientSecret = clientSecret; - } - - public String getAccountNumber() { - return accountNumber; - } - - public void setAccountNumber(String accountNumber) { - this.accountNumber = accountNumber; - } - - public String getProjectId() { - return projectId; - } - - public void setProjectId(String projectId) { - this.projectId = projectId; - } - - public String getClientId() { - return clientId; - } - - public void setClientId(String clientId) { - this.clientId = clientId; - } - - public enum UserName { - PANTHERS_FCR("fcr"), - PANTHERS_FNV("fnv"); - - public final String value; - - UserName(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - } -} - diff --git a/v4/api/dto/users/VirtualDevicesItem.java b/v4/api/dto/users/VirtualDevicesItem.java deleted file mode 100644 index 67887207..00000000 --- a/v4/api/dto/users/VirtualDevicesItem.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.equinix.openapi.fabric.v4.api.dto.users; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.UUID; - -public class VirtualDevicesItem{ - - @JsonProperty("orderNumber") - private String orderNumber; - - @JsonProperty("name") - private String name; - - @JsonProperty("uuid") - private UUID uuid; - - public void setOrderNumber(String orderNumber){ - this.orderNumber = orderNumber; - } - - public String getOrderNumber(){ - return orderNumber; - } - - public void setName(String name){ - this.name = name; - } - - public String getName(){ - return name; - } - - public void setUuid(UUID uuid){ - this.uuid = uuid; - } - - public UUID getUuid(){ - return uuid; - } -} diff --git a/v4/api/helpers/Apis.java b/v4/api/helpers/Apis.java deleted file mode 100644 index 23e4069f..00000000 --- a/v4/api/helpers/Apis.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.equinix.openapi.fabric.v4.api.helpers; - -import com.equinix.openapi.fabric.v4.api.*; -import com.equinix.openapi.fabric.v4.api.dto.users.UsersItem; - -import static com.equinix.openapi.fabric.v4.api.helpers.TokenGenerator.generate; - -public class Apis { - public static CloudRoutersApi cloudRoutersApi; - public static ConnectionsApi connectionsApi; - public static HealthApi healthApi; - public static MetrosApi metrosApi; - public static NetworksApi networksApi; - public static PortsApi portsApi; - public static PrecisionTimeApi precisionTimeApi; - public static PricesApi pricesApi; - public static RouteFilterRulesApi routeFilterRulesApi; - public static RouteFiltersApi routeFiltersApi; - public static RoutingProtocolsApi routingProtocolsApi; - public static ServiceProfilesApi serviceProfilesApi; - public static ServiceTokensApi serviceTokensApi; - public static StatisticsApi statisticsApi; - private static UsersItem.UserName currentUser; - - static { - currentUser = UsersItem.UserName.PANTHERS_FCR; - setApis(); - } - - public static void setUserName(UsersItem.UserName userName) { - currentUser = userName; - generate(currentUser); - setApis(); - } - - public static UsersItem.UserName getCurrentUser() { - return currentUser; - } - - private static void setApis() { - cloudRoutersApi = new CloudRoutersApi(TokenGenerator.getApiClient(currentUser)); - connectionsApi = new ConnectionsApi(TokenGenerator.getApiClient(currentUser)); - healthApi = new HealthApi(TokenGenerator.getApiClient(currentUser)); - metrosApi = new MetrosApi(TokenGenerator.getApiClient(currentUser)); - networksApi = new NetworksApi(TokenGenerator.getApiClient(currentUser)); - portsApi = new PortsApi(TokenGenerator.getApiClient(currentUser)); - precisionTimeApi = new PrecisionTimeApi(TokenGenerator.getApiClient(currentUser)); - pricesApi = new PricesApi(TokenGenerator.getApiClient(currentUser)); - routeFiltersApi = new RouteFiltersApi(TokenGenerator.getApiClient(currentUser)); - routeFilterRulesApi = new RouteFilterRulesApi(TokenGenerator.getApiClient(currentUser)); - routingProtocolsApi = new RoutingProtocolsApi(TokenGenerator.getApiClient(currentUser)); - serviceProfilesApi = new ServiceProfilesApi(TokenGenerator.getApiClient(currentUser)); - serviceTokensApi = new ServiceTokensApi(TokenGenerator.getApiClient(currentUser)); - statisticsApi = new StatisticsApi(TokenGenerator.getApiClient(currentUser)); - } -}