package com.bocloud.cmp.model.powervc;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.List;

/**
 * powervc中管理和未管理的云主机信息
 *
 * @author tanshaolong
 */
public class PowervcHmcServerModel {
    /**
     * 云主机状态
     */
    @JSONField(name = "status")
    private String status;
    /**
     * 云主机是否管理
     */
    @JSONField(name = "managed")
    private Boolean managed;
    /**
     * 云主机的名称
     */
    @JSONField(name = "name")
    private String name;

    public static class ServerSupport {
        /**
         * 云主机支持管理的状态
         */
        @JSONField(name = "status")
        private String status;
        /**
         * 云主机不支持管理的原因
         */
        @JSONField(name = "reasons")
        private List<String> reasons;

        public ServerSupport() {
        }

        public String getStatus() {
            return status;
        }

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

        public List<String> getReasons() {
            return reasons;
        }

        public void setReasons(List<String> reasons) {
            this.reasons = reasons;
        }

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

    /**
     * 云主机支持管理的状态
     */
    @JSONField(name = "support")
    private ServerSupport support;
    /**
     * 云主机的uuid
     */
    @JSONField(name = "id")
    private String uuid;

    public PowervcHmcServerModel() {
    }

    public String getStatus() {
        return status;
    }

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

    public Boolean getManaged() {
        return managed;
    }

    public void setManaged(Boolean managed) {
        this.managed = managed;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public ServerSupport getSupport() {
        return support;
    }

    public void setSupport(ServerSupport support) {
        this.support = support;
    }

    @JSONField(name = "id")
    public String getUuid() {
        return uuid;
    }

    @JSONField(name = "id")
    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

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