This is a Java wrapper for the official TCPShield API.
This wrapper supports every documented API endpoint, as seen in the API Documentation.
Download the latest build from our CI and the latest Jackson Databind and add them both to your buildpath.
Using build automation tools like Gradle or Maven streamlines the usage of our API.
see https://jitpack.io/#TCPShield/TCPShield-Java-API-Wrapper/-SNAPSHOT
Simple example of setting up a network from scratch:
publicclassNetworkSetup {
privatefinalAPIClientapiClient = newAPIClientImpl("APIKEY"); // create an instance of the API Clientpublicvoidsetup(StringnetworkName, Stringbackend, StringdomainName) {
List<Network> networks = apiClient.getNetworks(); // fetches all networksintnetworkID;
intdomainID;
Optional<Network> foundNetwork = networks.stream().filter(network -> network.getName().equals("TestNetwork")).findAny(); // checks if any networks with the name "TestNetwork" existif (foundNetwork.isPresent()) { // network foundNetworknetwork = foundNetwork.get();
networkID = network.getID();
DomainfoundDomain = apiClient.getDomains(networkID).stream().filter(domain -> domain.getName().equals(domainName)).findAny().orElseThrow(IllegalStateException::new); // gets the ID of the domaindomainID = foundDomain.getID();
} else { // no network foundnetworkID = apiClient.addNetwork("TestNetwork").getData().getNetworkID(); // adds the networkintbackendSetID = apiClient.addBackendSet(networkID, networkName + " Set", backend).getData().getID(); // adds the backend setdomainID = apiClient.addDomain(networkID, domainName, backendSetID, false).getData().getID(); // adds the domain
}
if (apiClient.verify(networkID, domainID)) { // verifies the domain; true if successful, false if notSystem.out.println("Successfully created the network.");
} else {
Networknetwork = apiClient.getNetwork(networkID); // fetches the network in order to get the TXT verification stringSystem.out.println("Create a TXT record on @ with \"" + network.getTXTVerification() + "\" and re-run the program.");
}
}
}If any help with the usage of the API is needed, feel free to contact us on our Discord.
We're more than happy to accept contributions! We welcome pull requests with open arms.
In order to get testing to work, follow the instructions outlined here.
- adding a repository for build tools like Gradle and Maven
- adding documentation