APIClient add postInt

Sometimes a post command need to return, this adds a method to perform a
post command that returns an int value.

The general postGetVal, can be used for other types if needed.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
This commit is contained in:
Amnon Heiman 2015-08-27 20:44:24 +03:00
parent 35e5b22746
commit 6fc2c5c720

View File

@ -75,6 +75,21 @@ public class APIClient {
post(path, null);
}
public String postGetVal(String path, MultivaluedMap<String, String> queryParams) {
if (queryParams != null) {
return get(path, queryParams).post(String.class);
}
return get(path).post(String.class);
}
public int postInt(String path, MultivaluedMap<String, String> queryParams) {
return Integer.parseInt(postGetVal(path, queryParams));
}
public int postInt(String path) {
return postInt(path, null);
}
public void delete(String path, MultivaluedMap<String, String> queryParams) {
if (queryParams != null) {
get(path, queryParams).delete();