package com.bocloud.ims.entity.middleware;

import com.bocloud.common.utils.DateSerializer;
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;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.List;

/**
 * K8s集群服务
 * 
 * @author weiwei
 *
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Table("k8s_cluster")
public class K8sCluster extends GenericEntity {

	@PK(PKStrategy.AUTO)
	private Long id;// ID
	@Column("uuid")
	private String uuid;// UID
	@Column("instance_id")
	private String instanceId;
	@Column("type")
	private String type;// 数据库类型(MYSQL,ORACLE)
	@Column("category")
	private String category;// 部署类型
	@Column("version")
	private String version;// 数据库版本
	@Column("sku_id")
	private Long skuId;// 商品规格
	@Column("network_id")
	private Long networkId;// 网络ID
	@Column("region")
	private String region;// 所属域
	@Column("tenant_id")
	private Long tenantId;// 所属租户
	@Column("inventory")
	private String inventory;
	@Column("category_id")
	private Long categoryId; // 类型ID
	@Column("spec")
	private String spec; // 配置
	@Column("address")
	private String address;
	@Column("username")
	private String username;
	@Column("password")
	private String password;
	@Column("manage_ip")
	private String manageIp;
	@IgnoreAll
	private List<K8sNode> nodes;
	@IgnoreAll
	@JsonSerialize(using = DateSerializer.class)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date expiredTime;// 过期时间
	@IgnoreAll
	private String categoryName;

	/**
	 * 
	 * @param uuid
	 * @param type
	 * @param version
	 * @param skuId
	 * @param networkId
	 * @param region
	 * @param tenantId
	 */
	public K8sCluster(String uuid, String type, String version, Long skuId, Long networkId, String region,
			Long tenantId) {
		super();
		this.uuid = uuid;
		this.type = type;
		this.version = version;
		this.skuId = skuId;
		this.networkId = networkId;
		this.region = region;
		this.tenantId = tenantId;
	}
}
