|
| 1 | +/* |
| 2 | + * Prompt Registry API |
| 3 | + * Prompt Storage service for Design time & Runtime prompt templates. |
| 4 | + * |
| 5 | + * |
| 6 | + * |
| 7 | + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). |
| 8 | + * https://openapi-generator.tech |
| 9 | + * Do not edit the class manually. |
| 10 | + */ |
| 11 | + |
| 12 | +package com.sap.ai.sdk.prompt.registry.model; |
| 13 | + |
| 14 | +import com.fasterxml.jackson.annotation.JsonAnyGetter; |
| 15 | +import com.fasterxml.jackson.annotation.JsonAnySetter; |
| 16 | +import com.fasterxml.jackson.annotation.JsonCreator; |
| 17 | +import com.fasterxml.jackson.annotation.JsonIgnore; |
| 18 | +import com.fasterxml.jackson.annotation.JsonProperty; |
| 19 | +import com.fasterxml.jackson.annotation.JsonValue; |
| 20 | +import java.util.LinkedHashMap; |
| 21 | +import java.util.Map; |
| 22 | +import java.util.NoSuchElementException; |
| 23 | +import java.util.Objects; |
| 24 | +import java.util.Set; |
| 25 | +import javax.annotation.Nonnull; |
| 26 | +import javax.annotation.Nullable; |
| 27 | + |
| 28 | +/** |
| 29 | + * Cache control directive for Anthropic prompt caching. Only applicable to Anthropic Claude models. |
| 30 | + * When set, marks the content block as a cache breakpoint. |
| 31 | + */ |
| 32 | +// CHECKSTYLE:OFF |
| 33 | +public class CacheControl |
| 34 | +// CHECKSTYLE:ON |
| 35 | +{ |
| 36 | + /** Gets or Sets type */ |
| 37 | + public enum TypeEnum { |
| 38 | + /** The EPHEMERAL option of this CacheControl */ |
| 39 | + EPHEMERAL("ephemeral"), |
| 40 | + |
| 41 | + /** The UNKNOWN_DEFAULT_OPEN_API option of this CacheControl */ |
| 42 | + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); |
| 43 | + |
| 44 | + private String value; |
| 45 | + |
| 46 | + TypeEnum(String value) { |
| 47 | + this.value = value; |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * Get the value of the enum |
| 52 | + * |
| 53 | + * @return The enum value |
| 54 | + */ |
| 55 | + @JsonValue |
| 56 | + @Nonnull |
| 57 | + public String getValue() { |
| 58 | + return value; |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * Get the String value of the enum value. |
| 63 | + * |
| 64 | + * @return The enum value as String |
| 65 | + */ |
| 66 | + @Override |
| 67 | + @Nonnull |
| 68 | + public String toString() { |
| 69 | + return String.valueOf(value); |
| 70 | + } |
| 71 | + |
| 72 | + /** |
| 73 | + * Get the enum value from a String value |
| 74 | + * |
| 75 | + * @param value The String value |
| 76 | + * @return The enum value of type CacheControl |
| 77 | + */ |
| 78 | + @JsonCreator |
| 79 | + @Nonnull |
| 80 | + public static TypeEnum fromValue(@Nonnull final String value) { |
| 81 | + for (TypeEnum b : TypeEnum.values()) { |
| 82 | + if (b.value.equals(value)) { |
| 83 | + return b; |
| 84 | + } |
| 85 | + } |
| 86 | + return UNKNOWN_DEFAULT_OPEN_API; |
| 87 | + } |
| 88 | + } |
| 89 | + |
| 90 | + @JsonProperty("type") |
| 91 | + private TypeEnum type; |
| 92 | + |
| 93 | + /** |
| 94 | + * Time-to-live for the cache entry. Default is \"5m\" (5 minutes). \"1h\" (1 |
| 95 | + * hour) is supported on select models (e.g. Claude Opus 4.5, Haiku 4.5, Sonnet 4.5). |
| 96 | + */ |
| 97 | + public enum TtlEnum { |
| 98 | + /** The _5M option of this CacheControl */ |
| 99 | + _5M("5m"), |
| 100 | + |
| 101 | + /** The _1H option of this CacheControl */ |
| 102 | + _1H("1h"), |
| 103 | + |
| 104 | + /** The UNKNOWN_DEFAULT_OPEN_API option of this CacheControl */ |
| 105 | + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); |
| 106 | + |
| 107 | + private String value; |
| 108 | + |
| 109 | + TtlEnum(String value) { |
| 110 | + this.value = value; |
| 111 | + } |
| 112 | + |
| 113 | + /** |
| 114 | + * Get the value of the enum |
| 115 | + * |
| 116 | + * @return The enum value |
| 117 | + */ |
| 118 | + @JsonValue |
| 119 | + @Nonnull |
| 120 | + public String getValue() { |
| 121 | + return value; |
| 122 | + } |
| 123 | + |
| 124 | + /** |
| 125 | + * Get the String value of the enum value. |
| 126 | + * |
| 127 | + * @return The enum value as String |
| 128 | + */ |
| 129 | + @Override |
| 130 | + @Nonnull |
| 131 | + public String toString() { |
| 132 | + return String.valueOf(value); |
| 133 | + } |
| 134 | + |
| 135 | + /** |
| 136 | + * Get the enum value from a String value |
| 137 | + * |
| 138 | + * @param value The String value |
| 139 | + * @return The enum value of type CacheControl |
| 140 | + */ |
| 141 | + @JsonCreator |
| 142 | + @Nonnull |
| 143 | + public static TtlEnum fromValue(@Nonnull final String value) { |
| 144 | + for (TtlEnum b : TtlEnum.values()) { |
| 145 | + if (b.value.equals(value)) { |
| 146 | + return b; |
| 147 | + } |
| 148 | + } |
| 149 | + return UNKNOWN_DEFAULT_OPEN_API; |
| 150 | + } |
| 151 | + } |
| 152 | + |
| 153 | + @JsonProperty("ttl") |
| 154 | + private TtlEnum ttl; |
| 155 | + |
| 156 | + @JsonAnySetter @JsonAnyGetter |
| 157 | + private final Map<String, Object> cloudSdkCustomFields = new LinkedHashMap<>(); |
| 158 | + |
| 159 | + /** Default constructor for CacheControl. */ |
| 160 | + protected CacheControl() {} |
| 161 | + |
| 162 | + /** |
| 163 | + * Set the type of this {@link CacheControl} instance and return the same instance. |
| 164 | + * |
| 165 | + * @param type The type of this {@link CacheControl} |
| 166 | + * @return The same instance of this {@link CacheControl} class |
| 167 | + */ |
| 168 | + @Nonnull |
| 169 | + public CacheControl type(@Nonnull final TypeEnum type) { |
| 170 | + this.type = type; |
| 171 | + return this; |
| 172 | + } |
| 173 | + |
| 174 | + /** |
| 175 | + * Get type |
| 176 | + * |
| 177 | + * @return type The type of this {@link CacheControl} instance. |
| 178 | + */ |
| 179 | + @Nonnull |
| 180 | + public TypeEnum getType() { |
| 181 | + return type; |
| 182 | + } |
| 183 | + |
| 184 | + /** |
| 185 | + * Set the type of this {@link CacheControl} instance. |
| 186 | + * |
| 187 | + * @param type The type of this {@link CacheControl} |
| 188 | + */ |
| 189 | + public void setType(@Nonnull final TypeEnum type) { |
| 190 | + this.type = type; |
| 191 | + } |
| 192 | + |
| 193 | + /** |
| 194 | + * Set the ttl of this {@link CacheControl} instance and return the same instance. |
| 195 | + * |
| 196 | + * @param ttl Time-to-live for the cache entry. Default is \"5m\" (5 minutes). |
| 197 | + * \"1h\" (1 hour) is supported on select models (e.g. Claude Opus 4.5, Haiku 4.5, |
| 198 | + * Sonnet 4.5). |
| 199 | + * @return The same instance of this {@link CacheControl} class |
| 200 | + */ |
| 201 | + @Nonnull |
| 202 | + public CacheControl ttl(@Nullable final TtlEnum ttl) { |
| 203 | + this.ttl = ttl; |
| 204 | + return this; |
| 205 | + } |
| 206 | + |
| 207 | + /** |
| 208 | + * Time-to-live for the cache entry. Default is \"5m\" (5 minutes). \"1h\" (1 |
| 209 | + * hour) is supported on select models (e.g. Claude Opus 4.5, Haiku 4.5, Sonnet 4.5). |
| 210 | + * |
| 211 | + * @return ttl The ttl of this {@link CacheControl} instance. |
| 212 | + */ |
| 213 | + @Nonnull |
| 214 | + public TtlEnum getTtl() { |
| 215 | + return ttl; |
| 216 | + } |
| 217 | + |
| 218 | + /** |
| 219 | + * Set the ttl of this {@link CacheControl} instance. |
| 220 | + * |
| 221 | + * @param ttl Time-to-live for the cache entry. Default is \"5m\" (5 minutes). |
| 222 | + * \"1h\" (1 hour) is supported on select models (e.g. Claude Opus 4.5, Haiku 4.5, |
| 223 | + * Sonnet 4.5). |
| 224 | + */ |
| 225 | + public void setTtl(@Nullable final TtlEnum ttl) { |
| 226 | + this.ttl = ttl; |
| 227 | + } |
| 228 | + |
| 229 | + /** |
| 230 | + * Get the names of the unrecognizable properties of the {@link CacheControl}. |
| 231 | + * |
| 232 | + * @return The set of properties names |
| 233 | + */ |
| 234 | + @JsonIgnore |
| 235 | + @Nonnull |
| 236 | + public Set<String> getCustomFieldNames() { |
| 237 | + return cloudSdkCustomFields.keySet(); |
| 238 | + } |
| 239 | + |
| 240 | + /** |
| 241 | + * Get the value of an unrecognizable property of this {@link CacheControl} instance. |
| 242 | + * |
| 243 | + * @deprecated Use {@link #toMap()} instead. |
| 244 | + * @param name The name of the property |
| 245 | + * @return The value of the property |
| 246 | + * @throws NoSuchElementException If no property with the given name could be found. |
| 247 | + */ |
| 248 | + @Nullable |
| 249 | + @Deprecated |
| 250 | + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { |
| 251 | + if (!cloudSdkCustomFields.containsKey(name)) { |
| 252 | + throw new NoSuchElementException("CacheControl has no field with name '" + name + "'."); |
| 253 | + } |
| 254 | + return cloudSdkCustomFields.get(name); |
| 255 | + } |
| 256 | + |
| 257 | + /** |
| 258 | + * Get the value of all properties of this {@link CacheControl} instance including unrecognized |
| 259 | + * properties. |
| 260 | + * |
| 261 | + * @return The map of all properties |
| 262 | + */ |
| 263 | + @JsonIgnore |
| 264 | + @Nonnull |
| 265 | + public Map<String, Object> toMap() { |
| 266 | + final Map<String, Object> declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); |
| 267 | + if (type != null) declaredFields.put("type", type); |
| 268 | + if (ttl != null) declaredFields.put("ttl", ttl); |
| 269 | + return declaredFields; |
| 270 | + } |
| 271 | + |
| 272 | + /** |
| 273 | + * Set an unrecognizable property of this {@link CacheControl} instance. If the map previously |
| 274 | + * contained a mapping for the key, the old value is replaced by the specified value. |
| 275 | + * |
| 276 | + * @param customFieldName The name of the property |
| 277 | + * @param customFieldValue The value of the property |
| 278 | + */ |
| 279 | + @JsonIgnore |
| 280 | + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { |
| 281 | + cloudSdkCustomFields.put(customFieldName, customFieldValue); |
| 282 | + } |
| 283 | + |
| 284 | + @Override |
| 285 | + public boolean equals(@Nullable final java.lang.Object o) { |
| 286 | + if (this == o) { |
| 287 | + return true; |
| 288 | + } |
| 289 | + if (o == null || getClass() != o.getClass()) { |
| 290 | + return false; |
| 291 | + } |
| 292 | + final CacheControl cacheControl = (CacheControl) o; |
| 293 | + return Objects.equals(this.cloudSdkCustomFields, cacheControl.cloudSdkCustomFields) |
| 294 | + && Objects.equals(this.type, cacheControl.type) |
| 295 | + && Objects.equals(this.ttl, cacheControl.ttl); |
| 296 | + } |
| 297 | + |
| 298 | + @Override |
| 299 | + public int hashCode() { |
| 300 | + return Objects.hash(type, ttl, cloudSdkCustomFields); |
| 301 | + } |
| 302 | + |
| 303 | + @Override |
| 304 | + @Nonnull |
| 305 | + public String toString() { |
| 306 | + final StringBuilder sb = new StringBuilder(); |
| 307 | + sb.append("class CacheControl {\n"); |
| 308 | + sb.append(" type: ").append(toIndentedString(type)).append("\n"); |
| 309 | + sb.append(" ttl: ").append(toIndentedString(ttl)).append("\n"); |
| 310 | + cloudSdkCustomFields.forEach( |
| 311 | + (k, v) -> |
| 312 | + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); |
| 313 | + sb.append("}"); |
| 314 | + return sb.toString(); |
| 315 | + } |
| 316 | + |
| 317 | + /** |
| 318 | + * Convert the given object to string with each line indented by 4 spaces (except the first line). |
| 319 | + */ |
| 320 | + private String toIndentedString(final java.lang.Object o) { |
| 321 | + if (o == null) { |
| 322 | + return "null"; |
| 323 | + } |
| 324 | + return o.toString().replace("\n", "\n "); |
| 325 | + } |
| 326 | + |
| 327 | + /** |
| 328 | + * Create a type-safe, fluent-api builder object to construct a new {@link CacheControl} instance |
| 329 | + * with all required arguments. |
| 330 | + */ |
| 331 | + public static Builder create() { |
| 332 | + return (type) -> new CacheControl().type(type); |
| 333 | + } |
| 334 | + |
| 335 | + /** Builder helper class. */ |
| 336 | + public interface Builder { |
| 337 | + /** |
| 338 | + * Set the type of this {@link CacheControl} instance. |
| 339 | + * |
| 340 | + * @param type The type of this {@link CacheControl} |
| 341 | + * @return The CacheControl instance. |
| 342 | + */ |
| 343 | + CacheControl type(@Nonnull final TypeEnum type); |
| 344 | + } |
| 345 | +} |
0 commit comments