#Saagie Java Client
Saagie Java Client is a library to easily call Saagie Manager.
All the code is written in Kotling and uses an HTTPClient (khttp) to call Saagie Manager.
###:warning: NOT READY FOR PRODUCTION NOW (and not available on Maven Central) #Versions
For each version of the manager, we update and release the library to add new features. Be sure to use the same version of the library as your Saagie Manager (version is available in the footer)
#Output formats
We decide to deliver 3 output formats :
- raw (i.e. java.lang.String)
- json (a org.json.JSONObject or a org.json.JSONArray)
- object (using our DTO included in this library)
Why ?
Because depending your need, you can use the format you want in your application.
#Examples
3 SaagieClient are availables :
- SaagieClientRaw to deliver raw
- SaagieClientJson to deliver json objects
- SaagieClient to deliver DTO objects
You can easily create these clients using their constructor (of course just create client you need):
SaagieClientRaw saagieClientRaw = new SaagieClientRaw();
SaagieClientJson saagieClientJson = new SaagieClientJson();
SaagieClient saagieClient = new SaagieClient();
By default, all are connected to Saagie Kumo (our cloud), if you want to connect in your Saagie Su (our appliance), your can specify the URL of the manager :
saagieClient.setBaseURL("https://your-saagie-manager-url/api/v1");
You have to set your credentials to use the Saagie Client.
saagieClient.setUser("login");
saagieClient.setPassword("password");
By default a timeout is set to 20 seconds, you can override the value (in seconds).
saagieClient.setTimeout(10.0) will set the timeout at 10 seconds
For example, to list all the platform you have access, this is the code of a simple application :
import io.saagie.client.SaagieClient;
import io.saagie.client.SaagieClientJson;
import io.saagie.client.SaagieClientRaw;
import io.saagie.client.dto.platform.Platform;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.List;
public class TestSaagieClient {
public static void main(String[] args) {
// Create a SaagieClientRaw
SaagieClientRaw saagieClientRaw = new SaagieClientRaw();
saagieClientRaw.setUser("login");
saagieClientRaw.setPassword("password");
// Use the SaagieClientRaw to display all platforms
String allPlatformsRaw = saagieClientRaw.getAllPlatforms();
System.out.println(allPlatformsRaw);
// Create a SaagieClientJson
SaagieClientJson saagieClientJson = new SaagieClientJson();
saagieClientJson.setUser("login");
saagieClientJson.setPassword("password");
// Use the SaagieClientJson to deplay all platforms
JSONArray allPlatformsJson = saagieClientJson.getAllPlatforms();
System.out.println(allPlatformsJson);
// Create a SaagieClient
SaagieClient saagieClient = new SaagieClient();
saagieClient.setUser("login");
saagieClient.setPassword("password");
// Use the SaagieClientJson to deplay all platforms
List<Platform> allPlatformsObject = saagieClient.getAllPlatforms();
System.out.println(allPlatformsObject);
}
}
Documentation coming soon
##Include it via maven/gradle
If your Saagie Manager is in version v1.2.0 (build 632), use the SaagieJavaClient in version 1.2.X ###Maven
<dependency>
<groupId>io.saagie</groupId>
<artifactId>saagieclient</artifactId>
<version>1.2.0</version>
</dependency>
###Gradle
dependencies {
testCompile 'io.saagie:saagieclient:1.2.0'
}