eqixiacEquinix Infrastructure as Code

Get started with the OpenCapacity client Proposal

Create an OpenCapacity client for one provider, read what the provider supports, list its locations, and send a first query.

What you will do#

You create an OpenCapacity client for one provider, read the capabilities of the provider, list its metros, and ask whether it can meet a requirement. The calls are reads and one query. They create nothing at the provider.

The client is in the package com.eqixiac.opencapacity, in the same Maven artifact as the rest of the SDK. Its model types are in com.eqixiac.opencapacity.model.

Prerequisites#

  • A JDK, version 21 or later, and the SDK. See Install the SDK.
  • The host of an OpenCapacity provider, and a client ID and client secret for that provider. Until a provider implements OpenCapacity, that host is a test provider.

Step 1: Create the client#

The following example creates a client for one provider:

Java
import com.eqixiac.opencapacity.OpenCapacity;

OpenCapacity capacity = OpenCapacity.builder()
    .endpoint("https://provider.example")
    .credentials("CLIENT_ID", "CLIENT_SECRET")
    .build();

The client has no default host. You give it the host of the provider and credentials for that provider.

The client adds the path of each operation to the host. It reads the paths from an endpoint catalog in the SDK jar, json/apiParams_OpenCapacity.json, which has the format of the catalogs of the Equinix clients. The catalog names no host, because no provider implements the specification. endpoint also accepts a URL that ends in /capacity/v1.

The client is separate from the Equinix session. It never sends an Equinix token to another host, and it never sends the token of one provider to any other host.

build() refuses an endpoint that isn't HTTPS, except on localhost.

Step 2: Read the capabilities#

The following example reads what the provider supports:

Java
import com.eqixiac.opencapacity.model.Capabilities;
import com.eqixiac.opencapacity.model.ConformanceClass;

Capabilities capabilities = capacity.capabilities();
System.out.println(capabilities.provider().name());
System.out.println("signals: " + capabilities.supports(ConformanceClass.SIGNALS));
System.out.println("subscriptions: " + capabilities.supports(ConformanceClass.SUBSCRIPTIONS));
System.out.println("areas: " + capabilities.acceptsAreas());

Step 3: List the locations#

A metro, campus, or facility code is the provider's own code. The following example prints the metros that the provider names:

Java
import com.eqixiac.opencapacity.model.LocationInfo;
import com.eqixiac.opencapacity.model.LocationLevel;

for (LocationInfo metro : capacity.locations().list(LocationLevel.METRO)) {
    System.out.println(metro.code() + " " + metro.name());
}

Step 4: Ask a query#

The following example asks for 40 cabinets at 5 to 100 kVA per cabinet in the metro FR, usable by June 2027, with liquid cooling required:

Java
import com.eqixiac.opencapacity.model.CapacityAnswer;
import com.eqixiac.opencapacity.model.CapacityRequirement;
import com.eqixiac.opencapacity.model.DensityRange;
import com.eqixiac.opencapacity.model.Feature;
import com.eqixiac.opencapacity.model.FlexibleDate;
import com.eqixiac.opencapacity.model.Location;
import com.eqixiac.opencapacity.model.LocationResult;

CapacityRequirement requirement = CapacityRequirement.define()
    .addLocation(Location.metro("FR"))
    .cabinets(40)
    .density(DensityRange.kva().min(5).target(8).max(100).create())
    .neededForService(FlexibleDate.month(2027, 6))
    .addFeature(Feature.LIQUID_COOLING, true)      // true: a hard constraint
    .create();

CapacityAnswer answer = capacity.queries().ask(requirement);
for (LocationResult result : answer.results()) {
    System.out.println(result.location().code() + " " + result.grade()
        + ", liquid cooling " + result.supportedFeature(Feature.LIQUID_COOLING).support());
}

Expected output#

Step 2 prints the name of the provider and three lines with true or false. Step 3 prints one line per metro, with its code and name. Step 4 prints one line per location in the answer, with its grade and the grade of liquid cooling.

If a request fails, the client throws OpenCapacityException. See Handle an error.

Clean up#

A query creates nothing. The provider doesn't keep it. There is nothing to delete.

Next steps#