
com.zabbix4j.itservice.ITService 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.
package com.zabbix4j.itservice;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.zabbix4j.ZabbixApiException;
import com.zabbix4j.ZabbixApiMethod;
/**
* @author Suguru Yajima
*/
public class ITService extends ZabbixApiMethod {
public ITService(String apiUrl, String auth) {
super(apiUrl, auth);
}
public ITServiceCreateResponse create(ITServiceCreateRequest request) throws ZabbixApiException {
ITServiceCreateResponse 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, ITServiceCreateResponse.class);
} catch (ZabbixApiException e) {
throw new ZabbixApiException(e);
}
return response;
}
public ITServiceDeleteResponse delete(ITServiceDeleteRequest request) throws ZabbixApiException {
ITServiceDeleteResponse 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, ITServiceDeleteResponse.class);
} catch (ZabbixApiException e) {
throw new ZabbixApiException(e);
}
return response;
}
public ITServiceUpdateResponse update(ITServiceUpdateRequest request) throws ZabbixApiException {
ITServiceUpdateResponse 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, ITServiceUpdateResponse.class);
} catch (ZabbixApiException e) {
throw new ZabbixApiException(e);
}
return response;
}
public ITServiceGetResponse get(ITServiceGetRequest request) throws ZabbixApiException {
ITServiceGetResponse 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, ITServiceGetResponse.class);
} catch (ZabbixApiException e) {
throw new ZabbixApiException(e);
}
return response;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy