222 lines
6.0 KiB
Java

package com.muse.dto;
import java.net.URI;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.springframework.lang.Nullable;
import java.io.Serializable;
import java.time.OffsetDateTime;
import jakarta.validation.Valid;
import jakarta.validation.constraints.*;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.*;
import jakarta.annotation.Generated;
/**
* 灰度规则配置
*/
@Schema(name = "GrayRulesConfig", description = "灰度规则配置")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2026-05-24T16:47:40.290595+08:00[Asia/Shanghai]", comments = "Generator version: 7.22.0")
public class GrayRulesConfig implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 灰度策略
*/
public enum StrategyEnum {
TENANT_WHITELIST("tenant_whitelist"),
PERCENTAGE("percentage"),
USER_WHITELIST("user_whitelist");
private final String value;
StrategyEnum(String value) {
this.value = value;
}
@JsonValue
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
@JsonCreator
public static StrategyEnum fromValue(String value) {
for (StrategyEnum b : StrategyEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}
private @Nullable StrategyEnum strategy;
@Valid
private List<String> tenantWhitelist = new ArrayList<>();
private @Nullable Integer percentage;
@Valid
private List<String> userWhitelist = new ArrayList<>();
public GrayRulesConfig strategy(@Nullable StrategyEnum strategy) {
this.strategy = strategy;
return this;
}
/**
* 灰度策略
* @return strategy
*/
@Schema(name = "strategy", description = "灰度策略", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("strategy")
public @Nullable StrategyEnum getStrategy() {
return strategy;
}
@JsonProperty("strategy")
public void setStrategy(@Nullable StrategyEnum strategy) {
this.strategy = strategy;
}
public GrayRulesConfig tenantWhitelist(List<String> tenantWhitelist) {
this.tenantWhitelist = tenantWhitelist;
return this;
}
public GrayRulesConfig addTenantWhitelistItem(String tenantWhitelistItem) {
if (this.tenantWhitelist == null) {
this.tenantWhitelist = new ArrayList<>();
}
this.tenantWhitelist.add(tenantWhitelistItem);
return this;
}
/**
* strategy=tenant_whitelist 时生效
* @return tenantWhitelist
*/
@Schema(name = "tenantWhitelist", description = "strategy=tenant_whitelist 时生效", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("tenantWhitelist")
public List<String> getTenantWhitelist() {
return tenantWhitelist;
}
@JsonProperty("tenantWhitelist")
public void setTenantWhitelist(List<String> tenantWhitelist) {
this.tenantWhitelist = tenantWhitelist;
}
public GrayRulesConfig percentage(@Nullable Integer percentage) {
this.percentage = percentage;
return this;
}
/**
* strategy=percentage 时生效
* minimum: 0
* maximum: 100
* @return percentage
*/
@Min(value = 0) @Max(value = 100)
@Schema(name = "percentage", description = "strategy=percentage 时生效", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("percentage")
public @Nullable Integer getPercentage() {
return percentage;
}
@JsonProperty("percentage")
public void setPercentage(@Nullable Integer percentage) {
this.percentage = percentage;
}
public GrayRulesConfig userWhitelist(List<String> userWhitelist) {
this.userWhitelist = userWhitelist;
return this;
}
public GrayRulesConfig addUserWhitelistItem(String userWhitelistItem) {
if (this.userWhitelist == null) {
this.userWhitelist = new ArrayList<>();
}
this.userWhitelist.add(userWhitelistItem);
return this;
}
/**
* strategy=user_whitelist 时生效
* @return userWhitelist
*/
@Schema(name = "userWhitelist", description = "strategy=user_whitelist 时生效", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("userWhitelist")
public List<String> getUserWhitelist() {
return userWhitelist;
}
@JsonProperty("userWhitelist")
public void setUserWhitelist(List<String> userWhitelist) {
this.userWhitelist = userWhitelist;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
GrayRulesConfig grayRulesConfig = (GrayRulesConfig) o;
return Objects.equals(this.strategy, grayRulesConfig.strategy) &&
Objects.equals(this.tenantWhitelist, grayRulesConfig.tenantWhitelist) &&
Objects.equals(this.percentage, grayRulesConfig.percentage) &&
Objects.equals(this.userWhitelist, grayRulesConfig.userWhitelist);
}
@Override
public int hashCode() {
return Objects.hash(strategy, tenantWhitelist, percentage, userWhitelist);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class GrayRulesConfig {\n");
sb.append(" strategy: ").append(toIndentedString(strategy)).append("\n");
sb.append(" tenantWhitelist: ").append(toIndentedString(tenantWhitelist)).append("\n");
sb.append(" percentage: ").append(toIndentedString(percentage)).append("\n");
sb.append(" userWhitelist: ").append(toIndentedString(userWhitelist)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(@Nullable Object o) {
return o == null ? "null" : o.toString().replace("\n", "\n ");
}
}