/*
 * Copyright 2019 THL A29 Limited, a Tencent company.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.netflix.spinnaker.clouddriver.tencentcloud.model;

import static com.netflix.spinnaker.clouddriver.model.HealthState.*;

import com.netflix.spinnaker.clouddriver.model.Health;
import com.netflix.spinnaker.clouddriver.model.HealthState;
import com.netflix.spinnaker.clouddriver.tencentcloud.model.TencentCloudTargetHealth.LBHealthSummary.ServiceStatus;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;

@Data
public class TencentCloudTargetHealth implements Health {

  private TargetHealthStatus targetHealthStatus;
  private List<LBHealthSummary> loadBalancers = new ArrayList<>();

  public TencentCloudTargetHealth(boolean healthStatus) {
    targetHealthStatus = healthStatus ? TargetHealthStatus.HEALTHY : TargetHealthStatus.UNHEALTHY;
  }

  public TencentCloudTargetHealth() {
    targetHealthStatus = TargetHealthStatus.UNKNOWN;
  }

  public HealthState getState() {
    switch (targetHealthStatus) {
      case UNHEALTHY:
      case UNKNOWN:
        return Down;
      case HEALTHY:
        return Up;
      default:
        return Unknown;
    }
  }

  public final String getType() {
    return "LoadBalancer";
  }

  public enum TargetHealthStatus {
    UNHEALTHY,
    HEALTHY,
    UNKNOWN;

    public ServiceStatus toServiceStatus() {
      if (this == TargetHealthStatus.HEALTHY) {
        return ServiceStatus.InService;
      }
      return ServiceStatus.OutOfService;
    }
  }

  @Data
  public static class LBHealthSummary {

    private String loadBalancerName;
    private ServiceStatus state;

    public String getDescription() {
      return state.equals(ServiceStatus.OutOfService)
          ? "Instance has failed at least the Unhealthy Threshold number of health checks consecutively."
          : "Healthy";
    }

    public enum ServiceStatus {
      InService,
      OutOfService
    }
  }
}

@@ -863,124 +863,8 @@
 te;%0A
-import com.netflix.spinnaker.clouddriver.tencentcloud.model.TencentCloudTargetHealth.LBHealthSummary.ServiceStatus;%0A
 impo
@@ -1745,16 +1745,32 @@
  public 
+LBHealthSummary.
 ServiceS
@@ -1850,32 +1850,48 @@
 %0A        return 
+LBHealthSummary.
 ServiceStatus.In
@@ -1920,16 +1920,32 @@
  return 
+LBHealthSummary.
 ServiceS

Fix compilation error due to import order (#4648)