package com.eactive.eai.manage.inflow;

import java.util.List;

public class GroupBucketStatusDTO {
    private String groupId;
    private String groupName;
    private boolean activate;
    private List<BucketInfo> buckets;

    public static class BucketInfo {
        private String type;           // "perSecond" | "threshold"
        private long capacity;         // 최대 토큰 수
        private long availableTokens;  // 현재 사용 가능한 토큰 수
        private String timeUnit;       // threshold인 경우 시간 단위
        private double usagePercent;   // 사용률 (100 - availableTokens/capacity * 100)

        public BucketInfo() {}

        public BucketInfo(String type, long capacity, long availableTokens, String timeUnit) {
            this.type = type;
            this.capacity = capacity;
            this.availableTokens = availableTokens;
            this.timeUnit = timeUnit;
            this.usagePercent = capacity > 0 ?
                Math.round((1.0 - (double) availableTokens / capacity) * 10000) / 100.0 : 0;
        }

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public long getCapacity() {
            return capacity;
        }

        public void setCapacity(long capacity) {
            this.capacity = capacity;
        }

        public long getAvailableTokens() {
            return availableTokens;
        }

        public void setAvailableTokens(long availableTokens) {
            this.availableTokens = availableTokens;
        }

        public String getTimeUnit() {
            return timeUnit;
        }

        public void setTimeUnit(String timeUnit) {
            this.timeUnit = timeUnit;
        }

        public double getUsagePercent() {
            return usagePercent;
        }

        public void setUsagePercent(double usagePercent) {
            this.usagePercent = usagePercent;
        }
    }

    public String getGroupId() {
        return groupId;
    }

    public void setGroupId(String groupId) {
        this.groupId = groupId;
    }

    public String getGroupName() {
        return groupName;
    }

    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }

    public boolean isActivate() {
        return activate;
    }

    public void setActivate(boolean activate) {
        this.activate = activate;
    }

    public List<BucketInfo> getBuckets() {
        return buckets;
    }

    public void setBuckets(List<BucketInfo> buckets) {
        this.buckets = buckets;
    }
}
