diff --git a/.github/workflows/sync-crossconnectsv2.yaml b/.github/workflows/sync-crossconnectsv2.yaml new file mode 100644 index 00000000..6554ac1c --- /dev/null +++ b/.github/workflows/sync-crossconnectsv2.yaml @@ -0,0 +1,96 @@ +name: Sync crossconnectsv2 API spec + +on: + workflow_dispatch: + +jobs: + sync: + strategy: + matrix: + java-version: [11.0.21] + java-distribution: [temurin] + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + + steps: + - name: Get current date + id: date + run: echo "date=$(date +'%Y-%m-%d')" >> "$GITHUB_OUTPUT" + + - name: Install Java + uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.java-version }} + distribution: ${{ matrix.java-distribution }} + + - name: Checkout code + uses: actions/checkout@v4 + + - name: GitHub user + run: | + # https://api.github.com/users/github-actions[bot] + git config user.name 'github-actions[bot]' + git config user.email '41898282+github-actions[bot]@users.noreply.github.com' + + - name: Fetch latest spec + id: fetch + run: | + make -f Makefile.crossconnectsv2 fetch + git add spec/services/crossconnectsv2 + echo `git commit -m 'sync: fetch ${{ steps.date.outputs.date }} spec'` + + - name: Apply spec patches + id: patch + if: ${{ always() && steps.fetch.conclusion == 'success' }} + run: | + make -f Makefile.crossconnectsv2 patch + git add spec/services/crossconnectsv2 + echo `git commit -m 'sync: patch spec with ${{ steps.date.outputs.date }} spec'` + + - name: Generate code + id: generate + if: ${{ always() && steps.fetch.conclusion == 'success' }} + run: | + make -f Makefile.crossconnectsv2 generate + git add services/crossconnectsv2 + echo `git commit -m 'sync: generate client with ${{ steps.date.outputs.date }} spec'` + + - name: Create Pull Request + id: cpr + uses: peter-evans/create-pull-request@v7 + if: ${{ always() && steps.fetch.conclusion == 'success' }} + with: + branch: sync/gh + branch-suffix: timestamp + author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> + commit-message: "sync: uncommitted changes detected when opening PR" + title: "feat: API Sync by GitHub Action for @${{ github.event.sender.login }}" + body: | + This API Sync PR was triggered by @${{ github.event.sender.login }} through [GitHub Actions workflow_displatch](https://github.com/equinix/equinix-sdk-go/actions?query=event%3Aworkflow_dispatch) + on ${{ steps.date.outputs.date }}. + + * latest Swagger is fetched + * patches have been applied + * generated client has been updated + delete-branch: true + draft: ${{ steps.patch.conclusion == 'failure' || steps.generate.conclusion == 'failure' }} + + - name: Comment for failed patch + uses: mshick/add-pr-comment@v2 + if: ${{ always() && steps.patch.conclusion == 'failure' && steps.cpr.conclusion == 'success' }} + with: + issue: ${{ steps.cpr.outputs.pull-request-number }} + message: Failed to patch latest spec. Someone with write access must review and, if necessary, fix this PR manually and then convert it from Draft status to Ready for Review. + + - name: Comment for failed generate + uses: mshick/add-pr-comment@v2 + if: ${{ always() && steps.generate.conclusion == 'failure' && steps.cpr.conclusion == 'success' }} + with: + issue: ${{ steps.cpr.outputs.pull-request-number }} + message: Failed to generate code from latest patched spec. Someone with write access must fix this PR manually and then convert it from Draft status to Ready for Review. + + - name: Check outputs + if: ${{ always() && steps.cpr.conclusion == 'success' }} + run: | + echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" + echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" diff --git a/Makefile.crossconnectsv2 b/Makefile.crossconnectsv2 new file mode 100644 index 00000000..7da7a11b --- /dev/null +++ b/Makefile.crossconnectsv2 @@ -0,0 +1,65 @@ +.PHONY: all pull fetch patch generate clean codegen mod docs move-other patch-post fmt test stage + +include Makefile + +PACKAGE_NAME=crossconnectsv2 +SPEC_BASE_URL:=https://docs.equinix.com/api-catalog/crossconnectsv2 +SPEC_ROOT_FILE:=openapi.yaml + +CODE_DIR=services/${PACKAGE_NAME} +TEMPLATE_DIR=${TEMPLATE_BASE_DIR}/${PACKAGE_NAME} +SPEC_FETCHED_DIR=${SPEC_BASE_DIR}/${PACKAGE_NAME}/oas3.fetched +SPEC_PATCH_DIR=${SPEC_BASE_DIR}/${PACKAGE_NAME}/patches +SPEC_PATCHED_DIR=${SPEC_BASE_DIR}/${PACKAGE_NAME}/oas3.patched +SPEC_FETCHER=curl + +ARTIFACT_ID=${GIT_REPO}-${PACKAGE_NAME} + +all: pull fetch patch generate stage + +generate: clean codegen patch-post fmt test + +pull: + ${CRI} pull ${OPENAPI_IMAGE} + +fetch: + ${SPEC_FETCHER} -o ${SPEC_FETCHED_DIR}/${SPEC_ROOT_FILE} ${SPEC_BASE_URL}/${SPEC_ROOT_FILE} + +patch: + rm -rf ${SPEC_PATCHED_DIR} + cp -r ${SPEC_FETCHED_DIR} ${SPEC_PATCHED_DIR} + + for diff in $(shell set -x; find ${SPEC_PATCH_DIR} -name '*.patch' | sort -n); do \ + patch --no-backup-if-mismatch -N -t -p1 -i $$diff; \ + RESULT=$$(($${RESULT} + $$?)); \ + done; \ + exit $$RESULT; + +patch-post: + # patch is idempotent, always starting with the generated files + for diff in $(shell find patches/services/${PACKAGE_NAME} -name \*.patch | sort -n); do \ + patch --no-backup-if-mismatch -N -t -p1 -i $$diff; \ + done + +clean: + rm -rf $(CODE_DIR) + +codegen: + ${OPENAPI_GENERATOR} generate -g java \ + --http-user-agent "${USER_AGENT}" \ + -p artifactVersion=${PACKAGE_VERSION} \ + -p artifactId="${PACKAGE_NAME}" \ + -p invokerPackage="com.equinix.sdk.${PACKAGE_NAME}" \ + -p apiPackage="com.equinix.sdk.${PACKAGE_NAME}.api" \ + -p modelPackage="com.equinix.sdk.${PACKAGE_NAME}.model" \ + -i ${SPEC_PATCHED_DIR}/${SPEC_ROOT_FILE} \ + -t ${TEMPLATE_DIR} \ + -c config/openapi-generator.json \ + -o ${CODE_DIR} \ + --git-repo-id ${GIT_REPO} \ + --git-user-id ${GIT_ORG} + +validate: + ${OPENAPI_GENERATOR} validate \ + --recommend \ + -i ${SPEC_PATCHED_DIR}/${SPEC_ROOT_FILE} diff --git a/equinix-sdk-java/pom.xml b/equinix-sdk-java/pom.xml index e3fca044..5c325eb7 100644 --- a/equinix-sdk-java/pom.xml +++ b/equinix-sdk-java/pom.xml @@ -18,5 +18,10 @@ fabricv4 ${project.version} + + com.equinix.sdk + crossconnectsv2 + ${project.version} + \ No newline at end of file diff --git a/examples/crossconnectsv2/README.md b/examples/crossconnectsv2/README.md new file mode 100644 index 00000000..08d69478 --- /dev/null +++ b/examples/crossconnectsv2/README.md @@ -0,0 +1,24 @@ +# crossconnectsv2 examples + +Examples for the Equinix Cross Connects v2 service. See [examples/README.md](../README.md) for the +environment variables and how to run them. + +The service only has operations that create or modify orders, so the three order examples below do +not send anything unless `EQUINIX_EXAMPLE_ALLOW_WRITES=true` is set. They build a realistic request +and print how to opt in otherwise. Clients here are not expected to match the earlier standalone +samples 1:1; the examples follow the maintained, spec-generated SDK. + +| Example | Shows | Replaces (earlier sample operation) | +| --- | --- | --- | +| `OrderCrossConnect` | ordering a standard fiber cross connect between two patch panels (creates an order, guarded) | standard, intracustomer, extended and fiber cross connect orders | +| `RequestDeinstall` | ordering the removal of an existing cross connect by asset ID (guarded) | cross connect deinstall order | +| `UpdateOrderContacts` | adding a notification contact to an existing order (modifies an order, guarded) | none | +| `HandleCrossConnectErrors` | catching `ApiException`, reading status, headers and body, parsing `ErrorDetails`; sends an invalid token so nothing is created | none | + +The service has no read operations, so there is no order retrieval example. It also has no list or +search operations, so there is no pagination example. The earlier sample's lookups (providers, +locations, types, connection services, patch panels) belong to other services and are not part of this +one. + +`OrderCrossConnect` uses `EQUINIX_EXAMPLE_ALLOW_WRITES`; `RequestDeinstall` also reads +`EQUINIX_EXAMPLE_ASSET_ID` and `UpdateOrderContacts` reads `EQUINIX_EXAMPLE_ORDER_ID`. diff --git a/examples/crossconnectsv2/pom.xml b/examples/crossconnectsv2/pom.xml new file mode 100644 index 00000000..b68e5f92 --- /dev/null +++ b/examples/crossconnectsv2/pom.xml @@ -0,0 +1,24 @@ + + 4.0.0 + + com.equinix.sdk + equinix-sdk-java-examples + 0.11.0 + + examples-crossconnectsv2 + examples-crossconnectsv2 + + + + com.equinix.sdk + crossconnectsv2 + ${project.version} + + + com.equinix.sdk + examples-common + ${project.version} + + + diff --git a/examples/crossconnectsv2/src/main/java/com/equinix/sdk/examples/crossconnectsv2/HandleCrossConnectErrors.java b/examples/crossconnectsv2/src/main/java/com/equinix/sdk/examples/crossconnectsv2/HandleCrossConnectErrors.java new file mode 100644 index 00000000..7af1ba05 --- /dev/null +++ b/examples/crossconnectsv2/src/main/java/com/equinix/sdk/examples/crossconnectsv2/HandleCrossConnectErrors.java @@ -0,0 +1,45 @@ +package com.equinix.sdk.examples.crossconnectsv2; + +import com.equinix.sdk.crossconnectsv2.ApiClient; +import com.equinix.sdk.crossconnectsv2.ApiException; +import com.equinix.sdk.crossconnectsv2.Configuration; +import com.equinix.sdk.crossconnectsv2.JSON; +import com.equinix.sdk.crossconnectsv2.api.CrossConnectsApi; +import com.equinix.sdk.crossconnectsv2.auth.HttpBearerAuth; +import com.equinix.sdk.crossconnectsv2.model.ErrorDetails; +import com.equinix.sdk.crossconnectsv2.model.Layer1Create; +import com.equinix.sdk.examples.ExampleEnv; + +/** + * Shows how failures surface: every non-2xx response is thrown as an {@link ApiException} carrying the + * HTTP status, response headers and raw body, and the body can be parsed into the service's error + * model. + * + *

