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

com.heanbian.block.zabbix.api.ZabbixHostCreateRequest Maven / Gradle / Ivy

There is a newer version: 1.0.8
Show newest version
package com.heanbian.block.zabbix.api;

import static java.util.stream.Collectors.toList;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ZabbixHostCreateRequest {

	// "Template Module Generic SNMP" "10204"
	// "Templates/Modules" "8"
	// 启用
	public ZabbixHostCreateRequest() {
		this.setTemplateIds("10204").setGroupsIds("8").available(1);
	}

	private Map params = new HashMap<>();

	public Map getParams() {
		return params;
	}

	public ZabbixHostCreateRequest setHost(String host) {
		this.params.put("host", host);
		return this;
	}

	/**
	 * 
	 * @param available 0 - (default) unknown; 1 - available; 2 - unavailable.
	 * @return ZabbixHostCreateRequest
	 */
	public ZabbixHostCreateRequest available(int available) {
		this.params.put("available", available);
		return this;
	}

	public ZabbixHostCreateRequest setInterface(ZabbixInterface interfaces) {
		return this.setInterfaces(Arrays.asList(interfaces));
	}

	public ZabbixHostCreateRequest setInterfaces(List interfaces) {
		this.params.put("interfaces", interfaces);
		return this;
	}

	public ZabbixHostCreateRequest setGroupsIds(String... groupids) {
		return this.setGroups(Arrays.asList(groupids).stream().map(ZabbixGroupId::new).collect(toList()));
	}

	public ZabbixHostCreateRequest setGroups(List groups) {
		this.params.put("groups", groups);
		return this;
	}

	public ZabbixHostCreateRequest setTags(List tags) {
		this.params.put("tags", tags);
		return this;
	}

	public ZabbixHostCreateRequest setTemplateIds(String... templateids) {
		return this.setTemplates(Arrays.asList(templateids).stream().map(ZabbixTemplateId::new).collect(toList()));
	}

	public ZabbixHostCreateRequest setTemplates(List templates) {
		this.params.put("templates", templates);
		return this;
	}

	public ZabbixHostCreateRequest setMacros(List macros) {
		this.params.put("macros", macros);
		return this;
	}

	public ZabbixHostCreateRequest setInventoryMode(int inventoryMode) {
		this.params.put("inventory_mode", inventoryMode);
		return this;
	}

	public ZabbixHostCreateRequest setInventory(String macaddress_a, String macaddress_b) {
		Map inventory = new HashMap<>(2);
		inventory.put("macaddress_a", macaddress_a);
		inventory.put("macaddress_b", macaddress_b);

		this.params.put("inventory", inventory);
		return this;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy