package com.bocloud.ims.entity.resource;

import com.bocloud.entity.annotations.Column;
import com.bocloud.entity.annotations.IgnoreAll;
import com.bocloud.entity.annotations.PK;
import com.bocloud.entity.annotations.Table;
import com.bocloud.entity.bean.GenericEntity;
import com.bocloud.entity.meta.PKStrategy;

/**
 * 防火墙规则实体类
 *
 * @author wangyu
 * @version 1.0
 * @since 2017年8月29日
 */
@Table("firewall_rule")
public class FirewallRule extends GenericEntity {

	@PK(PKStrategy.AUTO)
	private Long id;// ID
	@Column("rule_uuid")
	private String ruleUuid;// 规则ID
	@Column("tenant_uuid")
	private String tenantUuid;// 租户ID
	@Column("policy_id")
	private Long policyId;// 绑定的策略ID
	@Column("policy_uuid")
	private String policyUuid;// 绑定的策略UUID
	@Column("is_shared")
	private Boolean shared;// 是否共享
	@Column("protocol")
	private String protocol;// 协议
	@Column("ip_version")
	private String ipVersion;// IP版本
	@Column("source_ip")
	private String sourceIp;// 源IP或子网(CIDR)
	@Column("vendor_type")
	private String vendorType;// 源IP或子网(CIDR)
	@Column("dest_ip")
	private String destIp;// 目的IP或子网(CIDR)
	@Column("source_port")
	private String sourcePort;// 源端口/端口范围(范围用":"分隔)
	@Column("dest_port")
	private String destPort;// 目的端口/端口范围(范围用":"分隔)
	@Column("position")
	private Integer position;// 该规则在与防火墙策略关联时,position为在策略中的位置，值从1开始,如果没有绑定任何策略,则值为null
	@Column("action")
	private String action;// 是否执行规则(ALLOW允许/DENY不允许/UNRECOGNIZED无法识别)
	@Column("is_enabled")
	private Boolean enabled;// 规则是否激活
	@Column("vendor_id")
	private Long vendorId;// 云平台ID
	@Column("tenant_id")
	private Long tenantId;// 租户ID
	@Column("project_id")
	private Long projectId;// 项目ID
	@IgnoreAll
	private String policyName;// 绑定的策略名称
	@IgnoreAll
	private String vendorName;
	@IgnoreAll
	private String tenantName;// 所属租户
	@IgnoreAll
	private String projectName;
	@IgnoreAll
	private String osTenantName;// openstack租户id

	@IgnoreAll
	private String type; // 是否前置 或 后置
	@IgnoreAll
	private String referRuleId; // 参照ruleId

	@Column("firewall_id")
	private Long firewallId;
	@Column("firewall_uuid")
	private String firewallUuid;

	public FirewallRule() {
		super();
	}

	public void preSave(Long creatorId, Long menderId, Long vendorId, Long tenantId, Long projectId) {
		this.setCreatorId(creatorId);
		this.setMenderId(menderId);
		this.setVendorId(vendorId);
		this.setTenantId(tenantId);
		this.setProjectId(projectId);
	}

	/**
	 * @param ruleUuid
	 * @param tenantUuid
	 * @param policyId
	 * @param policyUuid
	 * @param shared
	 * @param protocol
	 * @param ipVersion
	 * @param sourceIp
	 * @param destIp
	 * @param sourcePort
	 * @param destPort
	 * @param position
	 * @param action
	 * @param enabled
	 * @param vendorId
	 */
	public FirewallRule(String ruleUuid, String tenantUuid, Long policyId, String policyUuid, Boolean shared,
			String protocol, String ipVersion, String sourceIp, String destIp, String sourcePort, String destPort,
			Integer position, String action, Boolean enabled, Long vendorId) {
		super();
		this.ruleUuid = ruleUuid;
		this.tenantUuid = tenantUuid;
		this.policyId = policyId;
		this.policyUuid = policyUuid;
		this.shared = shared;
		this.protocol = protocol;
		this.ipVersion = ipVersion;
		this.sourceIp = sourceIp;
		this.destIp = destIp;
		this.sourcePort = sourcePort;
		this.destPort = destPort;
		this.position = position;
		this.action = action;
		this.enabled = enabled;
		this.vendorId = vendorId;
	}

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the ruleUuid
	 */
	public String getRuleUuid() {
		return ruleUuid;
	}

	/**
	 * @param ruleUuid
	 *            the ruleUuid to set
	 */
	public void setRuleUuid(String ruleUuid) {
		this.ruleUuid = ruleUuid;
	}

	/**
	 * @return the tenantUuid
	 */
	public String getTenantUuid() {
		return tenantUuid;
	}

	/**
	 * @param tenantUuid
	 *            the tenantUuid to set
	 */
	public void setTenantUuid(String tenantUuid) {
		this.tenantUuid = tenantUuid;
	}

	/**
	 * @return the policyId
	 */
	public Long getPolicyId() {
		return policyId;
	}

	/**
	 * @param policyId
	 *            the policyId to set
	 */
	public void setPolicyId(Long policyId) {
		this.policyId = policyId;
	}

	/**
	 * @return the policyUuid
	 */
	public String getPolicyUuid() {
		return policyUuid;
	}

