package com.microservices.system.api.factory;

import com.alibaba.fastjson2.JSONObject;
import com.microservices.common.core.exception.ServiceException;
import com.microservices.system.api.RemoteGatewayService;
import com.microservices.system.api.RemoteRancherService;
import com.microservices.system.api.utils.FeignUtils;
import feign.FeignException;
import feign.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.nio.charset.StandardCharsets;
import java.util.Map;

/**
 * 用户服务降级处理
 *
 * @author microservices
 */
@Component
public class RemoteRancherFallbackFactory implements FallbackFactory<RemoteRancherService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteRancherFallbackFactory.class);

    @Override
    public RemoteRancherService create(Throwable throwable) {
        log.error("Rancher服务调用失败:{}", throwable.getMessage());

        return new RemoteRancherService() {
            @Override
            public Response getK8sNamespaceList(String cluster_id, String token) {
                return null;
            }

            @Override
            public Response getK8sDaemonsetsList(String cluster_id, String token) {
                return null;
            }

            @Override
            public Response getK8sDeployList(String cluster_id, String token) {
                return null;
            }

            @Override
            public Response getK8sStatefulList(String cluster_id, String token) {
                return null;
            }

            @Override
            public Response getK8sClusterNodeList(String cluster_id, String token) {
                return null;
            }

            @Override
            public Response getK8sApplicationDetail(String cluster_id, String fullKind, String namespace, String applicationName, String token) {
                return null;
            }

            @Override
            public Response getK8sPodListByNamespace(String cluster_id, String namespace, String token) {
                return null;
            }

            @Override
            public Response getK8sPodList(String cluster_id, String token) {
                return null;
            }

            @Override
            public Response getK8sServiceByApplicationId(String cluster_id, String nginxApplicationId, String token) {
                return null;
            }

            @Override
            public Response deletePod(String namespace, String podName, JSONObject deletePodBody, String token) {
                return null;
            }

            @Override
            public Response updateK8sApplication(String fullKind, String namespace, String applicationName, JSONObject applicationDetail, String userKey) {
                return null;
            }

            @Override
            public Response createK8sApplication(String fullName, String yamlContent, String userKey) {
                return null;
            }

            @Override
            public Response applyK8sYaml(String cluster_id, JSONObject yamlContent, String userKey) {
                return null;
            }

            @Override
            public Response getApplicationYamlFile(String kindName, String namespace, String applicationName, String token) {
                return null;
            }

            @Override
            public Response editK8sApplication(String fullKind, String namespace, String applicationName, String yamlContent, String token) {
                return null;
            }

            @Override
            public Response deleteApplication(String fullKind, String namespace, String applicationName, String token) {
                return null;
            }

            @Override
            public Response getK8sConfigmapByNamespace(String namespace, String token) {
                return null;
            }

            @Override
            public Response getK8sSecretByNamespace(String namespace, String token) {
                return null;
            }

            @Override
            public Response getK8sServiceByNamespace(String cluster_id, String namespace, String token) {
                return null;
            }

            @Override
            public Response deleteK8sService(String serviceId, String token) {
                return null;
            }
        };
    }
}
