All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.zabbix4j.templatescreen.TemplateScreen Maven / Gradle / Ivy

There is a newer version: 0.1.9
Show newest version
package com.zabbix4j.templatescreen;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.zabbix4j.ZabbixApiException;
import com.zabbix4j.ZabbixApiMethod;

/**
 * @author Suguru Yajima
 */
public class TemplateScreen extends ZabbixApiMethod {
    public TemplateScreen(String apiUrl, String auth) {
        super(apiUrl, auth);
    }

    public TemplateScreenCreateResponse create(TemplateScreenCreateRequest request) throws ZabbixApiException {
        TemplateScreenCreateResponse 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, TemplateScreenCreateResponse.class);
        } catch (ZabbixApiException e) {
            throw new ZabbixApiException(e);
        }

        return response;
    }

    public TemplateScreenDeleteResponse delete(TemplateScreenDeleteRequest request) throws ZabbixApiException {
        TemplateScreenDeleteResponse 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, TemplateScreenDeleteResponse.class);
        } catch (ZabbixApiException e) {
            throw new ZabbixApiException(e);
        }

        return response;
    }

    public TemplateScreenUpdateResponse update(TemplateScreenUpdateRequest request) throws ZabbixApiException {
        TemplateScreenUpdateResponse 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, TemplateScreenUpdateResponse.class);
        } catch (ZabbixApiException e) {
            throw new ZabbixApiException(e);
        }

        return response;
    }

    public TemplateScreenGetResponse get(TemplateScreenGetRequest request) throws ZabbixApiException {
        TemplateScreenGetResponse 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, TemplateScreenGetResponse.class);
        } catch (ZabbixApiException e) {
            throw new ZabbixApiException(e);
        }

        return response;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy