package com.red.circle.external.app.oss;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

/**
 * 腾讯云 COS 配置.
 */
@Component
@ConfigurationProperties(prefix = "red-circle.oss.tencent-cos")
public class TencentCosProperties {

  private boolean enabled = false;
  private String secretId = "";
  private String secretKey = "";
  private String bucketName = "";
  private String region = "";
  private String accessUrl = "";
  private int connectionTimeoutMs = 15000;
  private int connectionRequestTimeoutMs = 15000;
  private int socketTimeoutMs = 120000;
  private int requestTimeoutMs = 120000;
  private int shutdownTimeoutMs = 10000;
  private int maxErrorRetry = 0;

  public boolean isEnabled() {
    return enabled;
  }

  public void setEnabled(boolean enabled) {
    this.enabled = enabled;
  }

  public String getSecretId() {
    return secretId;
  }

  public void setSecretId(String secretId) {
    this.secretId = secretId;
  }

  public String getSecretKey() {
    return secretKey;
  }

  public void setSecretKey(String secretKey) {
    this.secretKey = secretKey;
  }

  public String getBucketName() {
    return bucketName;
  }

  public void setBucketName(String bucketName) {
    this.bucketName = bucketName;
  }

  public String getRegion() {
    return region;
  }

  public void setRegion(String region) {
    this.region = region;
  }

  public String getAccessUrl() {
    return accessUrl;
  }

  public void setAccessUrl(String accessUrl) {
    this.accessUrl = accessUrl;
  }

  public int getConnectionTimeoutMs() {
    return connectionTimeoutMs;
  }

  public void setConnectionTimeoutMs(int connectionTimeoutMs) {
    this.connectionTimeoutMs = connectionTimeoutMs;
  }

  public int getConnectionRequestTimeoutMs() {
    return connectionRequestTimeoutMs;
  }

  public void setConnectionRequestTimeoutMs(int connectionRequestTimeoutMs) {
    this.connectionRequestTimeoutMs = connectionRequestTimeoutMs;
  }

  public int getSocketTimeoutMs() {
    return socketTimeoutMs;
  }

  public void setSocketTimeoutMs(int socketTimeoutMs) {
    this.socketTimeoutMs = socketTimeoutMs;
  }

  public int getRequestTimeoutMs() {
    return requestTimeoutMs;
  }

  public void setRequestTimeoutMs(int requestTimeoutMs) {
    this.requestTimeoutMs = requestTimeoutMs;
  }

  public int getShutdownTimeoutMs() {
    return shutdownTimeoutMs;
  }

  public void setShutdownTimeoutMs(int shutdownTimeoutMs) {
    this.shutdownTimeoutMs = shutdownTimeoutMs;
  }

  public int getMaxErrorRetry() {
    return maxErrorRetry;
  }

  public void setMaxErrorRetry(int maxErrorRetry) {
    this.maxErrorRetry = maxErrorRetry;
  }

  public boolean isConfigured() {
    return enabled
        && StringUtils.hasText(secretId)
        && StringUtils.hasText(secretKey)
        && StringUtils.hasText(bucketName)
        && StringUtils.hasText(region);
  }
}