	/**
	 * @param policyUuid
	 *            the policyUuid to set
	 */
	public void setPolicyUuid(String policyUuid) {
		this.policyUuid = policyUuid;
	}

	/**
	 * @return the shared
	 */
	public Boolean getShared() {
		return shared;
	}

	/**
	 * @param shared
	 *            the shared to set
	 */
	public void setShared(Boolean shared) {
		this.shared = shared;
	}

	/**
	 * @return the protocol
	 */
	public String getProtocol() {
		return protocol;
	}

	/**
	 * @param protocol
	 *            the protocol to set
	 */
	public void setProtocol(String protocol) {
		this.protocol = protocol;
	}

	/**
	 * @return the ipVersion
	 */
	public String getIpVersion() {
		return ipVersion;
	}

	/**
	 * @param ipVersion
	 *            the ipVersion to set
	 */
	public void setIpVersion(String ipVersion) {
		this.ipVersion = ipVersion;
	}

	/**
	 * @return the sourceIp
	 */
	public String getSourceIp() {
		return sourceIp;
	}

	/**
	 * @param sourceIp
	 *            the sourceIp to set
	 */
	public void setSourceIp(String sourceIp) {
		this.sourceIp = sourceIp;
	}

	/**
	 * @return the destIp
	 */
	public String getDestIp() {
		return destIp;
	}

	/**
	 * @param destIp
	 *            the destIp to set
	 */
	public void setDestIp(String destIp) {
		this.destIp = destIp;
	}

	/**
	 * @return the sourcePort
	 */
	public String getSourcePort() {
		return sourcePort;
	}

	/**
	 * @param sourcePort
	 *            the sourcePort to set
	 */
	public void setSourcePort(String sourcePort) {
		this.sourcePort = sourcePort;
	}

	/**
	 * @return the destPort
	 */
	public String getDestPort() {
		return destPort;
	}

	/**
	 * @param destPort
	 *            the destPort to set
	 */
	public void setDestPort(String destPort) {
		this.destPort = destPort;
	}

	/**
	 * @return the position
	 */
	public Integer getPosition() {
		return position;
	}

	/**
	 * @param position
	 *            the position to set
	 */
	public void setPosition(Integer position) {
		this.position = position;
	}

	/**
	 * @return the action
	 */
	public String getAction() {
		return action;
	}

	/**
	 * @param action
	 *            the action to set
	 */
	public void setAction(String action) {
		this.action = action;
	}

	/**
	 * @return the enabled
	 */
	public Boolean getEnabled() {
		return enabled;
	}

	/**
	 * @param enabled
	 *            the enabled to set
	 */
	public void setEnabled(Boolean enabled) {
		this.enabled = enabled;
	}

	/**
	 * @return the vendorId
	 */
	public Long getVendorId() {
		return vendorId;
	}

	/**
	 * @param vendorId
	 *            the vendorId to set
	 */
	public void setVendorId(Long vendorId) {
		this.vendorId = vendorId;
	}

	/**
	 * @return the policyName
	 */
	public String getPolicyName() {
		return policyName;
	}

	/**
	 * @param policyName
	 *            the policyName to set
	 */
	public void setPolicyName(String policyName) {
		this.policyName = policyName;
	}

	/**
	 * @return the vendorName
	 */
	public String getVendorName() {
		return vendorName;
	}

	/**
	 * @param vendorName
	 *            the vendorName to set
	 */
	public void setVendorName(String vendorName) {
		this.vendorName = vendorName;
	}

	/**
	 * @return the tenantId
	 */
	public Long getTenantId() {
		return tenantId;
	}

	/**
	 * @param tenantId
	 *            the tenantId to set
	 */
	public void setTenantId(Long tenantId) {
		this.tenantId = tenantId;
	}

	/**
	 * @return the tenantName
	 */
	public String getTenantName() {
		return tenantName;
	}

	/**
	 * @param tenantName
	 *            the tenantName to set
	 */
	public void setTenantName(String tenantName) {
		this.tenantName = tenantName;
	}

	/**
	 * @return the projectId
	 */
	public Long getProjectId() {
		return projectId;
	}

	/**
	 * @param projectId
	 *            the projectId to set
	 */
	public void setProjectId(Long projectId) {
		this.projectId = projectId;
	}

	public String getProjectName() {
		return projectName;
	}

	public void setProjectName(String projectName) {
		this.projectName = projectName;
	}

	public String getOsTenantName() {
		return osTenantName;
	}

	public void setOsTenantName(String osTenantName) {
		this.osTenantName = osTenantName;
	}

	public Long getFirewallId() {
		return firewallId;
	}

	public void setFirewallId(Long firewallId) {
		this.firewallId = firewallId;
	}

	public String getFirewallUuid() {
		return firewallUuid;
	}

	public void setFirewallUuid(String firewallUuid) {
		this.firewallUuid = firewallUuid;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getReferRuleId() {
		return referRuleId;
	}

	public void setReferRuleId(String referRuleId) {
		this.referRuleId = referRuleId;
	}

	public String getVendorType() {
		return vendorType;
	}

	public void setVendorType(String vendorType) {
		this.vendorType = vendorType;
	}

}