Deliberately authenticates with an invalid token so that the order request is refused before + * anything is created. It needs no credentials and creates no resources. + */ +public class HandleCrossConnectErrors { + public static void main(String[] args) { + ApiClient client = Configuration.getDefaultApiClient(); + client.setBasePath(ExampleEnv.endpoint()); + ((HttpBearerAuth) client.getAuthentication("BearerAuth")).setBearerToken("not-a-real-token"); + CrossConnectsApi api = new CrossConnectsApi(client); + + try { + api.orderCrossConnects(new Layer1Create()); + System.out.println("unexpectedly succeeded"); + } catch (ApiException e) { + System.out.println("HTTP status: " + e.getCode()); + System.out.println("headers: " + e.getResponseHeaders()); + try { + ErrorDetails error = JSON.getGson().fromJson(e.getResponseBody(), ErrorDetails.class); + System.out.println("error code: " + error.getErrorCode()); + System.out.println("message: " + error.getErrorMessage()); + System.out.println("correlation: " + error.getCorrelationId()); + } catch (RuntimeException notJson) { + // gateways and proxies can return non-JSON bodies, e.g. for 502/503 + System.out.println("raw body: " + e.getResponseBody()); + } + } + } +} diff --git a/examples/crossconnectsv2/src/main/java/com/equinix/sdk/examples/crossconnectsv2/OrderCrossConnect.java b/examples/crossconnectsv2/src/main/java/com/equinix/sdk/examples/crossconnectsv2/OrderCrossConnect.java new file mode 100644 index 00000000..9f11d7f3 --- /dev/null +++ b/examples/crossconnectsv2/src/main/java/com/equinix/sdk/examples/crossconnectsv2/OrderCrossConnect.java @@ -0,0 +1,71 @@ +package com.equinix.sdk.examples.crossconnectsv2; + +import com.equinix.sdk.crossconnectsv2.ApiClient; +import com.equinix.sdk.crossconnectsv2.ApiException; +import com.equinix.sdk.crossconnectsv2.ApiResponse; +import com.equinix.sdk.crossconnectsv2.Configuration; +import com.equinix.sdk.crossconnectsv2.api.CrossConnectsApi; +import com.equinix.sdk.crossconnectsv2.auth.HttpBearerAuth; +import com.equinix.sdk.crossconnectsv2.model.ASide; +import com.equinix.sdk.crossconnectsv2.model.ConnectionServices; +import com.equinix.sdk.crossconnectsv2.model.ContactRequestRegisteredUser; +import com.equinix.sdk.crossconnectsv2.model.ConnectorTypes; +import com.equinix.sdk.crossconnectsv2.model.Layer1Create; +import com.equinix.sdk.crossconnectsv2.model.Layer1CreateContactsInner; +import com.equinix.sdk.crossconnectsv2.model.Layer1Details; +import com.equinix.sdk.crossconnectsv2.model.MediaTypes; +import com.equinix.sdk.crossconnectsv2.model.PatchPanel; +import com.equinix.sdk.crossconnectsv2.model.ProtocolTypes; +import com.equinix.sdk.crossconnectsv2.model.ZSide; +import com.equinix.sdk.crossconnectsv2.model.ZSideWithPatchPanel; +import com.equinix.sdk.examples.ExampleEnv; +import java.math.BigDecimal; + +/** + * Orders one standard single mode fiber cross connect between two patch panels. + * + *

Creates an order, which Equinix will then fulfil, so it only sends the request when + * EQUINIX_EXAMPLE_ALLOW_WRITES=true. Replace the patch panel IDs and contact below with your own + * (look them up in the Lookup API) before enabling it. + */ +public class OrderCrossConnect { + public static void main(String[] args) throws Exception { + ApiClient client = Configuration.getDefaultApiClient(); + client.setBasePath(ExampleEnv.endpoint()); + ((HttpBearerAuth) client.getAuthentication("BearerAuth")).setBearerToken(ExampleEnv.token()); + CrossConnectsApi api = new CrossConnectsApi(client); + + // one entry in details is one cross connect; add more entries to order several in one request + Layer1Create order = new Layer1Create() + .customerReferenceId("example-order-1") + .description("Created from the SDK examples") + .addDetailsItem(new Layer1Details() + .aSide(new ASide() + .connectionService(ConnectionServices.SINGLE_MODE_FIBER) + .mediaType(MediaTypes.SINGLE_MODE_FIBER) + .protocolType(ProtocolTypes._10_GIG_ETHERNET) + .connectorType(ConnectorTypes.FC) + .patchPanel(new PatchPanel().id("CP:0104:1199890").portA(new BigDecimal(12)).portB(new BigDecimal(13)))) + // zSide and contacts are oneOf types: wrap the variant that applies. This one + // connects to an existing patch panel; ZSideWithLOA is for a new provider. + .zSide(new ZSide(new ZSideWithPatchPanel() + .connectorType(ConnectorTypes.LC) + .circuitId("1-12312312") + .patchPanel(new PatchPanel().id("PP:0104:1190123"))))) + .addContactsItem(new Layer1CreateContactsInner(new ContactRequestRegisteredUser() + .type(ContactRequestRegisteredUser.TypeEnum.NOTIFICATION) + .addRegisteredUsersItem("john_doe"))); + + if (!WriteGuard.allowed()) { + return; + } + + try { + ApiResponse response = api.orderCrossConnectsWithHttpInfo(order); + System.out.println("HTTP status: " + response.getStatusCode()); + System.out.println("order: " + response.getHeaders().get("Location")); + } catch (ApiException e) { + System.out.println("order rejected with HTTP " + e.getCode() + ": " + e.getResponseBody()); + } + } +} diff --git a/examples/crossconnectsv2/src/main/java/com/equinix/sdk/examples/crossconnectsv2/RequestDeinstall.java b/examples/crossconnectsv2/src/main/java/com/equinix/sdk/examples/crossconnectsv2/RequestDeinstall.java new file mode 100644 index 00000000..e445ea98 --- /dev/null +++ b/examples/crossconnectsv2/src/main/java/com/equinix/sdk/examples/crossconnectsv2/RequestDeinstall.java @@ -0,0 +1,50 @@ +package com.equinix.sdk.examples.crossconnectsv2; + +import com.equinix.sdk.crossconnectsv2.ApiClient; +import com.equinix.sdk.crossconnectsv2.ApiException; +import com.equinix.sdk.crossconnectsv2.ApiResponse; +import com.equinix.sdk.crossconnectsv2.Configuration; +import com.equinix.sdk.crossconnectsv2.api.CrossConnectsApi; +import com.equinix.sdk.crossconnectsv2.auth.HttpBearerAuth; +import com.equinix.sdk.crossconnectsv2.model.Layer1DeinstallDetails; +import com.equinix.sdk.crossconnectsv2.model.Layer1DeinstallRequest; +import com.equinix.sdk.examples.ExampleEnv; +import java.time.LocalDate; + +/** + * Places an order to remove an existing cross connect. + * + *

Requests the removal of real infrastructure, so it only sends the request when + * EQUINIX_EXAMPLE_ALLOW_WRITES=true. Set EQUINIX_EXAMPLE_ASSET_ID to the asset ID of the cross + * connect to remove; the removal date is one week from today. + */ +public class RequestDeinstall { + public static void main(String[] args) throws Exception { + ApiClient client = Configuration.getDefaultApiClient(); + client.setBasePath(ExampleEnv.endpoint()); + ((HttpBearerAuth) client.getAuthentication("BearerAuth")).setBearerToken(ExampleEnv.token()); + CrossConnectsApi api = new CrossConnectsApi(client); + + String assetId = System.getenv().getOrDefault("EQUINIX_EXAMPLE_ASSET_ID", "4-1234567890"); + Layer1DeinstallRequest request = new Layer1DeinstallRequest() + .customerReferenceId("example-deinstall-1") + .description("Created from the SDK examples") + .removalDate(LocalDate.now().plusDays(7)) + .addDetailsItem(new Layer1DeinstallDetails() + .assetId(assetId) + // false: do not proceed if Equinix detects live traffic on the connection + .proceedWithLiveTraffic(false)); + + if (!WriteGuard.allowed()) { + return; + } + + try { + ApiResponse response = api.placeCrossConnectDeinstallationOrderWithHttpInfo(request); + System.out.println("HTTP status: " + response.getStatusCode()); + System.out.println("order: " + response.getHeaders().get("Location")); + } catch (ApiException e) { + System.out.println("deinstall rejected with HTTP " + e.getCode() + ": " + e.getResponseBody()); + } + } +} diff --git a/examples/crossconnectsv2/src/main/java/com/equinix/sdk/examples/crossconnectsv2/UpdateOrderContacts.java b/examples/crossconnectsv2/src/main/java/com/equinix/sdk/examples/crossconnectsv2/UpdateOrderContacts.java new file mode 100644 index 00000000..a87708b9 --- /dev/null +++ b/examples/crossconnectsv2/src/main/java/com/equinix/sdk/examples/crossconnectsv2/UpdateOrderContacts.java @@ -0,0 +1,42 @@ +package com.equinix.sdk.examples.crossconnectsv2; + +import com.equinix.sdk.crossconnectsv2.ApiClient; +import com.equinix.sdk.crossconnectsv2.ApiException; +import com.equinix.sdk.crossconnectsv2.Configuration; +import com.equinix.sdk.crossconnectsv2.api.CrossConnectsApi; +import com.equinix.sdk.crossconnectsv2.auth.HttpBearerAuth; +import com.equinix.sdk.crossconnectsv2.model.ContactRequestRegisteredUserUpdate; +import com.equinix.sdk.crossconnectsv2.model.ModifyRequest; +import com.equinix.sdk.examples.ExampleEnv; + +/** + * Adds a notification contact to an existing cross connect order. + * + *

Modifies an order, so it only sends the request when EQUINIX_EXAMPLE_ALLOW_WRITES=true. Set + * EQUINIX_EXAMPLE_ORDER_ID to the order to change. + */ +public class UpdateOrderContacts { + public static void main(String[] args) throws Exception { + ApiClient client = Configuration.getDefaultApiClient(); + client.setBasePath(ExampleEnv.endpoint()); + ((HttpBearerAuth) client.getAuthentication("BearerAuth")).setBearerToken(ExampleEnv.token()); + CrossConnectsApi api = new CrossConnectsApi(client); + + String orderId = System.getenv().getOrDefault("EQUINIX_EXAMPLE_ORDER_ID", "1-123456789"); + ModifyRequest request = new ModifyRequest() + .addContactsItem(new ContactRequestRegisteredUserUpdate() + .type(ContactRequestRegisteredUserUpdate.TypeEnum.NOTIFICATION) + .addRegisteredUsersItem("john_doe")); + + if (!WriteGuard.allowed()) { + return; + } + + try { + api.updateACrossConnectOrder(orderId, request); + System.out.println("order " + orderId + " updated"); + } catch (ApiException e) { + System.out.println("update rejected with HTTP " + e.getCode() + ": " + e.getResponseBody()); + } + } +} diff --git a/examples/crossconnectsv2/src/main/java/com/equinix/sdk/examples/crossconnectsv2/WriteGuard.java b/examples/crossconnectsv2/src/main/java/com/equinix/sdk/examples/crossconnectsv2/WriteGuard.java new file mode 100644 index 00000000..79396251 --- /dev/null +++ b/examples/crossconnectsv2/src/main/java/com/equinix/sdk/examples/crossconnectsv2/WriteGuard.java @@ -0,0 +1,19 @@ +package com.equinix.sdk.examples.crossconnectsv2; + +/** + * Keeps the examples that place or change orders from running by accident: they only send their + * request when EQUINIX_EXAMPLE_ALLOW_WRITES is {@code true}. + */ +final class WriteGuard { + private WriteGuard() {} + + /** Returns true if the caller opted in; otherwise prints how to opt in and returns false. */ + static boolean allowed() { + if ("true".equals(System.getenv("EQUINIX_EXAMPLE_ALLOW_WRITES"))) { + return true; + } + System.out.println("This example places or changes an order, so it is disabled by default."); + System.out.println("Review the request, then set EQUINIX_EXAMPLE_ALLOW_WRITES=true to send it."); + return false; + } +} diff --git a/examples/crossconnectsv2/src/main/java/com/equinix/sdk/examples/crossconnectsv2/package-info.java b/examples/crossconnectsv2/src/main/java/com/equinix/sdk/examples/crossconnectsv2/package-info.java new file mode 100644 index 00000000..40e4ee29 --- /dev/null +++ b/examples/crossconnectsv2/src/main/java/com/equinix/sdk/examples/crossconnectsv2/package-info.java @@ -0,0 +1,10 @@ +/** + * Examples for the Equinix Cross Connects v2 service (crossconnectsv2). + * + *

The service only offers operations that create or modify orders (order cross connects, place a + * deinstallation order, update an order's contacts) and has no read operations, so there is no + * order retrieval example. Those examples refuse to send anything unless EQUINIX_EXAMPLE_ALLOW_WRITES + * is set to {@code true}. The service has no list or search operations, so there is no pagination + * example. + */ +package com.equinix.sdk.examples.crossconnectsv2; diff --git a/examples/pom.xml b/examples/pom.xml index 6bd3ab22..93589809 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -16,5 +16,6 @@ common + crossconnectsv2 diff --git a/patches/services/crossconnectsv2/.keep b/patches/services/crossconnectsv2/.keep new file mode 100644 index 00000000..e69de29b diff --git a/pom.xml b/pom.xml index 6189dade..4466ec1d 100644 --- a/pom.xml +++ b/pom.xml @@ -16,5 +16,6 @@ services/fabricv4 examples equinix-sdk-java + services/crossconnectsv2 diff --git a/services/crossconnectsv2/.github/workflows/maven.yml b/services/crossconnectsv2/.github/workflows/maven.yml new file mode 100644 index 00000000..696b6fe5 --- /dev/null +++ b/services/crossconnectsv2/.github/workflows/maven.yml @@ -0,0 +1,30 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven +# +# This file is auto-generated by OpenAPI Generator (https://openapi-generator.tech) + +name: Java CI with Maven + +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] + +jobs: + build: + name: Build Cross Connect + runs-on: ubuntu-latest + strategy: + matrix: + java: [ 17, 21 ] + steps: + - uses: actions/checkout@v4 + - name: Set up JDK + uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.java }} + distribution: 'temurin' + cache: maven + - name: Build with Maven + run: mvn -B package --no-transfer-progress --file pom.xml diff --git a/services/crossconnectsv2/README.md b/services/crossconnectsv2/README.md new file mode 100644 index 00000000..4dc0403d --- /dev/null +++ b/services/crossconnectsv2/README.md @@ -0,0 +1,177 @@ +# crossconnectsv2 + +Cross Connect +- API version: 2.0 + - Generator version: 7.16.0 + +A Cross Connect is a physical cable connection that uses a coaxial, fiber or sometimes copper cable to connect customers equipment directly to other customers equipment inside Equinix data centers. Since cross connects transmit data point-to-point between computing systems inside our facility, they are not susceptible to the latency or congestion problems of the public Internet and can be relied upon to operate at consistently high speeds. + + For more information, please visit [https://docs.equinix.com/api-support.htm](https://docs.equinix.com/api-support.htm) + +*Automatically generated by the [OpenAPI Generator](https://openapi-generator.tech)* + + +## Requirements + +Building the API client library requires: +1. Java 1.8+ +2. Maven (3.8.3+)/Gradle (7.2+) + +## Installation + +To install the API client library to your local Maven repository, simply execute: + +```shell +mvn clean install +``` + +To deploy it to a remote Maven repository instead, configure the settings of the repository and execute: + +```shell +mvn clean deploy +``` + +Refer to the [OSSRH Guide](http://central.sonatype.org/pages/ossrh-guide.html) for more information. + +### Maven users + +Add this dependency to your project's POM: + +```xml + + com.equinix.sdk + crossconnectsv2 + 0.11.0 + compile + +``` + +### Gradle users + +Add this dependency to your project's build file: + +```groovy + repositories { + mavenCentral() // Needed if the 'crossconnectsv2' jar has been published to maven central. + mavenLocal() // Needed if the 'crossconnectsv2' jar has been published to the local maven repo. + } + + dependencies { + implementation "com.equinix.sdk:crossconnectsv2:0.11.0" + } +``` + +### Others + +At first generate the JAR by executing: + +```shell +mvn clean package +``` + +Then manually install the following JARs: + +* `target/crossconnectsv2-0.11.0.jar` +* `target/lib/*.jar` + +## Getting Started + +Please follow the [installation](#installation) instruction and execute the following Java code: + +```java + +// Import classes: +import com.equinix.sdk.crossconnectsv2.ApiClient; +import com.equinix.sdk.crossconnectsv2.ApiException; +import com.equinix.sdk.crossconnectsv2.Configuration; +import com.equinix.sdk.crossconnectsv2.auth.*; +import com.equinix.sdk.crossconnectsv2.model.*; +import com.equinix.sdk.crossconnectsv2.api.CrossConnectsApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.equinix.com"); + + // Configure HTTP bearer authorization: BearerAuth + HttpBearerAuth BearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("BearerAuth"); + BearerAuth.setBearerToken("BEARER TOKEN"); + + CrossConnectsApi apiInstance = new CrossConnectsApi(defaultClient); + Layer1Create layer1Create = new Layer1Create(); // Layer1Create | + try { + apiInstance.orderCrossConnects(layer1Create); + } catch (ApiException e) { + System.err.println("Exception when calling CrossConnectsApi#orderCrossConnects"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} + +``` + +## Documentation for API Endpoints + +All URIs are relative to *https://api.equinix.com* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*CrossConnectsApi* | [**orderCrossConnects**](docs/CrossConnectsApi.md#orderCrossConnects) | **POST** /colocations/v2/orders/crossConnects | Order cross connects +*CrossConnectsApi* | [**placeCrossConnectDeinstallationOrder**](docs/CrossConnectsApi.md#placeCrossConnectDeinstallationOrder) | **POST** /colocations/v2/orders/crossConnects/deinstall | Place cross connect deinstallation order +*CrossConnectsApi* | [**updateACrossConnectOrder**](docs/CrossConnectsApi.md#updateACrossConnectOrder) | **PATCH** /colocations/v2/orders/crossConnects/{orderId} | Update a cross connects order + + +## Documentation for Models + + - [ASide](docs/ASide.md) + - [AttachmentRequest](docs/AttachmentRequest.md) + - [ConnectionServices](docs/ConnectionServices.md) + - [ConnectorTypes](docs/ConnectorTypes.md) + - [ContactRequestNonRegisteredUser](docs/ContactRequestNonRegisteredUser.md) + - [ContactRequestRegisteredUser](docs/ContactRequestRegisteredUser.md) + - [ContactRequestRegisteredUserUpdate](docs/ContactRequestRegisteredUserUpdate.md) + - [ContactsRequestDetails](docs/ContactsRequestDetails.md) + - [DiverseConnections](docs/DiverseConnections.md) + - [DiverseConnectionsASide](docs/DiverseConnectionsASide.md) + - [DiverseConnectionsZSide](docs/DiverseConnectionsZSide.md) + - [ErrorDetails](docs/ErrorDetails.md) + - [Layer1Create](docs/Layer1Create.md) + - [Layer1CreateContactsInner](docs/Layer1CreateContactsInner.md) + - [Layer1DeinstallDetails](docs/Layer1DeinstallDetails.md) + - [Layer1DeinstallDetailsPatchEquipment](docs/Layer1DeinstallDetailsPatchEquipment.md) + - [Layer1DeinstallRequest](docs/Layer1DeinstallRequest.md) + - [Layer1Details](docs/Layer1Details.md) + - [MediaTypes](docs/MediaTypes.md) + - [ModifyRequest](docs/ModifyRequest.md) + - [PatchEquipment](docs/PatchEquipment.md) + - [PatchPanel](docs/PatchPanel.md) + - [ProtocolTypes](docs/ProtocolTypes.md) + - [PurchaseOrder](docs/PurchaseOrder.md) + - [TIMEZONELIST](docs/TIMEZONELIST.md) + - [ZSide](docs/ZSide.md) + - [ZSideWithLOA](docs/ZSideWithLOA.md) + - [ZSideWithPatchPanel](docs/ZSideWithPatchPanel.md) + + + +## Documentation for Authorization + + +Authentication schemes defined for the API: + +### BearerAuth + +- **Type**: HTTP Bearer Token authentication (JWT) + + +## Recommendation + +It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues. + +## Author + + + diff --git a/services/crossconnectsv2/build.gradle b/services/crossconnectsv2/build.gradle new file mode 100644 index 00000000..9e0566c7 --- /dev/null +++ b/services/crossconnectsv2/build.gradle @@ -0,0 +1,166 @@ +apply plugin: 'idea' +apply plugin: 'eclipse' +apply plugin: 'java' +apply plugin: 'com.diffplug.spotless' + +group = 'com.equinix.sdk' +version = '0.11.0' + +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath 'com.android.tools.build:gradle:2.3.+' + classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' + classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.11.0' + } +} + +repositories { + mavenCentral() +} +sourceSets { + main.java.srcDirs = ['src/main/java'] +} + +if(hasProperty('target') && target == 'android') { + + apply plugin: 'com.android.library' + apply plugin: 'com.github.dcendents.android-maven' + + android { + compileSdkVersion 25 + buildToolsVersion '25.0.2' + defaultConfig { + minSdkVersion 14 + targetSdkVersion 25 + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + // Rename the aar correctly + libraryVariants.all { variant -> + variant.outputs.each { output -> + def outputFile = output.outputFile + if (outputFile != null && outputFile.name.endsWith('.aar')) { + def fileName = "${project.name}-${variant.baseName}-${version}.aar" + output.outputFile = new File(outputFile.parent, fileName) + } + } + } + + dependencies { + provided "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version" + } + } + + afterEvaluate { + android.libraryVariants.all { variant -> + def task = project.tasks.create "jar${variant.name.capitalize()}", Jar + task.description = "Create jar artifact for ${variant.name}" + task.dependsOn variant.javaCompile + task.from variant.javaCompile.destinationDirectory + task.destinationDirectory = project.file("${project.buildDir}/outputs/jar") + task.archiveFileName = "${project.name}-${variant.baseName}-${version}.jar" + artifacts.add('archives', task) + } + } + + task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier = 'sources' + } + + artifacts { + archives sourcesJar + } + +} else { + + apply plugin: 'java' + apply plugin: 'maven-publish' + + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + + publishing { + publications { + maven(MavenPublication) { + artifactId = 'crossconnectsv2' + from components.java + } + } + } + + task execute(type:JavaExec) { + main = System.getProperty('mainClass') + classpath = sourceSets.main.runtimeClasspath + } +} + +ext { + jakarta_annotation_version = "1.3.5" +} + +dependencies { + implementation "com.google.code.findbugs:jsr305:3.0.2" + implementation 'com.squareup.okhttp3:okhttp:4.12.0' + implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0' + implementation 'com.google.code.gson:gson:2.9.1' + implementation 'io.gsonfire:gson-fire:1.9.0' + implementation 'jakarta.ws.rs:jakarta.ws.rs-api:2.1.6' + implementation 'org.openapitools:jackson-databind-nullable:0.2.7' + implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.18.0' + implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version" + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.3' + testImplementation 'org.mockito:mockito-core:3.12.4' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.3' +} + +javadoc { + options.tags = [ "http.response.details:a:Http Response Details" ] +} + +// Use spotless plugin to automatically format code, remove unused import, etc +// To apply changes directly to the file, run `gradlew spotlessApply` +// Ref: https://github.com/diffplug/spotless/tree/main/plugin-gradle +spotless { + // comment out below to run spotless as part of the `check` task + enforceCheck false + + format 'misc', { + // define the files (e.g. '*.gradle', '*.md') to apply `misc` to + target '.gitignore' + + // define the steps to apply to those files + trimTrailingWhitespace() + indentWithSpaces() // Takes an integer argument if you don't like 4 + endWithNewline() + } + java { + // don't need to set target, it is inferred from java + + // apply a specific flavor of google-java-format + googleJavaFormat('1.8').aosp().reflowLongStrings() + + removeUnusedImports() + importOrder() + } +} + +test { + // Enable JUnit 5 (Gradle 4.6+). + useJUnitPlatform() + + // Always run tests, even when nothing changed. + dependsOn 'cleanTest' + + // Show test results. + testLogging { + events "passed", "skipped", "failed" + } + +} diff --git a/services/crossconnectsv2/build.sbt b/services/crossconnectsv2/build.sbt new file mode 100644 index 00000000..17e2eae2 --- /dev/null +++ b/services/crossconnectsv2/build.sbt @@ -0,0 +1,27 @@ +lazy val root = (project in file(".")). + settings( + organization := "com.equinix.sdk", + name := "crossconnectsv2", + version := "0.11.0", + scalaVersion := "2.11.12", + scalacOptions ++= Seq("-feature"), + compile / javacOptions ++= Seq("-Xlint:deprecation"), + Compile / packageDoc / publishArtifact := false, + resolvers += Resolver.mavenLocal, + libraryDependencies ++= Seq( + "io.swagger" % "swagger-annotations" % "1.6.5", + "com.squareup.okhttp3" % "okhttp" % "4.12.0", + "com.squareup.okhttp3" % "logging-interceptor" % "4.12.0", + "com.google.code.gson" % "gson" % "2.9.1", + "org.apache.commons" % "commons-lang3" % "3.18.0", + "jakarta.ws.rs" % "jakarta.ws.rs-api" % "2.1.6", + "org.openapitools" % "jackson-databind-nullable" % "0.2.7", + "io.gsonfire" % "gson-fire" % "1.9.0" % "compile", + "jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile", + "com.google.code.findbugs" % "jsr305" % "3.0.2" % "compile", + "jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile", + "org.junit.jupiter" % "junit-jupiter-api" % "5.10.3" % "test", + "com.novocode" % "junit-interface" % "0.10" % "test", + "org.mockito" % "mockito-core" % "3.12.4" % "test" + ) + ) diff --git a/services/crossconnectsv2/docs/ASide.md b/services/crossconnectsv2/docs/ASide.md new file mode 100644 index 00000000..e442dfb5 --- /dev/null +++ b/services/crossconnectsv2/docs/ASide.md @@ -0,0 +1,21 @@ + + +# ASide + +A-Side source patch panel to establish connection to another customer. Connections Service , Media Type and Protocol Type is mandatory to establish new connection. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**patchPanel** | [**PatchPanel**](PatchPanel.md) | | | +|**connectionService** | **ConnectionServices** | | | +|**mediaType** | **MediaTypes** | | | +|**protocolType** | **ProtocolTypes** | | | +|**connectorType** | **ConnectorTypes** | | | +|**mediaConverterRequired** | **Boolean** | When `false`, Equinix will not proceed with cross connect installation that requires media conversion | [optional] | +|**ifcCircuitCount** | **Integer** | Use this field to request an intra-facility cable IFC with this order. Note that there might be a delay in fulfilment of Cross Connect as it is pending intra facility cabling | [optional] | +|**patchEquipment** | [**PatchEquipment**](PatchEquipment.md) | | [optional] | + + + diff --git a/services/crossconnectsv2/docs/AttachmentRequest.md b/services/crossconnectsv2/docs/AttachmentRequest.md new file mode 100644 index 00000000..09052353 --- /dev/null +++ b/services/crossconnectsv2/docs/AttachmentRequest.md @@ -0,0 +1,15 @@ + + +# AttachmentRequest + +Attachment request + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **String** | Identifier of the binary attachment UUID. | [optional] | +|**name** | **String** | Name of the binary attachment. | [optional] | + + + diff --git a/services/crossconnectsv2/docs/ConnectionServices.md b/services/crossconnectsv2/docs/ConnectionServices.md new file mode 100644 index 00000000..a6a91e22 --- /dev/null +++ b/services/crossconnectsv2/docs/ConnectionServices.md @@ -0,0 +1,21 @@ + + +# ConnectionServices + +## Enum + + +* `COAX` (value: `"COAX"`) + +* `MP4_CABLE` (value: `"MP4_CABLE"`) + +* `MULTI_MODE_FIBER` (value: `"MULTI_MODE_FIBER"`) + +* `POTS` (value: `"POTS"`) + +* `SINGLE_MODE_FIBER` (value: `"SINGLE_MODE_FIBER"`) + +* `UTP` (value: `"UTP"`) + + + diff --git a/services/crossconnectsv2/docs/ConnectorTypes.md b/services/crossconnectsv2/docs/ConnectorTypes.md new file mode 100644 index 00000000..0b668111 --- /dev/null +++ b/services/crossconnectsv2/docs/ConnectorTypes.md @@ -0,0 +1,27 @@ + + +# ConnectorTypes + +## Enum + + +* `BNC` (value: `"BNC"`) + +* `LC` (value: `"LC"`) + +* `FC` (value: `"FC"`) + +* `SC` (value: `"SC"`) + +* `ST` (value: `"ST"`) + +* `WIRE_WRAP` (value: `"WIRE_WRAP"`) + +* `RJ45` (value: `"RJ45"`) + +* `E2000` (value: `"E2000"`) + +* `RJ11` (value: `"RJ11"`) + + + diff --git a/services/crossconnectsv2/docs/ContactRequestNonRegisteredUser.md b/services/crossconnectsv2/docs/ContactRequestNonRegisteredUser.md new file mode 100644 index 00000000..2bfb42ba --- /dev/null +++ b/services/crossconnectsv2/docs/ContactRequestNonRegisteredUser.md @@ -0,0 +1,36 @@ + + +# ContactRequestNonRegisteredUser + +Contact information of a non-registered contact, including contact details. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**firstName** | **String** | First name of the contact. | | +|**lastName** | **String** | Last name of the contact. | | +|**type** | [**TypeEnum**](#TypeEnum) | Note that only one technical contact is allowed. | | +|**availability** | [**AvailabilityEnum**](#AvailabilityEnum) | Contact's availability to receive calls. | [optional] | +|**timezone** | **TIMEZONELIST** | | [optional] | +|**details** | [**List<ContactsRequestDetails>**](ContactsRequestDetails.md) | Reference of the related party, could be a party reference or a party role reference | | + + + +## Enum: TypeEnum + +| Name | Value | +|---- | -----| +| TECHNICAL | "TECHNICAL" | + + + +## Enum: AvailabilityEnum + +| Name | Value | +|---- | -----| +| WORK_HOURS | "WORK_HOURS" | +| ANYTIME | "ANYTIME" | + + + diff --git a/services/crossconnectsv2/docs/ContactRequestRegisteredUser.md b/services/crossconnectsv2/docs/ContactRequestRegisteredUser.md new file mode 100644 index 00000000..99b3b855 --- /dev/null +++ b/services/crossconnectsv2/docs/ContactRequestRegisteredUser.md @@ -0,0 +1,35 @@ + + +# ContactRequestRegisteredUser + +Contact information of a registered user. Ensure that the user status of this contact is approved, active or locked. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**registeredUsers** | **List<String>** | Username of a registered user. | | +|**availability** | [**AvailabilityEnum**](#AvailabilityEnum) | Contact's availability to receive calls. | [optional] | +|**timezone** | **TIMEZONELIST** | | [optional] | +|**type** | [**TypeEnum**](#TypeEnum) | Note that only one technical contact is allowed. | | + + + +## Enum: AvailabilityEnum + +| Name | Value | +|---- | -----| +| WORK_HOURS | "WORK_HOURS" | +| ANYTIME | "ANYTIME" | + + + +## Enum: TypeEnum + +| Name | Value | +|---- | -----| +| NOTIFICATION | "NOTIFICATION" | +| TECHNICAL | "TECHNICAL" | + + + diff --git a/services/crossconnectsv2/docs/ContactRequestRegisteredUserUpdate.md b/services/crossconnectsv2/docs/ContactRequestRegisteredUserUpdate.md new file mode 100644 index 00000000..065f1bf7 --- /dev/null +++ b/services/crossconnectsv2/docs/ContactRequestRegisteredUserUpdate.md @@ -0,0 +1,23 @@ + + +# ContactRequestRegisteredUserUpdate + +Contact information. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**registeredUsers** | **List<String>** | Username for the registered user party | | +|**type** | [**TypeEnum**](#TypeEnum) | Type of contact | | + + + +## Enum: TypeEnum + +| Name | Value | +|---- | -----| +| NOTIFICATION | "NOTIFICATION" | + + + diff --git a/services/crossconnectsv2/docs/ContactsRequestDetails.md b/services/crossconnectsv2/docs/ContactsRequestDetails.md new file mode 100644 index 00000000..0bcffaa4 --- /dev/null +++ b/services/crossconnectsv2/docs/ContactsRequestDetails.md @@ -0,0 +1,25 @@ + + +# ContactsRequestDetails + +Contact details. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | [**TypeEnum**](#TypeEnum) | Contact information such as email, phone and mobile number. Note that email is always required. | | +|**value** | **String** | Value of related `type`. Use email addresss when type of `EMAIL`. Use phone number and prefix with country (i.e. +1 for US) for `PHONE` and `MOBILE` type. | | + + + +## Enum: TypeEnum + +| Name | Value | +|---- | -----| +| PHONE | "PHONE" | +| MOBILE | "MOBILE" | +| EMAIL | "EMAIL" | + + + diff --git a/services/crossconnectsv2/docs/CrossConnectsApi.md b/services/crossconnectsv2/docs/CrossConnectsApi.md new file mode 100644 index 00000000..5c42e469 --- /dev/null +++ b/services/crossconnectsv2/docs/CrossConnectsApi.md @@ -0,0 +1,221 @@ +# CrossConnectsApi + +All URIs are relative to *https://api.equinix.com* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**orderCrossConnects**](CrossConnectsApi.md#orderCrossConnects) | **POST** /colocations/v2/orders/crossConnects | Order cross connects | +| [**placeCrossConnectDeinstallationOrder**](CrossConnectsApi.md#placeCrossConnectDeinstallationOrder) | **POST** /colocations/v2/orders/crossConnects/deinstall | Place cross connect deinstallation order | +| [**updateACrossConnectOrder**](CrossConnectsApi.md#updateACrossConnectOrder) | **PATCH** /colocations/v2/orders/crossConnects/{orderId} | Update a cross connects order | + + + +# **orderCrossConnects** +> orderCrossConnects(layer1Create) + +Order cross connects + +This method creates an order for single or multiple standard cross connects at locations where a user has cross connects ordering permission. + +### Example +```java +// Import classes: +import com.equinix.sdk.crossconnectsv2.ApiClient; +import com.equinix.sdk.crossconnectsv2.ApiException; +import com.equinix.sdk.crossconnectsv2.Configuration; +import com.equinix.sdk.crossconnectsv2.auth.*; +import com.equinix.sdk.crossconnectsv2.models.*; +import com.equinix.sdk.crossconnectsv2.api.CrossConnectsApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.equinix.com"); + + // Configure HTTP bearer authorization: BearerAuth + HttpBearerAuth BearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("BearerAuth"); + BearerAuth.setBearerToken("BEARER TOKEN"); + + CrossConnectsApi apiInstance = new CrossConnectsApi(defaultClient); + Layer1Create layer1Create = new Layer1Create(); // Layer1Create | + try { + apiInstance.orderCrossConnects(layer1Create); + } catch (ApiException e) { + System.err.println("Exception when calling CrossConnectsApi#orderCrossConnects"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **layer1Create** | [**Layer1Create**](Layer1Create.md)| | [optional] | + +### Return type + +null (empty response body) + +### Authorization + +[BearerAuth](../README.md#BearerAuth) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **201** | Layer 1 Created | * Location - Location on newly created deinstall request
| +| **400** | Bad Request | - | +| **403** | Forbidden | - | +| **500** | Internal Server Error | - | + + +# **placeCrossConnectDeinstallationOrder** +> placeCrossConnectDeinstallationOrder(layer1DeinstallRequest) + +Place cross connect deinstallation order + +This API allows user to initiate a cross connect deinstallation request. Cross connect asset will be removed according to order placed. + +### Example +```java +// Import classes: +import com.equinix.sdk.crossconnectsv2.ApiClient; +import com.equinix.sdk.crossconnectsv2.ApiException; +import com.equinix.sdk.crossconnectsv2.Configuration; +import com.equinix.sdk.crossconnectsv2.auth.*; +import com.equinix.sdk.crossconnectsv2.models.*; +import com.equinix.sdk.crossconnectsv2.api.CrossConnectsApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.equinix.com"); + + // Configure HTTP bearer authorization: BearerAuth + HttpBearerAuth BearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("BearerAuth"); + BearerAuth.setBearerToken("BEARER TOKEN"); + + CrossConnectsApi apiInstance = new CrossConnectsApi(defaultClient); + Layer1DeinstallRequest layer1DeinstallRequest = new Layer1DeinstallRequest(); // Layer1DeinstallRequest | + try { + apiInstance.placeCrossConnectDeinstallationOrder(layer1DeinstallRequest); + } catch (ApiException e) { + System.err.println("Exception when calling CrossConnectsApi#placeCrossConnectDeinstallationOrder"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **layer1DeinstallRequest** | [**Layer1DeinstallRequest**](Layer1DeinstallRequest.md)| | [optional] | + +### Return type + +null (empty response body) + +### Authorization + +[BearerAuth](../README.md#BearerAuth) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **201** | Layer 1 deinstall requested | * Location - Location on newly created deinstall request
| +| **400** | Bad Request | - | +| **403** | Forbidden | - | +| **500** | Internal Server Error | - | + + +# **updateACrossConnectOrder** +> updateACrossConnectOrder(orderId, modifyRequest) + +Update a cross connects order + +This method updates a cross connects order by its ID for a user with permission to view this request. + +### Example +```java +// Import classes: +import com.equinix.sdk.crossconnectsv2.ApiClient; +import com.equinix.sdk.crossconnectsv2.ApiException; +import com.equinix.sdk.crossconnectsv2.Configuration; +import com.equinix.sdk.crossconnectsv2.auth.*; +import com.equinix.sdk.crossconnectsv2.models.*; +import com.equinix.sdk.crossconnectsv2.api.CrossConnectsApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.equinix.com"); + + // Configure HTTP bearer authorization: BearerAuth + HttpBearerAuth BearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("BearerAuth"); + BearerAuth.setBearerToken("BEARER TOKEN"); + + CrossConnectsApi apiInstance = new CrossConnectsApi(defaultClient); + String orderId = "orderId_example"; // String | Identifier of the cross connect order + ModifyRequest modifyRequest = new ModifyRequest(); // ModifyRequest | The cross connect to be updated + try { + apiInstance.updateACrossConnectOrder(orderId, modifyRequest); + } catch (ApiException e) { + System.err.println("Exception when calling CrossConnectsApi#updateACrossConnectOrder"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **orderId** | **String**| Identifier of the cross connect order | | +| **modifyRequest** | [**ModifyRequest**](ModifyRequest.md)| The cross connect to be updated | | + +### Return type + +null (empty response body) + +### Authorization + +[BearerAuth](../README.md#BearerAuth) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **202** | Accepted | * Location - Location on newly created deinstall request
| +| **204** | No content | * Location - Location on newly created deinstall request
| +| **400** | Bad Request | - | +| **403** | Forbidden | - | +| **500** | Internal Server Error | - | + diff --git a/services/crossconnectsv2/docs/DiverseConnections.md b/services/crossconnectsv2/docs/DiverseConnections.md new file mode 100644 index 00000000..d224a9bb --- /dev/null +++ b/services/crossconnectsv2/docs/DiverseConnections.md @@ -0,0 +1,26 @@ + + +# DiverseConnections + +Diversified cross connect or redundant cross connect for the availability. If its a new redundant connection, A-Side and Z-Side is mandatory. If it is existing connection, Cross Connect serial number and type is mandatory. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | [**TypeEnum**](#TypeEnum) | Redundant connection with existing connections or new connections | [optional] | +|**serialNumber** | **String** | The serial number of Cross Connect is expecting when Diversified connection required from a previously provisioned connection | [optional] | +|**aSide** | [**DiverseConnectionsASide**](DiverseConnectionsASide.md) | | [optional] | +|**zSide** | [**DiverseConnectionsZSide**](DiverseConnectionsZSide.md) | | [optional] | + + + +## Enum: TypeEnum + +| Name | Value | +|---- | -----| +| NEW | "NEW" | +| EXISTING | "EXISTING" | + + + diff --git a/services/crossconnectsv2/docs/DiverseConnectionsASide.md b/services/crossconnectsv2/docs/DiverseConnectionsASide.md new file mode 100644 index 00000000..a255ddfe --- /dev/null +++ b/services/crossconnectsv2/docs/DiverseConnectionsASide.md @@ -0,0 +1,17 @@ + + +# DiverseConnectionsASide + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**patchPanel** | [**PatchPanel**](PatchPanel.md) | | [optional] | +|**connectorType** | **ConnectorTypes** | | [optional] | +|**mediaConverterRequired** | **Boolean** | ASide media Converter Required | [optional] | +|**ifcCircuitCount** | **Integer** | Use this field to request an intra-facility cable IFC with this order. Note that there might be a delay in fulfilment of Cross Connect as it is pending intra facility cabling | [optional] | +|**patchEquipment** | [**PatchEquipment**](PatchEquipment.md) | | [optional] | + + + diff --git a/services/crossconnectsv2/docs/DiverseConnectionsZSide.md b/services/crossconnectsv2/docs/DiverseConnectionsZSide.md new file mode 100644 index 00000000..a526726e --- /dev/null +++ b/services/crossconnectsv2/docs/DiverseConnectionsZSide.md @@ -0,0 +1,15 @@ + + +# DiverseConnectionsZSide + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**patchPanel** | [**PatchPanel**](PatchPanel.md) | | [optional] | +|**connectorType** | **ConnectorTypes** | | [optional] | +|**circuitId** | **String** | Unique Circut ID for future reference | [optional] | + + + diff --git a/services/crossconnectsv2/docs/ErrorDetails.md b/services/crossconnectsv2/docs/ErrorDetails.md new file mode 100644 index 00000000..7103bc90 --- /dev/null +++ b/services/crossconnectsv2/docs/ErrorDetails.md @@ -0,0 +1,18 @@ + + +# ErrorDetails + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**errorCode** | **String** | | [optional] | +|**errorMessage** | **String** | | [optional] | +|**details** | **String** | | [optional] | +|**correlationId** | **String** | | [optional] | +|**help** | **String** | | [optional] | +|**additionalInfo** | [**ErrorDetails**](ErrorDetails.md) | | [optional] | + + + diff --git a/services/crossconnectsv2/docs/Layer1Create.md b/services/crossconnectsv2/docs/Layer1Create.md new file mode 100644 index 00000000..62be9ead --- /dev/null +++ b/services/crossconnectsv2/docs/Layer1Create.md @@ -0,0 +1,20 @@ + + +# Layer1Create + +A layer 1 Physical interconnections establishment between aSide and zSide + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**customerReferenceId** | **String** | Customer Reference Identifier / External Reference Identifier | [optional] | +|**attachments** | [**List<AttachmentRequest>**](AttachmentRequest.md) | File(s) attached to the Cross Connect | [optional] | +|**description** | **String** | Description of Cross Connect | [optional] | +|**expediteDateTime** | **OffsetDateTime** | Expedite orders are delivered within the next 2 - 24 hours. Value must be in ISO-8601 UTC timezone format. | [optional] | +|**details** | [**List<Layer1Details>**](Layer1Details.md) | Cross connections details | | +|**purchaseOrder** | [**PurchaseOrder**](PurchaseOrder.md) | | [optional] | +|**contacts** | [**List<Layer1CreateContactsInner>**](Layer1CreateContactsInner.md) | | [optional] | + + + diff --git a/services/crossconnectsv2/docs/Layer1CreateContactsInner.md b/services/crossconnectsv2/docs/Layer1CreateContactsInner.md new file mode 100644 index 00000000..55ce97cc --- /dev/null +++ b/services/crossconnectsv2/docs/Layer1CreateContactsInner.md @@ -0,0 +1,37 @@ + + +# Layer1CreateContactsInner + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**registeredUsers** | **List<String>** | Username of a registered user. | | +|**availability** | [**AvailabilityEnum**](#AvailabilityEnum) | Contact's availability to receive calls. | [optional] | +|**timezone** | **TIMEZONELIST** | | [optional] | +|**type** | [**TypeEnum**](#TypeEnum) | Note that only one technical contact is allowed. | | +|**firstName** | **String** | First name of the contact. | | +|**lastName** | **String** | Last name of the contact. | | +|**details** | [**List<ContactsRequestDetails>**](ContactsRequestDetails.md) | Reference of the related party, could be a party reference or a party role reference | | + + + +## Enum: AvailabilityEnum + +| Name | Value | +|---- | -----| +| WORK_HOURS | "WORK_HOURS" | +| ANYTIME | "ANYTIME" | + + + +## Enum: TypeEnum + +| Name | Value | +|---- | -----| +| NOTIFICATION | "NOTIFICATION" | +| TECHNICAL | "TECHNICAL" | + + + diff --git a/services/crossconnectsv2/docs/Layer1DeinstallDetails.md b/services/crossconnectsv2/docs/Layer1DeinstallDetails.md new file mode 100644 index 00000000..f9ceb07b --- /dev/null +++ b/services/crossconnectsv2/docs/Layer1DeinstallDetails.md @@ -0,0 +1,15 @@ + + +# Layer1DeinstallDetails + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**assetId** | **String** | Asset ID of the cross connect you wish to de-install | | +|**proceedWithLiveTraffic** | **Boolean** | When `true`, Equinix will proceed with deinstallation request despite detecting live traffic. | [optional] | +|**patchEquipment** | [**Layer1DeinstallDetailsPatchEquipment**](Layer1DeinstallDetailsPatchEquipment.md) | | [optional] | + + + diff --git a/services/crossconnectsv2/docs/Layer1DeinstallDetailsPatchEquipment.md b/services/crossconnectsv2/docs/Layer1DeinstallDetailsPatchEquipment.md new file mode 100644 index 00000000..87e0c912 --- /dev/null +++ b/services/crossconnectsv2/docs/Layer1DeinstallDetailsPatchEquipment.md @@ -0,0 +1,15 @@ + + +# Layer1DeinstallDetailsPatchEquipment + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**cabinetId** | **String** | The cabinet to remove patch cable from | | +|**details** | **String** | Provide additional information to facilitate patch equipment removal | | +|**port** | **BigDecimal** | Device port number to be removed | | + + + diff --git a/services/crossconnectsv2/docs/Layer1DeinstallRequest.md b/services/crossconnectsv2/docs/Layer1DeinstallRequest.md new file mode 100644 index 00000000..5831508f --- /dev/null +++ b/services/crossconnectsv2/docs/Layer1DeinstallRequest.md @@ -0,0 +1,19 @@ + + +# Layer1DeinstallRequest + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**customerReferenceId** | **String** | Customer Reference Identifier / External Reference Identifier | [optional] | +|**purchaseOrder** | [**PurchaseOrder**](PurchaseOrder.md) | | [optional] | +|**contacts** | [**List<Layer1CreateContactsInner>**](Layer1CreateContactsInner.md) | | [optional] | +|**attachments** | [**List<AttachmentRequest>**](AttachmentRequest.md) | File(s) attached to the layer #1 connections | [optional] | +|**description** | **String** | Description of deinstallation | [optional] | +|**details** | [**List<Layer1DeinstallDetails>**](Layer1DeinstallDetails.md) | layer #1 connections details | | +|**removalDate** | **LocalDate** | Equinix will aim to terminate this Cross Connect at this date subjected to operation availability. | | + + + diff --git a/services/crossconnectsv2/docs/Layer1Details.md b/services/crossconnectsv2/docs/Layer1Details.md new file mode 100644 index 00000000..fbf981bc --- /dev/null +++ b/services/crossconnectsv2/docs/Layer1Details.md @@ -0,0 +1,18 @@ + + +# Layer1Details + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**aSide** | [**ASide**](ASide.md) | | | +|**zSide** | [**ZSide**](ZSide.md) | | | +|**diverseConnections** | [**DiverseConnections**](DiverseConnections.md) | | [optional] | +|**verifyLink** | **Boolean** | When `true`, light link verification is carried out. This may incur fixed fee based on your contract pricing. | [optional] | +|**circuitDeliveryDate** | **LocalDate** | Carrier Circuit Delivery Date | [optional] | +|**submarineEngineerRequired** | **Boolean** | Set to `true` if submarine cable station engineer is required. | [optional] | + + + diff --git a/services/crossconnectsv2/docs/MediaTypes.md b/services/crossconnectsv2/docs/MediaTypes.md new file mode 100644 index 00000000..dfa18239 --- /dev/null +++ b/services/crossconnectsv2/docs/MediaTypes.md @@ -0,0 +1,39 @@ + + +# MediaTypes + +## Enum + + +* `COAX` (value: `"COAX"`) + +* `MP4_CABLE` (value: `"MP4_CABLE"`) + +* `_50_MICRON_MULTI_MODE_FIBER` (value: `"50_MICRON_MULTI_MODE_FIBER"`) + +* `_50_MICRON_MULTI_MODE_FIBER_OM2` (value: `"50_MICRON_MULTI_MODE_FIBER_OM2"`) + +* `_50_MICRON_MULTI_MODE_FIBER_OM3` (value: `"50_MICRON_MULTI_MODE_FIBER_OM3"`) + +* `_50_MICRON_MULTI_MODE_FIBER_OM4` (value: `"50_MICRON_MULTI_MODE_FIBER_OM4"`) + +* `_62_5_MICRON_MULTI_MODE_FIBER` (value: `"62.5_MICRON_MULTI_MODE_FIBER"`) + +* `_62_5_MICRON_MULTI_MODE_FIBER_OM1` (value: `"62.5_MICRON_MULTI_MODE_FIBER_OM1"`) + +* `ABAM` (value: `"ABAM"`) + +* `CAT3` (value: `"CAT3"`) + +* `CAT5E` (value: `"CAT5E"`) + +* `CAT6` (value: `"CAT6"`) + +* `CAT6A` (value: `"CAT6A"`) + +* `OS1` (value: `"OS1"`) + +* `SINGLE_MODE_FIBER` (value: `"SINGLE_MODE_FIBER"`) + + + diff --git a/services/crossconnectsv2/docs/ModifyRequest.md b/services/crossconnectsv2/docs/ModifyRequest.md new file mode 100644 index 00000000..c5482962 --- /dev/null +++ b/services/crossconnectsv2/docs/ModifyRequest.md @@ -0,0 +1,13 @@ + + +# ModifyRequest + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**contacts** | [**List<ContactRequestRegisteredUserUpdate>**](ContactRequestRegisteredUserUpdate.md) | | [optional] | + + + diff --git a/services/crossconnectsv2/docs/PatchEquipment.md b/services/crossconnectsv2/docs/PatchEquipment.md new file mode 100644 index 00000000..37e3e7f7 --- /dev/null +++ b/services/crossconnectsv2/docs/PatchEquipment.md @@ -0,0 +1,17 @@ + + +# PatchEquipment + +Patch equipment is chargeable as an additional service. This request will enable Equinix to install the cross connect from demarcation panel to your equipment. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**cabinetId** | **String** | Device Cabinet Id. The cabinet for patching must belong to the specific cage defined in the A-side details. | | +|**connectorType** | **String** | Device Connector Type to facilitate cross connection. | | +|**details** | **String** | Provide additional information to facilitate patch equipment connection | | +|**port** | **BigDecimal** | Device port number to be connected | | + + + diff --git a/services/crossconnectsv2/docs/PatchPanel.md b/services/crossconnectsv2/docs/PatchPanel.md new file mode 100644 index 00000000..d000f405 --- /dev/null +++ b/services/crossconnectsv2/docs/PatchPanel.md @@ -0,0 +1,16 @@ + + +# PatchPanel + +The patch panel is a device which has a series of connector ports. This device is to identify the source and destination location to connect. Patch Panel can be installed with a cabinet. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **String** | Patch Panel ID | | +|**portA** | **BigDecimal** | Specify the desired port number for port A. When ports are not selected, next available ports will be used | [optional] | +|**portB** | **BigDecimal** | Specify the desired port number for port B. When ports are not selected, next available ports will be used. If no selection is required, use value of `-1` | [optional] | + + + diff --git a/services/crossconnectsv2/docs/ProtocolTypes.md b/services/crossconnectsv2/docs/ProtocolTypes.md new file mode 100644 index 00000000..51d24d32 --- /dev/null +++ b/services/crossconnectsv2/docs/ProtocolTypes.md @@ -0,0 +1,61 @@ + + +# ProtocolTypes + +## Enum + + +* `ANTENNA` (value: `"ANTENNA"`) + +* `DS_3` (value: `"DS-3"`) + +* `E1` (value: `"E1"`) + +* `E3` (value: `"E3"`) + +* `ETHERNET` (value: `"ETHERNET"`) + +* `FAST_ETHERNET` (value: `"FAST_ETHERNET"`) + +* `GIGABIT_ETHERNET` (value: `"GIGABIT_ETHERNET"`) + +* `POTS` (value: `"POTS"`) + +* `T1` (value: `"T1"`) + +* `FIBRE_CHANNEL` (value: `"FIBRE_CHANNEL"`) + +* `_10_GIG_ETHERNET` (value: `"10_GIG_ETHERNET"`) + +* `_100_GIG_ETHERNET` (value: `"100_GIG_ETHERNET"`) + +* `_40_GIG_ETHERNET` (value: `"40_GIG_ETHERNET"`) + +* `DARK_FIBER` (value: `"DARK_FIBER"`) + +* `DWDM` (value: `"DWDM"`) + +* `_56K` (value: `"56K"`) + +* `ISDN` (value: `"ISDN"`) + +* `OC_12` (value: `"OC-12"`) + +* `OC_192` (value: `"OC-192"`) + +* `OC_3` (value: `"OC-3"`) + +* `OC_48` (value: `"OC-48"`) + +* `STM_1` (value: `"STM-1"`) + +* `STM_16` (value: `"STM-16"`) + +* `STM_4` (value: `"STM-4"`) + +* `STM_64` (value: `"STM-64"`) + +* `NA` (value: `"NA"`) + + + diff --git a/services/crossconnectsv2/docs/PurchaseOrder.md b/services/crossconnectsv2/docs/PurchaseOrder.md new file mode 100644 index 00000000..2c2e5093 --- /dev/null +++ b/services/crossconnectsv2/docs/PurchaseOrder.md @@ -0,0 +1,29 @@ + + +# PurchaseOrder + +Purchase Order + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | [**TypeEnum**](#TypeEnum) | Type of the Purchase Order | | +|**number** | **String** | Purchase order number is applicable when `type` is EXISTING or NEW | | +|**amount** | **BigDecimal** | This is only applicable when `type` is NEW | [optional] | +|**startDate** | **LocalDate** | This is only applicable when `type` is NEW | [optional] | +|**endDate** | **LocalDate** | This is only applicable when `type` is NEW | [optional] | +|**attachmentId** | **String** | Attachment ID of Purchase Order document. | [optional] | + + + +## Enum: TypeEnum + +| Name | Value | +|---- | -----| +| EXEMPTED | "EXEMPTED" | +| NEW | "NEW" | +| EXISTING | "EXISTING" | + + + diff --git a/services/crossconnectsv2/docs/TIMEZONELIST.md b/services/crossconnectsv2/docs/TIMEZONELIST.md new file mode 100644 index 00000000..274b0e88 --- /dev/null +++ b/services/crossconnectsv2/docs/TIMEZONELIST.md @@ -0,0 +1,219 @@ + + +# TIMEZONELIST + +## Enum + + +* `ATLANTIC_CANARY` (value: `"Atlantic/Canary"`) + +* `EUROPE_DUBLIN` (value: `"Europe/Dublin"`) + +* `EUROPE_LONDON` (value: `"Europe/London"`) + +* `EUROPE_LISBON` (value: `"Europe/Lisbon"`) + +* `AFRICA_ALGIERS` (value: `"Africa/Algiers"`) + +* `EUROPE_BERLIN` (value: `"Europe/Berlin"`) + +* `EUROPE_AMSTERDAM` (value: `"Europe/Amsterdam"`) + +* `EUROPE_COPENHAGEN` (value: `"Europe/Copenhagen"`) + +* `EUROPE_MADRID` (value: `"Europe/Madrid"`) + +* `EUROPE_PARIS` (value: `"Europe/Paris"`) + +* `EUROPE_STOCKHOLM` (value: `"Europe/Stockholm"`) + +* `EUROPE_ZURICH` (value: `"Europe/Zurich"`) + +* `EUROPE_WARSAW` (value: `"Europe/Warsaw"`) + +* `AFRICA_CAIRO` (value: `"Africa/Cairo"`) + +* `AFRICA_JOHANNESBURG` (value: `"Africa/Johannesburg"`) + +* `AFRICA_LAGOS` (value: `"Africa/Lagos"`) + +* `EUROPE_SOFIA` (value: `"Europe/Sofia"`) + +* `AFRICA_NAIROBI` (value: `"Africa/Nairobi"`) + +* `ASIA_JERUSALEM` (value: `"Asia/Jerusalem"`) + +* `EUROPE_ISTANBUL` (value: `"Europe/Istanbul"`) + +* `EUROPE_MOSCOW` (value: `"Europe/Moscow"`) + +* `ASIA_RIYADH` (value: `"Asia/Riyadh"`) + +* `ASIA_DUBAI` (value: `"Asia/Dubai"`) + +* `ASIA_KABUL` (value: `"Asia/Kabul"`) + +* `ASIA_TEHRAN` (value: `"Asia/Tehran"`) + +* `ASIA_KARACHI` (value: `"Asia/Karachi"`) + +* `INDIAN_MALDIVES` (value: `"Indian/Maldives"`) + +* `ASIA_KOLKATA` (value: `"Asia/Kolkata"`) + +* `ASIA_KATHMANDU` (value: `"Asia/Kathmandu"`) + +* `ASIA_OMSK` (value: `"Asia/Omsk"`) + +* `ASIA_RANGOON` (value: `"Asia/Rangoon"`) + +* `ASIA_JAKARTA` (value: `"Asia/Jakarta"`) + +* `ASIA_HO_CHI_MINH` (value: `"Asia/Ho_Chi_Minh"`) + +* `ASIA_BRUNEI` (value: `"Asia/Brunei"`) + +* `ASIA_HONG_KONG` (value: `"Asia/Hong_Kong"`) + +* `ASIA_KUALA_LUMPUR` (value: `"Asia/Kuala_Lumpur"`) + +* `ASIA_MANILA` (value: `"Asia/Manila"`) + +* `ASIA_SHANGHAI` (value: `"Asia/Shanghai"`) + +* `ASIA_SINGAPORE` (value: `"Asia/Singapore"`) + +* `ASIA_TAIPEI` (value: `"Asia/Taipei"`) + +* `AUSTRALIA_PERTH` (value: `"Australia/Perth"`) + +* `ASIA_SEOUL` (value: `"Asia/Seoul"`) + +* `ASIA_TOKYO` (value: `"Asia/Tokyo"`) + +* `AUSTRALIA_DARWIN` (value: `"Australia/Darwin"`) + +* `AUSTRALIA_BRISBANE` (value: `"Australia/Brisbane"`) + +* `PACIFIC_GUAM` (value: `"Pacific/Guam"`) + +* `AUSTRALIA_ADELAIDE` (value: `"Australia/Adelaide"`) + +* `AUSTRALIA_SYDNEY` (value: `"Australia/Sydney"`) + +* `PACIFIC_AUCKLAND` (value: `"Pacific/Auckland"`) + +* `PACIFIC_CHATHAM` (value: `"Pacific/Chatham"`) + +* `INDIAN_CHRISTMAS` (value: `"Indian/Christmas"`) + +* `AMERICA_SCORESBYSUND` (value: `"America/Scoresbysund"`) + +* `ATLANTIC_SOUTH_GEORGIA` (value: `"Atlantic/South_Georgia"`) + +* `AMERICA_SAO_PAULO` (value: `"America/Sao_Paulo"`) + +* `AMERICA_DETROIT` (value: `"America/Detroit"`) + +* `AMERICA_NEW_YORK` (value: `"America/New_York"`) + +* `AMERICA_PUERTO_RICO` (value: `"America/Puerto_Rico"`) + +* `AMERICA_TORONTO` (value: `"America/Toronto"`) + +* `AMERICA_BOGOTA` (value: `"America/Bogota"`) + +* `AMERICA_CHICAGO` (value: `"America/Chicago"`) + +* `AMERICA_WINNIPEG` (value: `"America/Winnipeg"`) + +* `AMERICA_DENVER` (value: `"America/Denver"`) + +* `AMERICA_EDMONTON` (value: `"America/Edmonton"`) + +* `AMERICA_MEXICO_CITY` (value: `"America/Mexico_City"`) + +* `AMERICA_LOS_ANGELES` (value: `"America/Los_Angeles"`) + +* `AMERICA_VANCOUVER` (value: `"America/Vancouver"`) + +* `AMERICA_PHOENIX` (value: `"America/Phoenix"`) + +* `AMERICA_ANCHORAGE` (value: `"America/Anchorage"`) + +* `AMERICA_HALIFAX` (value: `"America/Halifax"`) + +* `AMERICA_LIMA` (value: `"America/Lima"`) + +* `AMERICA_MONTERREY` (value: `"America/Monterrey"`) + +* `PACIFIC_GAMBIER` (value: `"Pacific/Gambier"`) + +* `PACIFIC_MARQUESAS` (value: `"Pacific/Marquesas"`) + +* `PACIFIC_HONOLULU` (value: `"Pacific/Honolulu"`) + +* `PACIFIC_FIJI` (value: `"Pacific/Fiji"`) + +* `ASIA_MUSCAT` (value: `"Asia/Muscat"`) + +* `AMERICA_ARGENTINA_BUENOS_AIRES` (value: `"America/Argentina/Buenos_Aires"`) + +* `AMERICA_CARACAS` (value: `"America/Caracas"`) + +* `ETC_GMT_12` (value: `"Etc/GMT+12"`) + +* `UTC` (value: `"UTC"`) + +* `GMT` (value: `"GMT"`) + +* `AMERICA_SANTIAGO` (value: `"America/Santiago"`) + +* `AMERICA_ST_JOHNS` (value: `"America/St_Johns"`) + +* `ASIA_ALMATY` (value: `"Asia/Almaty"`) + +* `ASIA_BANGKOK` (value: `"Asia/Bangkok"`) + +* `ASIA_CALCUTTA` (value: `"Asia/Calcutta"`) + +* `ASIA_MAGADAN` (value: `"Asia/Magadan"`) + +* `ASIA_YEKATERINBURG` (value: `"Asia/Yekaterinburg"`) + +* `AUSTRALIA_EUCLA` (value: `"Australia/Eucla"`) + +* `AUSTRALIA_LORD_HOWE` (value: `"Australia/Lord_Howe"`) + +* `EUROPE_BRATISLAVA` (value: `"Europe/Bratislava"`) + +* `EUROPE_BRUSSELS` (value: `"Europe/Brussels"`) + +* `EUROPE_PRAGUE` (value: `"Europe/Prague"`) + +* `EUROPE_ROME` (value: `"Europe/Rome"`) + +* `EUROPE_HELSINKI` (value: `"Europe/Helsinki"`) + +* `PACIFIC_KIRITIMATI` (value: `"Pacific/Kiritimati"`) + +* `PACIFIC_MIDWAY` (value: `"Pacific/Midway"`) + +* `PACIFIC_TONGATAPU` (value: `"Pacific/Tongatapu"`) + +* `AUSTRALIA_MELBOURNE` (value: `"Australia/Melbourne"`) + +* `AUSTRALIA_NSW` (value: `"Australia/NSW"`) + +* `AUSTRALIA_QUEENSLAND` (value: `"Australia/Queensland"`) + +* `AUSTRALIA_SOUTH` (value: `"Australia/South"`) + +* `AUSTRALIA_VICTORIA` (value: `"Australia/Victoria"`) + +* `AUSTRALIA_WEST` (value: `"Australia/West"`) + +* `AUSTRALIA_CANBERRA` (value: `"Australia/Canberra"`) + + + diff --git a/services/crossconnectsv2/docs/ZSide.md b/services/crossconnectsv2/docs/ZSide.md new file mode 100644 index 00000000..c71e13b5 --- /dev/null +++ b/services/crossconnectsv2/docs/ZSide.md @@ -0,0 +1,20 @@ + + +# ZSide + +Z-Side can be an existing or a new customer without patch panel. For an existing customer, only `patchPanel` and `connectorType` are required. For a new customer or patch panel, `providerName`, `ibx`, and `loaAttachmentId` are required + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**notificationEmail** | **String** | Z-Side customer will be notified when cross connect is complete via specified email address | [optional] | +|**loaAttachmentId** | **String** | Attachment ID of Letter of Authorization (LOA). Refer to Attachment API to upload documents via API. | | +|**ibx** | **String** | IBX location code. | | +|**providerName** | **String** | Account name of service provider. | | +|**connectorType** | **ConnectorTypes** | | | +|**patchPanel** | [**PatchPanel**](PatchPanel.md) | | | +|**circuitId** | **String** | Customer or carrier circuit ID cable reference number for verification purposes. | [optional] | + + + diff --git a/services/crossconnectsv2/docs/ZSideWithLOA.md b/services/crossconnectsv2/docs/ZSideWithLOA.md new file mode 100644 index 00000000..44412fc4 --- /dev/null +++ b/services/crossconnectsv2/docs/ZSideWithLOA.md @@ -0,0 +1,15 @@ + + +# ZSideWithLOA + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**loaAttachmentId** | **String** | Attachment ID of Letter of Authorization (LOA). Refer to Attachment API to upload documents via API. | | +|**ibx** | **String** | IBX location code. | | +|**providerName** | **String** | Account name of service provider. | | + + + diff --git a/services/crossconnectsv2/docs/ZSideWithPatchPanel.md b/services/crossconnectsv2/docs/ZSideWithPatchPanel.md new file mode 100644 index 00000000..f4be6464 --- /dev/null +++ b/services/crossconnectsv2/docs/ZSideWithPatchPanel.md @@ -0,0 +1,15 @@ + + +# ZSideWithPatchPanel + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**connectorType** | **ConnectorTypes** | | | +|**patchPanel** | [**PatchPanel**](PatchPanel.md) | | | +|**circuitId** | **String** | Customer or carrier circuit ID cable reference number for verification purposes. | [optional] | + + + diff --git a/services/crossconnectsv2/gradle.properties b/services/crossconnectsv2/gradle.properties new file mode 100644 index 00000000..a3408578 --- /dev/null +++ b/services/crossconnectsv2/gradle.properties @@ -0,0 +1,6 @@ +# This file is automatically generated by OpenAPI Generator (https://github.com/openAPITools/openapi-generator). +# To include other gradle properties as part of the code generation process, please use the `gradleProperties` option. +# +# Gradle properties reference: https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties +# For example, uncomment below to build for Android +#target = android diff --git a/services/crossconnectsv2/gradle/wrapper/gradle-wrapper.properties b/services/crossconnectsv2/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..b82aa23a --- /dev/null +++ b/services/crossconnectsv2/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/services/crossconnectsv2/gradlew b/services/crossconnectsv2/gradlew new file mode 100644 index 00000000..9d0ce634 --- /dev/null +++ b/services/crossconnectsv2/gradlew @@ -0,0 +1,249 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while +APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path +[ -h "$app_path" ] +do +ls=$( ls -ld "$app_path" ) +link=${ls#*' -> '} +case $link in #( +/*) app_path=$link ;; #( +*) app_path=$APP_HOME$link ;; +esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { +echo "$*" +} >&2 + +die () { +echo +echo "$*" +echo +exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( +CYGWIN* ) cygwin=true ;; #( +Darwin* ) darwin=true ;; #( +MSYS* | MINGW* ) msys=true ;; #( +NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then +if [ -x "$JAVA_HOME/jre/sh/java" ] ; then +# IBM's JDK on AIX uses strange locations for the executables +JAVACMD=$JAVA_HOME/jre/sh/java +else +JAVACMD=$JAVA_HOME/bin/java +fi +if [ ! -x "$JAVACMD" ] ; then +die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi +else +JAVACMD=java +if ! command -v java >/dev/null 2>&1 +then +die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then +case $MAX_FD in #( +max*) +# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. +# shellcheck disable=SC2039,SC3045 +MAX_FD=$( ulimit -H -n ) || +warn "Could not query maximum file descriptor limit" +esac +case $MAX_FD in #( +'' | soft) :;; #( +*) +# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. +# shellcheck disable=SC2039,SC3045 +ulimit -n "$MAX_FD" || +warn "Could not set maximum file descriptor limit to $MAX_FD" +esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then +APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) +CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + +JAVACMD=$( cygpath --unix "$JAVACMD" ) + +# Now convert the arguments - kludge to limit ourselves to /bin/sh +for arg do +if +case $arg in #( +-*) false ;; # don't mess with options #( +/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath +[ -e "$t" ] ;; #( +*) false ;; +esac +then +arg=$( cygpath --path --ignore --mixed "$arg" ) +fi +# Roll the args list around exactly as many times as the number of +# args, so each arg winds up back in the position where it started, but +# possibly modified. +# +# NB: a `for` loop captures its iteration list before it begins, so +# changing the positional parameters here affects neither the number of +# iterations, nor the values presented in `arg`. +shift # remove old arg +set -- "$@" "$arg" # push replacement arg +done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ +"-Dorg.gradle.appname=$APP_BASE_NAME" \ +-classpath "$CLASSPATH" \ +org.gradle.wrapper.GradleWrapperMain \ +"$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then +die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( +printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | +xargs -n1 | +sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | +tr '\n' ' ' +)" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/services/crossconnectsv2/gradlew.bat b/services/crossconnectsv2/gradlew.bat new file mode 100644 index 00000000..25da30db --- /dev/null +++ b/services/crossconnectsv2/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/services/crossconnectsv2/pom.xml b/services/crossconnectsv2/pom.xml new file mode 100644 index 00000000..c85018b3 --- /dev/null +++ b/services/crossconnectsv2/pom.xml @@ -0,0 +1,340 @@ + + 4.0.0 + com.equinix.sdk + crossconnectsv2 + jar + crossconnectsv2 + 0.11.0 + https://github.com/equinix/equinix-sdk-java + Equinix Java SDK + + scm:git:git@github.com:equinix/equinix-sdk-java.git + scm:git:git@github.com:equinix/equinix-sdk-java.git + https://github.com/equinix/equinix-sdk-java + + + + + Unlicense + http://unlicense.org + repo + + + + + + Equinix Developers + support@equinix.com + Equinix + https://equinix.com + + + + + + + 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.4.1 + + + 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.6.1 + + + 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.5.0 + + + add_sources + generate-sources + + add-source + + + + src/main/java + + + + + add_test_sources + generate-test-sources + + add-test-source + + + + src/test/java + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.6.3 + + + attach-javadocs + + jar + + + + + none + + + http.response.details + a + Http Response Details: + + + + + + org.apache.maven.plugins + maven-source-plugin + 3.3.0 + + + 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.2.1 + + + sign-artifacts + verify + + sign + + + + + + + + + + + + + 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} + + + org.apache.commons + commons-lang3 + ${commons-lang3-version} + + + jakarta.annotation + jakarta.annotation-api + ${jakarta-annotation-version} + provided + + + org.openapitools + jackson-databind-nullable + ${jackson-databind-nullable-version} + + + jakarta.ws.rs + jakarta.ws.rs-api + ${jakarta.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 + 4.12.0 + 2.10.1 + 3.18.0 + 0.2.7 + 1.3.5 + 2.0.2 + 5.10.3 + 1.10.0 + 2.1.6 + 1.1.1 + UTF-8 + 2.43.0 + + diff --git a/services/crossconnectsv2/settings.gradle b/services/crossconnectsv2/settings.gradle new file mode 100644 index 00000000..1ab2dcb7 --- /dev/null +++ b/services/crossconnectsv2/settings.gradle @@ -0,0 +1 @@ +rootProject.name = "crossconnectsv2" \ No newline at end of file diff --git a/services/crossconnectsv2/src/main/AndroidManifest.xml b/services/crossconnectsv2/src/main/AndroidManifest.xml new file mode 100644 index 00000000..ef79881f --- /dev/null +++ b/services/crossconnectsv2/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + + diff --git a/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/ApiCallback.java b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/ApiCallback.java new file mode 100644 index 00000000..25dd2f47 --- /dev/null +++ b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/ApiCallback.java @@ -0,0 +1,62 @@ +/* + * Cross Connect + * A Cross Connect is a physical cable connection that uses a coaxial, fiber or sometimes copper cable to connect customers equipment directly to other customers equipment inside Equinix data centers. Since cross connects transmit data point-to-point between computing systems inside our facility, they are not susceptible to the latency or congestion problems of the public Internet and can be relied upon to operate at consistently high speeds. + * + * The version of the OpenAPI document: 2.0 + * + * + * 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.sdk.crossconnectsv2; + +import java.io.IOException; + +import java.util.Map; +import java.util.List; + +/** + * Callback for asynchronous API call. + * + * @param The return type + */ +public interface ApiCallback { + /** + * This is called when the API call fails. + * + * @param e The exception causing the failure + * @param statusCode Status code of the response if available, otherwise it would be 0 + * @param responseHeaders Headers of the response if available, otherwise it would be null + */ + void onFailure(ApiException e, int statusCode, Map> responseHeaders); + + /** + * This is called when the API call succeeded. + * + * @param result The result deserialized from response + * @param statusCode Status code of the response + * @param responseHeaders Headers of the response + */ + void onSuccess(T result, int statusCode, Map> responseHeaders); + + /** + * This is called when the API upload processing. + * + * @param bytesWritten bytes Written + * @param contentLength content length of request body + * @param done write end + */ + void onUploadProgress(long bytesWritten, long contentLength, boolean done); + + /** + * This is called when the API download processing. + * + * @param bytesRead bytes Read + * @param contentLength content length of the response + * @param done Read end + */ + void onDownloadProgress(long bytesRead, long contentLength, boolean done); +} diff --git a/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/ApiClient.java b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/ApiClient.java new file mode 100644 index 00000000..85f660cd --- /dev/null +++ b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/ApiClient.java @@ -0,0 +1,1616 @@ +/* + * Cross Connect + * A Cross Connect is a physical cable connection that uses a coaxial, fiber or sometimes copper cable to connect customers equipment directly to other customers equipment inside Equinix data centers. Since cross connects transmit data point-to-point between computing systems inside our facility, they are not susceptible to the latency or congestion problems of the public Internet and can be relied upon to operate at consistently high speeds. + * + * The version of the OpenAPI document: 2.0 + * + * + * 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.sdk.crossconnectsv2; + +import okhttp3.*; +import okhttp3.internal.http.HttpMethod; +import okhttp3.internal.tls.OkHostnameVerifier; +import okhttp3.logging.HttpLoggingInterceptor; +import okhttp3.logging.HttpLoggingInterceptor.Level; +import okio.Buffer; +import okio.BufferedSink; +import okio.Okio; + +import javax.net.ssl.*; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Type; +import java.net.URI; +import java.net.URLConnection; +import java.net.URLEncoder; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.security.GeneralSecurityException; +import java.security.KeyStore; +import java.security.SecureRandom; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; +import java.text.DateFormat; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; +import java.util.function.Supplier; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.equinix.sdk.crossconnectsv2.auth.Authentication; +import com.equinix.sdk.crossconnectsv2.auth.HttpBasicAuth; +import com.equinix.sdk.crossconnectsv2.auth.HttpBearerAuth; +import com.equinix.sdk.crossconnectsv2.auth.ApiKeyAuth; + +/** + *

ApiClient class.

+ */ +public class ApiClient { + + protected String basePath = "https://api.equinix.com"; + protected List servers = new ArrayList(Arrays.asList( + new ServerConfiguration( + "https://api.equinix.com", + "No description provided", + new HashMap() + ), + new ServerConfiguration( + "https://sandboxapi.equinix.com", + "No description provided", + new HashMap() + ) + )); + protected Integer serverIndex = 0; + protected Map serverVariables = null; + protected boolean debugging = false; + protected Map defaultHeaderMap = new HashMap(); + protected Map defaultCookieMap = new HashMap(); + protected String tempFolderPath = null; + + protected Map authentications; + + protected DateFormat dateFormat; + protected DateFormat datetimeFormat; + protected boolean lenientDatetimeFormat; + protected int dateLength; + + protected InputStream sslCaCert; + protected boolean verifyingSsl; + protected KeyManager[] keyManagers; + + protected OkHttpClient httpClient; + protected JSON json; + + protected HttpLoggingInterceptor loggingInterceptor; + + /** + * Basic constructor for ApiClient + */ + public ApiClient() { + init(); + initHttpClient(); + + // Setup authentications (key: authentication name, value: authentication). + authentications.put("BearerAuth", new HttpBearerAuth("bearer")); + // Prevent the authentications from being modified. + authentications = Collections.unmodifiableMap(authentications); + } + + /** + * Basic constructor with custom OkHttpClient + * + * @param client a {@link okhttp3.OkHttpClient} object + */ + public ApiClient(OkHttpClient client) { + init(); + + httpClient = client; + + // Setup authentications (key: authentication name, value: authentication). + authentications.put("BearerAuth", new HttpBearerAuth("bearer")); + // Prevent the authentications from being modified. + authentications = Collections.unmodifiableMap(authentications); + } + + protected void initHttpClient() { + initHttpClient(Collections.emptyList()); + } + + protected void initHttpClient(List interceptors) { + OkHttpClient.Builder builder = new OkHttpClient.Builder(); + builder.addNetworkInterceptor(getProgressInterceptor()); + for (Interceptor interceptor: interceptors) { + builder.addInterceptor(interceptor); + } + + httpClient = builder.build(); + } + + protected void init() { + verifyingSsl = true; + + json = new JSON(); + + // Set default User-Agent. + setUserAgent("equinix-sdk-java/0.11.0"); + + authentications = new HashMap(); + } + + /** + * Get base path + * + * @return Base path + */ + public String getBasePath() { + return basePath; + } + + /** + * Set base path + * + * @param basePath Base path of the URL (e.g https://api.equinix.com) + * @return An instance of ApiClient + */ + public ApiClient setBasePath(String basePath) { + this.basePath = basePath; + this.serverIndex = null; + return this; + } + + public List getServers() { + return servers; + } + + public ApiClient setServers(List servers) { + this.servers = servers; + return this; + } + + public Integer getServerIndex() { + return serverIndex; + } + + public ApiClient setServerIndex(Integer serverIndex) { + this.serverIndex = serverIndex; + return this; + } + + public Map getServerVariables() { + return serverVariables; + } + + public ApiClient setServerVariables(Map serverVariables) { + this.serverVariables = serverVariables; + return this; + } + + /** + * Get HTTP client + * + * @return An instance of OkHttpClient + */ + public OkHttpClient getHttpClient() { + return httpClient; + } + + /** + * Set HTTP client, which must never be null. + * + * @param newHttpClient An instance of OkHttpClient + * @return ApiClient + * @throws java.lang.NullPointerException when newHttpClient is null + */ + public ApiClient setHttpClient(OkHttpClient newHttpClient) { + this.httpClient = Objects.requireNonNull(newHttpClient, "HttpClient must not be null!"); + return this; + } + + /** + * Get JSON + * + * @return JSON object + */ + public JSON getJSON() { + return json; + } + + /** + * Set JSON + * + * @param json JSON object + * @return Api client + */ + public ApiClient setJSON(JSON json) { + this.json = json; + return this; + } + + /** + * True if isVerifyingSsl flag is on + * + * @return True if isVerifySsl flag is on + */ + public boolean isVerifyingSsl() { + return verifyingSsl; + } + + /** + * Configure whether to verify certificate and hostname when making https requests. + * Default to true. + * NOTE: Do NOT set to false in production code, otherwise you would face multiple types of cryptographic attacks. + * + * @param verifyingSsl True to verify TLS/SSL connection + * @return ApiClient + */ + public ApiClient setVerifyingSsl(boolean verifyingSsl) { + this.verifyingSsl = verifyingSsl; + applySslSettings(); + return this; + } + + /** + * Get SSL CA cert. + * + * @return Input stream to the SSL CA cert + */ + public InputStream getSslCaCert() { + return sslCaCert; + } + + /** + * Configure the CA certificate to be trusted when making https requests. + * Use null to reset to default. + * + * @param sslCaCert input stream for SSL CA cert + * @return ApiClient + */ + public ApiClient setSslCaCert(InputStream sslCaCert) { + this.sslCaCert = sslCaCert; + applySslSettings(); + return this; + } + + /** + *

Getter for the field keyManagers.

+ * + * @return an array of {@link javax.net.ssl.KeyManager} objects + */ + public KeyManager[] getKeyManagers() { + return keyManagers; + } + + /** + * Configure client keys to use for authorization in an SSL session. + * Use null to reset to default. + * + * @param managers The KeyManagers to use + * @return ApiClient + */ + public ApiClient setKeyManagers(KeyManager[] managers) { + this.keyManagers = managers; + applySslSettings(); + return this; + } + + /** + *

Getter for the field dateFormat.

+ * + * @return a {@link java.text.DateFormat} object + */ + public DateFormat getDateFormat() { + return dateFormat; + } + + /** + *

Setter for the field dateFormat.

+ * + * @param dateFormat a {@link java.text.DateFormat} object + * @return a {@link com.equinix.sdk.crossconnectsv2.ApiClient} object + */ + public ApiClient setDateFormat(DateFormat dateFormat) { + JSON.setDateFormat(dateFormat); + return this; + } + + /** + *

Set SqlDateFormat.

+ * + * @param dateFormat a {@link java.text.DateFormat} object + * @return a {@link com.equinix.sdk.crossconnectsv2.ApiClient} object + */ + public ApiClient setSqlDateFormat(DateFormat dateFormat) { + JSON.setSqlDateFormat(dateFormat); + return this; + } + + /** + *

Set OffsetDateTimeFormat.

+ * + * @param dateFormat a {@link java.time.format.DateTimeFormatter} object + * @return a {@link com.equinix.sdk.crossconnectsv2.ApiClient} object + */ + public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { + JSON.setOffsetDateTimeFormat(dateFormat); + return this; + } + + /** + *

Set LocalDateFormat.

+ * + * @param dateFormat a {@link java.time.format.DateTimeFormatter} object + * @return a {@link com.equinix.sdk.crossconnectsv2.ApiClient} object + */ + public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) { + JSON.setLocalDateFormat(dateFormat); + return this; + } + + /** + *

Set LenientOnJson.

+ * + * @param lenientOnJson a boolean + * @return a {@link com.equinix.sdk.crossconnectsv2.ApiClient} object + */ + public ApiClient setLenientOnJson(boolean lenientOnJson) { + JSON.setLenientOnJson(lenientOnJson); + return this; + } + + /** + * Get authentications (key: authentication name, value: authentication). + * + * @return Map of authentication objects + */ + public Map getAuthentications() { + return authentications; + } + + /** + * Get authentication for the given name. + * + * @param authName The authentication name + * @return The authentication, null if not found + */ + public Authentication getAuthentication(String authName) { + return authentications.get(authName); + } + + /** + * Helper method to set access token for the first Bearer authentication. + * @param bearerToken Bearer token + */ + public void setBearerToken(String bearerToken) { + setBearerToken(() -> bearerToken); + } + + /** + * Helper method to set the supplier of access tokens for Bearer authentication. + * + * @param tokenSupplier The supplier of bearer tokens + */ + public void setBearerToken(Supplier tokenSupplier) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBearerAuth) { + ((HttpBearerAuth) auth).setBearerToken(tokenSupplier); + return; + } + } + throw new RuntimeException("No Bearer authentication configured!"); + } + + /** + * Helper method to set username for the first HTTP basic authentication. + * + * @param username Username + */ + public void setUsername(String username) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setUsername(username); + return; + } + } + throw new RuntimeException("No HTTP basic authentication configured!"); + } + + /** + * Helper method to set password for the first HTTP basic authentication. + * + * @param password Password + */ + public void setPassword(String password) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setPassword(password); + return; + } + } + throw new RuntimeException("No HTTP basic authentication configured!"); + } + + /** + * Helper method to set API key value for the first API key authentication. + * + * @param apiKey API key + */ + public void setApiKey(String apiKey) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKey(apiKey); + return; + } + } + throw new RuntimeException("No API key authentication configured!"); + } + + /** + * Helper method to set API key prefix for the first API key authentication. + * + * @param apiKeyPrefix API key prefix + */ + public void setApiKeyPrefix(String apiKeyPrefix) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix); + return; + } + } + throw new RuntimeException("No API key authentication configured!"); + } + + /** + * Helper method to set access token for the first OAuth2 authentication. + * + * @param accessToken Access token + */ + public void setAccessToken(String accessToken) { + throw new RuntimeException("No OAuth2 authentication configured!"); + } + + /** + * Helper method to set credentials for AWSV4 Signature + * + * @param accessKey Access Key + * @param secretKey Secret Key + * @param region Region + * @param service Service to access to + */ + public void setAWS4Configuration(String accessKey, String secretKey, String region, String service) { + throw new RuntimeException("No AWS4 authentication configured!"); + } + + /** + * Helper method to set credentials for AWSV4 Signature + * + * @param accessKey Access Key + * @param secretKey Secret Key + * @param sessionToken Session Token + * @param region Region + * @param service Service to access to + */ + public void setAWS4Configuration(String accessKey, String secretKey, String sessionToken, String region, String service) { + throw new RuntimeException("No AWS4 authentication configured!"); + } + + /** + * Set the User-Agent header's value (by adding to the default header map). + * + * @param userAgent HTTP request's user agent + * @return ApiClient + */ + public ApiClient setUserAgent(String userAgent) { + addDefaultHeader("User-Agent", userAgent); + return this; + } + + /** + * Add a default header. + * + * @param key The header's key + * @param value The header's value + * @return ApiClient + */ + public ApiClient addDefaultHeader(String key, String value) { + defaultHeaderMap.put(key, value); + return this; + } + + /** + * Add a default cookie. + * + * @param key The cookie's key + * @param value The cookie's value + * @return ApiClient + */ + public ApiClient addDefaultCookie(String key, String value) { + defaultCookieMap.put(key, value); + return this; + } + + /** + * Check that whether debugging is enabled for this API client. + * + * @return True if debugging is enabled, false otherwise. + */ + public boolean isDebugging() { + return debugging; + } + + /** + * Enable/disable debugging for this API client. + * + * @param debugging To enable (true) or disable (false) debugging + * @return ApiClient + */ + public ApiClient setDebugging(boolean debugging) { + if (debugging != this.debugging) { + if (debugging) { + loggingInterceptor = new HttpLoggingInterceptor(); + loggingInterceptor.setLevel(Level.BODY); + httpClient = httpClient.newBuilder().addInterceptor(loggingInterceptor).build(); + } else { + final OkHttpClient.Builder builder = httpClient.newBuilder(); + builder.interceptors().remove(loggingInterceptor); + httpClient = builder.build(); + loggingInterceptor = null; + } + } + this.debugging = debugging; + return this; + } + + /** + * The path of temporary folder used to store downloaded files from endpoints + * with file response. The default value is null, i.e. using + * the system's default temporary folder. + * + * @see createTempFile + * @return Temporary folder path + */ + public String getTempFolderPath() { + return tempFolderPath; + } + + /** + * Set the temporary folder path (for downloading files) + * + * @param tempFolderPath Temporary folder path + * @return ApiClient + */ + public ApiClient setTempFolderPath(String tempFolderPath) { + this.tempFolderPath = tempFolderPath; + return this; + } + + /** + * Get connection timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public int getConnectTimeout() { + return httpClient.connectTimeoutMillis(); + } + + /** + * Sets the connect timeout (in milliseconds). + * A value of 0 means no timeout, otherwise values must be between 1 and + * {@link java.lang.Integer#MAX_VALUE}. + * + * @param connectionTimeout connection timeout in milliseconds + * @return Api client + */ + public ApiClient setConnectTimeout(int connectionTimeout) { + httpClient = httpClient.newBuilder().connectTimeout(connectionTimeout, TimeUnit.MILLISECONDS).build(); + return this; + } + + /** + * Get read timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public int getReadTimeout() { + return httpClient.readTimeoutMillis(); + } + + /** + * Sets the read timeout (in milliseconds). + * A value of 0 means no timeout, otherwise values must be between 1 and + * {@link java.lang.Integer#MAX_VALUE}. + * + * @param readTimeout read timeout in milliseconds + * @return Api client + */ + public ApiClient setReadTimeout(int readTimeout) { + httpClient = httpClient.newBuilder().readTimeout(readTimeout, TimeUnit.MILLISECONDS).build(); + return this; + } + + /** + * Get write timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public int getWriteTimeout() { + return httpClient.writeTimeoutMillis(); + } + + /** + * Sets the write timeout (in milliseconds). + * A value of 0 means no timeout, otherwise values must be between 1 and + * {@link java.lang.Integer#MAX_VALUE}. + * + * @param writeTimeout connection timeout in milliseconds + * @return Api client + */ + public ApiClient setWriteTimeout(int writeTimeout) { + httpClient = httpClient.newBuilder().writeTimeout(writeTimeout, TimeUnit.MILLISECONDS).build(); + return this; + } + + + /** + * Format the given parameter object into string. + * + * @param param Parameter + * @return String representation of the parameter + */ + public String parameterToString(Object param) { + if (param == null) { + return ""; + } else if (param instanceof Date || param instanceof OffsetDateTime || param instanceof LocalDate) { + //Serialize to json string and remove the " enclosing characters + String jsonStr = JSON.serialize(param); + return jsonStr.substring(1, jsonStr.length() - 1); + } else if (param instanceof Collection) { + StringBuilder b = new StringBuilder(); + for (Object o : (Collection) param) { + if (b.length() > 0) { + b.append(","); + } + b.append(o); + } + return b.toString(); + } else { + return String.valueOf(param); + } + } + + /** + * Formats the specified query parameter to a list containing a single {@code Pair} object. + * + * Note that {@code value} must not be a collection. + * + * @param name The name of the parameter. + * @param value The value of the parameter. + * @return A list containing a single {@code Pair} object. + */ + public List parameterToPair(String name, Object value) { + List params = new ArrayList(); + + // preconditions + if (name == null || name.isEmpty() || value == null || value instanceof Collection) { + return params; + } + + params.add(new Pair(name, parameterToString(value))); + return params; + } + + /** + * Formats the specified collection query parameters to a list of {@code Pair} objects. + * + * Note that the values of each of the returned Pair objects are percent-encoded. + * + * @param collectionFormat The collection format of the parameter. + * @param name The name of the parameter. + * @param value The value of the parameter. + * @return A list of {@code Pair} objects. + */ + public List parameterToPairs(String collectionFormat, String name, Collection value) { + List params = new ArrayList(); + + // preconditions + if (name == null || name.isEmpty() || value == null || value.isEmpty()) { + return params; + } + + // create the params based on the collection format + if ("multi".equals(collectionFormat)) { + for (Object item : value) { + params.add(new Pair(name, escapeString(parameterToString(item)))); + } + return params; + } + + // collectionFormat is assumed to be "csv" by default + String delimiter = ","; + + // escape all delimiters except commas, which are URI reserved + // characters + if ("ssv".equals(collectionFormat)) { + delimiter = escapeString(" "); + } else if ("tsv".equals(collectionFormat)) { + delimiter = escapeString("\t"); + } else if ("pipes".equals(collectionFormat)) { + delimiter = escapeString("|"); + } + + StringBuilder sb = new StringBuilder(); + for (Object item : value) { + sb.append(delimiter); + sb.append(escapeString(parameterToString(item))); + } + + params.add(new Pair(name, sb.substring(delimiter.length()))); + + return params; + } + + /** + * Formats the specified free-form query parameters to a list of {@code Pair} objects. + * + * @param value The free-form query parameters. + * @return A list of {@code Pair} objects. + */ + public List freeFormParameterToPairs(Object value) { + List params = new ArrayList<>(); + + // preconditions + if (value == null || !(value instanceof Map )) { + return params; + } + + @SuppressWarnings("unchecked") + final Map valuesMap = (Map) value; + + for (Map.Entry entry : valuesMap.entrySet()) { + params.add(new Pair(entry.getKey(), parameterToString(entry.getValue()))); + } + + return params; + } + + + /** + * Formats the specified collection path parameter to a string value. + * + * @param collectionFormat The collection format of the parameter. + * @param value The value of the parameter. + * @return String representation of the parameter + */ + public String collectionPathParameterToString(String collectionFormat, Collection value) { + // create the value based on the collection format + if ("multi".equals(collectionFormat)) { + // not valid for path params + return parameterToString(value); + } + + // collectionFormat is assumed to be "csv" by default + String delimiter = ","; + + if ("ssv".equals(collectionFormat)) { + delimiter = " "; + } else if ("tsv".equals(collectionFormat)) { + delimiter = "\t"; + } else if ("pipes".equals(collectionFormat)) { + delimiter = "|"; + } + + StringBuilder sb = new StringBuilder() ; + for (Object item : value) { + sb.append(delimiter); + sb.append(parameterToString(item)); + } + + return sb.substring(delimiter.length()); + } + + /** + * Sanitize filename by removing path. + * e.g. ../../sun.gif becomes sun.gif + * + * @param filename The filename to be sanitized + * @return The sanitized filename + */ + public String sanitizeFilename(String filename) { + return filename.replaceFirst("^.*[/\\\\]", ""); + } + + /** + * Check if the given MIME is a JSON MIME. + * JSON MIME examples: + * application/json + * application/json; charset=UTF8 + * APPLICATION/JSON + * application/vnd.company+json + * "* / *" is also default to JSON + * @param mime MIME (Multipurpose Internet Mail Extensions) + * @return True if the given MIME is JSON, false otherwise. + */ + public boolean isJsonMime(String mime) { + String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"; + return mime != null && (mime.matches(jsonMime) || mime.equals("*/*")); + } + + /** + * Select the Accept header's value from the given accepts array: + * if JSON exists in the given array, use it; + * otherwise use all of them (joining into a string) + * + * @param accepts The accepts array to select from + * @return The Accept header to use. If the given array is empty, + * null will be returned (not to set the Accept header explicitly). + */ + public String selectHeaderAccept(String[] accepts) { + if (accepts.length == 0) { + return null; + } + for (String accept : accepts) { + if (isJsonMime(accept)) { + return accept; + } + } + return StringUtil.join(accepts, ","); + } + + /** + * Select the Content-Type header's value from the given array: + * if JSON exists in the given array, use it; + * otherwise use the first one of the array. + * + * @param contentTypes The Content-Type array to select from + * @return The Content-Type header to use. If the given array is empty, + * returns null. If it matches "any", JSON will be used. + */ + public String selectHeaderContentType(String[] contentTypes) { + if (contentTypes.length == 0) { + return null; + } + + if (contentTypes[0].equals("*/*")) { + return "application/json"; + } + + for (String contentType : contentTypes) { + if (isJsonMime(contentType)) { + return contentType; + } + } + + return contentTypes[0]; + } + + /** + * Escape the given string to be used as URL query value. + * + * @param str String to be escaped + * @return Escaped string + */ + public String escapeString(String str) { + try { + return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20"); + } catch (UnsupportedEncodingException e) { + return str; + } + } + + /** + * Deserialize response body to Java object, according to the return type and + * the Content-Type response header. + * + * @param Type + * @param response HTTP response + * @param returnType The type of the Java object + * @return The deserialized Java object + * @throws com.equinix.sdk.crossconnectsv2.ApiException If fail to deserialize response body, i.e. cannot read response body + * or the Content-Type of the response is not supported. + */ + @SuppressWarnings("unchecked") + public T deserialize(Response response, Type returnType) throws ApiException { + if (response == null || returnType == null) { + return null; + } + + if ("byte[]".equals(returnType.toString())) { + // Handle binary response (byte array). + try { + return (T) response.body().bytes(); + } catch (IOException e) { + throw new ApiException(e); + } + } else if (returnType.equals(File.class)) { + // Handle file downloading. + return (T) downloadFileFromResponse(response); + } + + ResponseBody respBody = response.body(); + if (respBody == null) { + return null; + } + + String contentType = response.headers().get("Content-Type"); + if (contentType == null) { + // ensuring a default content type + contentType = "application/json"; + } + try { + if (isJsonMime(contentType)) { + return JSON.deserialize(respBody.byteStream(), returnType); + } else if (returnType.equals(String.class)) { + String respBodyString = respBody.string(); + if (respBodyString.isEmpty()) { + return null; + } + // Expecting string, return the raw response body. + return (T) respBodyString; + } else { + throw new ApiException( + "Content type \"" + contentType + "\" is not supported for type: " + returnType, + response.code(), + response.headers().toMultimap(), + response.body().string()); + } + } catch (IOException e) { + throw new ApiException(e); + } + } + + /** + * Serialize the given Java object into request body according to the object's + * class and the request Content-Type. + * + * @param obj The Java object + * @param contentType The request Content-Type + * @return The serialized request body + * @throws com.equinix.sdk.crossconnectsv2.ApiException If fail to serialize the given object + */ + public RequestBody serialize(Object obj, String contentType) throws ApiException { + if (obj instanceof byte[]) { + // Binary (byte array) body parameter support. + return RequestBody.create((byte[]) obj, MediaType.parse(contentType)); + } else if (obj instanceof File) { + // File body parameter support. + return RequestBody.create((File) obj, MediaType.parse(contentType)); + } else if ("text/plain".equals(contentType) && obj instanceof String) { + return RequestBody.create((String) obj, MediaType.parse(contentType)); + } else if (isJsonMime(contentType)) { + String content; + if (obj != null) { + content = JSON.serialize(obj); + } else { + content = null; + } + return RequestBody.create(content, MediaType.parse(contentType)); + } else if (obj instanceof String) { + return RequestBody.create((String) obj, MediaType.parse(contentType)); + } else { + throw new ApiException("Content type \"" + contentType + "\" is not supported"); + } + } + + /** + * Download file from the given response. + * + * @param response An instance of the Response object + * @throws com.equinix.sdk.crossconnectsv2.ApiException If fail to read file content from response and write to disk + * @return Downloaded file + */ + public File downloadFileFromResponse(Response response) throws ApiException { + try { + File file = prepareDownloadFile(response); + BufferedSink sink = Okio.buffer(Okio.sink(file)); + sink.writeAll(response.body().source()); + sink.close(); + return file; + } catch (IOException e) { + throw new ApiException(e); + } + } + + /** + * Prepare file for download + * + * @param response An instance of the Response object + * @return Prepared file for the download + * @throws java.io.IOException If fail to prepare file for download + */ + public File prepareDownloadFile(Response response) throws IOException { + String filename = null; + String contentDisposition = response.header("Content-Disposition"); + if (contentDisposition != null && !"".equals(contentDisposition)) { + // Get filename from the Content-Disposition header. + Pattern pattern = Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?"); + Matcher matcher = pattern.matcher(contentDisposition); + if (matcher.find()) { + filename = sanitizeFilename(matcher.group(1)); + } + } + + String prefix = null; + String suffix = null; + if (filename == null) { + prefix = "download-"; + suffix = ""; + } else { + int pos = filename.lastIndexOf("."); + if (pos == -1) { + prefix = filename + "-"; + } else { + prefix = filename.substring(0, pos) + "-"; + suffix = filename.substring(pos); + } + // Files.createTempFile requires the prefix to be at least three characters long + if (prefix.length() < 3) + prefix = "download-"; + } + + if (tempFolderPath == null) + return Files.createTempFile(prefix, suffix).toFile(); + else + return Files.createTempFile(Paths.get(tempFolderPath), prefix, suffix).toFile(); + } + + /** + * {@link #execute(Call, Type)} + * + * @param Type + * @param call An instance of the Call object + * @return ApiResponse<T> + * @throws com.equinix.sdk.crossconnectsv2.ApiException If fail to execute the call + */ + public ApiResponse execute(Call call) throws ApiException { + return execute(call, null); + } + + /** + * Execute HTTP call and deserialize the HTTP response body into the given return type. + * + * @param returnType The return type used to deserialize HTTP response body + * @param The return type corresponding to (same with) returnType + * @param call Call + * @return ApiResponse object containing response status, headers and + * data, which is a Java object deserialized from response body and would be null + * when returnType is null. + * @throws com.equinix.sdk.crossconnectsv2.ApiException If fail to execute the call + */ + public ApiResponse execute(Call call, Type returnType) throws ApiException { + try { + Response response = call.execute(); + T data = handleResponse(response, returnType); + return new ApiResponse(response.code(), response.headers().toMultimap(), data); + } catch (IOException e) { + throw new ApiException(e); + } + } + + /** + * {@link #executeAsync(Call, Type, ApiCallback)} + * + * @param Type + * @param call An instance of the Call object + * @param callback ApiCallback<T> + */ + public void executeAsync(Call call, ApiCallback callback) { + executeAsync(call, null, callback); + } + + /** + * Execute HTTP call asynchronously. + * + * @param Type + * @param call The callback to be executed when the API call finishes + * @param returnType Return type + * @param callback ApiCallback + * @see #execute(Call, Type) + */ + @SuppressWarnings("unchecked") + public void executeAsync(Call call, final Type returnType, final ApiCallback callback) { + call.enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + callback.onFailure(new ApiException(e), 0, null); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + T result; + try { + result = (T) handleResponse(response, returnType); + } catch (ApiException e) { + callback.onFailure(e, response.code(), response.headers().toMultimap()); + return; + } catch (Exception e) { + callback.onFailure(new ApiException(e), response.code(), response.headers().toMultimap()); + return; + } + callback.onSuccess(result, response.code(), response.headers().toMultimap()); + } + }); + } + + /** + * Handle the given response, return the deserialized object when the response is successful. + * + * @param Type + * @param response Response + * @param returnType Return type + * @return Type + * @throws com.equinix.sdk.crossconnectsv2.ApiException If the response has an unsuccessful status code or + * fail to deserialize the response body + */ + public T handleResponse(Response response, Type returnType) throws ApiException { + if (response.isSuccessful()) { + if (returnType == null || response.code() == 204) { + // returning null if the returnType is not defined, + // or the status code is 204 (No Content) + if (response.body() != null) { + try { + response.body().close(); + } catch (Exception e) { + throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap()); + } + } + return null; + } else { + return deserialize(response, returnType); + } + } else { + String respBody = null; + if (response.body() != null) { + try { + respBody = response.body().string(); + } catch (IOException e) { + throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap()); + } + } + throw new ApiException(response.message(), response.code(), response.headers().toMultimap(), respBody); + } + } + + /** + * Build HTTP call with the given options. + * + * @param baseUrl The base URL + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE" + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param cookieParams The cookie parameters + * @param formParams The form parameters + * @param authNames The authentications to apply + * @param callback Callback for upload/download progress + * @return The HTTP call + * @throws com.equinix.sdk.crossconnectsv2.ApiException If fail to serialize the request body object + */ + public Call buildCall(String baseUrl, String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { + Request request = buildRequest(baseUrl, path, method, queryParams, collectionQueryParams, body, headerParams, cookieParams, formParams, authNames, callback); + + return httpClient.newCall(request); + } + + /** + * Build an HTTP request with the given options. + * + * @param baseUrl The base URL + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE" + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param cookieParams The cookie parameters + * @param formParams The form parameters + * @param authNames The authentications to apply + * @param callback Callback for upload/download progress + * @return The HTTP request + * @throws com.equinix.sdk.crossconnectsv2.ApiException If fail to serialize the request body object + */ + public Request buildRequest(String baseUrl, String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { + final String url = buildUrl(baseUrl, path, queryParams, collectionQueryParams); + + // prepare HTTP request body + RequestBody reqBody; + String contentType = headerParams.get("Content-Type"); + String contentTypePure = contentType; + if (contentTypePure != null && contentTypePure.contains(";")) { + contentTypePure = contentType.substring(0, contentType.indexOf(";")); + } + if (!HttpMethod.permitsRequestBody(method)) { + reqBody = null; + } else if ("application/x-www-form-urlencoded".equals(contentTypePure)) { + reqBody = buildRequestBodyFormEncoding(formParams); + } else if ("multipart/form-data".equals(contentTypePure)) { + reqBody = buildRequestBodyMultipart(formParams); + } else if (body == null) { + if ("DELETE".equals(method)) { + // allow calling DELETE without sending a request body + reqBody = null; + } else { + // use an empty request body (for POST, PUT and PATCH) + reqBody = RequestBody.create("", contentType == null ? null : MediaType.parse(contentType)); + } + } else { + reqBody = serialize(body, contentType); + } + + List updatedQueryParams = new ArrayList<>(queryParams); + + // update parameters with authentication settings + updateParamsForAuth(authNames, updatedQueryParams, headerParams, cookieParams, requestBodyToString(reqBody), method, URI.create(url)); + + final Request.Builder reqBuilder = new Request.Builder().url(buildUrl(baseUrl, path, updatedQueryParams, collectionQueryParams)); + processHeaderParams(headerParams, reqBuilder); + processCookieParams(cookieParams, reqBuilder); + + // Associate callback with request (if not null) so interceptor can + // access it when creating ProgressResponseBody + reqBuilder.tag(callback); + + Request request = null; + + if (callback != null && reqBody != null) { + ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, callback); + request = reqBuilder.method(method, progressRequestBody).build(); + } else { + request = reqBuilder.method(method, reqBody).build(); + } + + return request; + } + + /** + * Build full URL by concatenating base path, the given sub path and query parameters. + * + * @param baseUrl The base URL + * @param path The sub path + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @return The full URL + */ + public String buildUrl(String baseUrl, String path, List queryParams, List collectionQueryParams) { + final StringBuilder url = new StringBuilder(); + if (baseUrl != null) { + url.append(baseUrl).append(path); + } else { + String baseURL; + if (serverIndex != null) { + if (serverIndex < 0 || serverIndex >= servers.size()) { + throw new ArrayIndexOutOfBoundsException(String.format( + Locale.ROOT, + "Invalid index %d when selecting the host settings. Must be less than %d", serverIndex, servers.size() + )); + } + baseURL = servers.get(serverIndex).URL(serverVariables); + } else { + baseURL = basePath; + } + url.append(baseURL).append(path); + } + + if (queryParams != null && !queryParams.isEmpty()) { + // support (constant) query string in `path`, e.g. "/posts?draft=1" + String prefix = path.contains("?") ? "&" : "?"; + for (Pair param : queryParams) { + if (param.getValue() != null) { + if (prefix != null) { + url.append(prefix); + prefix = null; + } else { + url.append("&"); + } + String value = parameterToString(param.getValue()); + url.append(escapeString(param.getName())).append("=").append(escapeString(value)); + } + } + } + + if (collectionQueryParams != null && !collectionQueryParams.isEmpty()) { + String prefix = url.toString().contains("?") ? "&" : "?"; + for (Pair param : collectionQueryParams) { + if (param.getValue() != null) { + if (prefix != null) { + url.append(prefix); + prefix = null; + } else { + url.append("&"); + } + String value = parameterToString(param.getValue()); + // collection query parameter value already escaped as part of parameterToPairs + url.append(escapeString(param.getName())).append("=").append(value); + } + } + } + + return url.toString(); + } + + /** + * Set header parameters to the request builder, including default headers. + * + * @param headerParams Header parameters in the form of Map + * @param reqBuilder Request.Builder + */ + public void processHeaderParams(Map headerParams, Request.Builder reqBuilder) { + for (Entry param : headerParams.entrySet()) { + reqBuilder.header(param.getKey(), parameterToString(param.getValue())); + } + for (Entry header : defaultHeaderMap.entrySet()) { + if (!headerParams.containsKey(header.getKey())) { + reqBuilder.header(header.getKey(), parameterToString(header.getValue())); + } + } + } + + /** + * Set cookie parameters to the request builder, including default cookies. + * + * @param cookieParams Cookie parameters in the form of Map + * @param reqBuilder Request.Builder + */ + public void processCookieParams(Map cookieParams, Request.Builder reqBuilder) { + for (Entry param : cookieParams.entrySet()) { + reqBuilder.addHeader("Cookie", String.format(Locale.ROOT, "%s=%s", param.getKey(), param.getValue())); + } + for (Entry param : defaultCookieMap.entrySet()) { + if (!cookieParams.containsKey(param.getKey())) { + reqBuilder.addHeader("Cookie", String.format(Locale.ROOT, "%s=%s", param.getKey(), param.getValue())); + } + } + } + + /** + * Update query and header parameters based on authentication settings. + * + * @param authNames The authentications to apply + * @param queryParams List of query parameters + * @param headerParams Map of header parameters + * @param cookieParams Map of cookie parameters + * @param payload HTTP request body + * @param method HTTP method + * @param uri URI + * @throws com.equinix.sdk.crossconnectsv2.ApiException If fails to update the parameters + */ + public void updateParamsForAuth(String[] authNames, List queryParams, Map headerParams, + Map cookieParams, String payload, String method, URI uri) throws ApiException { + for (String authName : authNames) { + Authentication auth = authentications.get(authName); + if (auth == null) { + throw new RuntimeException("Authentication undefined: " + authName); + } + auth.applyToParams(queryParams, headerParams, cookieParams, payload, method, uri); + } + } + + /** + * Build a form-encoding request body with the given form parameters. + * + * @param formParams Form parameters in the form of Map + * @return RequestBody + */ + public RequestBody buildRequestBodyFormEncoding(Map formParams) { + okhttp3.FormBody.Builder formBuilder = new okhttp3.FormBody.Builder(); + for (Entry param : formParams.entrySet()) { + formBuilder.add(param.getKey(), parameterToString(param.getValue())); + } + return formBuilder.build(); + } + + /** + * Build a multipart (file uploading) request body with the given form parameters, + * which could contain text fields and file fields. + * + * @param formParams Form parameters in the form of Map + * @return RequestBody + */ + public RequestBody buildRequestBodyMultipart(Map formParams) { + MultipartBody.Builder mpBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM); + for (Entry param : formParams.entrySet()) { + if (param.getValue() instanceof File) { + File file = (File) param.getValue(); + addPartToMultiPartBuilder(mpBuilder, param.getKey(), file); + } else if (param.getValue() instanceof List) { + List list = (List) param.getValue(); + for (Object item: list) { + if (item instanceof File) { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), (File) item); + } else { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); + } + } + } else { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); + } + } + return mpBuilder.build(); + } + + /** + * Guess Content-Type header from the given file (defaults to "application/octet-stream"). + * + * @param file The given file + * @return The guessed Content-Type + */ + public String guessContentTypeFromFile(File file) { + String contentType = URLConnection.guessContentTypeFromName(file.getName()); + if (contentType == null) { + return "application/octet-stream"; + } else { + return contentType; + } + } + + /** + * Add a Content-Disposition Header for the given key and file to the MultipartBody Builder. + * + * @param mpBuilder MultipartBody.Builder + * @param key The key of the Header element + * @param file The file to add to the Header + */ + protected void addPartToMultiPartBuilder(MultipartBody.Builder mpBuilder, String key, File file) { + Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + key + "\"; filename=\"" + file.getName() + "\""); + MediaType mediaType = MediaType.parse(guessContentTypeFromFile(file)); + mpBuilder.addPart(partHeaders, RequestBody.create(file, mediaType)); + } + + /** + * Add a Content-Disposition Header for the given key and complex object to the MultipartBody Builder. + * + * @param mpBuilder MultipartBody.Builder + * @param key The key of the Header element + * @param obj The complex object to add to the Header + */ + protected void addPartToMultiPartBuilder(MultipartBody.Builder mpBuilder, String key, Object obj) { + RequestBody requestBody; + if (obj instanceof String) { + requestBody = RequestBody.create((String) obj, MediaType.parse("text/plain")); + } else { + String content; + if (obj != null) { + content = JSON.serialize(obj); + } else { + content = null; + } + requestBody = RequestBody.create(content, MediaType.parse("application/json")); + } + + Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + key + "\""); + mpBuilder.addPart(partHeaders, requestBody); + } + + /** + * Get network interceptor to add it to the httpClient to track download progress for + * async requests. + */ + protected Interceptor getProgressInterceptor() { + return new Interceptor() { + @Override + public Response intercept(Interceptor.Chain chain) throws IOException { + final Request request = chain.request(); + final Response originalResponse = chain.proceed(request); + if (request.tag() instanceof ApiCallback) { + final ApiCallback callback = (ApiCallback) request.tag(); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), callback)) + .build(); + } + return originalResponse; + } + }; + } + + /** + * Apply SSL related settings to httpClient according to the current values of + * verifyingSsl and sslCaCert. + */ + protected void applySslSettings() { + try { + TrustManager[] trustManagers; + HostnameVerifier hostnameVerifier; + if (!verifyingSsl) { + trustManagers = new TrustManager[]{ + new X509TrustManager() { + @Override + public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { + } + + @Override + public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { + } + + @Override + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return new java.security.cert.X509Certificate[]{}; + } + } + }; + hostnameVerifier = new HostnameVerifier() { + @Override + public boolean verify(String hostname, SSLSession session) { + return true; + } + }; + } else { + TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); + + if (sslCaCert == null) { + trustManagerFactory.init((KeyStore) null); + } else { + char[] password = null; // Any password will work. + CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509"); + Collection certificates = certificateFactory.generateCertificates(sslCaCert); + if (certificates.isEmpty()) { + throw new IllegalArgumentException("expected non-empty set of trusted certificates"); + } + KeyStore caKeyStore = newEmptyKeyStore(password); + int index = 0; + for (Certificate certificate : certificates) { + String certificateAlias = "ca" + (index++); + caKeyStore.setCertificateEntry(certificateAlias, certificate); + } + trustManagerFactory.init(caKeyStore); + } + trustManagers = trustManagerFactory.getTrustManagers(); + hostnameVerifier = OkHostnameVerifier.INSTANCE; + } + + SSLContext sslContext = SSLContext.getInstance("TLS"); + sslContext.init(keyManagers, trustManagers, new SecureRandom()); + httpClient = httpClient.newBuilder() + .sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustManagers[0]) + .hostnameVerifier(hostnameVerifier) + .build(); + } catch (GeneralSecurityException e) { + throw new RuntimeException(e); + } + } + + protected KeyStore newEmptyKeyStore(char[] password) throws GeneralSecurityException { + try { + KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); + keyStore.load(null, password); + return keyStore; + } catch (IOException e) { + throw new AssertionError(e); + } + } + + /** + * Convert the HTTP request body to a string. + * + * @param requestBody The HTTP request object + * @return The string representation of the HTTP request body + * @throws com.equinix.sdk.crossconnectsv2.ApiException If fail to serialize the request body object into a string + */ + protected String requestBodyToString(RequestBody requestBody) throws ApiException { + if (requestBody != null) { + try { + final Buffer buffer = new Buffer(); + requestBody.writeTo(buffer); + return buffer.readUtf8(); + } catch (final IOException e) { + throw new ApiException(e); + } + } + + // empty http request body + return ""; + } +} diff --git a/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/ApiException.java b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/ApiException.java new file mode 100644 index 00000000..73def737 --- /dev/null +++ b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/ApiException.java @@ -0,0 +1,168 @@ +/* + * Cross Connect + * A Cross Connect is a physical cable connection that uses a coaxial, fiber or sometimes copper cable to connect customers equipment directly to other customers equipment inside Equinix data centers. Since cross connects transmit data point-to-point between computing systems inside our facility, they are not susceptible to the latency or congestion problems of the public Internet and can be relied upon to operate at consistently high speeds. + * + * The version of the OpenAPI document: 2.0 + * + * + * 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.sdk.crossconnectsv2; + +import java.util.Map; +import java.util.List; +import java.util.Locale; + + +/** + *

ApiException class.

+ */ +@SuppressWarnings("serial") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.16.0") +public class ApiException extends Exception { + private static final long serialVersionUID = 1L; + + private int code = 0; + private Map> responseHeaders = null; + private String responseBody = null; + + /** + *

Constructor for ApiException.

+ */ + public ApiException() {} + + /** + *

Constructor for ApiException.

+ * + * @param throwable a {@link java.lang.Throwable} object + */ + public ApiException(Throwable throwable) { + super(throwable); + } + + /** + *

Constructor for ApiException.

+ * + * @param message the error message + */ + public ApiException(String message) { + super(message); + } + + /** + *

Constructor for ApiException.

+ * + * @param message the error message + * @param throwable a {@link java.lang.Throwable} object + * @param code HTTP status code + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(String message, Throwable throwable, int code, Map> responseHeaders, String responseBody) { + super(message, throwable); + this.code = code; + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + /** + *

Constructor for ApiException.

+ * + * @param message the error message + * @param code HTTP status code + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(String message, int code, Map> responseHeaders, String responseBody) { + this(message, (Throwable) null, code, responseHeaders, responseBody); + } + + /** + *

Constructor for ApiException.

+ * + * @param message the error message + * @param throwable a {@link java.lang.Throwable} object + * @param code HTTP status code + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + */ + public ApiException(String message, Throwable throwable, int code, Map> responseHeaders) { + this(message, throwable, code, responseHeaders, null); + } + + /** + *

Constructor for ApiException.

+ * + * @param code HTTP status code + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(int code, Map> responseHeaders, String responseBody) { + this("Response Code: " + code + " Response Body: " + responseBody, (Throwable) null, code, responseHeaders, responseBody); + } + + /** + *

Constructor for ApiException.

+ * + * @param code HTTP status code + * @param message a {@link java.lang.String} object + */ + public ApiException(int code, String message) { + super(message); + this.code = code; + } + + /** + *

Constructor for ApiException.

+ * + * @param code HTTP status code + * @param message the error message + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(int code, String message, Map> responseHeaders, String responseBody) { + this(code, message); + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + /** + * Get the HTTP status code. + * + * @return HTTP status code + */ + public int getCode() { + return code; + } + + /** + * Get the HTTP response headers. + * + * @return A map of list of string + */ + public Map> getResponseHeaders() { + return responseHeaders; + } + + /** + * Get the HTTP response body. + * + * @return Response body in the form of string + */ + public String getResponseBody() { + return responseBody; + } + + /** + * Get the exception message including HTTP response data. + * + * @return The exception message + */ + public String getMessage() { + return String.format(Locale.ROOT, "Message: %s%nHTTP response code: %s%nHTTP response body: %s%nHTTP response headers: %s", + super.getMessage(), this.getCode(), this.getResponseBody(), this.getResponseHeaders()); + } +} diff --git a/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/ApiResponse.java b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/ApiResponse.java new file mode 100644 index 00000000..760dc1f5 --- /dev/null +++ b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/ApiResponse.java @@ -0,0 +1,76 @@ +/* + * Cross Connect + * A Cross Connect is a physical cable connection that uses a coaxial, fiber or sometimes copper cable to connect customers equipment directly to other customers equipment inside Equinix data centers. Since cross connects transmit data point-to-point between computing systems inside our facility, they are not susceptible to the latency or congestion problems of the public Internet and can be relied upon to operate at consistently high speeds. + * + * The version of the OpenAPI document: 2.0 + * + * + * 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.sdk.crossconnectsv2; + +import java.util.List; +import java.util.Map; + +/** + * API response returned by API call. + */ +public class ApiResponse { + final private int statusCode; + final private Map> headers; + final private T data; + + /** + *

Constructor for ApiResponse.

+ * + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + */ + public ApiResponse(int statusCode, Map> headers) { + this(statusCode, headers, null); + } + + /** + *

Constructor for ApiResponse.

+ * + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + * @param data The object deserialized from response bod + */ + public ApiResponse(int statusCode, Map> headers, T data) { + this.statusCode = statusCode; + this.headers = headers; + this.data = data; + } + + /** + *

Get the status code.

+ * + * @return the status code + */ + public int getStatusCode() { + return statusCode; + } + + /** + *

Get the headers.

+ * + * @return a {@link java.util.Map} of headers + */ + public Map> getHeaders() { + return headers; + } + + /** + *

Get the data.

+ * + * @return the data + */ + public T getData() { + return data; + } +} diff --git a/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/Configuration.java b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/Configuration.java new file mode 100644 index 00000000..ba11f3fe --- /dev/null +++ b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/Configuration.java @@ -0,0 +1,63 @@ +/* + * Cross Connect + * A Cross Connect is a physical cable connection that uses a coaxial, fiber or sometimes copper cable to connect customers equipment directly to other customers equipment inside Equinix data centers. Since cross connects transmit data point-to-point between computing systems inside our facility, they are not susceptible to the latency or congestion problems of the public Internet and can be relied upon to operate at consistently high speeds. + * + * The version of the OpenAPI document: 2.0 + * + * + * 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.sdk.crossconnectsv2; + +import java.util.Objects; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Supplier; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.16.0") +public class Configuration { + public static final String VERSION = "0.11.0"; + + private static final AtomicReference defaultApiClient = new AtomicReference<>(); + private static volatile Supplier apiClientFactory = ApiClient::new; + + /** + * Get the default API client, which would be used when creating API instances without providing an API client. + * + * @return Default API client + */ + public static ApiClient getDefaultApiClient() { + ApiClient client = defaultApiClient.get(); + if (client == null) { + client = defaultApiClient.updateAndGet(val -> { + if (val != null) { // changed by another thread + return val; + } + return apiClientFactory.get(); + }); + } + return client; + } + + /** + * Set the default API client, which would be used when creating API instances without providing an API client. + * + * @param apiClient API client + */ + public static void setDefaultApiClient(ApiClient apiClient) { + defaultApiClient.set(apiClient); + } + + /** + * set the callback used to create new ApiClient objects + */ + public static void setApiClientFactory(Supplier factory) { + apiClientFactory = Objects.requireNonNull(factory); + } + + private Configuration() { + } +} \ No newline at end of file diff --git a/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/GzipRequestInterceptor.java b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/GzipRequestInterceptor.java new file mode 100644 index 00000000..13a0db1e --- /dev/null +++ b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/GzipRequestInterceptor.java @@ -0,0 +1,85 @@ +/* + * Cross Connect + * A Cross Connect is a physical cable connection that uses a coaxial, fiber or sometimes copper cable to connect customers equipment directly to other customers equipment inside Equinix data centers. Since cross connects transmit data point-to-point between computing systems inside our facility, they are not susceptible to the latency or congestion problems of the public Internet and can be relied upon to operate at consistently high speeds. + * + * The version of the OpenAPI document: 2.0 + * + * + * 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.sdk.crossconnectsv2; + +import okhttp3.*; +import okio.Buffer; +import okio.BufferedSink; +import okio.GzipSink; +import okio.Okio; + +import java.io.IOException; + +/** + * Encodes request bodies using gzip. + * + * Taken from https://github.com/square/okhttp/issues/350 + */ +class GzipRequestInterceptor implements Interceptor { + @Override + public Response intercept(Chain chain) throws IOException { + Request originalRequest = chain.request(); + if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) { + return chain.proceed(originalRequest); + } + + Request compressedRequest = originalRequest.newBuilder() + .header("Content-Encoding", "gzip") + .method(originalRequest.method(), forceContentLength(gzip(originalRequest.body()))) + .build(); + return chain.proceed(compressedRequest); + } + + private RequestBody forceContentLength(final RequestBody requestBody) throws IOException { + final Buffer buffer = new Buffer(); + requestBody.writeTo(buffer); + return new RequestBody() { + @Override + public MediaType contentType() { + return requestBody.contentType(); + } + + @Override + public long contentLength() { + return buffer.size(); + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + sink.write(buffer.snapshot()); + } + }; + } + + private RequestBody gzip(final RequestBody body) { + return new RequestBody() { + @Override + public MediaType contentType() { + return body.contentType(); + } + + @Override + public long contentLength() { + return -1; // We don't know the compressed length in advance! + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + BufferedSink gzipSink = Okio.buffer(new GzipSink(sink)); + body.writeTo(gzipSink); + gzipSink.close(); + } + }; + } +} diff --git a/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/JSON.java b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/JSON.java new file mode 100644 index 00000000..4e0638ca --- /dev/null +++ b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/JSON.java @@ -0,0 +1,448 @@ +/* + * Cross Connect + * A Cross Connect is a physical cable connection that uses a coaxial, fiber or sometimes copper cable to connect customers equipment directly to other customers equipment inside Equinix data centers. Since cross connects transmit data point-to-point between computing systems inside our facility, they are not susceptible to the latency or congestion problems of the public Internet and can be relied upon to operate at consistently high speeds. + * + * The version of the OpenAPI document: 2.0 + * + * + * 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.sdk.crossconnectsv2; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.internal.bind.util.ISO8601Utils; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonElement; +import io.gsonfire.GsonFireBuilder; +import io.gsonfire.TypeSelector; + +import okio.ByteString; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.StringReader; +import java.lang.reflect.Type; +import java.nio.charset.StandardCharsets; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.ParsePosition; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Date; +import java.util.Locale; +import java.util.Map; +import java.util.HashMap; + +/* + * 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 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() + ; + 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; + } + + static { + GsonBuilder gsonBuilder = createGson(); + 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.sdk.crossconnectsv2.model.ASide.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.sdk.crossconnectsv2.model.AttachmentRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.sdk.crossconnectsv2.model.ContactRequestNonRegisteredUser.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.sdk.crossconnectsv2.model.ContactRequestRegisteredUser.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.sdk.crossconnectsv2.model.ContactRequestRegisteredUserUpdate.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.sdk.crossconnectsv2.model.ContactsRequestDetails.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.sdk.crossconnectsv2.model.DiverseConnections.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.sdk.crossconnectsv2.model.DiverseConnectionsASide.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.sdk.crossconnectsv2.model.DiverseConnectionsZSide.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.sdk.crossconnectsv2.model.ErrorDetails.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.sdk.crossconnectsv2.model.Layer1Create.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.sdk.crossconnectsv2.model.Layer1CreateContactsInner.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.sdk.crossconnectsv2.model.Layer1DeinstallDetails.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.sdk.crossconnectsv2.model.Layer1DeinstallDetailsPatchEquipment.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.sdk.crossconnectsv2.model.Layer1DeinstallRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.sdk.crossconnectsv2.model.Layer1Details.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.sdk.crossconnectsv2.model.ModifyRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.sdk.crossconnectsv2.model.PatchEquipment.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.sdk.crossconnectsv2.model.PatchPanel.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.sdk.crossconnectsv2.model.PurchaseOrder.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.sdk.crossconnectsv2.model.ZSide.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.sdk.crossconnectsv2.model.ZSideWithLOA.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.equinix.sdk.crossconnectsv2.model.ZSideWithPatchPanel.CustomTypeAdapterFactory()); + gson = gsonBuilder.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); + } + } 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); + } + } + } + + /** + * Deserialize the given JSON InputStream to a Java object. + * + * @param Type + * @param inputStream The JSON InputStream + * @param returnType The type to deserialize into + * @return The deserialized Java object + */ + @SuppressWarnings("unchecked") + public static T deserialize(InputStream inputStream, Type returnType) throws IOException { + try (InputStreamReader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8)) { + if (isLenientOnJson) { + // see https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean) + JsonReader jsonReader = new JsonReader(reader); + jsonReader.setLenient(true); + return gson.fromJson(jsonReader, returnType); + } else { + return gson.fromJson(reader, returnType); + } + } + } + + /** + * 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()); + } + } + + @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(); + } + } + } + + /** + * Gson TypeAdapter for JSR310 OffsetDateTime type + */ + public static class OffsetDateTimeTypeAdapter extends TypeAdapter { + + private DateTimeFormatter formatter; + + public OffsetDateTimeTypeAdapter() { + this(DateTimeFormatter.ISO_OFFSET_DATE_TIME); + } + + public OffsetDateTimeTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, OffsetDateTime date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @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); + } + } + } + + /** + * Gson TypeAdapter for JSR310 LocalDate type + */ + public static class LocalDateTypeAdapter extends TypeAdapter { + + private DateTimeFormatter formatter; + + public LocalDateTypeAdapter() { + this(DateTimeFormatter.ISO_LOCAL_DATE); + } + + public LocalDateTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, LocalDate date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @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); + } + } + } + + public static void setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { + offsetDateTimeTypeAdapter.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 { + + private DateFormat dateFormat; + + public SqlDateTypeAdapter() {} + + public SqlDateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + @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); + } else { + value = date.toString(); + } + out.value(value); + } + } + + @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); + } + } + } + } + + /** + * Gson TypeAdapter for java.util.Date type + * If the dateFormat is null, ISO8601Utils will be used. + */ + public static class DateTypeAdapter extends TypeAdapter { + + private DateFormat dateFormat; + + public DateTypeAdapter() {} + + public DateTypeAdapter(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) { + out.nullValue(); + } else { + String value; + if (dateFormat != null) { + value = dateFormat.format(date); + } else { + value = ISO8601Utils.format(date, true); + } + out.value(value); + } + } + + @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); + } + } + } catch (IllegalArgumentException e) { + throw new JsonParseException(e); + } + } + } + + public static void setDateFormat(DateFormat dateFormat) { + dateTypeAdapter.setFormat(dateFormat); + } + + public static void setSqlDateFormat(DateFormat dateFormat) { + sqlDateTypeAdapter.setFormat(dateFormat); + } +} diff --git a/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/Pair.java b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/Pair.java new file mode 100644 index 00000000..c2709d16 --- /dev/null +++ b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/Pair.java @@ -0,0 +1,37 @@ +/* + * Cross Connect + * A Cross Connect is a physical cable connection that uses a coaxial, fiber or sometimes copper cable to connect customers equipment directly to other customers equipment inside Equinix data centers. Since cross connects transmit data point-to-point between computing systems inside our facility, they are not susceptible to the latency or congestion problems of the public Internet and can be relied upon to operate at consistently high speeds. + * + * The version of the OpenAPI document: 2.0 + * + * + * 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.sdk.crossconnectsv2; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.16.0") +public class Pair { + private final String name; + private final String value; + + public Pair(String name, String value) { + this.name = isValidString(name) ? name : ""; + this.value = isValidString(value) ? value : ""; + } + + public String getName() { + return this.name; + } + + public String getValue() { + return this.value; + } + + private static boolean isValidString(String arg) { + return arg != null; + } +} diff --git a/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/ProgressRequestBody.java b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/ProgressRequestBody.java new file mode 100644 index 00000000..922a7bea --- /dev/null +++ b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/ProgressRequestBody.java @@ -0,0 +1,73 @@ +/* + * Cross Connect + * A Cross Connect is a physical cable connection that uses a coaxial, fiber or sometimes copper cable to connect customers equipment directly to other customers equipment inside Equinix data centers. Since cross connects transmit data point-to-point between computing systems inside our facility, they are not susceptible to the latency or congestion problems of the public Internet and can be relied upon to operate at consistently high speeds. + * + * The version of the OpenAPI document: 2.0 + * + * + * 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.sdk.crossconnectsv2; + +import okhttp3.MediaType; +import okhttp3.RequestBody; + +import java.io.IOException; + +import okio.Buffer; +import okio.BufferedSink; +import okio.ForwardingSink; +import okio.Okio; +import okio.Sink; + +public class ProgressRequestBody extends RequestBody { + + private final RequestBody requestBody; + + private final ApiCallback callback; + + public ProgressRequestBody(RequestBody requestBody, ApiCallback callback) { + this.requestBody = requestBody; + this.callback = callback; + } + + @Override + public MediaType contentType() { + return requestBody.contentType(); + } + + @Override + public long contentLength() throws IOException { + return requestBody.contentLength(); + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + BufferedSink bufferedSink = Okio.buffer(sink(sink)); + requestBody.writeTo(bufferedSink); + bufferedSink.flush(); + } + + private Sink sink(Sink sink) { + return new ForwardingSink(sink) { + + long bytesWritten = 0L; + long contentLength = 0L; + + @Override + public void write(Buffer source, long byteCount) throws IOException { + super.write(source, byteCount); + if (contentLength == 0) { + contentLength = contentLength(); + } + + bytesWritten += byteCount; + callback.onUploadProgress(bytesWritten, contentLength, bytesWritten == contentLength); + } + }; + } +} diff --git a/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/ProgressResponseBody.java b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/ProgressResponseBody.java new file mode 100644 index 00000000..cdcf6382 --- /dev/null +++ b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/ProgressResponseBody.java @@ -0,0 +1,70 @@ +/* + * Cross Connect + * A Cross Connect is a physical cable connection that uses a coaxial, fiber or sometimes copper cable to connect customers equipment directly to other customers equipment inside Equinix data centers. Since cross connects transmit data point-to-point between computing systems inside our facility, they are not susceptible to the latency or congestion problems of the public Internet and can be relied upon to operate at consistently high speeds. + * + * The version of the OpenAPI document: 2.0 + * + * + * 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.sdk.crossconnectsv2; + +import okhttp3.MediaType; +import okhttp3.ResponseBody; + +import java.io.IOException; + +import okio.Buffer; +import okio.BufferedSource; +import okio.ForwardingSource; +import okio.Okio; +import okio.Source; + +public class ProgressResponseBody extends ResponseBody { + + private final ResponseBody responseBody; + private final ApiCallback callback; + private BufferedSource bufferedSource; + + public ProgressResponseBody(ResponseBody responseBody, ApiCallback callback) { + this.responseBody = responseBody; + this.callback = callback; + } + + @Override + public MediaType contentType() { + return responseBody.contentType(); + } + + @Override + public long contentLength() { + return responseBody.contentLength(); + } + + @Override + public BufferedSource source() { + if (bufferedSource == null) { + bufferedSource = Okio.buffer(source(responseBody.source())); + } + return bufferedSource; + } + + private Source source(Source source) { + return new ForwardingSource(source) { + long totalBytesRead = 0L; + + @Override + public long read(Buffer sink, long byteCount) throws IOException { + long bytesRead = super.read(sink, byteCount); + // read() returns the number of bytes read, or -1 if this source is exhausted. + totalBytesRead += bytesRead != -1 ? bytesRead : 0; + callback.onDownloadProgress(totalBytesRead, responseBody.contentLength(), bytesRead == -1); + return bytesRead; + } + }; + } +} diff --git a/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/ServerConfiguration.java b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/ServerConfiguration.java new file mode 100644 index 00000000..02f86ded --- /dev/null +++ b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/ServerConfiguration.java @@ -0,0 +1,72 @@ +/* + * Cross Connect + * A Cross Connect is a physical cable connection that uses a coaxial, fiber or sometimes copper cable to connect customers equipment directly to other customers equipment inside Equinix data centers. Since cross connects transmit data point-to-point between computing systems inside our facility, they are not susceptible to the latency or congestion problems of the public Internet and can be relied upon to operate at consistently high speeds. + * + * The version of the OpenAPI document: 2.0 + * + * + * 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.sdk.crossconnectsv2; + +import java.util.Map; + +/** + * Representing a Server configuration. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.16.0") +public class ServerConfiguration { + public String URL; + public String description; + public Map variables; + + /** + * @param URL A URL to the target host. + * @param description A description of the host designated by the URL. + * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. + */ + public ServerConfiguration(String URL, String description, Map variables) { + this.URL = URL; + this.description = description; + this.variables = variables; + } + + /** + * Format URL template using given variables. + * + * @param variables A map between a variable name and its value. + * @return Formatted URL. + */ + public String URL(Map variables) { + String url = this.URL; + + // go through variables and replace placeholders + for (Map.Entry variable: this.variables.entrySet()) { + String name = variable.getKey(); + ServerVariable serverVariable = variable.getValue(); + String value = serverVariable.defaultValue; + + if (variables != null && variables.containsKey(name)) { + value = variables.get(name); + if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) { + throw new IllegalArgumentException("The variable " + name + " in the server URL has invalid value " + value + "."); + } + } + url = url.replace("{" + name + "}", value); + } + return url; + } + + /** + * Format URL template using default server variables. + * + * @return Formatted URL. + */ + public String URL() { + return URL(null); + } +} diff --git a/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/ServerVariable.java b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/ServerVariable.java new file mode 100644 index 00000000..f65fa130 --- /dev/null +++ b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/ServerVariable.java @@ -0,0 +1,37 @@ +/* + * Cross Connect + * A Cross Connect is a physical cable connection that uses a coaxial, fiber or sometimes copper cable to connect customers equipment directly to other customers equipment inside Equinix data centers. Since cross connects transmit data point-to-point between computing systems inside our facility, they are not susceptible to the latency or congestion problems of the public Internet and can be relied upon to operate at consistently high speeds. + * + * The version of the OpenAPI document: 2.0 + * + * + * 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.sdk.crossconnectsv2; + +import java.util.HashSet; + +/** + * Representing a Server Variable for server URL template substitution. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.16.0") +public class ServerVariable { + public String description; + public String defaultValue; + public HashSet enumValues = null; + + /** + * @param description A description for the server variable. + * @param defaultValue The default value to use for substitution. + * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set. + */ + public ServerVariable(String description, String defaultValue, HashSet enumValues) { + this.description = description; + this.defaultValue = defaultValue; + this.enumValues = enumValues; + } +} diff --git a/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/StringUtil.java b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/StringUtil.java new file mode 100644 index 00000000..30eadd8f --- /dev/null +++ b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/StringUtil.java @@ -0,0 +1,83 @@ +/* + * Cross Connect + * A Cross Connect is a physical cable connection that uses a coaxial, fiber or sometimes copper cable to connect customers equipment directly to other customers equipment inside Equinix data centers. Since cross connects transmit data point-to-point between computing systems inside our facility, they are not susceptible to the latency or congestion problems of the public Internet and can be relied upon to operate at consistently high speeds. + * + * The version of the OpenAPI document: 2.0 + * + * + * 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.sdk.crossconnectsv2; + +import java.util.Collection; +import java.util.Iterator; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.16.0") +public class StringUtil { + /** + * Check if the given array contains the given value (with case-insensitive comparison). + * + * @param array The array + * @param value The value to search + * @return true if the array contains the value + */ + public static boolean containsIgnoreCase(String[] array, String value) { + for (String str : array) { + if (value == null && str == null) { + return true; + } + if (value != null && value.equalsIgnoreCase(str)) { + return true; + } + } + return false; + } + + /** + * Join an array of strings with the given separator. + *

+ * Note: This might be replaced by utility method from commons-lang or guava someday + * if one of those libraries is added as dependency. + *

+ * + * @param array The array of strings + * @param separator The separator + * @return the resulting string + */ + public static String join(String[] array, String separator) { + int len = array.length; + if (len == 0) { + return ""; + } + + StringBuilder out = new StringBuilder(); + out.append(array[0]); + for (int i = 1; i < len; i++) { + out.append(separator).append(array[i]); + } + return out.toString(); + } + + /** + * Join a list of strings with the given separator. + * + * @param list The list of strings + * @param separator The separator + * @return the resulting string + */ + public static String join(Collection list, String separator) { + Iterator iterator = list.iterator(); + StringBuilder out = new StringBuilder(); + if (iterator.hasNext()) { + out.append(iterator.next()); + } + while (iterator.hasNext()) { + out.append(separator).append(iterator.next()); + } + return out.toString(); + } +} diff --git a/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/api/CrossConnectsApi.java b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/api/CrossConnectsApi.java new file mode 100644 index 00000000..1938aa5c --- /dev/null +++ b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/api/CrossConnectsApi.java @@ -0,0 +1,487 @@ +/* + * Cross Connect + * A Cross Connect is a physical cable connection that uses a coaxial, fiber or sometimes copper cable to connect customers equipment directly to other customers equipment inside Equinix data centers. Since cross connects transmit data point-to-point between computing systems inside our facility, they are not susceptible to the latency or congestion problems of the public Internet and can be relied upon to operate at consistently high speeds. + * + * The version of the OpenAPI document: 2.0 + * + * + * 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.sdk.crossconnectsv2.api; + +import com.equinix.sdk.crossconnectsv2.ApiCallback; +import com.equinix.sdk.crossconnectsv2.ApiClient; +import com.equinix.sdk.crossconnectsv2.ApiException; +import com.equinix.sdk.crossconnectsv2.ApiResponse; +import com.equinix.sdk.crossconnectsv2.Configuration; +import com.equinix.sdk.crossconnectsv2.Pair; +import com.equinix.sdk.crossconnectsv2.ProgressRequestBody; +import com.equinix.sdk.crossconnectsv2.ProgressResponseBody; + +import com.google.gson.reflect.TypeToken; + +import java.io.IOException; + + +import com.equinix.sdk.crossconnectsv2.model.ErrorDetails; +import com.equinix.sdk.crossconnectsv2.model.Layer1Create; +import com.equinix.sdk.crossconnectsv2.model.Layer1DeinstallRequest; +import com.equinix.sdk.crossconnectsv2.model.ModifyRequest; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class CrossConnectsApi { + private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; + + public CrossConnectsApi() { + this(Configuration.getDefaultApiClient()); + } + + public CrossConnectsApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + + /** + * Build call for orderCrossConnects + * @param layer1Create (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
201 Layer 1 Created * Location - Location on newly created deinstall request
400 Bad Request -
403 Forbidden -
500 Internal Server Error -
+ */ + public okhttp3.Call orderCrossConnectsCall(@javax.annotation.Nullable Layer1Create layer1Create, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = layer1Create; + + // create path and map variables + String localVarPath = "/colocations/v2/orders/crossConnects"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "BearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call orderCrossConnectsValidateBeforeCall(@javax.annotation.Nullable Layer1Create layer1Create, final ApiCallback _callback) throws ApiException { + return orderCrossConnectsCall(layer1Create, _callback); + + } + + /** + * Order cross connects + * This method creates an order for single or multiple standard cross connects at locations where a user has cross connects ordering permission. + * @param layer1Create (optional) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
201 Layer 1 Created * Location - Location on newly created deinstall request
400 Bad Request -
403 Forbidden -
500 Internal Server Error -
+ */ + public void orderCrossConnects(@javax.annotation.Nullable Layer1Create layer1Create) throws ApiException { + orderCrossConnectsWithHttpInfo(layer1Create); + } + + /** + * Order cross connects + * This method creates an order for single or multiple standard cross connects at locations where a user has cross connects ordering permission. + * @param layer1Create (optional) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
201 Layer 1 Created * Location - Location on newly created deinstall request
400 Bad Request -
403 Forbidden -
500 Internal Server Error -
+ */ + public ApiResponse orderCrossConnectsWithHttpInfo(@javax.annotation.Nullable Layer1Create layer1Create) throws ApiException { + okhttp3.Call localVarCall = orderCrossConnectsValidateBeforeCall(layer1Create, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * Order cross connects (asynchronously) + * This method creates an order for single or multiple standard cross connects at locations where a user has cross connects ordering permission. + * @param layer1Create (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
201 Layer 1 Created * Location - Location on newly created deinstall request
400 Bad Request -
403 Forbidden -
500 Internal Server Error -
+ */ + public okhttp3.Call orderCrossConnectsAsync(@javax.annotation.Nullable Layer1Create layer1Create, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = orderCrossConnectsValidateBeforeCall(layer1Create, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + /** + * Build call for placeCrossConnectDeinstallationOrder + * @param layer1DeinstallRequest (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
201 Layer 1 deinstall requested * Location - Location on newly created deinstall request
400 Bad Request -
403 Forbidden -
500 Internal Server Error -
+ */ + public okhttp3.Call placeCrossConnectDeinstallationOrderCall(@javax.annotation.Nullable Layer1DeinstallRequest layer1DeinstallRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = layer1DeinstallRequest; + + // create path and map variables + String localVarPath = "/colocations/v2/orders/crossConnects/deinstall"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "BearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call placeCrossConnectDeinstallationOrderValidateBeforeCall(@javax.annotation.Nullable Layer1DeinstallRequest layer1DeinstallRequest, final ApiCallback _callback) throws ApiException { + return placeCrossConnectDeinstallationOrderCall(layer1DeinstallRequest, _callback); + + } + + /** + * Place cross connect deinstallation order + * This API allows user to initiate a cross connect deinstallation request. Cross connect asset will be removed according to order placed. + * @param layer1DeinstallRequest (optional) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
201 Layer 1 deinstall requested * Location - Location on newly created deinstall request
400 Bad Request -
403 Forbidden -
500 Internal Server Error -
+ */ + public void placeCrossConnectDeinstallationOrder(@javax.annotation.Nullable Layer1DeinstallRequest layer1DeinstallRequest) throws ApiException { + placeCrossConnectDeinstallationOrderWithHttpInfo(layer1DeinstallRequest); + } + + /** + * Place cross connect deinstallation order + * This API allows user to initiate a cross connect deinstallation request. Cross connect asset will be removed according to order placed. + * @param layer1DeinstallRequest (optional) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
201 Layer 1 deinstall requested * Location - Location on newly created deinstall request
400 Bad Request -
403 Forbidden -
500 Internal Server Error -
+ */ + public ApiResponse placeCrossConnectDeinstallationOrderWithHttpInfo(@javax.annotation.Nullable Layer1DeinstallRequest layer1DeinstallRequest) throws ApiException { + okhttp3.Call localVarCall = placeCrossConnectDeinstallationOrderValidateBeforeCall(layer1DeinstallRequest, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * Place cross connect deinstallation order (asynchronously) + * This API allows user to initiate a cross connect deinstallation request. Cross connect asset will be removed according to order placed. + * @param layer1DeinstallRequest (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
201 Layer 1 deinstall requested * Location - Location on newly created deinstall request
400 Bad Request -
403 Forbidden -
500 Internal Server Error -
+ */ + public okhttp3.Call placeCrossConnectDeinstallationOrderAsync(@javax.annotation.Nullable Layer1DeinstallRequest layer1DeinstallRequest, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = placeCrossConnectDeinstallationOrderValidateBeforeCall(layer1DeinstallRequest, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + /** + * Build call for updateACrossConnectOrder + * @param orderId Identifier of the cross connect order (required) + * @param modifyRequest The cross connect to be updated (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
202 Accepted * Location - Location on newly created deinstall request
204 No content * Location - Location on newly created deinstall request
400 Bad Request -
403 Forbidden -
500 Internal Server Error -
+ */ + public okhttp3.Call updateACrossConnectOrderCall(@javax.annotation.Nonnull String orderId, @javax.annotation.Nonnull ModifyRequest modifyRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = modifyRequest; + + // create path and map variables + String localVarPath = "/colocations/v2/orders/crossConnects/{orderId}" + .replace("{" + "orderId" + "}", localVarApiClient.escapeString(orderId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "BearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call updateACrossConnectOrderValidateBeforeCall(@javax.annotation.Nonnull String orderId, @javax.annotation.Nonnull ModifyRequest modifyRequest, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'orderId' is set + if (orderId == null) { + throw new ApiException("Missing the required parameter 'orderId' when calling updateACrossConnectOrder(Async)"); + } + + // verify the required parameter 'modifyRequest' is set + if (modifyRequest == null) { + throw new ApiException("Missing the required parameter 'modifyRequest' when calling updateACrossConnectOrder(Async)"); + } + + return updateACrossConnectOrderCall(orderId, modifyRequest, _callback); + + } + + /** + * Update a cross connects order + * This method updates a cross connects order by its ID for a user with permission to view this request. + * @param orderId Identifier of the cross connect order (required) + * @param modifyRequest The cross connect to be updated (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
202 Accepted * Location - Location on newly created deinstall request
204 No content * Location - Location on newly created deinstall request
400 Bad Request -
403 Forbidden -
500 Internal Server Error -
+ */ + public void updateACrossConnectOrder(@javax.annotation.Nonnull String orderId, @javax.annotation.Nonnull ModifyRequest modifyRequest) throws ApiException { + updateACrossConnectOrderWithHttpInfo(orderId, modifyRequest); + } + + /** + * Update a cross connects order + * This method updates a cross connects order by its ID for a user with permission to view this request. + * @param orderId Identifier of the cross connect order (required) + * @param modifyRequest The cross connect to be updated (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
202 Accepted * Location - Location on newly created deinstall request
204 No content * Location - Location on newly created deinstall request
400 Bad Request -
403 Forbidden -
500 Internal Server Error -
+ */ + public ApiResponse updateACrossConnectOrderWithHttpInfo(@javax.annotation.Nonnull String orderId, @javax.annotation.Nonnull ModifyRequest modifyRequest) throws ApiException { + okhttp3.Call localVarCall = updateACrossConnectOrderValidateBeforeCall(orderId, modifyRequest, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * Update a cross connects order (asynchronously) + * This method updates a cross connects order by its ID for a user with permission to view this request. + * @param orderId Identifier of the cross connect order (required) + * @param modifyRequest The cross connect to be updated (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
202 Accepted * Location - Location on newly created deinstall request
204 No content * Location - Location on newly created deinstall request
400 Bad Request -
403 Forbidden -
500 Internal Server Error -
+ */ + public okhttp3.Call updateACrossConnectOrderAsync(@javax.annotation.Nonnull String orderId, @javax.annotation.Nonnull ModifyRequest modifyRequest, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = updateACrossConnectOrderValidateBeforeCall(orderId, modifyRequest, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } +} diff --git a/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/auth/ApiKeyAuth.java b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/auth/ApiKeyAuth.java new file mode 100644 index 00000000..f292f4d1 --- /dev/null +++ b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/auth/ApiKeyAuth.java @@ -0,0 +1,80 @@ +/* + * Cross Connect + * A Cross Connect is a physical cable connection that uses a coaxial, fiber or sometimes copper cable to connect customers equipment directly to other customers equipment inside Equinix data centers. Since cross connects transmit data point-to-point between computing systems inside our facility, they are not susceptible to the latency or congestion problems of the public Internet and can be relied upon to operate at consistently high speeds. + * + * The version of the OpenAPI document: 2.0 + * + * + * 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.sdk.crossconnectsv2.auth; + +import com.equinix.sdk.crossconnectsv2.ApiException; +import com.equinix.sdk.crossconnectsv2.Pair; + +import java.net.URI; +import java.util.Map; +import java.util.List; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.16.0") +public class ApiKeyAuth implements Authentication { + private final String location; + private final String paramName; + + private String apiKey; + private String apiKeyPrefix; + + public ApiKeyAuth(String location, String paramName) { + this.location = location; + this.paramName = paramName; + } + + public String getLocation() { + return location; + } + + public String getParamName() { + return paramName; + } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + public String getApiKeyPrefix() { + return apiKeyPrefix; + } + + public void setApiKeyPrefix(String apiKeyPrefix) { + this.apiKeyPrefix = apiKeyPrefix; + } + + @Override + public void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { + if (apiKey == null) { + return; + } + String value; + if (apiKeyPrefix != null) { + value = apiKeyPrefix + " " + apiKey; + } else { + value = apiKey; + } + if ("query".equals(location)) { + queryParams.add(new Pair(paramName, value)); + } else if ("header".equals(location)) { + headerParams.put(paramName, value); + } else if ("cookie".equals(location)) { + cookieParams.put(paramName, value); + } + } +} diff --git a/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/auth/Authentication.java b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/auth/Authentication.java new file mode 100644 index 00000000..e809464a --- /dev/null +++ b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/auth/Authentication.java @@ -0,0 +1,37 @@ +/* + * Cross Connect + * A Cross Connect is a physical cable connection that uses a coaxial, fiber or sometimes copper cable to connect customers equipment directly to other customers equipment inside Equinix data centers. Since cross connects transmit data point-to-point between computing systems inside our facility, they are not susceptible to the latency or congestion problems of the public Internet and can be relied upon to operate at consistently high speeds. + * + * The version of the OpenAPI document: 2.0 + * + * + * 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.sdk.crossconnectsv2.auth; + +import com.equinix.sdk.crossconnectsv2.Pair; +import com.equinix.sdk.crossconnectsv2.ApiException; + +import java.net.URI; +import java.util.Map; +import java.util.List; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.16.0") +public interface Authentication { + /** + * Apply authentication settings to header and query params. + * + * @param queryParams List of query parameters + * @param headerParams Map of header parameters + * @param cookieParams Map of cookie parameters + * @param payload HTTP request body + * @param method HTTP method + * @param uri URI + * @throws ApiException if failed to update the parameters + */ + void applyToParams(List queryParams, Map headerParams, Map cookieParams, String payload, String method, URI uri) throws ApiException; +} diff --git a/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/auth/HttpBasicAuth.java b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/auth/HttpBasicAuth.java new file mode 100644 index 00000000..2957a2c2 --- /dev/null +++ b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/auth/HttpBasicAuth.java @@ -0,0 +1,55 @@ +/* + * Cross Connect + * A Cross Connect is a physical cable connection that uses a coaxial, fiber or sometimes copper cable to connect customers equipment directly to other customers equipment inside Equinix data centers. Since cross connects transmit data point-to-point between computing systems inside our facility, they are not susceptible to the latency or congestion problems of the public Internet and can be relied upon to operate at consistently high speeds. + * + * The version of the OpenAPI document: 2.0 + * + * + * 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.sdk.crossconnectsv2.auth; + +import com.equinix.sdk.crossconnectsv2.Pair; +import com.equinix.sdk.crossconnectsv2.ApiException; + +import okhttp3.Credentials; + +import java.net.URI; +import java.util.Map; +import java.util.List; + +public class HttpBasicAuth implements Authentication { + private String username; + private String password; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @Override + public void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { + if (username == null && password == null) { + return; + } + headerParams.put("Authorization", Credentials.basic( + username == null ? "" : username, + password == null ? "" : password)); + } +} diff --git a/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/auth/HttpBearerAuth.java b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/auth/HttpBearerAuth.java new file mode 100644 index 00000000..0913a3a9 --- /dev/null +++ b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/auth/HttpBearerAuth.java @@ -0,0 +1,75 @@ +/* + * Cross Connect + * A Cross Connect is a physical cable connection that uses a coaxial, fiber or sometimes copper cable to connect customers equipment directly to other customers equipment inside Equinix data centers. Since cross connects transmit data point-to-point between computing systems inside our facility, they are not susceptible to the latency or congestion problems of the public Internet and can be relied upon to operate at consistently high speeds. + * + * The version of the OpenAPI document: 2.0 + * + * + * 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.sdk.crossconnectsv2.auth; + +import com.equinix.sdk.crossconnectsv2.ApiException; +import com.equinix.sdk.crossconnectsv2.Pair; + +import java.net.URI; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.function.Supplier; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.16.0") +public class HttpBearerAuth implements Authentication { + private final String scheme; + private Supplier tokenSupplier; + + public HttpBearerAuth(String scheme) { + this.scheme = scheme; + } + + /** + * Gets the token, which together with the scheme, will be sent as the value of the Authorization header. + * + * @return The bearer token + */ + public String getBearerToken() { + return tokenSupplier.get(); + } + + /** + * Sets the token, which together with the scheme, will be sent as the value of the Authorization header. + * + * @param bearerToken The bearer token to send in the Authorization header + */ + public void setBearerToken(String bearerToken) { + this.tokenSupplier = () -> bearerToken; + } + + /** + * Sets the supplier of tokens, which together with the scheme, will be sent as the value of the Authorization header. + * + * @param tokenSupplier The supplier of bearer tokens to send in the Authorization header + */ + public void setBearerToken(Supplier tokenSupplier) { + this.tokenSupplier = tokenSupplier; + } + + @Override + public void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { + String bearerToken = Optional.ofNullable(tokenSupplier).map(Supplier::get).orElse(null); + if (bearerToken == null) { + return; + } + + headerParams.put("Authorization", (scheme != null ? upperCaseBearer(scheme) + " " : "") + bearerToken); + } + + private static String upperCaseBearer(String scheme) { + return ("bearer".equalsIgnoreCase(scheme)) ? "Bearer" : scheme; + } +} diff --git a/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/model/ASide.java b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/model/ASide.java new file mode 100644 index 00000000..19aabf94 --- /dev/null +++ b/services/crossconnectsv2/src/main/java/com/equinix/sdk/crossconnectsv2/model/ASide.java @@ -0,0 +1,496 @@ +/* + * Cross Connect + * A Cross Connect is a physical cable connection that uses a coaxial, fiber or sometimes copper cable to connect customers equipment directly to other customers equipment inside Equinix data centers. Since cross connects transmit data point-to-point between computing systems inside our facility, they are not susceptible to the latency or congestion problems of the public Internet and can be relied upon to operate at consistently high speeds. + * + * The version of the OpenAPI document: 2.0 + * + * + * 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.sdk.crossconnectsv2.model; + +import java.util.Objects; +import java.util.Locale; +import com.equinix.sdk.crossconnectsv2.model.ConnectionServices; +import com.equinix.sdk.crossconnectsv2.model.ConnectorTypes; +import com.equinix.sdk.crossconnectsv2.model.MediaTypes; +import com.equinix.sdk.crossconnectsv2.model.PatchEquipment; +import com.equinix.sdk.crossconnectsv2.model.PatchPanel; +import com.equinix.sdk.crossconnectsv2.model.ProtocolTypes; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Locale; + +import com.equinix.sdk.crossconnectsv2.JSON; + +/** + * A-Side source patch panel to establish connection to another customer. Connections Service , Media Type and Protocol Type is mandatory to establish new connection. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.16.0") +public class ASide { + public static final String SERIALIZED_NAME_PATCH_PANEL = "patchPanel"; + @SerializedName(SERIALIZED_NAME_PATCH_PANEL) + @javax.annotation.Nonnull + private PatchPanel patchPanel; + + public static final String SERIALIZED_NAME_CONNECTION_SERVICE = "connectionService"; + @SerializedName(SERIALIZED_NAME_CONNECTION_SERVICE) + @javax.annotation.Nonnull + private ConnectionServices connectionService; + + public static final String SERIALIZED_NAME_MEDIA_TYPE = "mediaType"; + @SerializedName(SERIALIZED_NAME_MEDIA_TYPE) + @javax.annotation.Nonnull + private MediaTypes mediaType; + + public static final String SERIALIZED_NAME_PROTOCOL_TYPE = "protocolType"; + @SerializedName(SERIALIZED_NAME_PROTOCOL_TYPE) + @javax.annotation.Nonnull + private ProtocolTypes protocolType; + + public static final String SERIALIZED_NAME_CONNECTOR_TYPE = "connectorType"; + @SerializedName(SERIALIZED_NAME_CONNECTOR_TYPE) + @javax.annotation.Nonnull + private ConnectorTypes connectorType; + + public static final String SERIALIZED_NAME_MEDIA_CONVERTER_REQUIRED = "mediaConverterRequired"; + @SerializedName(SERIALIZED_NAME_MEDIA_CONVERTER_REQUIRED) + @javax.annotation.Nullable + private Boolean mediaConverterRequired; + + public static final String SERIALIZED_NAME_IFC_CIRCUIT_COUNT = "ifcCircuitCount"; + @SerializedName(SERIALIZED_NAME_IFC_CIRCUIT_COUNT) + @javax.annotation.Nullable + private Integer ifcCircuitCount; + + public static final String SERIALIZED_NAME_PATCH_EQUIPMENT = "patchEquipment"; + @SerializedName(SERIALIZED_NAME_PATCH_EQUIPMENT) + @javax.annotation.Nullable + private PatchEquipment patchEquipment; + + public ASide() { + } + + public ASide patchPanel(@javax.annotation.Nonnull PatchPanel patchPanel) { + this.patchPanel = patchPanel; + return this; + } + + /** + * Get patchPanel + * @return patchPanel + */ + @javax.annotation.Nonnull + public PatchPanel getPatchPanel() { + return patchPanel; + } + + public void setPatchPanel(@javax.annotation.Nonnull PatchPanel patchPanel) { + this.patchPanel = patchPanel; + } + + + public ASide connectionService(@javax.annotation.Nonnull ConnectionServices connectionService) { + this.connectionService = connectionService; + return this; + } + + /** + * Get connectionService + * @return connectionService + */ + @javax.annotation.Nonnull + public ConnectionServices getConnectionService() { + return connectionService; + } + + public void setConnectionService(@javax.annotation.Nonnull ConnectionServices connectionService) { + this.connectionService = connectionService; + } + + + public ASide mediaType(@javax.annotation.Nonnull MediaTypes mediaType) { + this.mediaType = mediaType; + return this; + } + + /** + * Get mediaType + * @return mediaType + */ + @javax.annotation.Nonnull + public MediaTypes getMediaType() { + return mediaType; + } + + public void setMediaType(@javax.annotation.Nonnull MediaTypes mediaType) { + this.mediaType = mediaType; + } + + + public ASide protocolType(@javax.annotation.Nonnull ProtocolTypes protocolType) { + this.protocolType = protocolType; + return this; + } + + /** + * Get protocolType + * @return protocolType + */ + @javax.annotation.Nonnull + public ProtocolTypes getProtocolType() { + return protocolType; + } + + public void setProtocolType(@javax.annotation.Nonnull ProtocolTypes protocolType) { + this.protocolType = protocolType; + } + + + public ASide connectorType(@javax.annotation.Nonnull ConnectorTypes connectorType) { + this.connectorType = connectorType; + return this; + } + + /** + * Get connectorType + * @return connectorType + */ + @javax.annotation.Nonnull + public ConnectorTypes getConnectorType() { + return connectorType; + } + + public void setConnectorType(@javax.annotation.Nonnull ConnectorTypes connectorType) { + this.connectorType = connectorType; + } + + + public ASide mediaConverterRequired(@javax.annotation.Nullable Boolean mediaConverterRequired) { + this.mediaConverterRequired = mediaConverterRequired; + return this; + } + + /** + * When `false`, Equinix will not proceed with cross connect installation that requires media conversion + * @return mediaConverterRequired + */ + @javax.annotation.Nullable + public Boolean getMediaConverterRequired() { + return mediaConverterRequired; + } + + public void setMediaConverterRequired(@javax.annotation.Nullable Boolean mediaConverterRequired) { + this.mediaConverterRequired = mediaConverterRequired; + } + + + public ASide ifcCircuitCount(@javax.annotation.Nullable Integer ifcCircuitCount) { + this.ifcCircuitCount = ifcCircuitCount; + return this; + } + + /** + * Use this field to request an intra-facility cable IFC with this order. Note that there might be a delay in fulfilment of Cross Connect as it is pending intra facility cabling + * minimum: 1 + * maximum: 48 + * @return ifcCircuitCount + */ + @javax.annotation.Nullable + public Integer getIfcCircuitCount() { + return ifcCircuitCount; + } + + public void setIfcCircuitCount(@javax.annotation.Nullable Integer ifcCircuitCount) { + this.ifcCircuitCount = ifcCircuitCount; + } + + + public ASide patchEquipment(@javax.annotation.Nullable PatchEquipment patchEquipment) { + this.patchEquipment = patchEquipment; + return this; + } + + /** + * Get patchEquipment + * @return patchEquipment + */ + @javax.annotation.Nullable + public PatchEquipment getPatchEquipment() { + return patchEquipment; + } + + public void setPatchEquipment(@javax.annotation.Nullable PatchEquipment patchEquipment) { + this.patchEquipment = patchEquipment; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ASide instance itself + */ + public ASide putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ASide aSide = (ASide) o; + return Objects.equals(this.patchPanel, aSide.patchPanel) && + Objects.equals(this.connectionService, aSide.connectionService) && + Objects.equals(this.mediaType, aSide.mediaType) && + Objects.equals(this.protocolType, aSide.protocolType) && + Objects.equals(this.connectorType, aSide.connectorType) && + Objects.equals(this.mediaConverterRequired, aSide.mediaConverterRequired) && + Objects.equals(this.ifcCircuitCount, aSide.ifcCircuitCount) && + Objects.equals(this.patchEquipment, aSide.patchEquipment)&& + Objects.equals(this.additionalProperties, aSide.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(patchPanel, connectionService, mediaType, protocolType, connectorType, mediaConverterRequired, ifcCircuitCount, patchEquipment, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ASide {\n"); + sb.append(" patchPanel: ").append(toIndentedString(patchPanel)).append("\n"); + sb.append(" connectionService: ").append(toIndentedString(connectionService)).append("\n"); + sb.append(" mediaType: ").append(toIndentedString(mediaType)).append("\n"); + sb.append(" protocolType: ").append(toIndentedString(protocolType)).append("\n"); + sb.append(" connectorType: ").append(toIndentedString(connectorType)).append("\n"); + sb.append(" mediaConverterRequired: ").append(toIndentedString(mediaConverterRequired)).append("\n"); + sb.append(" ifcCircuitCount: ").append(toIndentedString(ifcCircuitCount)).append("\n"); + sb.append(" patchEquipment: ").append(toIndentedString(patchEquipment)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("patchPanel", "connectionService", "mediaType", "protocolType", "connectorType", "mediaConverterRequired", "ifcCircuitCount", "patchEquipment")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("patchPanel", "connectionService", "mediaType", "protocolType", "connectorType")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ASide + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ASide.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ASide is not found in the empty JSON string", ASide.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ASide.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `patchPanel` + PatchPanel.validateJsonElement(jsonObj.get("patchPanel")); + // validate the required field `connectionService` + ConnectionServices.validateJsonElement(jsonObj.get("connectionService")); + // validate the required field `mediaType` + MediaTypes.validateJsonElement(jsonObj.get("mediaType")); + // validate the required field `protocolType` + ProtocolTypes.validateJsonElement(jsonObj.get("protocolType")); + // validate the required field `connectorType` + ConnectorTypes.validateJsonElement(jsonObj.get("connectorType")); + // validate the optional field `patchEquipment` + if (jsonObj.get("patchEquipment") != null && !jsonObj.get("patchEquipment").isJsonNull()) { + PatchEquipment.validateJsonElement(jsonObj.get("patchEquipment")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ASide.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ASide' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter