Skip to content

Latest commit

History

28 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

TCPShield API Wrapper

Build badge

This is a Java wrapper for the official TCPShield API.
This wrapper supports every documented API endpoint, as seen in the API Documentation.

Download

Option 1: Standalone Jar

Download the latest build from our CI and the latest Jackson Databind and add them both to your buildpath.

Option 2: Build automation tools

Using build automation tools like Gradle or Maven streamlines the usage of our API.

see https://jitpack.io/#TCPShield/TCPShield-Java-API-Wrapper/-SNAPSHOT

Example

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.");
}
}
}

Support

If any help with the usage of the API is needed, feel free to contact us on our Discord.

Used Libraries

Contributions

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.

ToDo

  • adding a repository for build tools like Gradle and Maven
  • adding documentation

Contributors

Languages