
com.zabbix4j.maintenance.Maintenance 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.maintenance;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.zabbix4j.ZabbixApiException;
import com.zabbix4j.ZabbixApiMethod;
/**
* @author Suguru Yajima
*/
public class Maintenance extends ZabbixApiMethod {
public Maintenance(String apiUrl, String auth) {
super(apiUrl, auth);
}
public MaintenanceCreateResponse create(MaintenanceCreateRequest request) throws ZabbixApiException {
MaintenanceCreateResponse 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, MaintenanceCreateResponse.class);
} catch (ZabbixApiException e) {
throw new ZabbixApiException(e);
}
return response;
}
public MaintenanceDeleteResponse delete(MaintenanceDeleteRequest request) throws ZabbixApiException {
MaintenanceDeleteResponse 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, MaintenanceDeleteResponse.class);
} catch (ZabbixApiException e) {
throw new ZabbixApiException(e);
}
return response;
}
public MaintenanceUpdateResponse update(MaintenanceUpdateRequest request) throws ZabbixApiException {
MaintenanceUpdateResponse 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, MaintenanceUpdateResponse.class);
} catch (ZabbixApiException e) {
throw new ZabbixApiException(e);
}
return response;
}
public MaintenanceGetResponse get(MaintenanceGetRequest request) throws ZabbixApiException {
MaintenanceGetResponse 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, MaintenanceGetResponse.class);
} catch (ZabbixApiException e) {
throw new ZabbixApiException(e);
}
return response;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy