See: Description
| Package | Description |
|---|---|
| com.brkt.client | |
| com.brkt.client.util |
The Bracket Java SDK is a Java library for interacting with the Bracket
REST API. The caller has the flexibility of making high-level calls that
return Java objects, or lower-level calls that return the response payload
as a Map of JSON elements or byte[].
Here's some sample code that updates the name of a billing group:
String rootUri = "http://10.95.0.10";
String macKey = "6e08558938f346038c61716ccb98dacf";
String accessToken = "60435a8b84104e25bbe13ad7b63f8695";
BrktRestClient client = new BrktRestClient.Builder(rootUri)
.macKey(macKey).accessToken(accessToken).build();
BrktService service = new BrktService(client);
BillingGroup engineering = null;
for (BillingGroup bg : service.getAllBillingGroups()) {
if (bg.getName().equals("Engineering")) {
engineering = bg;
}
}
if (engineering != null) {
Map<String, Object> attrs = new BillingGroupRequestBuilder()
.name("Product Development").build();
service.updateBillingGroup(engineering.getId(), attrs);
}
BrktHttpClient is an HTTP-level interface to
the Bracket service. It uses BrktAuth to
generate the Authorization OAuth2 header based on the user's MAC key and
access token.
BrktRestClient is a higher-level client.
It accepts a request as a Java Map and uses the Gson library to
deserialize the server response to a plain Java object.
BrktService contains high-level methods for
interacting with the Bracket service.
The Bracket Java SDK JAR file is executable. This allows you
to exercise the code in BrktService from the command
line. You can find the CLI code in Main.
~/test/brkt-sdk-java (master)$ java -jar ./target/brkt-sdk-java-1.0-SNAPSHOT.jar --token 60435a8b84104e25bbe13ad7b63f8695 --key 6e08558938f346038c61716ccb98dacf --root-uri http://10.95.0.10 getAllWorkloads
Workload{id=828196b0675f4ef78f858a51321040a9, name=NUC-7407b, requestedState=AVAILABLE}
Workload{id=9d1bbef921b5486a9bf991b4460131b5, name=NUC-7407c, requestedState=AVAILABLE}
Workload{id=442c8ad633994ee28fbf998a175cf5b9, name=NUC-7461a, requestedState=AVAILABLE}
Copyright © 2015. All rights reserved.