Git Product home page Git Product logo

tcpshield-java-api-wrapper's Introduction

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:

public class NetworkSetup {

    private final APIClient apiClient = new APIClientImpl("APIKEY"); // create an instance of the API Client
    
    public void setup(String networkName, String backend, String domainName) {
        List<Network> networks = apiClient.getNetworks(); // fetches all networks

        int networkID;
        int domainID;

        Optional<Network> foundNetwork = networks.stream().filter(network -> network.getName().equals("TestNetwork")).findAny(); // checks if any networks with the name "TestNetwork" exist

        if (foundNetwork.isPresent()) { // network found
            Network network = foundNetwork.get();
            networkID = network.getID();

            Domain foundDomain = apiClient.getDomains(networkID).stream().filter(domain -> domain.getName().equals(domainName)).findAny().orElseThrow(IllegalStateException::new); // gets the ID of the domain
            domainID = foundDomain.getID();
        } else { // no network found
            networkID = apiClient.addNetwork("TestNetwork").getData().getNetworkID(); // adds the network
            int backendSetID = apiClient.addBackendSet(networkID, networkName + " Set", backend).getData().getID(); // adds the backend set
            domainID = apiClient.addDomain(networkID, domainName, backendSetID, false).getData().getID(); // adds the domain
        }

        if (apiClient.verify(networkID, domainID)) { // verifies the domain; true if successful, false if not
            System.out.println("Successfully created the network.");
        } else {
            Network network = apiClient.getNetwork(networkID); // fetches the network in order to get the TXT verification string

            System.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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.