
com.zabbix4j.template.Template Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Zabbix4j Show documentation
Show all versions of Zabbix4j Show documentation
Zabbix API library for the Java language.
The newest version!
package com.zabbix4j.template;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.zabbix4j.ZabbixApiException;
import com.zabbix4j.ZabbixApiMethod;
/**
* @author Suguru Yajima
*/
public class Template extends ZabbixApiMethod {
public Template(String apiUrl, String auth) {
super(apiUrl, auth);
}
public TemplateCreateResponse create(TemplateCreateRequest request) throws ZabbixApiException {
TemplateCreateResponse response = null;
request.setAuth(auth);
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String requestJson = gson.toJson(request);
try {
String responseJson = sendRequest(requestJson);
response = gson.fromJson(responseJson, TemplateCreateResponse.class);
} catch (ZabbixApiException e) {
throw new ZabbixApiException(e);
}
return response;
}
public TemplateDeleteResponse delete(TemplateDeleteRequest request) throws ZabbixApiException {
TemplateDeleteResponse response = null;
request.setAuth(auth);
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String requestJson = gson.toJson(request);
try {
String responseJson = sendRequest(requestJson);
response = gson.fromJson(responseJson, TemplateDeleteResponse.class);
} catch (ZabbixApiException e) {
throw new ZabbixApiException(e);
}
return response;
}
public TemplateUpdateResponse update(TemplateUpdateRequest request) throws ZabbixApiException {
TemplateUpdateResponse response = null;
request.setAuth(auth);
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String requestJson = gson.toJson(request);
try {
String responseJson = sendRequest(requestJson);
response = gson.fromJson(responseJson, TemplateUpdateResponse.class);
} catch (ZabbixApiException e) {
throw new ZabbixApiException(e);
}
return response;
}
public TemplateGetResponse get(TemplateGetRequest request) throws ZabbixApiException {
TemplateGetResponse response = null;
request.setAuth(auth);
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String requestJson = gson.toJson(request);
try {
String responseJson = sendRequest(requestJson);
response = gson.fromJson(responseJson, TemplateGetResponse.class);
} catch (ZabbixApiException e) {
throw new ZabbixApiException(e);
}
return response;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy