package com.microservices.mon.k8s.domain;

import com.microservices.common.core.exception.ServiceException;
import com.microservices.common.core.utils.StringUtils;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * @author OTTO
 */
@Getter
public enum ApplicationFunctionType {
    LINK_TRACKING("LinkTracking", "链路追踪", "mon-skywalking-key"),
    FLOW_CONTROL("FlowControl", "流量控制", "mon-sentinel-key"),
    CONFIGURATION_MANAGEMENT("ConfigurationManagement", "配置管理", ""),
    REGISTRATION_CENTER("RegistrationCenter", "注册中心", "mon-nacos-key"),
    GATEWAY_MANAGEMENT("GatewayManagement", "网关管理", "mon-gateway-key"),
    START_AND_STOP_MANAGEMENT("StartAndStopManagement", "启停管理", "");
    private final String key;
    private final String name;
    private final String k8sLabel;

    ApplicationFunctionType(String key, String name, String k8sLabel) {
        this.key = key;
        this.name = name;
        this.k8sLabel = k8sLabel;
    }

    public static ApplicationFunctionType getByLabelsKey(String k8sLabel) {
        if (StringUtils.isNotEmpty(k8sLabel)) {
            for (ApplicationFunctionType type : ApplicationFunctionType.values()) {
                if (type.getK8sLabel().equals(k8sLabel)) {
                    return type;
                }
            }
        }
        return null;
    }
}
