eqixiacEquinix Infrastructure as Code

Query capacity Proposal

Use the OpenCapacity client to write a capacity requirement, ask a provider whether it can be met, read the graded answer, and handle an error.

Prerequisites#

Ask for cabinets at a density#

The following example creates a client, asks for 40 cabinets in two alternative locations with one party that must be present in the metro, and gives the query your own reference:

Java
import com.eqixiac.opencapacity.OpenCapacity;
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.InterconnectionScope;
import com.eqixiac.opencapacity.model.Location;
import com.eqixiac.opencapacity.model.Party;

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

CapacityRequirement cabinets = CapacityRequirement.define()
    .addLocation(Location.metro("FR"))
    .addLocation(Location.country("NL"))
    .cabinets(40)
    .density(DensityRange.kva().min(5).target(8).max(100).create())
    .contiguous(true)
    .neededForSale(FlexibleDate.quarter(2026, 4))
    .neededForService(FlexibleDate.month(2027, 6))
    .termMonths(60)
    .addFeature(Feature.LIQUID_COOLING, true)
    .addFeature(Feature.PRIVATE_CAGE, false)
    .addInterconnection(Party.asn(64500), InterconnectionScope.METRO, true)
    .create();

CapacityAnswer answer = capacity.queries().ask(cabinets, "example-query-1");

addFeature and addInterconnection take a required flag. It has no default. true is a hard constraint, and false is a preference.

Ask for power alone#

For a need that isn't yet expressed in cabinets, state the power. The following example asks for 12 MW in EMEA, or within 50 km of a point, in two steps during 2028:

Java
import com.eqixiac.opencapacity.model.Power;

CapacityRequirement power = CapacityRequirement.define()
    .addLocation(Location.region("EMEA"))
    .addLocation(Location.within(50.11, 8.68, 50))      // latitude, longitude, radius in km
    .power(Power.mw(12))
    .neededForService(FlexibleDate.year(2028))
    .addRampStep(FlexibleDate.day(2028, 1, 1), 50)      // cumulative percent
    .addRampStep(FlexibleDate.day(2028, 7, 1), 100)
    .addFeature(Feature.DIRECT_TO_CHIP_COOLING, true)
    .create();

CapacityAnswer powerAnswer = capacity.queries().ask(power);

A provider that doesn't accept areas rejects Location.within(...). To find out first, call capabilities().acceptsAreas().

Read the answer#

The following example prints the best grade of the answer, each location with its reasons, and the locations that are graded AVAILABLE:

Java
import com.eqixiac.opencapacity.model.Grade;
import com.eqixiac.opencapacity.model.LocationResult;

System.out.println(answer.grade() + ", valid until " + answer.validUntil());

for (LocationResult result : answer.results()) {
    System.out.println(result.location().code() + " " + result.grade() + " " + result.reasons());
    System.out.println("  liquid cooling: " + result.supportedFeature(Feature.LIQUID_COOLING).support());
    System.out.println("  party present: " + result.presenceOf(Party.asn(64500)));
    if (result.cabinets() != null) {
        System.out.println("  cabinets: " + result.cabinets());
    }
}

for (LocationResult available : answer.resultsGraded(Grade.AVAILABLE)) {
    System.out.println("available in " + available.location().code());
}

Every band and every date in a result is optional. timing(), density(), cabinets(), and power() return null when the provider doesn't disclose them.

An answer is an indication. It isn't an offer, a quote, or a reservation. It expires at validUntil(). To check, call answer.isExpired(Instant.now()).

Handle an error#

A failed request throws OpenCapacityException. The following example prints the status, the error code, and each field error of a rejected query:

Java
import com.eqixiac.opencapacity.OpenCapacityException;

try {
    capacity.queries().ask(power);
} catch (OpenCapacityException e) {
    System.err.println(e.status() + " " + e.code().orElse("no code"));
    e.problem().ifPresent(problem ->
        problem.errors().forEach(error -> System.err.println(error.pointer() + ": " + error.detail())));
}

The client doesn't retry a request. The one exception is a 401: the client gets a new token and repeats the request once.

For the error codes, see Error codes.