package com.bocloud.ims.entity.resource;

import com.alibaba.fastjson.annotation.JSONField;
import com.bocloud.common.utils.DaySerializer;
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.Data;

import org.springframework.format.annotation.DateTimeFormat;

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

/**
 * 密钥类
 *
 * @author wangyu
 * @version 1.0
 * @since 2017年10月12日
 */
@Table("keypair")
@Data
public class Keypair extends GenericEntity {

	@PK(value = PKStrategy.AUTO)
	private Long id;// ID
	@Column("fingerprint")
	private String fingerprint;// 指纹
	@Column("public_key")
	private String publicKey;// 公钥
	@Column("user_uuid")
	private String userUuid;// 用户UUID(远端传回)
	@Column("vendor_id")
	private Long vendorId;// 云平台ID
	@Column("tenant_id")
	private Long tenantId;// 租户ID
	@Column("project_id")
	private Long projectId;
	@Column("private_key")
	@JSONField(serialize = false)
	private String privateKey;// 私钥
	@JsonSerialize(using = DaySerializer.class)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column("create_time")
	private Date createTime;// 创建时间
	//azure
	@Column("resource_group_id")
	private Long resourceGroupId;
	@IgnoreAll
	private String tenantName;// 所属租户
	@IgnoreAll
	private String vendorName;// 平台名称
	@IgnoreAll
	private String projectName;// 所属项目名称
	@IgnoreAll
	private String projectVisibility;
	@Column("region_id")
	private String regionId;
	@IgnoreAll
	private Integer instancesCount;
	@IgnoreAll
	private String regionName;
	@IgnoreAll
	private String privateKeyContent;

	@Column("resource_group_uuid")
	private String resourceGroupUuid; // 资源组ID
	@IgnoreAll
	private String resourceGroupName;

	@IgnoreAll
	private List<Long> serverIds;

	/**
	 *
	 */
	public Keypair() {
		super();
	}

	/**
	 * @param fingerprint
	 * @param publicKey
	 * @param userUuid
	 * @param vendorId
	 * @param tenantId
	 */
	public Keypair(String fingerprint, String publicKey, String userUuid, Long vendorId, Long tenantId) {
		super();
		this.fingerprint = fingerprint;
		this.publicKey = publicKey;
		this.userUuid = userUuid;
		this.vendorId = vendorId;
		this.tenantId = tenantId;
	}

}
