diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/AbstractTest.java b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/AbstractTest.java index 1be51b99..4814f221 100644 --- a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/AbstractTest.java +++ b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/AbstractTest.java @@ -4,9 +4,9 @@ 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.PortDto; 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.port.PortDto; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectWriter; diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/PortsApiTest.java b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/PortsApiTest.java index 29d430ae..a8a72d64 100644 --- a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/PortsApiTest.java +++ b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/PortsApiTest.java @@ -12,7 +12,7 @@ package com.equinix.openapi.fabric.v4.api; import com.equinix.openapi.fabric.ApiException; -import com.equinix.openapi.fabric.v4.api.dto.PortDto; +import com.equinix.openapi.fabric.v4.api.dto.port.PortDto; import com.equinix.openapi.fabric.v4.model.*; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Disabled; @@ -108,9 +108,9 @@ public void getPortByUuidTest() throws ApiException { @Test public void getPortsTest() throws ApiException { PortDto portDto = getPort(JsonFiles.PORT_2_PUBLIC_SERVICE_PROFILE_CONNECTION); - AllPortsResponse response = api.getPorts(portDto.getAsidePortName()); + AllPortsResponse response = api.getPorts(portDto.getName()); assertEquals(200, api.getApiClient().getStatusCode()); - assertEquals(portDto.getAsidePortName(), response.getData().get(0).getName()); + assertEquals(portDto.getName(), response.getData().get(0).getName()); } /** diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/StatisticsApiTest.java b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/StatisticsApiTest.java index 5775dfc1..86dd2b02 100644 --- a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/StatisticsApiTest.java +++ b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/StatisticsApiTest.java @@ -9,47 +9,37 @@ * 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.Duration; -import com.equinix.openapi.fabric.v4.model.Error; -import com.equinix.openapi.fabric.v4.model.MetricInterval; -import java.time.OffsetDateTime; -import com.equinix.openapi.fabric.v4.model.QueryDirection; -import com.equinix.openapi.fabric.v4.model.Sort; -import com.equinix.openapi.fabric.v4.model.Statistics; -import com.equinix.openapi.fabric.v4.model.TopUtilizedStatistics; -import java.util.UUID; -import com.equinix.openapi.fabric.v4.model.ViewPoint; -import org.junit.jupiter.api.Test; -import org.junit.Assert; +import com.equinix.openapi.fabric.v4.api.dto.port.PortDto; +import com.equinix.openapi.fabric.v4.model.*; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; -import java.time.LocalDate; import java.time.OffsetDateTime; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.time.ZoneOffset; +import java.time.temporal.ChronoUnit; +import java.util.Collections; +import java.util.UUID; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * API tests for StatisticsApi */ -@Disabled public class StatisticsApiTest extends AbstractTest { private final StatisticsApi api = new StatisticsApi(generateToken()); /** * Get Stats by uuid - * + *

* This API provides service-level metrics so that you can view access and gather key information required to manage service subscription sizing and capacity * - * @throws ApiException - * if the Api call fails + * @throws ApiException if the Api call fails */ + @Disabled @Test public void getConnectionStatsByPortUuidTest() throws ApiException { // @@ -65,54 +55,43 @@ public void getConnectionStatsByPortUuidTest() throws ApiException { // TODO: test validations } + /** * Top Port Statistics - * + *

* This API provides top utilized service-level traffic metrics so that you can view access and gather key information required to manage service subscription sizing and capacity. * - * @throws ApiException - * if the Api call fails + * @throws ApiException if the Api call fails */ @Test public void getPortStatsTest() throws ApiException { - // - //List metros = null; - // - //Sort sort = null; - // - //Integer top = null; - // - //Duration duration = null; - // - //QueryDirection direction = null; - // - //MetricInterval metricInterval = null; - // - //String projectId = null; - // - //TopUtilizedStatistics response = api.getPortStats(metros, sort, top, duration, direction, metricInterval, projectId); - - // TODO: test validations + String projectId = "291639000636552"; + TopUtilizedStatistics response = api.getPortStats( + Collections.singletonList(""), + Sort._BANDWIDTHUTILIZATION, + 5, + Duration.P7D, + QueryDirection.OUTBOUND, + MetricInterval.P7D, + projectId); + assertEquals(200, api.getApiClient().getStatusCode()); } + /** * Get Stats by uuid - * + *

* This API provides service-level traffic metrics so that you can view access and gather key information required to manage service subscription sizing and capacity. * - * @throws ApiException - * if the Api call fails + * @throws ApiException if the Api call fails */ @Test public void getPortStatsByPortUuidTest() throws ApiException { - // - //UUID portId = null; - // - //OffsetDateTime startDateTime = null; - // - //OffsetDateTime endDateTime = null; - // - //Statistics response = api.getPortStatsByPortUuid(portId, startDateTime, endDateTime); + PortDto portDto = getPort(JsonFiles.PORT_2_PUBLIC_SERVICE_PROFILE_CONNECTION); + OffsetDateTime startDate = OffsetDateTime.now().minusMonths(3).withOffsetSameLocal(ZoneOffset.UTC).truncatedTo(ChronoUnit.SECONDS); + OffsetDateTime endDate = OffsetDateTime.now().withOffsetSameLocal(ZoneOffset.UTC).truncatedTo(ChronoUnit.SECONDS); - // TODO: test validations + Statistics response = api.getPortStatsByPortUuid(UUID.fromString(portDto.getUuid()), startDate, endDate); + assertEquals(200, api.getApiClient().getStatusCode()); + assertEquals(portDto.getName(), response.getAdditionalProperties().get("name")); } } diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/PortDto.java b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/PortDto.java deleted file mode 100644 index 578e94af..00000000 --- a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/PortDto.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.equinix.openapi.fabric.v4.api.dto; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.gson.annotations.SerializedName; - -public class PortDto{ - - @SerializedName("connection_name") - private String connectionName; - - @SerializedName("connection_type") - private String connectionType; - - @SerializedName("bandwidth") - private int bandwidth; - - @SerializedName("aside_vlan_tag") - private String asideVlanTag; - - @SerializedName("zside_ap_profile_type") - private String zsideApProfileType; - - @SerializedName("purchase_order_number") - private String purchaseOrderNumber; - - @SerializedName("notifications_type") - private String notificationsType; - - @SerializedName("zside_ap_type") - private String zsideApType; - - @SerializedName("zside_sp_name") - private String zsideSpName; - - @SerializedName("notifications_emails") - private List notificationsEmails; - - @SerializedName("zside_location") - private String zsideLocation; - - @SerializedName("aside_port_name") - private String asidePortName; - - public String getConnectionName(){ - return connectionName; - } - - public String getConnectionType(){ - return connectionType; - } - - public int getBandwidth(){ - return bandwidth; - } - - public String getAsideVlanTag(){ - return asideVlanTag; - } - - public String getZsideApProfileType(){ - return zsideApProfileType; - } - - public String getPurchaseOrderNumber(){ - return purchaseOrderNumber; - } - - public String getNotificationsType(){ - return notificationsType; - } - - public String getZsideApType(){ - return zsideApType; - } - - public String getZsideSpName(){ - return zsideSpName; - } - - public List getNotificationsEmails(){ - return notificationsEmails; - } - - public String getZsideLocation(){ - return zsideLocation; - } - - public String getAsidePortName(){ - return asidePortName; - } -} diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/Device.java b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/Device.java new file mode 100644 index 00000000..7741d913 --- /dev/null +++ b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/Device.java @@ -0,0 +1,20 @@ +package com.equinix.openapi.fabric.v4.api.dto.port; + +import com.google.gson.annotations.SerializedName; + +public class Device{ + + @SerializedName("name") + private String name; + + @SerializedName("redundancy") + private Redundancy redundancy; + + public String getName(){ + return name; + } + + public Redundancy getRedundancy(){ + return redundancy; + } +} \ No newline at end of file diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/Encapsulation.java b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/Encapsulation.java new file mode 100644 index 00000000..6c00315d --- /dev/null +++ b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/Encapsulation.java @@ -0,0 +1,20 @@ +package com.equinix.openapi.fabric.v4.api.dto.port; + +import com.google.gson.annotations.SerializedName; + +public class Encapsulation{ + + @SerializedName("tagProtocolId") + private String tagProtocolId; + + @SerializedName("type") + private String type; + + public String getTagProtocolId(){ + return tagProtocolId; + } + + public String getType(){ + return type; + } +} \ No newline at end of file diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/Lag.java b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/Lag.java new file mode 100644 index 00000000..5eb9fecf --- /dev/null +++ b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/Lag.java @@ -0,0 +1,27 @@ +package com.equinix.openapi.fabric.v4.api.dto.port; + +import com.google.gson.annotations.SerializedName; + +public class Lag{ + + @SerializedName("name") + private String name; + + @SerializedName("id") + private String id; + + @SerializedName("enabled") + private boolean enabled; + + public String getName(){ + return name; + } + + public String getId(){ + return id; + } + + public boolean isEnabled(){ + return enabled; + } +} \ 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 new file mode 100644 index 00000000..0138c6f7 --- /dev/null +++ b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/Location.java @@ -0,0 +1,41 @@ +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("href") + private String href; + + @SerializedName("region") + private String region; + + @SerializedName("ibx") + private String ibx; + + public String getMetroName(){ + return metroName; + } + + public String getMetroCode(){ + return metroCode; + } + + public String getHref(){ + return href; + } + + 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 new file mode 100644 index 00000000..adb75723 --- /dev/null +++ b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/PortDto.java @@ -0,0 +1,118 @@ +package com.equinix.openapi.fabric.v4.api.dto.port; + +import com.google.gson.annotations.SerializedName; + +public class PortDto{ + + @SerializedName("encapsulation") + private Encapsulation encapsulation; + + @SerializedName("settings") + private Settings settings; + + @SerializedName("availableBandwidth") + private int availableBandwidth; + + @SerializedName("bandwidth") + private int bandwidth; + + @SerializedName("lagEnabled") + private boolean lagEnabled; + + @SerializedName("type") + private String type; + + @SerializedName("uuid") + private String uuid; + + @SerializedName("cvpId") + private String cvpId; + + @SerializedName("lag") + private Lag lag; + + @SerializedName("usedBandwidth") + private int usedBandwidth; + + @SerializedName("name") + private String name; + + @SerializedName("location") + private Location location; + + @SerializedName("href") + private String href; + + @SerializedName("state") + private String state; + + @SerializedName("redundancy") + private Redundancy redundancy; + + @SerializedName("device") + private Device device; + + public Encapsulation getEncapsulation(){ + return encapsulation; + } + + public Settings getSettings(){ + return settings; + } + + public int getAvailableBandwidth(){ + return availableBandwidth; + } + + public int getBandwidth(){ + return bandwidth; + } + + public boolean isLagEnabled(){ + return lagEnabled; + } + + public String getType(){ + return type; + } + + public String getUuid(){ + return uuid; + } + + public String getCvpId(){ + return cvpId; + } + + public Lag getLag(){ + return lag; + } + + public int getUsedBandwidth(){ + return usedBandwidth; + } + + public String getName(){ + return name; + } + + public Location getLocation(){ + return location; + } + + public String getHref(){ + return href; + } + + public String getState(){ + return state; + } + + public Redundancy getRedundancy(){ + return redundancy; + } + + public Device getDevice(){ + return device; + } +} \ No newline at end of file diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/Redundancy.java b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/Redundancy.java new file mode 100644 index 00000000..c5d42f78 --- /dev/null +++ b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/Redundancy.java @@ -0,0 +1,13 @@ +package com.equinix.openapi.fabric.v4.api.dto.port; + +import com.google.gson.annotations.SerializedName; + +public class Redundancy{ + + @SerializedName("priority") + private String priority; + + public String getPriority(){ + return priority; + } +} \ No newline at end of file diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/Settings.java b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/Settings.java new file mode 100644 index 00000000..fa3450a6 --- /dev/null +++ b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/dto/port/Settings.java @@ -0,0 +1,27 @@ +package com.equinix.openapi.fabric.v4.api.dto.port; + +import com.google.gson.annotations.SerializedName; + +public class Settings{ + + @SerializedName("buyout") + private boolean buyout; + + @SerializedName("placeVcOrderPermission") + private boolean placeVcOrderPermission; + + @SerializedName("viewPortPermission") + private boolean viewPortPermission; + + public boolean isBuyout(){ + return buyout; + } + + public boolean isPlaceVcOrderPermission(){ + return placeVcOrderPermission; + } + + public boolean isViewPortPermission(){ + return viewPortPermission; + } +} \ No newline at end of file diff --git a/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/json/port-2-public-service-profile-connection.json b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/json/port-2-public-service-profile-connection.json new file mode 100644 index 00000000..d5dde86d --- /dev/null +++ b/equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/json/port-2-public-service-profile-connection.json @@ -0,0 +1,43 @@ +{ + "href": "https://api.equinix.com/fabric/v4/ports/c4d9350e-77f1-7f1d-1ce0-306a5c00a600", + "type": "XF_PORT", + "uuid": "c4d9350e-77f1-7f1d-1ce0-306a5c00a600", + "name": "ops-user100-CX-CH1-L-Qinq-BO-20G-SEC-JP-238", + "state": "ACTIVE", + "cvpId": "1615792", + "bandwidth": 20000, + "usedBandwidth": 0, + "availableBandwidth": 20000, + "location": { + "href": "https://api.equinix.com/fabric/v4/metros/CH", + "ibx": "CH1", + "metroCode": "CH", + "metroName": "Chicago", + "region": "AMER" + }, + "device": { + "name": "sit-tb1-ch-e2.lab", + "redundancy": { + "priority": "SECONDARY" + } + }, + "redundancy": { + "priority": "SECONDARY" + }, + "encapsulation": { + "type": "QINQ", + "tagProtocolId": "0x9100" + }, + "lag": { + "id": "206", + "enabled": true, + "name": "ae206" + }, + "lagEnabled": true, + "settings": { + "buyout": true, + "placeVcOrderPermission": true, + "viewPortPermission": true + } +} +{ "href": "https://api.equinix.com/fabric/v4/ports/c4d9350e-77f1-7f1d-1ce0-306a5c00a600", "type": "XF_PORT", "uuid": "c4d9350e-77f1-7f1d-1ce0-306a5c00a600", "name": "ops-user100-CX-CH1-L-Qinq-BO-20G-SEC-JP-238", "state": "ACTIVE", "cvpId": "1615792", "bandwidth": 20000, "usedBandwidth": 0, "availableBandwidth": 20000, "location": { "href": "https://api.equinix.com/fabric/v4/metros/CH", "ibx": "CH1", "metroCode": "CH", "metroName": "Chicago", "region": "AMER" }, "device": { "name": "sit-tb1-ch-e2.lab", "redundancy": { "priority": "SECONDARY" } }, "redundancy": { "priority": "SECONDARY" }, "encapsulation": { "type": "QINQ", "tagProtocolId": "0x9100" }, "lag": { "id": "206", "enabled": true, "name": "ae206" }, "lagEnabled": true, "settings": { "buyout": true, "placeVcOrderPermission": true, "viewPortPermission": true } } diff --git a/v4/api/json/port-2-public-service-profile-connection.json b/v4/api/json/port-2-public-service-profile-connection.json index 67dc68d4..d5dde86d 100644 --- a/v4/api/json/port-2-public-service-profile-connection.json +++ b/v4/api/json/port-2-public-service-profile-connection.json @@ -40,3 +40,4 @@ "viewPortPermission": true } } +{ "href": "https://api.equinix.com/fabric/v4/ports/c4d9350e-77f1-7f1d-1ce0-306a5c00a600", "type": "XF_PORT", "uuid": "c4d9350e-77f1-7f1d-1ce0-306a5c00a600", "name": "ops-user100-CX-CH1-L-Qinq-BO-20G-SEC-JP-238", "state": "ACTIVE", "cvpId": "1615792", "bandwidth": 20000, "usedBandwidth": 0, "availableBandwidth": 20000, "location": { "href": "https://api.equinix.com/fabric/v4/metros/CH", "ibx": "CH1", "metroCode": "CH", "metroName": "Chicago", "region": "AMER" }, "device": { "name": "sit-tb1-ch-e2.lab", "redundancy": { "priority": "SECONDARY" } }, "redundancy": { "priority": "SECONDARY" }, "encapsulation": { "type": "QINQ", "tagProtocolId": "0x9100" }, "lag": { "id": "206", "enabled": true, "name": "ae206" }, "lagEnabled": true, "settings": { "buyout": true, "placeVcOrderPermission": true, "viewPortPermission": true } }