Get started with the SDK
Make a first request to the Equinix Fabric API. The request lists the Fabric metros and creates nothing.
What you will do#
You create a Fabric client with the credentials of an API client, list the Fabric metros, and print the code and name of each metro. The request is a read. It creates no resource and has no cost.
Prerequisites#
- A JDK, version 21 or later.
- A project that has the SDK as a dependency. See Install the SDK.
- The client ID and client secret of an application created in the Equinix Developer Platform. See Authentication.
Step 1: Create a client#
Create a Fabric client from your client ID and client secret. Replace CLIENT_ID and CLIENT_SECRET with your values:
import com.eqixiac.equinix.Fabric;
import com.eqixiac.equinix.core.auth.BasicEquinixCredentials;
import com.eqixiac.equinix.fabric.model.Metro;
Fabric fabric = new Fabric(new BasicEquinixCredentials("CLIENT_ID", "CLIENT_SECRET"));The constructor sends nothing. The SDK requests an OAuth token on the first call.
Step 2: List the metros#
Call metros().list() and print each metro:
for (Metro metro : fabric.metros().list()) {
System.out.println(metro.metroId() + " " + metro.getName());
}Expected output#
The program prints one line for each Fabric metro. Each line has the metro code and the metro name.
If the credentials are wrong, the SDK throws an exception. To read it, see Errors.
Clean up#
The program creates nothing in your Equinix account. There is nothing to delete.
Next steps#
- To use several API domains with one token, see Sessions and configuration.
- To learn the method names that every resource shares, see Design patterns.
- To validate a create request without creating anything, see Dry run.
- To create a Fabric connection, see Connections.