package com.bocloud.cmp.model.powervc;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.bocloud.cmp.model.HealthStatus;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

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

/**
 * powervc中使用的hmc主机信息
 *
 * @author lkx007
 */
public class PowervcHmcHostModel {
    /**
     * hmc host ip
     * <p>
     * 1.2.3.4
     */
    @JSONField(name = "access_ip")
    private String ip;
    /**
     * hmc user id
     * <p>
     * hscroot
     */
    @JSONField(name = "user_id")
    private String username;
    /**
     * hmc password
     * <p>
     * abc123
     */
    @JSONField(name = "password")
    private String password;
    /**
     * hmc host display name
     */
    @JSONField(name = "hmc_display_name")
    private String name;
    /**
     * 可选值。
     * <p>
     * 是自动接受或添加系统的 X.509 证书
     * <p>
     * （如果指纹尚不可信或者不同于先前的可信指纹），还是失败，响应码为 403，以便可以验证该证书。缺省值为 True。
     */
    @JSONField(name = "auto_add_certificate")
    private Boolean addCert;
    /**
     * 新增hmc后，powervc回传的hmc的uuid
     */
    @JSONField(name = "hmc_uuid")
    private String uuid;
    @JSONField(name = "managed_hosts")
    private List<String> managedHosts;
    /**
     * V687-f59 7644505
     */
    @JSONField(name = "mtmsn")
    private String mtmsn;
    /**
     * 2018-12-25T08:22:44.000000
     */
    @JSONField(name = "registered_at", format = "yyyy-MM-dd'T'HH:mm:ss.SSSSSS")
    private Date gmtCreate;
    @JSONField(name = "health_status")
    private HealthStatus status;

    public PowervcHmcHostModel() {
    }

    /**
     * @return the ip
     */
    public String getIp() {
        return ip;
    }

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

    /**
     * @return the username
     */
    public String getUsername() {
        return username;
    }

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

    /**
     * @return the password
     */
    public String getPassword() {
        return password;
    }

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

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

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

    /**
     * @return the addCert
     */
    public Boolean getAddCert() {
        return addCert;
    }

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

    /**
     * @return the uuid
     */
    @JSONField(name = "hmc_uuid")
    public String getUuid() {
        return uuid;
    }

    /**
     * @param uuid the uuid to set
     */
    @JSONField(name = "hmc_uuid")
    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public List<String> getManagedHosts() {
        return managedHosts;
    }

    public void setManagedHosts(List<String> managedHosts) {
        this.managedHosts = managedHosts;
    }

    public String getMtmsn() {
        return mtmsn;
    }

    public void setMtmsn(String mtmsn) {
        this.mtmsn = mtmsn;
    }

    public Date getGmtCreate() {
        return gmtCreate;
    }

    public void setGmtCreate(Date gmtCreate) {
        this.gmtCreate = gmtCreate;
    }

    public HealthStatus getStatus() {
        return status;
    }

    public void setStatus(HealthStatus status) {
        this.status = status;
    }

    @Override
    public String toString() {
        try {
            return new ObjectMapper().writeValueAsString(this);
        } catch (JsonProcessingException e) {
            return JSONObject.toJSONString(this);
        }
    }
}
