Create, amend, and delete a signal Proposal
Use the OpenCapacity client to record a capacity requirement with a provider as a standing need, read its state and answer, amend it, withdraw it, and delete it.
Prerequisites#
- An
OpenCapacityclient for a provider that supports signals. To check, callcapabilities().supports(ConformanceClass.SIGNALS). See Get started with the OpenCapacity client.
Create a signal#
The following example creates a client and records a need of 40 cabinets and 800 kVA in the metro FR, for the provider's planning only, with a contact:
import com.eqixiac.opencapacity.OpenCapacity;
import com.eqixiac.opencapacity.Signal;
import com.eqixiac.opencapacity.model.CapacityRequirement;
import com.eqixiac.opencapacity.model.Confidence;
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.Power;
import com.eqixiac.opencapacity.model.Sharing;
OpenCapacity capacity = OpenCapacity.builder()
.endpoint("https://provider.example")
.credentials("CLIENT_ID", "CLIENT_SECRET")
.build();
CapacityRequirement requirement = CapacityRequirement.define()
.addLocation(Location.metro("FR"))
.power(Power.kva(800))
.cabinets(40)
.density(DensityRange.kva().target(20).create())
.neededForService(FlexibleDate.day(2027, 6, 1))
.addFeature(Feature.LIQUID_COOLING, true)
.create();
Signal signal = capacity.signals().define(requirement)
.reference("example-signal-1")
.confidence(Confidence.PLANNED)
.sharing(Sharing.NONE)
.contact("Network Operations", "noc@example.com")
.create();
System.out.println(signal.id() + " " + signal.state() + " revision " + signal.revision());A new signal has the state RECEIVED and the revision 1.
Read the state and the answer#
The following example reads the signal again and prints the answer of the provider, where the provider gives one:
signal.refresh();
System.out.println(signal.state());
signal.answer().ifPresent(answer -> System.out.println(answer.grade() + " until " + answer.validUntil()));To read a signal by its ID, call capacity.signals().get(signalId). To list your signals, call capacity.signals().list(), or list(SignalState) for one state.
Amend a signal#
To change a signal, call update(), set the new values, and call save(). The following example raises the demand to 60 cabinets and 1,200 kVA:
CapacityRequirement larger = signal.requirement().toBuilder()
.power(Power.kva(1200))
.cabinets(60)
.create();
signal.update()
.requirement(larger)
.confidence(Confidence.FUNDED)
.save();save() replaces the part of the signal that you supply. The revision increases by one, and the state returns to RECEIVED.
save() sends the version that the signal had when you read it. If the signal changed at the provider since then, the provider answers 412, and the client throws OpenCapacityException. Call refresh() and repeat the change.
A signal in the state CLOSED or EXPIRED can't be amended. The provider answers 409.
Withdraw a signal#
To end the need and keep the record, withdraw the signal. The following example withdraws a signal and then makes it active again:
signal.withdraw();
System.out.println(signal.state() + " active: " + signal.isActive());
signal.update().save(); // an amend makes a withdrawn signal active againDelete a signal#
The following example removes the signal from the API:
signal.delete();
System.out.println(signal.isDeleted());After a delete, a read of the signal returns 404, and subscriptions that follow the signal expire.
Related pages#
- For signal states and confidentiality, see Signals and subscriptions.
- To follow the answer to a signal, see Subscribe to capacity events.
- For the requests and responses behind these calls, see Signal examples.