}
public Rule getRule(UserCredentials userCredentials, String key) {
Map<String, Object> params=new HashMap<>();
params.put("key", key);
HttpRequestFactory httpRequestFactory = new HttpRequestFactory(baseUrl);
if(userCredentials != null) {
httpRequestFactory.setLogin(userCredentials.getUsername()).setPassword(PassEncoder.decodeAsString(userCredentials.getPassword()));
}
String jsonRule = httpRequestFactory.get("/api/rules/show", params);
try{
JsonElement jsonElement = new JsonParser().parse(new StringReader(jsonRule));
JsonObject rule = (JsonObject) ((JsonObject)jsonElement).get("rule");
Rule rule1 = new Rule();
rule1.setKey(rule.get("key").getAsString());