package com.lanyuanxiaoyao.service.web.entity;

import com.fasterxml.jackson.annotation.JsonProperty;
import org.eclipse.collections.api.list.ImmutableList;
import org.eclipse.collections.api.map.ImmutableMap;

/**
 * @author lanyuanxiaoyao
 * @date 2023-04-30
 */
public class CloudServiceVO {
    private final String name;
    @JsonProperty("children")
    private final ImmutableList<Service> services;

    public CloudServiceVO(String name, ImmutableList<Service> services) {
        this.name = name;
        this.services = services;
    }

    public String getName() {
        return name;
    }

    public ImmutableList<Service> getServices() {
        return services;
    }

    @Override
    public String toString() {
        return "CloudServiceVO{" +
                "name='" + name + '\'' +
                ", services=" + services +
                '}';
    }

    public static final class Service {
        @JsonProperty("name")
        private final String instanceId;
        private final String serviceId;
        private final String host;
        private final Integer port;
        private final Boolean secure;
        private final String url;
        private final ImmutableMap<String, String> metadata;

        private String actionType;
        private String status;
        private Long updateTime;
        private Integer duration;
        private Long registrationTime;
        private Long lastRenewalTime;
        private Long evictionTime;
        private Long serviceUpTime;

        public Service(String instanceId, String serviceId, String host, Integer port, Boolean secure, String url, ImmutableMap<String, String> metadata) {
            this.instanceId = instanceId;
            this.serviceId = serviceId;
            this.host = host;
            this.port = port;
            this.secure = secure;
            this.url = url;
            this.metadata = metadata;
        }

        public String getInstanceId() {
            return instanceId;
        }

        public String getServiceId() {
            return serviceId;
        }

        public String getHost() {
            return host;
        }

        public Integer getPort() {
            return port;
        }

        public Boolean isSecure() {
            return secure;
        }

        public String getUrl() {
            return url;
        }

        public ImmutableMap<String, String> getMetadata() {
            return metadata;
        }

        public String getActionType() {
            return actionType;
        }

        public void setActionType(String actionType) {
            this.actionType = actionType;
        }

        public String getStatus() {
            return status;
        }

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

        public Long getUpdateTime() {
            return updateTime;
        }

        public void setUpdateTime(Long updateTime) {
            this.updateTime = updateTime;
        }

        public Integer getDuration() {
            return duration;
        }

        public void setDuration(Integer duration) {
            this.duration = duration;
        }

        public Long getRegistrationTime() {
            return registrationTime;
        }

        public void setRegistrationTime(Long registrationTime) {
            this.registrationTime = registrationTime;
        }

        public Long getLastRenewalTime() {
            return lastRenewalTime;
        }

        public void setLastRenewalTime(Long lastRenewalTime) {
            this.lastRenewalTime = lastRenewalTime;
        }

        public Long getEvictionTime() {
            return evictionTime;
        }

        public void setEvictionTime(Long evictionTime) {
            this.evictionTime = evictionTime;
        }

        public Long getServiceUpTime() {
            return serviceUpTime;
        }

        public void setServiceUpTime(Long serviceUpTime) {
            this.serviceUpTime = serviceUpTime;
        }

        @Override
        public String toString() {
            return "Service{" +
                    "instanceId='" + instanceId + '\'' +
                    ", serviceId='" + serviceId + '\'' +
                    ", host='" + host + '\'' +
                    ", port=" + port +
                    ", secure=" + secure +
                    ", url='" + url + '\'' +
                    ", metadata=" + metadata +
                    ", actionType='" + actionType + '\'' +
                    ", status='" + status + '\'' +
                    ", updateTime='" + updateTime + '\'' +
                    '}';
        }
    }
}
