diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 9f6026f1c..69efe8f53 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.39.0" + ".": "2.40.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 15bfd9e85..82f3ca091 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 106 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic/anthropic-e171bad0ea7923db27b0b640915579588c46e44f26c0d4b2bfd63eb6da486b2a.yml -openapi_spec_hash: 29b3b2ba0d00467b5c6943533fa0c07a -config_hash: 12441a8fae7ee2cb6a2accf3a5fa43ee +configured_endpoints: 116 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic/anthropic-3368ac7f3ae66514b5e46832c85918a6ea36e95c0efe98e0955c4455dd57a6b8.yml +openapi_spec_hash: 255cf18e4e19ab1ab5cdc52717abe558 +config_hash: 44acd8a997dff056931fb4466201cdeb diff --git a/CHANGELOG.md b/CHANGELOG.md index 67ada0438..ab6a837ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 2.40.0 (2026-06-09) + +Full Changelog: [v2.39.0...v2.40.0](https://github.com/anthropics/anthropic-sdk-java/compare/v2.39.0...v2.40.0) + +### Features + +* **api:** add support for Managed Agents deployments and environment variable credentials ([628720b](https://github.com/anthropics/anthropic-sdk-java/commit/628720bcd5dcc0b34ecf0cbf334cae528e8f0fb3)) + ## 2.39.0 (2026-06-09) Full Changelog: [v2.38.0...v2.39.0](https://github.com/anthropics/anthropic-sdk-java/compare/v2.38.0...v2.39.0) diff --git a/README.md b/README.md index 4e9f924b2..4190b27e2 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Full documentation is available at **[platform.claude.com/docs/en/api/sdks/java] ### Gradle ```kotlin -implementation("com.anthropic:anthropic-java:2.39.0") +implementation("com.anthropic:anthropic-java:2.40.0") ``` ### Maven @@ -24,7 +24,7 @@ implementation("com.anthropic:anthropic-java:2.39.0") com.anthropic anthropic-java - 2.39.0 + 2.40.0 ``` diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsAgentArchivedRunError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsAgentArchivedRunError.kt new file mode 100644 index 000000000..f7de5d75c --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsAgentArchivedRunError.kt @@ -0,0 +1,352 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** The deployment's agent was archived. */ +class BetaManagedAgentsAgentArchivedRunError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val message: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(message, type, mutableMapOf()) + + /** + * Human-readable error description. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): String = message.getRequired("message") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsAgentArchivedRunError]. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsAgentArchivedRunError]. */ + class Builder internal constructor() { + + private var message: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsAgentArchivedRunError: BetaManagedAgentsAgentArchivedRunError + ) = apply { + message = betaManagedAgentsAgentArchivedRunError.message + type = betaManagedAgentsAgentArchivedRunError.type + additionalProperties = + betaManagedAgentsAgentArchivedRunError.additionalProperties.toMutableMap() + } + + /** Human-readable error description. */ + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsAgentArchivedRunError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsAgentArchivedRunError = + BetaManagedAgentsAgentArchivedRunError( + checkRequired("message", message), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsAgentArchivedRunError = apply { + if (validated) { + return@apply + } + + message() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (message.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AGENT_ARCHIVED_ERROR = of("agent_archived_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + AGENT_ARCHIVED_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AGENT_ARCHIVED_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AGENT_ARCHIVED_ERROR -> Value.AGENT_ARCHIVED_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AGENT_ARCHIVED_ERROR -> Known.AGENT_ARCHIVED_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsAgentArchivedRunError && + message == other.message && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(message, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsAgentArchivedRunError{message=$message, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsDeploymentRun.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsDeploymentRun.kt new file mode 100644 index 000000000..638c3e624 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsDeploymentRun.kt @@ -0,0 +1,1966 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.BaseDeserializer +import com.anthropic.core.BaseSerializer +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.core.getOrThrow +import com.anthropic.errors.AnthropicInvalidDataException +import com.anthropic.models.beta.agents.BetaManagedAgentsAgentReference +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * A persistent, append-only record of a single deployment execution. Records session creation + * success or failure — no session lifecycle tracking. + */ +class BetaManagedAgentsDeploymentRun +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val agent: JsonField, + private val createdAt: JsonField, + private val deploymentId: JsonField, + private val error: JsonField, + private val sessionId: JsonField, + private val triggerContext: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("agent") + @ExcludeMissing + agent: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("deployment_id") + @ExcludeMissing + deploymentId: JsonField = JsonMissing.of(), + @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), + @JsonProperty("session_id") @ExcludeMissing sessionId: JsonField = JsonMissing.of(), + @JsonProperty("trigger_context") + @ExcludeMissing + triggerContext: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this( + id, + agent, + createdAt, + deploymentId, + error, + sessionId, + triggerContext, + type, + mutableMapOf(), + ) + + /** + * Unique identifier for this run (`drun_...`). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * A resolved agent reference with a concrete version. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun agent(): BetaManagedAgentsAgentReference = agent.getRequired("agent") + + /** + * A timestamp in RFC 3339 format + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * ID of the deployment that produced this run. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun deploymentId(): String = deploymentId.getRequired("deployment_id") + + /** + * Why the run failed to create a session. The type identifies the failure; message is + * human-readable detail. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun error(): Optional = error.getOptional("error") + + /** + * Populated on success. Null on creation failure. Exactly one of session_id or error is + * non-null. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sessionId(): Optional = sessionId.getOptional("session_id") + + /** + * Describes what triggered a deployment run, with trigger-specific metadata. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun triggerContext(): BetaManagedAgentsTriggerContext = + triggerContext.getRequired("trigger_context") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [agent]. + * + * Unlike [agent], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("agent") + @ExcludeMissing + fun _agent(): JsonField = agent + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [deploymentId]. + * + * Unlike [deploymentId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("deployment_id") + @ExcludeMissing + fun _deploymentId(): JsonField = deploymentId + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField = sessionId + + /** + * Returns the raw JSON value of [triggerContext]. + * + * Unlike [triggerContext], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trigger_context") + @ExcludeMissing + fun _triggerContext(): JsonField = triggerContext + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsDeploymentRun]. + * + * The following fields are required: + * ```java + * .id() + * .agent() + * .createdAt() + * .deploymentId() + * .error() + * .sessionId() + * .triggerContext() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsDeploymentRun]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var agent: JsonField? = null + private var createdAt: JsonField? = null + private var deploymentId: JsonField? = null + private var error: JsonField? = null + private var sessionId: JsonField? = null + private var triggerContext: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaManagedAgentsDeploymentRun: BetaManagedAgentsDeploymentRun) = apply { + id = betaManagedAgentsDeploymentRun.id + agent = betaManagedAgentsDeploymentRun.agent + createdAt = betaManagedAgentsDeploymentRun.createdAt + deploymentId = betaManagedAgentsDeploymentRun.deploymentId + error = betaManagedAgentsDeploymentRun.error + sessionId = betaManagedAgentsDeploymentRun.sessionId + triggerContext = betaManagedAgentsDeploymentRun.triggerContext + type = betaManagedAgentsDeploymentRun.type + additionalProperties = + betaManagedAgentsDeploymentRun.additionalProperties.toMutableMap() + } + + /** Unique identifier for this run (`drun_...`). */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** A resolved agent reference with a concrete version. */ + fun agent(agent: BetaManagedAgentsAgentReference) = agent(JsonField.of(agent)) + + /** + * Sets [Builder.agent] to an arbitrary JSON value. + * + * You should usually call [Builder.agent] with a well-typed + * [BetaManagedAgentsAgentReference] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun agent(agent: JsonField) = apply { this.agent = agent } + + /** A timestamp in RFC 3339 format */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** ID of the deployment that produced this run. */ + fun deploymentId(deploymentId: String) = deploymentId(JsonField.of(deploymentId)) + + /** + * Sets [Builder.deploymentId] to an arbitrary JSON value. + * + * You should usually call [Builder.deploymentId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun deploymentId(deploymentId: JsonField) = apply { + this.deploymentId = deploymentId + } + + /** + * Why the run failed to create a session. The type identifies the failure; message is + * human-readable detail. + */ + fun error(error: Error?) = error(JsonField.ofNullable(error)) + + /** Alias for calling [Builder.error] with `error.orElse(null)`. */ + fun error(error: Optional) = error(error.getOrNull()) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [Error] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun error(error: JsonField) = apply { this.error = error } + + /** Alias for calling [error] with `Error.ofEnvironmentArchived(environmentArchived)`. */ + fun error(environmentArchived: BetaManagedAgentsEnvironmentArchivedRunError) = + error(Error.ofEnvironmentArchived(environmentArchived)) + + /** + * Alias for calling [error] with the following: + * ```java + * BetaManagedAgentsEnvironmentArchivedRunError.builder() + * .type(BetaManagedAgentsEnvironmentArchivedRunError.Type.ENVIRONMENT_ARCHIVED_ERROR) + * .message(message) + * .build() + * ``` + */ + fun environmentArchivedError(message: String) = + error( + BetaManagedAgentsEnvironmentArchivedRunError.builder() + .type( + BetaManagedAgentsEnvironmentArchivedRunError.Type.ENVIRONMENT_ARCHIVED_ERROR + ) + .message(message) + .build() + ) + + /** Alias for calling [error] with `Error.ofAgentArchived(agentArchived)`. */ + fun error(agentArchived: BetaManagedAgentsAgentArchivedRunError) = + error(Error.ofAgentArchived(agentArchived)) + + /** + * Alias for calling [error] with the following: + * ```java + * BetaManagedAgentsAgentArchivedRunError.builder() + * .type(BetaManagedAgentsAgentArchivedRunError.Type.AGENT_ARCHIVED_ERROR) + * .message(message) + * .build() + * ``` + */ + fun agentArchivedError(message: String) = + error( + BetaManagedAgentsAgentArchivedRunError.builder() + .type(BetaManagedAgentsAgentArchivedRunError.Type.AGENT_ARCHIVED_ERROR) + .message(message) + .build() + ) + + /** Alias for calling [error] with `Error.ofEnvironmentNotFound(environmentNotFound)`. */ + fun error(environmentNotFound: BetaManagedAgentsEnvironmentNotFoundRunError) = + error(Error.ofEnvironmentNotFound(environmentNotFound)) + + /** + * Alias for calling [error] with the following: + * ```java + * BetaManagedAgentsEnvironmentNotFoundRunError.builder() + * .type(BetaManagedAgentsEnvironmentNotFoundRunError.Type.ENVIRONMENT_NOT_FOUND_ERROR) + * .message(message) + * .build() + * ``` + */ + fun environmentNotFoundError(message: String) = + error( + BetaManagedAgentsEnvironmentNotFoundRunError.builder() + .type( + BetaManagedAgentsEnvironmentNotFoundRunError.Type + .ENVIRONMENT_NOT_FOUND_ERROR + ) + .message(message) + .build() + ) + + /** Alias for calling [error] with `Error.ofVaultNotFound(vaultNotFound)`. */ + fun error(vaultNotFound: BetaManagedAgentsVaultNotFoundRunError) = + error(Error.ofVaultNotFound(vaultNotFound)) + + /** + * Alias for calling [error] with the following: + * ```java + * BetaManagedAgentsVaultNotFoundRunError.builder() + * .type(BetaManagedAgentsVaultNotFoundRunError.Type.VAULT_NOT_FOUND_ERROR) + * .message(message) + * .build() + * ``` + */ + fun vaultNotFoundError(message: String) = + error( + BetaManagedAgentsVaultNotFoundRunError.builder() + .type(BetaManagedAgentsVaultNotFoundRunError.Type.VAULT_NOT_FOUND_ERROR) + .message(message) + .build() + ) + + /** Alias for calling [error] with `Error.ofVaultArchived(vaultArchived)`. */ + fun error(vaultArchived: BetaManagedAgentsVaultArchivedRunError) = + error(Error.ofVaultArchived(vaultArchived)) + + /** + * Alias for calling [error] with the following: + * ```java + * BetaManagedAgentsVaultArchivedRunError.builder() + * .type(BetaManagedAgentsVaultArchivedRunError.Type.VAULT_ARCHIVED_ERROR) + * .message(message) + * .build() + * ``` + */ + fun vaultArchivedError(message: String) = + error( + BetaManagedAgentsVaultArchivedRunError.builder() + .type(BetaManagedAgentsVaultArchivedRunError.Type.VAULT_ARCHIVED_ERROR) + .message(message) + .build() + ) + + /** Alias for calling [error] with `Error.ofFileNotFound(fileNotFound)`. */ + fun error(fileNotFound: BetaManagedAgentsFileNotFoundRunError) = + error(Error.ofFileNotFound(fileNotFound)) + + /** + * Alias for calling [error] with the following: + * ```java + * BetaManagedAgentsFileNotFoundRunError.builder() + * .type(BetaManagedAgentsFileNotFoundRunError.Type.FILE_NOT_FOUND_ERROR) + * .message(message) + * .build() + * ``` + */ + fun fileNotFoundError(message: String) = + error( + BetaManagedAgentsFileNotFoundRunError.builder() + .type(BetaManagedAgentsFileNotFoundRunError.Type.FILE_NOT_FOUND_ERROR) + .message(message) + .build() + ) + + /** Alias for calling [error] with `Error.ofMemoryStoreArchived(memoryStoreArchived)`. */ + fun error(memoryStoreArchived: BetaManagedAgentsMemoryStoreArchivedRunError) = + error(Error.ofMemoryStoreArchived(memoryStoreArchived)) + + /** + * Alias for calling [error] with the following: + * ```java + * BetaManagedAgentsMemoryStoreArchivedRunError.builder() + * .type(BetaManagedAgentsMemoryStoreArchivedRunError.Type.MEMORY_STORE_ARCHIVED_ERROR) + * .message(message) + * .build() + * ``` + */ + fun memoryStoreArchivedError(message: String) = + error( + BetaManagedAgentsMemoryStoreArchivedRunError.builder() + .type( + BetaManagedAgentsMemoryStoreArchivedRunError.Type + .MEMORY_STORE_ARCHIVED_ERROR + ) + .message(message) + .build() + ) + + /** Alias for calling [error] with `Error.ofSkillNotFound(skillNotFound)`. */ + fun error(skillNotFound: BetaManagedAgentsSkillNotFoundRunError) = + error(Error.ofSkillNotFound(skillNotFound)) + + /** + * Alias for calling [error] with the following: + * ```java + * BetaManagedAgentsSkillNotFoundRunError.builder() + * .type(BetaManagedAgentsSkillNotFoundRunError.Type.SKILL_NOT_FOUND_ERROR) + * .message(message) + * .build() + * ``` + */ + fun skillNotFoundError(message: String) = + error( + BetaManagedAgentsSkillNotFoundRunError.builder() + .type(BetaManagedAgentsSkillNotFoundRunError.Type.SKILL_NOT_FOUND_ERROR) + .message(message) + .build() + ) + + /** + * Alias for calling [error] with + * `Error.ofSessionResourceNotFound(sessionResourceNotFound)`. + */ + fun error(sessionResourceNotFound: BetaManagedAgentsSessionResourceNotFoundRunError) = + error(Error.ofSessionResourceNotFound(sessionResourceNotFound)) + + /** + * Alias for calling [error] with the following: + * ```java + * BetaManagedAgentsSessionResourceNotFoundRunError.builder() + * .type(BetaManagedAgentsSessionResourceNotFoundRunError.Type.SESSION_RESOURCE_NOT_FOUND_ERROR) + * .message(message) + * .build() + * ``` + */ + fun sessionResourceNotFoundError(message: String) = + error( + BetaManagedAgentsSessionResourceNotFoundRunError.builder() + .type( + BetaManagedAgentsSessionResourceNotFoundRunError.Type + .SESSION_RESOURCE_NOT_FOUND_ERROR + ) + .message(message) + .build() + ) + + /** Alias for calling [error] with `Error.ofWorkspaceArchived(workspaceArchived)`. */ + fun error(workspaceArchived: BetaManagedAgentsWorkspaceArchivedRunError) = + error(Error.ofWorkspaceArchived(workspaceArchived)) + + /** + * Alias for calling [error] with the following: + * ```java + * BetaManagedAgentsWorkspaceArchivedRunError.builder() + * .type(BetaManagedAgentsWorkspaceArchivedRunError.Type.WORKSPACE_ARCHIVED_ERROR) + * .message(message) + * .build() + * ``` + */ + fun workspaceArchivedError(message: String) = + error( + BetaManagedAgentsWorkspaceArchivedRunError.builder() + .type(BetaManagedAgentsWorkspaceArchivedRunError.Type.WORKSPACE_ARCHIVED_ERROR) + .message(message) + .build() + ) + + /** Alias for calling [error] with `Error.ofOrganizationDisabled(organizationDisabled)`. */ + fun error(organizationDisabled: BetaManagedAgentsOrganizationDisabledRunError) = + error(Error.ofOrganizationDisabled(organizationDisabled)) + + /** + * Alias for calling [error] with the following: + * ```java + * BetaManagedAgentsOrganizationDisabledRunError.builder() + * .type(BetaManagedAgentsOrganizationDisabledRunError.Type.ORGANIZATION_DISABLED_ERROR) + * .message(message) + * .build() + * ``` + */ + fun organizationDisabledError(message: String) = + error( + BetaManagedAgentsOrganizationDisabledRunError.builder() + .type( + BetaManagedAgentsOrganizationDisabledRunError.Type + .ORGANIZATION_DISABLED_ERROR + ) + .message(message) + .build() + ) + + /** Alias for calling [error] with `Error.ofSessionRateLimited(sessionRateLimited)`. */ + fun error(sessionRateLimited: BetaManagedAgentsSessionRateLimitedRunError) = + error(Error.ofSessionRateLimited(sessionRateLimited)) + + /** + * Alias for calling [error] with the following: + * ```java + * BetaManagedAgentsSessionRateLimitedRunError.builder() + * .type(BetaManagedAgentsSessionRateLimitedRunError.Type.SESSION_RATE_LIMITED_ERROR) + * .message(message) + * .build() + * ``` + */ + fun sessionRateLimitedError(message: String) = + error( + BetaManagedAgentsSessionRateLimitedRunError.builder() + .type( + BetaManagedAgentsSessionRateLimitedRunError.Type.SESSION_RATE_LIMITED_ERROR + ) + .message(message) + .build() + ) + + /** + * Alias for calling [error] with + * `Error.ofSessionCreationRejected(sessionCreationRejected)`. + */ + fun error(sessionCreationRejected: BetaManagedAgentsSessionCreationRejectedRunError) = + error(Error.ofSessionCreationRejected(sessionCreationRejected)) + + /** + * Alias for calling [error] with the following: + * ```java + * BetaManagedAgentsSessionCreationRejectedRunError.builder() + * .type(BetaManagedAgentsSessionCreationRejectedRunError.Type.SESSION_CREATION_REJECTED_ERROR) + * .message(message) + * .build() + * ``` + */ + fun sessionCreationRejectedError(message: String) = + error( + BetaManagedAgentsSessionCreationRejectedRunError.builder() + .type( + BetaManagedAgentsSessionCreationRejectedRunError.Type + .SESSION_CREATION_REJECTED_ERROR + ) + .message(message) + .build() + ) + + /** Alias for calling [error] with `Error.ofUnknown(unknown)`. */ + fun error(unknown: BetaManagedAgentsUnknownRunError) = error(Error.ofUnknown(unknown)) + + /** + * Alias for calling [error] with the following: + * ```java + * BetaManagedAgentsUnknownRunError.builder() + * .type(BetaManagedAgentsUnknownRunError.Type.UNKNOWN_ERROR) + * .message(message) + * .build() + * ``` + */ + fun unknownError(message: String) = + error( + BetaManagedAgentsUnknownRunError.builder() + .type(BetaManagedAgentsUnknownRunError.Type.UNKNOWN_ERROR) + .message(message) + .build() + ) + + /** + * Alias for calling [error] with + * `Error.ofSelfHostedResourcesUnsupported(selfHostedResourcesUnsupported)`. + */ + fun error( + selfHostedResourcesUnsupported: BetaManagedAgentsSelfHostedResourcesUnsupportedRunError + ) = error(Error.ofSelfHostedResourcesUnsupported(selfHostedResourcesUnsupported)) + + /** + * Alias for calling [error] with the following: + * ```java + * BetaManagedAgentsSelfHostedResourcesUnsupportedRunError.builder() + * .type(BetaManagedAgentsSelfHostedResourcesUnsupportedRunError.Type.SELF_HOSTED_RESOURCES_UNSUPPORTED_ERROR) + * .message(message) + * .build() + * ``` + */ + fun selfHostedResourcesUnsupportedError(message: String) = + error( + BetaManagedAgentsSelfHostedResourcesUnsupportedRunError.builder() + .type( + BetaManagedAgentsSelfHostedResourcesUnsupportedRunError.Type + .SELF_HOSTED_RESOURCES_UNSUPPORTED_ERROR + ) + .message(message) + .build() + ) + + /** Alias for calling [error] with `Error.ofMcpEgressBlocked(mcpEgressBlocked)`. */ + fun error(mcpEgressBlocked: BetaManagedAgentsMcpEgressBlockedRunError) = + error(Error.ofMcpEgressBlocked(mcpEgressBlocked)) + + /** + * Alias for calling [error] with the following: + * ```java + * BetaManagedAgentsMcpEgressBlockedRunError.builder() + * .type(BetaManagedAgentsMcpEgressBlockedRunError.Type.MCP_EGRESS_BLOCKED_ERROR) + * .message(message) + * .build() + * ``` + */ + fun mcpEgressBlockedError(message: String) = + error( + BetaManagedAgentsMcpEgressBlockedRunError.builder() + .type(BetaManagedAgentsMcpEgressBlockedRunError.Type.MCP_EGRESS_BLOCKED_ERROR) + .message(message) + .build() + ) + + /** + * Populated on success. Null on creation failure. Exactly one of session_id or error is + * non-null. + */ + fun sessionId(sessionId: String?) = sessionId(JsonField.ofNullable(sessionId)) + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional) = sessionId(sessionId.getOrNull()) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sessionId(sessionId: JsonField) = apply { this.sessionId = sessionId } + + /** Describes what triggered a deployment run, with trigger-specific metadata. */ + fun triggerContext(triggerContext: BetaManagedAgentsTriggerContext) = + triggerContext(JsonField.of(triggerContext)) + + /** + * Sets [Builder.triggerContext] to an arbitrary JSON value. + * + * You should usually call [Builder.triggerContext] with a well-typed + * [BetaManagedAgentsTriggerContext] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun triggerContext(triggerContext: JsonField) = apply { + this.triggerContext = triggerContext + } + + /** + * Alias for calling [triggerContext] with + * `BetaManagedAgentsTriggerContext.ofSchedule(schedule)`. + */ + fun triggerContext(schedule: BetaManagedAgentsScheduleTriggerContext) = + triggerContext(BetaManagedAgentsTriggerContext.ofSchedule(schedule)) + + /** + * Alias for calling [triggerContext] with the following: + * ```java + * BetaManagedAgentsScheduleTriggerContext.builder() + * .type(BetaManagedAgentsScheduleTriggerContext.Type.SCHEDULE) + * .scheduledAt(scheduledAt) + * .build() + * ``` + */ + fun scheduleTriggerContext(scheduledAt: OffsetDateTime) = + triggerContext( + BetaManagedAgentsScheduleTriggerContext.builder() + .type(BetaManagedAgentsScheduleTriggerContext.Type.SCHEDULE) + .scheduledAt(scheduledAt) + .build() + ) + + /** + * Alias for calling [triggerContext] with + * `BetaManagedAgentsTriggerContext.ofManual(manual)`. + */ + fun triggerContext(manual: BetaManagedAgentsManualTriggerContext) = + triggerContext(BetaManagedAgentsTriggerContext.ofManual(manual)) + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsDeploymentRun]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .agent() + * .createdAt() + * .deploymentId() + * .error() + * .sessionId() + * .triggerContext() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsDeploymentRun = + BetaManagedAgentsDeploymentRun( + checkRequired("id", id), + checkRequired("agent", agent), + checkRequired("createdAt", createdAt), + checkRequired("deploymentId", deploymentId), + checkRequired("error", error), + checkRequired("sessionId", sessionId), + checkRequired("triggerContext", triggerContext), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsDeploymentRun = apply { + if (validated) { + return@apply + } + + id() + agent().validate() + createdAt() + deploymentId() + error().ifPresent { it.validate() } + sessionId() + triggerContext().validate() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (agent.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (deploymentId.asKnown().isPresent) 1 else 0) + + (error.asKnown().getOrNull()?.validity() ?: 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + (triggerContext.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Why the run failed to create a session. The type identifies the failure; message is + * human-readable detail. + */ + @JsonDeserialize(using = Error.Deserializer::class) + @JsonSerialize(using = Error.Serializer::class) + class Error + private constructor( + private val environmentArchived: BetaManagedAgentsEnvironmentArchivedRunError? = null, + private val agentArchived: BetaManagedAgentsAgentArchivedRunError? = null, + private val environmentNotFound: BetaManagedAgentsEnvironmentNotFoundRunError? = null, + private val vaultNotFound: BetaManagedAgentsVaultNotFoundRunError? = null, + private val vaultArchived: BetaManagedAgentsVaultArchivedRunError? = null, + private val fileNotFound: BetaManagedAgentsFileNotFoundRunError? = null, + private val memoryStoreArchived: BetaManagedAgentsMemoryStoreArchivedRunError? = null, + private val skillNotFound: BetaManagedAgentsSkillNotFoundRunError? = null, + private val sessionResourceNotFound: BetaManagedAgentsSessionResourceNotFoundRunError? = + null, + private val workspaceArchived: BetaManagedAgentsWorkspaceArchivedRunError? = null, + private val organizationDisabled: BetaManagedAgentsOrganizationDisabledRunError? = null, + private val sessionRateLimited: BetaManagedAgentsSessionRateLimitedRunError? = null, + private val sessionCreationRejected: BetaManagedAgentsSessionCreationRejectedRunError? = + null, + private val unknown: BetaManagedAgentsUnknownRunError? = null, + private val selfHostedResourcesUnsupported: + BetaManagedAgentsSelfHostedResourcesUnsupportedRunError? = + null, + private val mcpEgressBlocked: BetaManagedAgentsMcpEgressBlockedRunError? = null, + private val _json: JsonValue? = null, + ) { + + /** The deployment's environment was archived. */ + fun environmentArchived(): Optional = + Optional.ofNullable(environmentArchived) + + /** The deployment's agent was archived. */ + fun agentArchived(): Optional = + Optional.ofNullable(agentArchived) + + /** The deployment's environment no longer exists. */ + fun environmentNotFound(): Optional = + Optional.ofNullable(environmentNotFound) + + /** A vault referenced by the deployment no longer exists. */ + fun vaultNotFound(): Optional = + Optional.ofNullable(vaultNotFound) + + /** A vault referenced by the deployment is archived. */ + fun vaultArchived(): Optional = + Optional.ofNullable(vaultArchived) + + /** A file resource referenced by the deployment no longer exists. */ + fun fileNotFound(): Optional = + Optional.ofNullable(fileNotFound) + + /** A memory store referenced by the deployment is archived. */ + fun memoryStoreArchived(): Optional = + Optional.ofNullable(memoryStoreArchived) + + /** A skill referenced by the deployment's agent no longer exists. */ + fun skillNotFound(): Optional = + Optional.ofNullable(skillNotFound) + + /** A referenced resource no longer exists and its kind was not reported. */ + fun sessionResourceNotFound(): Optional = + Optional.ofNullable(sessionResourceNotFound) + + /** The deployment's workspace was archived. */ + fun workspaceArchived(): Optional = + Optional.ofNullable(workspaceArchived) + + /** The deployment's organization is disabled. */ + fun organizationDisabled(): Optional = + Optional.ofNullable(organizationDisabled) + + /** + * Session creation was rejected due to rate limiting. The schedule keeps firing; subsequent + * runs may succeed. + */ + fun sessionRateLimited(): Optional = + Optional.ofNullable(sessionRateLimited) + + /** The session create request was rejected with a non-retryable validation error. */ + fun sessionCreationRejected(): Optional = + Optional.ofNullable(sessionCreationRejected) + + /** + * An unknown or unexpected error caused the run to fail. A fallback variant; clients that + * do not recognize a new error type can match on message alone. + */ + fun unknown(): Optional = Optional.ofNullable(unknown) + + /** + * The deployment configures resources, but its environment is self-hosted and cannot mount + * them. + */ + fun selfHostedResourcesUnsupported(): + Optional = + Optional.ofNullable(selfHostedResourcesUnsupported) + + /** + * An MCP server host used by the deployment's agent is blocked by the environment's network + * policy. + */ + fun mcpEgressBlocked(): Optional = + Optional.ofNullable(mcpEgressBlocked) + + fun isEnvironmentArchived(): Boolean = environmentArchived != null + + fun isAgentArchived(): Boolean = agentArchived != null + + fun isEnvironmentNotFound(): Boolean = environmentNotFound != null + + fun isVaultNotFound(): Boolean = vaultNotFound != null + + fun isVaultArchived(): Boolean = vaultArchived != null + + fun isFileNotFound(): Boolean = fileNotFound != null + + fun isMemoryStoreArchived(): Boolean = memoryStoreArchived != null + + fun isSkillNotFound(): Boolean = skillNotFound != null + + fun isSessionResourceNotFound(): Boolean = sessionResourceNotFound != null + + fun isWorkspaceArchived(): Boolean = workspaceArchived != null + + fun isOrganizationDisabled(): Boolean = organizationDisabled != null + + fun isSessionRateLimited(): Boolean = sessionRateLimited != null + + fun isSessionCreationRejected(): Boolean = sessionCreationRejected != null + + fun isUnknown(): Boolean = unknown != null + + fun isSelfHostedResourcesUnsupported(): Boolean = selfHostedResourcesUnsupported != null + + fun isMcpEgressBlocked(): Boolean = mcpEgressBlocked != null + + /** The deployment's environment was archived. */ + fun asEnvironmentArchived(): BetaManagedAgentsEnvironmentArchivedRunError = + environmentArchived.getOrThrow("environmentArchived") + + /** The deployment's agent was archived. */ + fun asAgentArchived(): BetaManagedAgentsAgentArchivedRunError = + agentArchived.getOrThrow("agentArchived") + + /** The deployment's environment no longer exists. */ + fun asEnvironmentNotFound(): BetaManagedAgentsEnvironmentNotFoundRunError = + environmentNotFound.getOrThrow("environmentNotFound") + + /** A vault referenced by the deployment no longer exists. */ + fun asVaultNotFound(): BetaManagedAgentsVaultNotFoundRunError = + vaultNotFound.getOrThrow("vaultNotFound") + + /** A vault referenced by the deployment is archived. */ + fun asVaultArchived(): BetaManagedAgentsVaultArchivedRunError = + vaultArchived.getOrThrow("vaultArchived") + + /** A file resource referenced by the deployment no longer exists. */ + fun asFileNotFound(): BetaManagedAgentsFileNotFoundRunError = + fileNotFound.getOrThrow("fileNotFound") + + /** A memory store referenced by the deployment is archived. */ + fun asMemoryStoreArchived(): BetaManagedAgentsMemoryStoreArchivedRunError = + memoryStoreArchived.getOrThrow("memoryStoreArchived") + + /** A skill referenced by the deployment's agent no longer exists. */ + fun asSkillNotFound(): BetaManagedAgentsSkillNotFoundRunError = + skillNotFound.getOrThrow("skillNotFound") + + /** A referenced resource no longer exists and its kind was not reported. */ + fun asSessionResourceNotFound(): BetaManagedAgentsSessionResourceNotFoundRunError = + sessionResourceNotFound.getOrThrow("sessionResourceNotFound") + + /** The deployment's workspace was archived. */ + fun asWorkspaceArchived(): BetaManagedAgentsWorkspaceArchivedRunError = + workspaceArchived.getOrThrow("workspaceArchived") + + /** The deployment's organization is disabled. */ + fun asOrganizationDisabled(): BetaManagedAgentsOrganizationDisabledRunError = + organizationDisabled.getOrThrow("organizationDisabled") + + /** + * Session creation was rejected due to rate limiting. The schedule keeps firing; subsequent + * runs may succeed. + */ + fun asSessionRateLimited(): BetaManagedAgentsSessionRateLimitedRunError = + sessionRateLimited.getOrThrow("sessionRateLimited") + + /** The session create request was rejected with a non-retryable validation error. */ + fun asSessionCreationRejected(): BetaManagedAgentsSessionCreationRejectedRunError = + sessionCreationRejected.getOrThrow("sessionCreationRejected") + + /** + * An unknown or unexpected error caused the run to fail. A fallback variant; clients that + * do not recognize a new error type can match on message alone. + */ + fun asUnknown(): BetaManagedAgentsUnknownRunError = unknown.getOrThrow("unknown") + + /** + * The deployment configures resources, but its environment is self-hosted and cannot mount + * them. + */ + fun asSelfHostedResourcesUnsupported(): + BetaManagedAgentsSelfHostedResourcesUnsupportedRunError = + selfHostedResourcesUnsupported.getOrThrow("selfHostedResourcesUnsupported") + + /** + * An MCP server host used by the deployment's agent is blocked by the environment's network + * policy. + */ + fun asMcpEgressBlocked(): BetaManagedAgentsMcpEgressBlockedRunError = + mcpEgressBlocked.getOrThrow("mcpEgressBlocked") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.anthropic.core.JsonValue; + * import java.util.Optional; + * + * Optional result = error.accept(new Error.Visitor>() { + * @Override + * public Optional visitEnvironmentArchived(BetaManagedAgentsEnvironmentArchivedRunError environmentArchived) { + * return Optional.of(environmentArchived.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws AnthropicInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + environmentArchived != null -> visitor.visitEnvironmentArchived(environmentArchived) + agentArchived != null -> visitor.visitAgentArchived(agentArchived) + environmentNotFound != null -> visitor.visitEnvironmentNotFound(environmentNotFound) + vaultNotFound != null -> visitor.visitVaultNotFound(vaultNotFound) + vaultArchived != null -> visitor.visitVaultArchived(vaultArchived) + fileNotFound != null -> visitor.visitFileNotFound(fileNotFound) + memoryStoreArchived != null -> visitor.visitMemoryStoreArchived(memoryStoreArchived) + skillNotFound != null -> visitor.visitSkillNotFound(skillNotFound) + sessionResourceNotFound != null -> + visitor.visitSessionResourceNotFound(sessionResourceNotFound) + workspaceArchived != null -> visitor.visitWorkspaceArchived(workspaceArchived) + organizationDisabled != null -> + visitor.visitOrganizationDisabled(organizationDisabled) + sessionRateLimited != null -> visitor.visitSessionRateLimited(sessionRateLimited) + sessionCreationRejected != null -> + visitor.visitSessionCreationRejected(sessionCreationRejected) + unknown != null -> visitor.visitUnknown(unknown) + selfHostedResourcesUnsupported != null -> + visitor.visitSelfHostedResourcesUnsupported(selfHostedResourcesUnsupported) + mcpEgressBlocked != null -> visitor.visitMcpEgressBlocked(mcpEgressBlocked) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Error = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitEnvironmentArchived( + environmentArchived: BetaManagedAgentsEnvironmentArchivedRunError + ) { + environmentArchived.validate() + } + + override fun visitAgentArchived( + agentArchived: BetaManagedAgentsAgentArchivedRunError + ) { + agentArchived.validate() + } + + override fun visitEnvironmentNotFound( + environmentNotFound: BetaManagedAgentsEnvironmentNotFoundRunError + ) { + environmentNotFound.validate() + } + + override fun visitVaultNotFound( + vaultNotFound: BetaManagedAgentsVaultNotFoundRunError + ) { + vaultNotFound.validate() + } + + override fun visitVaultArchived( + vaultArchived: BetaManagedAgentsVaultArchivedRunError + ) { + vaultArchived.validate() + } + + override fun visitFileNotFound( + fileNotFound: BetaManagedAgentsFileNotFoundRunError + ) { + fileNotFound.validate() + } + + override fun visitMemoryStoreArchived( + memoryStoreArchived: BetaManagedAgentsMemoryStoreArchivedRunError + ) { + memoryStoreArchived.validate() + } + + override fun visitSkillNotFound( + skillNotFound: BetaManagedAgentsSkillNotFoundRunError + ) { + skillNotFound.validate() + } + + override fun visitSessionResourceNotFound( + sessionResourceNotFound: BetaManagedAgentsSessionResourceNotFoundRunError + ) { + sessionResourceNotFound.validate() + } + + override fun visitWorkspaceArchived( + workspaceArchived: BetaManagedAgentsWorkspaceArchivedRunError + ) { + workspaceArchived.validate() + } + + override fun visitOrganizationDisabled( + organizationDisabled: BetaManagedAgentsOrganizationDisabledRunError + ) { + organizationDisabled.validate() + } + + override fun visitSessionRateLimited( + sessionRateLimited: BetaManagedAgentsSessionRateLimitedRunError + ) { + sessionRateLimited.validate() + } + + override fun visitSessionCreationRejected( + sessionCreationRejected: BetaManagedAgentsSessionCreationRejectedRunError + ) { + sessionCreationRejected.validate() + } + + override fun visitUnknown(unknown: BetaManagedAgentsUnknownRunError) { + unknown.validate() + } + + override fun visitSelfHostedResourcesUnsupported( + selfHostedResourcesUnsupported: + BetaManagedAgentsSelfHostedResourcesUnsupportedRunError + ) { + selfHostedResourcesUnsupported.validate() + } + + override fun visitMcpEgressBlocked( + mcpEgressBlocked: BetaManagedAgentsMcpEgressBlockedRunError + ) { + mcpEgressBlocked.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitEnvironmentArchived( + environmentArchived: BetaManagedAgentsEnvironmentArchivedRunError + ) = environmentArchived.validity() + + override fun visitAgentArchived( + agentArchived: BetaManagedAgentsAgentArchivedRunError + ) = agentArchived.validity() + + override fun visitEnvironmentNotFound( + environmentNotFound: BetaManagedAgentsEnvironmentNotFoundRunError + ) = environmentNotFound.validity() + + override fun visitVaultNotFound( + vaultNotFound: BetaManagedAgentsVaultNotFoundRunError + ) = vaultNotFound.validity() + + override fun visitVaultArchived( + vaultArchived: BetaManagedAgentsVaultArchivedRunError + ) = vaultArchived.validity() + + override fun visitFileNotFound( + fileNotFound: BetaManagedAgentsFileNotFoundRunError + ) = fileNotFound.validity() + + override fun visitMemoryStoreArchived( + memoryStoreArchived: BetaManagedAgentsMemoryStoreArchivedRunError + ) = memoryStoreArchived.validity() + + override fun visitSkillNotFound( + skillNotFound: BetaManagedAgentsSkillNotFoundRunError + ) = skillNotFound.validity() + + override fun visitSessionResourceNotFound( + sessionResourceNotFound: BetaManagedAgentsSessionResourceNotFoundRunError + ) = sessionResourceNotFound.validity() + + override fun visitWorkspaceArchived( + workspaceArchived: BetaManagedAgentsWorkspaceArchivedRunError + ) = workspaceArchived.validity() + + override fun visitOrganizationDisabled( + organizationDisabled: BetaManagedAgentsOrganizationDisabledRunError + ) = organizationDisabled.validity() + + override fun visitSessionRateLimited( + sessionRateLimited: BetaManagedAgentsSessionRateLimitedRunError + ) = sessionRateLimited.validity() + + override fun visitSessionCreationRejected( + sessionCreationRejected: BetaManagedAgentsSessionCreationRejectedRunError + ) = sessionCreationRejected.validity() + + override fun visitUnknown(unknown: BetaManagedAgentsUnknownRunError) = + unknown.validity() + + override fun visitSelfHostedResourcesUnsupported( + selfHostedResourcesUnsupported: + BetaManagedAgentsSelfHostedResourcesUnsupportedRunError + ) = selfHostedResourcesUnsupported.validity() + + override fun visitMcpEgressBlocked( + mcpEgressBlocked: BetaManagedAgentsMcpEgressBlockedRunError + ) = mcpEgressBlocked.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Error && + environmentArchived == other.environmentArchived && + agentArchived == other.agentArchived && + environmentNotFound == other.environmentNotFound && + vaultNotFound == other.vaultNotFound && + vaultArchived == other.vaultArchived && + fileNotFound == other.fileNotFound && + memoryStoreArchived == other.memoryStoreArchived && + skillNotFound == other.skillNotFound && + sessionResourceNotFound == other.sessionResourceNotFound && + workspaceArchived == other.workspaceArchived && + organizationDisabled == other.organizationDisabled && + sessionRateLimited == other.sessionRateLimited && + sessionCreationRejected == other.sessionCreationRejected && + unknown == other.unknown && + selfHostedResourcesUnsupported == other.selfHostedResourcesUnsupported && + mcpEgressBlocked == other.mcpEgressBlocked + } + + override fun hashCode(): Int = + Objects.hash( + environmentArchived, + agentArchived, + environmentNotFound, + vaultNotFound, + vaultArchived, + fileNotFound, + memoryStoreArchived, + skillNotFound, + sessionResourceNotFound, + workspaceArchived, + organizationDisabled, + sessionRateLimited, + sessionCreationRejected, + unknown, + selfHostedResourcesUnsupported, + mcpEgressBlocked, + ) + + override fun toString(): String = + when { + environmentArchived != null -> "Error{environmentArchived=$environmentArchived}" + agentArchived != null -> "Error{agentArchived=$agentArchived}" + environmentNotFound != null -> "Error{environmentNotFound=$environmentNotFound}" + vaultNotFound != null -> "Error{vaultNotFound=$vaultNotFound}" + vaultArchived != null -> "Error{vaultArchived=$vaultArchived}" + fileNotFound != null -> "Error{fileNotFound=$fileNotFound}" + memoryStoreArchived != null -> "Error{memoryStoreArchived=$memoryStoreArchived}" + skillNotFound != null -> "Error{skillNotFound=$skillNotFound}" + sessionResourceNotFound != null -> + "Error{sessionResourceNotFound=$sessionResourceNotFound}" + workspaceArchived != null -> "Error{workspaceArchived=$workspaceArchived}" + organizationDisabled != null -> "Error{organizationDisabled=$organizationDisabled}" + sessionRateLimited != null -> "Error{sessionRateLimited=$sessionRateLimited}" + sessionCreationRejected != null -> + "Error{sessionCreationRejected=$sessionCreationRejected}" + unknown != null -> "Error{unknown=$unknown}" + selfHostedResourcesUnsupported != null -> + "Error{selfHostedResourcesUnsupported=$selfHostedResourcesUnsupported}" + mcpEgressBlocked != null -> "Error{mcpEgressBlocked=$mcpEgressBlocked}" + _json != null -> "Error{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Error") + } + + companion object { + + /** The deployment's environment was archived. */ + @JvmStatic + fun ofEnvironmentArchived( + environmentArchived: BetaManagedAgentsEnvironmentArchivedRunError + ) = Error(environmentArchived = environmentArchived) + + /** The deployment's agent was archived. */ + @JvmStatic + fun ofAgentArchived(agentArchived: BetaManagedAgentsAgentArchivedRunError) = + Error(agentArchived = agentArchived) + + /** The deployment's environment no longer exists. */ + @JvmStatic + fun ofEnvironmentNotFound( + environmentNotFound: BetaManagedAgentsEnvironmentNotFoundRunError + ) = Error(environmentNotFound = environmentNotFound) + + /** A vault referenced by the deployment no longer exists. */ + @JvmStatic + fun ofVaultNotFound(vaultNotFound: BetaManagedAgentsVaultNotFoundRunError) = + Error(vaultNotFound = vaultNotFound) + + /** A vault referenced by the deployment is archived. */ + @JvmStatic + fun ofVaultArchived(vaultArchived: BetaManagedAgentsVaultArchivedRunError) = + Error(vaultArchived = vaultArchived) + + /** A file resource referenced by the deployment no longer exists. */ + @JvmStatic + fun ofFileNotFound(fileNotFound: BetaManagedAgentsFileNotFoundRunError) = + Error(fileNotFound = fileNotFound) + + /** A memory store referenced by the deployment is archived. */ + @JvmStatic + fun ofMemoryStoreArchived( + memoryStoreArchived: BetaManagedAgentsMemoryStoreArchivedRunError + ) = Error(memoryStoreArchived = memoryStoreArchived) + + /** A skill referenced by the deployment's agent no longer exists. */ + @JvmStatic + fun ofSkillNotFound(skillNotFound: BetaManagedAgentsSkillNotFoundRunError) = + Error(skillNotFound = skillNotFound) + + /** A referenced resource no longer exists and its kind was not reported. */ + @JvmStatic + fun ofSessionResourceNotFound( + sessionResourceNotFound: BetaManagedAgentsSessionResourceNotFoundRunError + ) = Error(sessionResourceNotFound = sessionResourceNotFound) + + /** The deployment's workspace was archived. */ + @JvmStatic + fun ofWorkspaceArchived(workspaceArchived: BetaManagedAgentsWorkspaceArchivedRunError) = + Error(workspaceArchived = workspaceArchived) + + /** The deployment's organization is disabled. */ + @JvmStatic + fun ofOrganizationDisabled( + organizationDisabled: BetaManagedAgentsOrganizationDisabledRunError + ) = Error(organizationDisabled = organizationDisabled) + + /** + * Session creation was rejected due to rate limiting. The schedule keeps firing; + * subsequent runs may succeed. + */ + @JvmStatic + fun ofSessionRateLimited( + sessionRateLimited: BetaManagedAgentsSessionRateLimitedRunError + ) = Error(sessionRateLimited = sessionRateLimited) + + /** The session create request was rejected with a non-retryable validation error. */ + @JvmStatic + fun ofSessionCreationRejected( + sessionCreationRejected: BetaManagedAgentsSessionCreationRejectedRunError + ) = Error(sessionCreationRejected = sessionCreationRejected) + + /** + * An unknown or unexpected error caused the run to fail. A fallback variant; clients + * that do not recognize a new error type can match on message alone. + */ + @JvmStatic + fun ofUnknown(unknown: BetaManagedAgentsUnknownRunError) = Error(unknown = unknown) + + /** + * The deployment configures resources, but its environment is self-hosted and cannot + * mount them. + */ + @JvmStatic + fun ofSelfHostedResourcesUnsupported( + selfHostedResourcesUnsupported: + BetaManagedAgentsSelfHostedResourcesUnsupportedRunError + ) = Error(selfHostedResourcesUnsupported = selfHostedResourcesUnsupported) + + /** + * An MCP server host used by the deployment's agent is blocked by the environment's + * network policy. + */ + @JvmStatic + fun ofMcpEgressBlocked(mcpEgressBlocked: BetaManagedAgentsMcpEgressBlockedRunError) = + Error(mcpEgressBlocked = mcpEgressBlocked) + } + + /** An interface that defines how to map each variant of [Error] to a value of type [T]. */ + interface Visitor { + + /** The deployment's environment was archived. */ + fun visitEnvironmentArchived( + environmentArchived: BetaManagedAgentsEnvironmentArchivedRunError + ): T + + /** The deployment's agent was archived. */ + fun visitAgentArchived(agentArchived: BetaManagedAgentsAgentArchivedRunError): T + + /** The deployment's environment no longer exists. */ + fun visitEnvironmentNotFound( + environmentNotFound: BetaManagedAgentsEnvironmentNotFoundRunError + ): T + + /** A vault referenced by the deployment no longer exists. */ + fun visitVaultNotFound(vaultNotFound: BetaManagedAgentsVaultNotFoundRunError): T + + /** A vault referenced by the deployment is archived. */ + fun visitVaultArchived(vaultArchived: BetaManagedAgentsVaultArchivedRunError): T + + /** A file resource referenced by the deployment no longer exists. */ + fun visitFileNotFound(fileNotFound: BetaManagedAgentsFileNotFoundRunError): T + + /** A memory store referenced by the deployment is archived. */ + fun visitMemoryStoreArchived( + memoryStoreArchived: BetaManagedAgentsMemoryStoreArchivedRunError + ): T + + /** A skill referenced by the deployment's agent no longer exists. */ + fun visitSkillNotFound(skillNotFound: BetaManagedAgentsSkillNotFoundRunError): T + + /** A referenced resource no longer exists and its kind was not reported. */ + fun visitSessionResourceNotFound( + sessionResourceNotFound: BetaManagedAgentsSessionResourceNotFoundRunError + ): T + + /** The deployment's workspace was archived. */ + fun visitWorkspaceArchived( + workspaceArchived: BetaManagedAgentsWorkspaceArchivedRunError + ): T + + /** The deployment's organization is disabled. */ + fun visitOrganizationDisabled( + organizationDisabled: BetaManagedAgentsOrganizationDisabledRunError + ): T + + /** + * Session creation was rejected due to rate limiting. The schedule keeps firing; + * subsequent runs may succeed. + */ + fun visitSessionRateLimited( + sessionRateLimited: BetaManagedAgentsSessionRateLimitedRunError + ): T + + /** The session create request was rejected with a non-retryable validation error. */ + fun visitSessionCreationRejected( + sessionCreationRejected: BetaManagedAgentsSessionCreationRejectedRunError + ): T + + /** + * An unknown or unexpected error caused the run to fail. A fallback variant; clients + * that do not recognize a new error type can match on message alone. + */ + fun visitUnknown(unknown: BetaManagedAgentsUnknownRunError): T + + /** + * The deployment configures resources, but its environment is self-hosted and cannot + * mount them. + */ + fun visitSelfHostedResourcesUnsupported( + selfHostedResourcesUnsupported: + BetaManagedAgentsSelfHostedResourcesUnsupportedRunError + ): T + + /** + * An MCP server host used by the deployment's agent is blocked by the environment's + * network policy. + */ + fun visitMcpEgressBlocked( + mcpEgressBlocked: BetaManagedAgentsMcpEgressBlockedRunError + ): T + + /** + * Maps an unknown variant of [Error] to a value of type [T]. + * + * An instance of [Error] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws AnthropicInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw AnthropicInvalidDataException("Unknown Error: $json") + } + } + + internal class Deserializer : BaseDeserializer(Error::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Error { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "environment_archived_error" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Error(environmentArchived = it, _json = json) } + ?: Error(_json = json) + } + "agent_archived_error" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Error(agentArchived = it, _json = json) } ?: Error(_json = json) + } + "environment_not_found_error" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Error(environmentNotFound = it, _json = json) } + ?: Error(_json = json) + } + "vault_not_found_error" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Error(vaultNotFound = it, _json = json) } ?: Error(_json = json) + } + "vault_archived_error" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Error(vaultArchived = it, _json = json) } ?: Error(_json = json) + } + "file_not_found_error" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Error(fileNotFound = it, _json = json) } ?: Error(_json = json) + } + "memory_store_archived_error" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Error(memoryStoreArchived = it, _json = json) } + ?: Error(_json = json) + } + "skill_not_found_error" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Error(skillNotFound = it, _json = json) } ?: Error(_json = json) + } + "session_resource_not_found_error" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Error(sessionResourceNotFound = it, _json = json) } + ?: Error(_json = json) + } + "workspace_archived_error" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Error(workspaceArchived = it, _json = json) } + ?: Error(_json = json) + } + "organization_disabled_error" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Error(organizationDisabled = it, _json = json) } + ?: Error(_json = json) + } + "session_rate_limited_error" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Error(sessionRateLimited = it, _json = json) } + ?: Error(_json = json) + } + "session_creation_rejected_error" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Error(sessionCreationRejected = it, _json = json) } + ?: Error(_json = json) + } + "unknown_error" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Error(unknown = it, _json = json) } ?: Error(_json = json) + } + "self_hosted_resources_unsupported_error" -> { + return tryDeserialize( + node, + jacksonTypeRef< + BetaManagedAgentsSelfHostedResourcesUnsupportedRunError + >(), + ) + ?.let { Error(selfHostedResourcesUnsupported = it, _json = json) } + ?: Error(_json = json) + } + "mcp_egress_blocked_error" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Error(mcpEgressBlocked = it, _json = json) } + ?: Error(_json = json) + } + } + + return Error(_json = json) + } + } + + internal class Serializer : BaseSerializer(Error::class) { + + override fun serialize( + value: Error, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.environmentArchived != null -> + generator.writeObject(value.environmentArchived) + value.agentArchived != null -> generator.writeObject(value.agentArchived) + value.environmentNotFound != null -> + generator.writeObject(value.environmentNotFound) + value.vaultNotFound != null -> generator.writeObject(value.vaultNotFound) + value.vaultArchived != null -> generator.writeObject(value.vaultArchived) + value.fileNotFound != null -> generator.writeObject(value.fileNotFound) + value.memoryStoreArchived != null -> + generator.writeObject(value.memoryStoreArchived) + value.skillNotFound != null -> generator.writeObject(value.skillNotFound) + value.sessionResourceNotFound != null -> + generator.writeObject(value.sessionResourceNotFound) + value.workspaceArchived != null -> + generator.writeObject(value.workspaceArchived) + value.organizationDisabled != null -> + generator.writeObject(value.organizationDisabled) + value.sessionRateLimited != null -> + generator.writeObject(value.sessionRateLimited) + value.sessionCreationRejected != null -> + generator.writeObject(value.sessionCreationRejected) + value.unknown != null -> generator.writeObject(value.unknown) + value.selfHostedResourcesUnsupported != null -> + generator.writeObject(value.selfHostedResourcesUnsupported) + value.mcpEgressBlocked != null -> generator.writeObject(value.mcpEgressBlocked) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Error") + } + } + } + } + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val DEPLOYMENT_RUN = of("deployment_run") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + DEPLOYMENT_RUN + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + DEPLOYMENT_RUN, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + DEPLOYMENT_RUN -> Value.DEPLOYMENT_RUN + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + DEPLOYMENT_RUN -> Known.DEPLOYMENT_RUN + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsDeploymentRun && + id == other.id && + agent == other.agent && + createdAt == other.createdAt && + deploymentId == other.deploymentId && + error == other.error && + sessionId == other.sessionId && + triggerContext == other.triggerContext && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + agent, + createdAt, + deploymentId, + error, + sessionId, + triggerContext, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsDeploymentRun{id=$id, agent=$agent, createdAt=$createdAt, deploymentId=$deploymentId, error=$error, sessionId=$sessionId, triggerContext=$triggerContext, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsEnvironmentArchivedRunError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsEnvironmentArchivedRunError.kt new file mode 100644 index 000000000..75533fc06 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsEnvironmentArchivedRunError.kt @@ -0,0 +1,353 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** The deployment's environment was archived. */ +class BetaManagedAgentsEnvironmentArchivedRunError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val message: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(message, type, mutableMapOf()) + + /** + * Human-readable error description. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): String = message.getRequired("message") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsEnvironmentArchivedRunError]. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsEnvironmentArchivedRunError]. */ + class Builder internal constructor() { + + private var message: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsEnvironmentArchivedRunError: + BetaManagedAgentsEnvironmentArchivedRunError + ) = apply { + message = betaManagedAgentsEnvironmentArchivedRunError.message + type = betaManagedAgentsEnvironmentArchivedRunError.type + additionalProperties = + betaManagedAgentsEnvironmentArchivedRunError.additionalProperties.toMutableMap() + } + + /** Human-readable error description. */ + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsEnvironmentArchivedRunError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsEnvironmentArchivedRunError = + BetaManagedAgentsEnvironmentArchivedRunError( + checkRequired("message", message), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsEnvironmentArchivedRunError = apply { + if (validated) { + return@apply + } + + message() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (message.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ENVIRONMENT_ARCHIVED_ERROR = of("environment_archived_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ENVIRONMENT_ARCHIVED_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ENVIRONMENT_ARCHIVED_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ENVIRONMENT_ARCHIVED_ERROR -> Value.ENVIRONMENT_ARCHIVED_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ENVIRONMENT_ARCHIVED_ERROR -> Known.ENVIRONMENT_ARCHIVED_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsEnvironmentArchivedRunError && + message == other.message && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(message, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsEnvironmentArchivedRunError{message=$message, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsEnvironmentNotFoundRunError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsEnvironmentNotFoundRunError.kt new file mode 100644 index 000000000..45b70e087 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsEnvironmentNotFoundRunError.kt @@ -0,0 +1,353 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** The deployment's environment no longer exists. */ +class BetaManagedAgentsEnvironmentNotFoundRunError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val message: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(message, type, mutableMapOf()) + + /** + * Human-readable error description. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): String = message.getRequired("message") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsEnvironmentNotFoundRunError]. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsEnvironmentNotFoundRunError]. */ + class Builder internal constructor() { + + private var message: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsEnvironmentNotFoundRunError: + BetaManagedAgentsEnvironmentNotFoundRunError + ) = apply { + message = betaManagedAgentsEnvironmentNotFoundRunError.message + type = betaManagedAgentsEnvironmentNotFoundRunError.type + additionalProperties = + betaManagedAgentsEnvironmentNotFoundRunError.additionalProperties.toMutableMap() + } + + /** Human-readable error description. */ + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsEnvironmentNotFoundRunError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsEnvironmentNotFoundRunError = + BetaManagedAgentsEnvironmentNotFoundRunError( + checkRequired("message", message), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsEnvironmentNotFoundRunError = apply { + if (validated) { + return@apply + } + + message() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (message.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ENVIRONMENT_NOT_FOUND_ERROR = of("environment_not_found_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ENVIRONMENT_NOT_FOUND_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ENVIRONMENT_NOT_FOUND_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ENVIRONMENT_NOT_FOUND_ERROR -> Value.ENVIRONMENT_NOT_FOUND_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ENVIRONMENT_NOT_FOUND_ERROR -> Known.ENVIRONMENT_NOT_FOUND_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsEnvironmentNotFoundRunError && + message == other.message && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(message, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsEnvironmentNotFoundRunError{message=$message, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsFileNotFoundRunError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsFileNotFoundRunError.kt new file mode 100644 index 000000000..fcfe7fd1a --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsFileNotFoundRunError.kt @@ -0,0 +1,352 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** A file resource referenced by the deployment no longer exists. */ +class BetaManagedAgentsFileNotFoundRunError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val message: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(message, type, mutableMapOf()) + + /** + * Human-readable error description. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): String = message.getRequired("message") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsFileNotFoundRunError]. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsFileNotFoundRunError]. */ + class Builder internal constructor() { + + private var message: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsFileNotFoundRunError: BetaManagedAgentsFileNotFoundRunError + ) = apply { + message = betaManagedAgentsFileNotFoundRunError.message + type = betaManagedAgentsFileNotFoundRunError.type + additionalProperties = + betaManagedAgentsFileNotFoundRunError.additionalProperties.toMutableMap() + } + + /** Human-readable error description. */ + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsFileNotFoundRunError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsFileNotFoundRunError = + BetaManagedAgentsFileNotFoundRunError( + checkRequired("message", message), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsFileNotFoundRunError = apply { + if (validated) { + return@apply + } + + message() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (message.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val FILE_NOT_FOUND_ERROR = of("file_not_found_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + FILE_NOT_FOUND_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + FILE_NOT_FOUND_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + FILE_NOT_FOUND_ERROR -> Value.FILE_NOT_FOUND_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + FILE_NOT_FOUND_ERROR -> Known.FILE_NOT_FOUND_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsFileNotFoundRunError && + message == other.message && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(message, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsFileNotFoundRunError{message=$message, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsManualTriggerContext.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsManualTriggerContext.kt new file mode 100644 index 000000000..c8163beae --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsManualTriggerContext.kt @@ -0,0 +1,315 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** The run was started manually by creating a session directly against the deployment. */ +class BetaManagedAgentsManualTriggerContext +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsManualTriggerContext]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsManualTriggerContext]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsManualTriggerContext: BetaManagedAgentsManualTriggerContext + ) = apply { + type = betaManagedAgentsManualTriggerContext.type + additionalProperties = + betaManagedAgentsManualTriggerContext.additionalProperties.toMutableMap() + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsManualTriggerContext]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsManualTriggerContext = + BetaManagedAgentsManualTriggerContext( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsManualTriggerContext = apply { + if (validated) { + return@apply + } + + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MANUAL = of("manual") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + MANUAL + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MANUAL, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MANUAL -> Value.MANUAL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MANUAL -> Known.MANUAL + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsManualTriggerContext && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsManualTriggerContext{type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsMcpEgressBlockedRunError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsMcpEgressBlockedRunError.kt new file mode 100644 index 000000000..097b17b6b --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsMcpEgressBlockedRunError.kt @@ -0,0 +1,354 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** + * An MCP server host used by the deployment's agent is blocked by the environment's network policy. + */ +class BetaManagedAgentsMcpEgressBlockedRunError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val message: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(message, type, mutableMapOf()) + + /** + * Human-readable error description. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): String = message.getRequired("message") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsMcpEgressBlockedRunError]. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsMcpEgressBlockedRunError]. */ + class Builder internal constructor() { + + private var message: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsMcpEgressBlockedRunError: BetaManagedAgentsMcpEgressBlockedRunError + ) = apply { + message = betaManagedAgentsMcpEgressBlockedRunError.message + type = betaManagedAgentsMcpEgressBlockedRunError.type + additionalProperties = + betaManagedAgentsMcpEgressBlockedRunError.additionalProperties.toMutableMap() + } + + /** Human-readable error description. */ + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsMcpEgressBlockedRunError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsMcpEgressBlockedRunError = + BetaManagedAgentsMcpEgressBlockedRunError( + checkRequired("message", message), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsMcpEgressBlockedRunError = apply { + if (validated) { + return@apply + } + + message() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (message.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MCP_EGRESS_BLOCKED_ERROR = of("mcp_egress_blocked_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + MCP_EGRESS_BLOCKED_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MCP_EGRESS_BLOCKED_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MCP_EGRESS_BLOCKED_ERROR -> Value.MCP_EGRESS_BLOCKED_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MCP_EGRESS_BLOCKED_ERROR -> Known.MCP_EGRESS_BLOCKED_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsMcpEgressBlockedRunError && + message == other.message && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(message, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsMcpEgressBlockedRunError{message=$message, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsMemoryStoreArchivedRunError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsMemoryStoreArchivedRunError.kt new file mode 100644 index 000000000..4c1e2aea2 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsMemoryStoreArchivedRunError.kt @@ -0,0 +1,353 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** A memory store referenced by the deployment is archived. */ +class BetaManagedAgentsMemoryStoreArchivedRunError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val message: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(message, type, mutableMapOf()) + + /** + * Human-readable error description. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): String = message.getRequired("message") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsMemoryStoreArchivedRunError]. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsMemoryStoreArchivedRunError]. */ + class Builder internal constructor() { + + private var message: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsMemoryStoreArchivedRunError: + BetaManagedAgentsMemoryStoreArchivedRunError + ) = apply { + message = betaManagedAgentsMemoryStoreArchivedRunError.message + type = betaManagedAgentsMemoryStoreArchivedRunError.type + additionalProperties = + betaManagedAgentsMemoryStoreArchivedRunError.additionalProperties.toMutableMap() + } + + /** Human-readable error description. */ + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsMemoryStoreArchivedRunError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsMemoryStoreArchivedRunError = + BetaManagedAgentsMemoryStoreArchivedRunError( + checkRequired("message", message), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsMemoryStoreArchivedRunError = apply { + if (validated) { + return@apply + } + + message() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (message.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MEMORY_STORE_ARCHIVED_ERROR = of("memory_store_archived_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + MEMORY_STORE_ARCHIVED_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MEMORY_STORE_ARCHIVED_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MEMORY_STORE_ARCHIVED_ERROR -> Value.MEMORY_STORE_ARCHIVED_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MEMORY_STORE_ARCHIVED_ERROR -> Known.MEMORY_STORE_ARCHIVED_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsMemoryStoreArchivedRunError && + message == other.message && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(message, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsMemoryStoreArchivedRunError{message=$message, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsOrganizationDisabledRunError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsOrganizationDisabledRunError.kt new file mode 100644 index 000000000..de520d506 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsOrganizationDisabledRunError.kt @@ -0,0 +1,353 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** The deployment's organization is disabled. */ +class BetaManagedAgentsOrganizationDisabledRunError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val message: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(message, type, mutableMapOf()) + + /** + * Human-readable error description. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): String = message.getRequired("message") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsOrganizationDisabledRunError]. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsOrganizationDisabledRunError]. */ + class Builder internal constructor() { + + private var message: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsOrganizationDisabledRunError: + BetaManagedAgentsOrganizationDisabledRunError + ) = apply { + message = betaManagedAgentsOrganizationDisabledRunError.message + type = betaManagedAgentsOrganizationDisabledRunError.type + additionalProperties = + betaManagedAgentsOrganizationDisabledRunError.additionalProperties.toMutableMap() + } + + /** Human-readable error description. */ + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsOrganizationDisabledRunError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsOrganizationDisabledRunError = + BetaManagedAgentsOrganizationDisabledRunError( + checkRequired("message", message), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsOrganizationDisabledRunError = apply { + if (validated) { + return@apply + } + + message() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (message.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ORGANIZATION_DISABLED_ERROR = of("organization_disabled_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ORGANIZATION_DISABLED_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ORGANIZATION_DISABLED_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ORGANIZATION_DISABLED_ERROR -> Value.ORGANIZATION_DISABLED_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ORGANIZATION_DISABLED_ERROR -> Known.ORGANIZATION_DISABLED_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsOrganizationDisabledRunError && + message == other.message && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(message, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsOrganizationDisabledRunError{message=$message, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsScheduleTriggerContext.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsScheduleTriggerContext.kt new file mode 100644 index 000000000..c4cb8e298 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsScheduleTriggerContext.kt @@ -0,0 +1,361 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** The run was fired by the deployment's cron schedule. */ +class BetaManagedAgentsScheduleTriggerContext +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val scheduledAt: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("scheduled_at") + @ExcludeMissing + scheduledAt: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(scheduledAt, type, mutableMapOf()) + + /** + * A timestamp in RFC 3339 format + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun scheduledAt(): OffsetDateTime = scheduledAt.getRequired("scheduled_at") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [scheduledAt]. + * + * Unlike [scheduledAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("scheduled_at") + @ExcludeMissing + fun _scheduledAt(): JsonField = scheduledAt + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsScheduleTriggerContext]. + * + * The following fields are required: + * ```java + * .scheduledAt() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsScheduleTriggerContext]. */ + class Builder internal constructor() { + + private var scheduledAt: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsScheduleTriggerContext: BetaManagedAgentsScheduleTriggerContext + ) = apply { + scheduledAt = betaManagedAgentsScheduleTriggerContext.scheduledAt + type = betaManagedAgentsScheduleTriggerContext.type + additionalProperties = + betaManagedAgentsScheduleTriggerContext.additionalProperties.toMutableMap() + } + + /** A timestamp in RFC 3339 format */ + fun scheduledAt(scheduledAt: OffsetDateTime) = scheduledAt(JsonField.of(scheduledAt)) + + /** + * Sets [Builder.scheduledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun scheduledAt(scheduledAt: JsonField) = apply { + this.scheduledAt = scheduledAt + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsScheduleTriggerContext]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .scheduledAt() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsScheduleTriggerContext = + BetaManagedAgentsScheduleTriggerContext( + checkRequired("scheduledAt", scheduledAt), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsScheduleTriggerContext = apply { + if (validated) { + return@apply + } + + scheduledAt() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (scheduledAt.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SCHEDULE = of("schedule") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + SCHEDULE + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SCHEDULE, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SCHEDULE -> Value.SCHEDULE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SCHEDULE -> Known.SCHEDULE + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsScheduleTriggerContext && + scheduledAt == other.scheduledAt && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(scheduledAt, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsScheduleTriggerContext{scheduledAt=$scheduledAt, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSelfHostedResourcesUnsupportedRunError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSelfHostedResourcesUnsupportedRunError.kt new file mode 100644 index 000000000..2a6ea193b --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSelfHostedResourcesUnsupportedRunError.kt @@ -0,0 +1,361 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** + * The deployment configures resources, but its environment is self-hosted and cannot mount them. + */ +class BetaManagedAgentsSelfHostedResourcesUnsupportedRunError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val message: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(message, type, mutableMapOf()) + + /** + * Human-readable error description. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): String = message.getRequired("message") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsSelfHostedResourcesUnsupportedRunError]. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsSelfHostedResourcesUnsupportedRunError]. */ + class Builder internal constructor() { + + private var message: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsSelfHostedResourcesUnsupportedRunError: + BetaManagedAgentsSelfHostedResourcesUnsupportedRunError + ) = apply { + message = betaManagedAgentsSelfHostedResourcesUnsupportedRunError.message + type = betaManagedAgentsSelfHostedResourcesUnsupportedRunError.type + additionalProperties = + betaManagedAgentsSelfHostedResourcesUnsupportedRunError.additionalProperties + .toMutableMap() + } + + /** Human-readable error description. */ + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of + * [BetaManagedAgentsSelfHostedResourcesUnsupportedRunError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsSelfHostedResourcesUnsupportedRunError = + BetaManagedAgentsSelfHostedResourcesUnsupportedRunError( + checkRequired("message", message), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsSelfHostedResourcesUnsupportedRunError = apply { + if (validated) { + return@apply + } + + message() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (message.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField + val SELF_HOSTED_RESOURCES_UNSUPPORTED_ERROR = + of("self_hosted_resources_unsupported_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + SELF_HOSTED_RESOURCES_UNSUPPORTED_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SELF_HOSTED_RESOURCES_UNSUPPORTED_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SELF_HOSTED_RESOURCES_UNSUPPORTED_ERROR -> + Value.SELF_HOSTED_RESOURCES_UNSUPPORTED_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SELF_HOSTED_RESOURCES_UNSUPPORTED_ERROR -> + Known.SELF_HOSTED_RESOURCES_UNSUPPORTED_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsSelfHostedResourcesUnsupportedRunError && + message == other.message && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(message, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsSelfHostedResourcesUnsupportedRunError{message=$message, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSessionCreationRejectedRunError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSessionCreationRejectedRunError.kt new file mode 100644 index 000000000..b8d786357 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSessionCreationRejectedRunError.kt @@ -0,0 +1,353 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** The session create request was rejected with a non-retryable validation error. */ +class BetaManagedAgentsSessionCreationRejectedRunError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val message: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(message, type, mutableMapOf()) + + /** + * Human-readable error description. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): String = message.getRequired("message") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsSessionCreationRejectedRunError]. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsSessionCreationRejectedRunError]. */ + class Builder internal constructor() { + + private var message: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsSessionCreationRejectedRunError: + BetaManagedAgentsSessionCreationRejectedRunError + ) = apply { + message = betaManagedAgentsSessionCreationRejectedRunError.message + type = betaManagedAgentsSessionCreationRejectedRunError.type + additionalProperties = + betaManagedAgentsSessionCreationRejectedRunError.additionalProperties.toMutableMap() + } + + /** Human-readable error description. */ + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsSessionCreationRejectedRunError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsSessionCreationRejectedRunError = + BetaManagedAgentsSessionCreationRejectedRunError( + checkRequired("message", message), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsSessionCreationRejectedRunError = apply { + if (validated) { + return@apply + } + + message() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (message.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SESSION_CREATION_REJECTED_ERROR = of("session_creation_rejected_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + SESSION_CREATION_REJECTED_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SESSION_CREATION_REJECTED_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SESSION_CREATION_REJECTED_ERROR -> Value.SESSION_CREATION_REJECTED_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SESSION_CREATION_REJECTED_ERROR -> Known.SESSION_CREATION_REJECTED_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsSessionCreationRejectedRunError && + message == other.message && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(message, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsSessionCreationRejectedRunError{message=$message, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSessionRateLimitedRunError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSessionRateLimitedRunError.kt new file mode 100644 index 000000000..0ebbb6498 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSessionRateLimitedRunError.kt @@ -0,0 +1,355 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** + * Session creation was rejected due to rate limiting. The schedule keeps firing; subsequent runs + * may succeed. + */ +class BetaManagedAgentsSessionRateLimitedRunError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val message: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(message, type, mutableMapOf()) + + /** + * Human-readable error description. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): String = message.getRequired("message") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsSessionRateLimitedRunError]. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsSessionRateLimitedRunError]. */ + class Builder internal constructor() { + + private var message: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsSessionRateLimitedRunError: BetaManagedAgentsSessionRateLimitedRunError + ) = apply { + message = betaManagedAgentsSessionRateLimitedRunError.message + type = betaManagedAgentsSessionRateLimitedRunError.type + additionalProperties = + betaManagedAgentsSessionRateLimitedRunError.additionalProperties.toMutableMap() + } + + /** Human-readable error description. */ + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsSessionRateLimitedRunError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsSessionRateLimitedRunError = + BetaManagedAgentsSessionRateLimitedRunError( + checkRequired("message", message), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsSessionRateLimitedRunError = apply { + if (validated) { + return@apply + } + + message() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (message.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SESSION_RATE_LIMITED_ERROR = of("session_rate_limited_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + SESSION_RATE_LIMITED_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SESSION_RATE_LIMITED_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SESSION_RATE_LIMITED_ERROR -> Value.SESSION_RATE_LIMITED_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SESSION_RATE_LIMITED_ERROR -> Known.SESSION_RATE_LIMITED_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsSessionRateLimitedRunError && + message == other.message && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(message, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsSessionRateLimitedRunError{message=$message, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSessionResourceNotFoundRunError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSessionResourceNotFoundRunError.kt new file mode 100644 index 000000000..2255b4951 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSessionResourceNotFoundRunError.kt @@ -0,0 +1,353 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** A referenced resource no longer exists and its kind was not reported. */ +class BetaManagedAgentsSessionResourceNotFoundRunError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val message: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(message, type, mutableMapOf()) + + /** + * Human-readable error description. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): String = message.getRequired("message") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsSessionResourceNotFoundRunError]. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsSessionResourceNotFoundRunError]. */ + class Builder internal constructor() { + + private var message: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsSessionResourceNotFoundRunError: + BetaManagedAgentsSessionResourceNotFoundRunError + ) = apply { + message = betaManagedAgentsSessionResourceNotFoundRunError.message + type = betaManagedAgentsSessionResourceNotFoundRunError.type + additionalProperties = + betaManagedAgentsSessionResourceNotFoundRunError.additionalProperties.toMutableMap() + } + + /** Human-readable error description. */ + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsSessionResourceNotFoundRunError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsSessionResourceNotFoundRunError = + BetaManagedAgentsSessionResourceNotFoundRunError( + checkRequired("message", message), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsSessionResourceNotFoundRunError = apply { + if (validated) { + return@apply + } + + message() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (message.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SESSION_RESOURCE_NOT_FOUND_ERROR = of("session_resource_not_found_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + SESSION_RESOURCE_NOT_FOUND_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SESSION_RESOURCE_NOT_FOUND_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SESSION_RESOURCE_NOT_FOUND_ERROR -> Value.SESSION_RESOURCE_NOT_FOUND_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SESSION_RESOURCE_NOT_FOUND_ERROR -> Known.SESSION_RESOURCE_NOT_FOUND_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsSessionResourceNotFoundRunError && + message == other.message && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(message, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsSessionResourceNotFoundRunError{message=$message, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSkillNotFoundRunError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSkillNotFoundRunError.kt new file mode 100644 index 000000000..73d982ea3 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSkillNotFoundRunError.kt @@ -0,0 +1,352 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** A skill referenced by the deployment's agent no longer exists. */ +class BetaManagedAgentsSkillNotFoundRunError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val message: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(message, type, mutableMapOf()) + + /** + * Human-readable error description. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): String = message.getRequired("message") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsSkillNotFoundRunError]. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsSkillNotFoundRunError]. */ + class Builder internal constructor() { + + private var message: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsSkillNotFoundRunError: BetaManagedAgentsSkillNotFoundRunError + ) = apply { + message = betaManagedAgentsSkillNotFoundRunError.message + type = betaManagedAgentsSkillNotFoundRunError.type + additionalProperties = + betaManagedAgentsSkillNotFoundRunError.additionalProperties.toMutableMap() + } + + /** Human-readable error description. */ + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsSkillNotFoundRunError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsSkillNotFoundRunError = + BetaManagedAgentsSkillNotFoundRunError( + checkRequired("message", message), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsSkillNotFoundRunError = apply { + if (validated) { + return@apply + } + + message() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (message.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SKILL_NOT_FOUND_ERROR = of("skill_not_found_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + SKILL_NOT_FOUND_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SKILL_NOT_FOUND_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SKILL_NOT_FOUND_ERROR -> Value.SKILL_NOT_FOUND_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SKILL_NOT_FOUND_ERROR -> Known.SKILL_NOT_FOUND_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsSkillNotFoundRunError && + message == other.message && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(message, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsSkillNotFoundRunError{message=$message, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsTriggerContext.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsTriggerContext.kt new file mode 100644 index 000000000..f5f00961e --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsTriggerContext.kt @@ -0,0 +1,248 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.BaseDeserializer +import com.anthropic.core.BaseSerializer +import com.anthropic.core.JsonValue +import com.anthropic.core.getOrThrow +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Describes what triggered a deployment run, with trigger-specific metadata. */ +@JsonDeserialize(using = BetaManagedAgentsTriggerContext.Deserializer::class) +@JsonSerialize(using = BetaManagedAgentsTriggerContext.Serializer::class) +class BetaManagedAgentsTriggerContext +private constructor( + private val schedule: BetaManagedAgentsScheduleTriggerContext? = null, + private val manual: BetaManagedAgentsManualTriggerContext? = null, + private val _json: JsonValue? = null, +) { + + /** The run was fired by the deployment's cron schedule. */ + fun schedule(): Optional = + Optional.ofNullable(schedule) + + /** The run was started manually by creating a session directly against the deployment. */ + fun manual(): Optional = Optional.ofNullable(manual) + + fun isSchedule(): Boolean = schedule != null + + fun isManual(): Boolean = manual != null + + /** The run was fired by the deployment's cron schedule. */ + fun asSchedule(): BetaManagedAgentsScheduleTriggerContext = schedule.getOrThrow("schedule") + + /** The run was started manually by creating a session directly against the deployment. */ + fun asManual(): BetaManagedAgentsManualTriggerContext = manual.getOrThrow("manual") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.anthropic.core.JsonValue; + * import java.util.Optional; + * + * Optional result = betaManagedAgentsTriggerContext.accept(new BetaManagedAgentsTriggerContext.Visitor>() { + * @Override + * public Optional visitSchedule(BetaManagedAgentsScheduleTriggerContext schedule) { + * return Optional.of(schedule.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws AnthropicInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + schedule != null -> visitor.visitSchedule(schedule) + manual != null -> visitor.visitManual(manual) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsTriggerContext = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitSchedule(schedule: BetaManagedAgentsScheduleTriggerContext) { + schedule.validate() + } + + override fun visitManual(manual: BetaManagedAgentsManualTriggerContext) { + manual.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitSchedule(schedule: BetaManagedAgentsScheduleTriggerContext) = + schedule.validity() + + override fun visitManual(manual: BetaManagedAgentsManualTriggerContext) = + manual.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsTriggerContext && + schedule == other.schedule && + manual == other.manual + } + + override fun hashCode(): Int = Objects.hash(schedule, manual) + + override fun toString(): String = + when { + schedule != null -> "BetaManagedAgentsTriggerContext{schedule=$schedule}" + manual != null -> "BetaManagedAgentsTriggerContext{manual=$manual}" + _json != null -> "BetaManagedAgentsTriggerContext{_unknown=$_json}" + else -> throw IllegalStateException("Invalid BetaManagedAgentsTriggerContext") + } + + companion object { + + /** The run was fired by the deployment's cron schedule. */ + @JvmStatic + fun ofSchedule(schedule: BetaManagedAgentsScheduleTriggerContext) = + BetaManagedAgentsTriggerContext(schedule = schedule) + + /** The run was started manually by creating a session directly against the deployment. */ + @JvmStatic + fun ofManual(manual: BetaManagedAgentsManualTriggerContext) = + BetaManagedAgentsTriggerContext(manual = manual) + } + + /** + * An interface that defines how to map each variant of [BetaManagedAgentsTriggerContext] to a + * value of type [T]. + */ + interface Visitor { + + /** The run was fired by the deployment's cron schedule. */ + fun visitSchedule(schedule: BetaManagedAgentsScheduleTriggerContext): T + + /** The run was started manually by creating a session directly against the deployment. */ + fun visitManual(manual: BetaManagedAgentsManualTriggerContext): T + + /** + * Maps an unknown variant of [BetaManagedAgentsTriggerContext] to a value of type [T]. + * + * An instance of [BetaManagedAgentsTriggerContext] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK is + * on an older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws AnthropicInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw AnthropicInvalidDataException("Unknown BetaManagedAgentsTriggerContext: $json") + } + } + + internal class Deserializer : + BaseDeserializer(BetaManagedAgentsTriggerContext::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): BetaManagedAgentsTriggerContext { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "schedule" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { BetaManagedAgentsTriggerContext(schedule = it, _json = json) } + ?: BetaManagedAgentsTriggerContext(_json = json) + } + "manual" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { BetaManagedAgentsTriggerContext(manual = it, _json = json) } + ?: BetaManagedAgentsTriggerContext(_json = json) + } + } + + return BetaManagedAgentsTriggerContext(_json = json) + } + } + + internal class Serializer : + BaseSerializer(BetaManagedAgentsTriggerContext::class) { + + override fun serialize( + value: BetaManagedAgentsTriggerContext, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.schedule != null -> generator.writeObject(value.schedule) + value.manual != null -> generator.writeObject(value.manual) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid BetaManagedAgentsTriggerContext") + } + } + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsTriggerType.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsTriggerType.kt new file mode 100644 index 000000000..9254e0e97 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsTriggerType.kt @@ -0,0 +1,147 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.Enum +import com.anthropic.core.JsonField +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator + +/** What triggered a deployment run. */ +class BetaManagedAgentsTriggerType +@JsonCreator +private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SCHEDULE = of("schedule") + + @JvmField val MANUAL = of("manual") + + @JvmStatic fun of(value: String) = BetaManagedAgentsTriggerType(JsonField.of(value)) + } + + /** An enum containing [BetaManagedAgentsTriggerType]'s known values. */ + enum class Known { + SCHEDULE, + MANUAL, + } + + /** + * An enum containing [BetaManagedAgentsTriggerType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [BetaManagedAgentsTriggerType] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SCHEDULE, + MANUAL, + /** + * An enum member indicating that [BetaManagedAgentsTriggerType] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + SCHEDULE -> Value.SCHEDULE + MANUAL -> Value.MANUAL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + SCHEDULE -> Known.SCHEDULE + MANUAL -> Known.MANUAL + else -> + throw AnthropicInvalidDataException("Unknown BetaManagedAgentsTriggerType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { AnthropicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsTriggerType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsTriggerType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsUnknownRunError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsUnknownRunError.kt new file mode 100644 index 000000000..9a0a6fb1e --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsUnknownRunError.kt @@ -0,0 +1,354 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** + * An unknown or unexpected error caused the run to fail. A fallback variant; clients that do not + * recognize a new error type can match on message alone. + */ +class BetaManagedAgentsUnknownRunError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val message: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(message, type, mutableMapOf()) + + /** + * Human-readable error description. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): String = message.getRequired("message") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsUnknownRunError]. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsUnknownRunError]. */ + class Builder internal constructor() { + + private var message: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaManagedAgentsUnknownRunError: BetaManagedAgentsUnknownRunError) = + apply { + message = betaManagedAgentsUnknownRunError.message + type = betaManagedAgentsUnknownRunError.type + additionalProperties = + betaManagedAgentsUnknownRunError.additionalProperties.toMutableMap() + } + + /** Human-readable error description. */ + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsUnknownRunError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsUnknownRunError = + BetaManagedAgentsUnknownRunError( + checkRequired("message", message), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsUnknownRunError = apply { + if (validated) { + return@apply + } + + message() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (message.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val UNKNOWN_ERROR = of("unknown_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + UNKNOWN_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + UNKNOWN_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + UNKNOWN_ERROR -> Value.UNKNOWN_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + UNKNOWN_ERROR -> Known.UNKNOWN_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsUnknownRunError && + message == other.message && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(message, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsUnknownRunError{message=$message, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsVaultArchivedRunError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsVaultArchivedRunError.kt new file mode 100644 index 000000000..9ed0a1cde --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsVaultArchivedRunError.kt @@ -0,0 +1,352 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** A vault referenced by the deployment is archived. */ +class BetaManagedAgentsVaultArchivedRunError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val message: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(message, type, mutableMapOf()) + + /** + * Human-readable error description. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): String = message.getRequired("message") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsVaultArchivedRunError]. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsVaultArchivedRunError]. */ + class Builder internal constructor() { + + private var message: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsVaultArchivedRunError: BetaManagedAgentsVaultArchivedRunError + ) = apply { + message = betaManagedAgentsVaultArchivedRunError.message + type = betaManagedAgentsVaultArchivedRunError.type + additionalProperties = + betaManagedAgentsVaultArchivedRunError.additionalProperties.toMutableMap() + } + + /** Human-readable error description. */ + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsVaultArchivedRunError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsVaultArchivedRunError = + BetaManagedAgentsVaultArchivedRunError( + checkRequired("message", message), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsVaultArchivedRunError = apply { + if (validated) { + return@apply + } + + message() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (message.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val VAULT_ARCHIVED_ERROR = of("vault_archived_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + VAULT_ARCHIVED_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + VAULT_ARCHIVED_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + VAULT_ARCHIVED_ERROR -> Value.VAULT_ARCHIVED_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + VAULT_ARCHIVED_ERROR -> Known.VAULT_ARCHIVED_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsVaultArchivedRunError && + message == other.message && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(message, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsVaultArchivedRunError{message=$message, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsVaultNotFoundRunError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsVaultNotFoundRunError.kt new file mode 100644 index 000000000..be68689ad --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsVaultNotFoundRunError.kt @@ -0,0 +1,352 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** A vault referenced by the deployment no longer exists. */ +class BetaManagedAgentsVaultNotFoundRunError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val message: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(message, type, mutableMapOf()) + + /** + * Human-readable error description. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): String = message.getRequired("message") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsVaultNotFoundRunError]. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsVaultNotFoundRunError]. */ + class Builder internal constructor() { + + private var message: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsVaultNotFoundRunError: BetaManagedAgentsVaultNotFoundRunError + ) = apply { + message = betaManagedAgentsVaultNotFoundRunError.message + type = betaManagedAgentsVaultNotFoundRunError.type + additionalProperties = + betaManagedAgentsVaultNotFoundRunError.additionalProperties.toMutableMap() + } + + /** Human-readable error description. */ + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsVaultNotFoundRunError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsVaultNotFoundRunError = + BetaManagedAgentsVaultNotFoundRunError( + checkRequired("message", message), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsVaultNotFoundRunError = apply { + if (validated) { + return@apply + } + + message() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (message.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val VAULT_NOT_FOUND_ERROR = of("vault_not_found_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + VAULT_NOT_FOUND_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + VAULT_NOT_FOUND_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + VAULT_NOT_FOUND_ERROR -> Value.VAULT_NOT_FOUND_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + VAULT_NOT_FOUND_ERROR -> Known.VAULT_NOT_FOUND_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsVaultNotFoundRunError && + message == other.message && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(message, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsVaultNotFoundRunError{message=$message, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsWorkspaceArchivedRunError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsWorkspaceArchivedRunError.kt new file mode 100644 index 000000000..3b7c722ee --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsWorkspaceArchivedRunError.kt @@ -0,0 +1,352 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** The deployment's workspace was archived. */ +class BetaManagedAgentsWorkspaceArchivedRunError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val message: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(message, type, mutableMapOf()) + + /** + * Human-readable error description. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): String = message.getRequired("message") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsWorkspaceArchivedRunError]. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsWorkspaceArchivedRunError]. */ + class Builder internal constructor() { + + private var message: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsWorkspaceArchivedRunError: BetaManagedAgentsWorkspaceArchivedRunError + ) = apply { + message = betaManagedAgentsWorkspaceArchivedRunError.message + type = betaManagedAgentsWorkspaceArchivedRunError.type + additionalProperties = + betaManagedAgentsWorkspaceArchivedRunError.additionalProperties.toMutableMap() + } + + /** Human-readable error description. */ + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsWorkspaceArchivedRunError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .message() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsWorkspaceArchivedRunError = + BetaManagedAgentsWorkspaceArchivedRunError( + checkRequired("message", message), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsWorkspaceArchivedRunError = apply { + if (validated) { + return@apply + } + + message() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (message.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val WORKSPACE_ARCHIVED_ERROR = of("workspace_archived_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + WORKSPACE_ARCHIVED_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + WORKSPACE_ARCHIVED_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + WORKSPACE_ARCHIVED_ERROR -> Value.WORKSPACE_ARCHIVED_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + WORKSPACE_ARCHIVED_ERROR -> Known.WORKSPACE_ARCHIVED_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsWorkspaceArchivedRunError && + message == other.message && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(message, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsWorkspaceArchivedRunError{message=$message, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunListPage.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunListPage.kt new file mode 100644 index 000000000..f5a01a9b2 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunListPage.kt @@ -0,0 +1,133 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.AutoPager +import com.anthropic.core.Page +import com.anthropic.core.checkRequired +import com.anthropic.services.blocking.beta.DeploymentRunService +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** @see DeploymentRunService.list */ +class DeploymentRunListPage +private constructor( + private val service: DeploymentRunService, + private val params: DeploymentRunListParams, + private val response: DeploymentRunListPageResponse, +) : Page { + + /** + * Delegates to [DeploymentRunListPageResponse], but gracefully handles missing data. + * + * @see DeploymentRunListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [DeploymentRunListPageResponse], but gracefully handles missing data. + * + * @see DeploymentRunListPageResponse.nextPage + */ + fun nextPageRaw(): Optional = response._nextPage().getOptional("next_page") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextPageRaw().isPresent + + fun nextPageParams(): DeploymentRunListParams { + val nextCursor = + nextPageRaw().getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().page(nextCursor).build() + } + + override fun nextPage(): DeploymentRunListPage = service.list(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): DeploymentRunListParams = params + + /** The response that this page was parsed from. */ + fun response(): DeploymentRunListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DeploymentRunListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DeploymentRunListPage]. */ + class Builder internal constructor() { + + private var service: DeploymentRunService? = null + private var params: DeploymentRunListParams? = null + private var response: DeploymentRunListPageResponse? = null + + @JvmSynthetic + internal fun from(deploymentRunListPage: DeploymentRunListPage) = apply { + service = deploymentRunListPage.service + params = deploymentRunListPage.params + response = deploymentRunListPage.response + } + + fun service(service: DeploymentRunService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: DeploymentRunListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: DeploymentRunListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [DeploymentRunListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DeploymentRunListPage = + DeploymentRunListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DeploymentRunListPage && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = + "DeploymentRunListPage{service=$service, params=$params, response=$response}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunListPageAsync.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunListPageAsync.kt new file mode 100644 index 000000000..e4d3e97c1 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunListPageAsync.kt @@ -0,0 +1,148 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.AutoPagerAsync +import com.anthropic.core.PageAsync +import com.anthropic.core.checkRequired +import com.anthropic.services.async.beta.DeploymentRunServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import kotlin.jvm.optionals.getOrNull + +/** @see DeploymentRunServiceAsync.list */ +class DeploymentRunListPageAsync +private constructor( + private val service: DeploymentRunServiceAsync, + private val streamHandlerExecutor: Executor, + private val params: DeploymentRunListParams, + private val response: DeploymentRunListPageResponse, +) : PageAsync { + + /** + * Delegates to [DeploymentRunListPageResponse], but gracefully handles missing data. + * + * @see DeploymentRunListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [DeploymentRunListPageResponse], but gracefully handles missing data. + * + * @see DeploymentRunListPageResponse.nextPage + */ + fun nextPageRaw(): Optional = response._nextPage().getOptional("next_page") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextPageRaw().isPresent + + fun nextPageParams(): DeploymentRunListParams { + val nextCursor = + nextPageRaw().getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().page(nextCursor).build() + } + + override fun nextPage(): CompletableFuture = + service.list(nextPageParams()) + + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) + + /** The parameters that were used to request this page. */ + fun params(): DeploymentRunListParams = params + + /** The response that this page was parsed from. */ + fun response(): DeploymentRunListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DeploymentRunListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DeploymentRunListPageAsync]. */ + class Builder internal constructor() { + + private var service: DeploymentRunServiceAsync? = null + private var streamHandlerExecutor: Executor? = null + private var params: DeploymentRunListParams? = null + private var response: DeploymentRunListPageResponse? = null + + @JvmSynthetic + internal fun from(deploymentRunListPageAsync: DeploymentRunListPageAsync) = apply { + service = deploymentRunListPageAsync.service + streamHandlerExecutor = deploymentRunListPageAsync.streamHandlerExecutor + params = deploymentRunListPageAsync.params + response = deploymentRunListPageAsync.response + } + + fun service(service: DeploymentRunServiceAsync) = apply { this.service = service } + + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + + /** The parameters that were used to request this page. */ + fun params(params: DeploymentRunListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: DeploymentRunListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [DeploymentRunListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DeploymentRunListPageAsync = + DeploymentRunListPageAsync( + checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DeploymentRunListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) + + override fun toString() = + "DeploymentRunListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunListPageResponse.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunListPageResponse.kt new file mode 100644 index 000000000..98914214e --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunListPageResponse.kt @@ -0,0 +1,248 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkKnown +import com.anthropic.core.checkRequired +import com.anthropic.core.toImmutable +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Paginated list of deployment runs. Sorted by created_at descending (most recent first). */ +class DeploymentRunListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField>, + private val nextPage: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + data: JsonField> = JsonMissing.of(), + @JsonProperty("next_page") @ExcludeMissing nextPage: JsonField = JsonMissing.of(), + ) : this(data, nextPage, mutableMapOf()) + + /** + * List of deployment runs. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): List = data.getRequired("data") + + /** + * Opaque cursor for the next page. Null when no more results. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun nextPage(): Optional = nextPage.getOptional("next_page") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") + @ExcludeMissing + fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [nextPage]. + * + * Unlike [nextPage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_page") @ExcludeMissing fun _nextPage(): JsonField = nextPage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [DeploymentRunListPageResponse]. + * + * The following fields are required: + * ```java + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DeploymentRunListPageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var nextPage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(deploymentRunListPageResponse: DeploymentRunListPageResponse) = apply { + data = + deploymentRunListPageResponse.data + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + nextPage = deploymentRunListPageResponse.nextPage + additionalProperties = deploymentRunListPageResponse.additionalProperties.toMutableMap() + } + + /** List of deployment runs. */ + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [BetaManagedAgentsDeploymentRun] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: BetaManagedAgentsDeploymentRun) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + /** Opaque cursor for the next page. Null when no more results. */ + fun nextPage(nextPage: String?) = nextPage(JsonField.ofNullable(nextPage)) + + /** Alias for calling [Builder.nextPage] with `nextPage.orElse(null)`. */ + fun nextPage(nextPage: Optional) = nextPage(nextPage.getOrNull()) + + /** + * Sets [Builder.nextPage] to an arbitrary JSON value. + * + * You should usually call [Builder.nextPage] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun nextPage(nextPage: JsonField) = apply { this.nextPage = nextPage } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DeploymentRunListPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DeploymentRunListPageResponse = + DeploymentRunListPageResponse( + checkRequired("data", data).map { it.toImmutable() }, + nextPage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): DeploymentRunListPageResponse = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + nextPage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (nextPage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DeploymentRunListPageResponse && + data == other.data && + nextPage == other.nextPage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, nextPage, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DeploymentRunListPageResponse{data=$data, nextPage=$nextPage, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunListParams.kt new file mode 100644 index 000000000..37f41d564 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunListParams.kt @@ -0,0 +1,418 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.Params +import com.anthropic.core.http.Headers +import com.anthropic.core.http.QueryParams +import com.anthropic.core.toImmutable +import com.anthropic.models.beta.AnthropicBeta +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** List Deployment Runs */ +class DeploymentRunListParams +private constructor( + private val createdAtGt: OffsetDateTime?, + private val createdAtGte: OffsetDateTime?, + private val createdAtLt: OffsetDateTime?, + private val createdAtLte: OffsetDateTime?, + private val deploymentId: String?, + private val hasError: Boolean?, + private val limit: Int?, + private val page: String?, + private val triggerType: BetaManagedAgentsTriggerType?, + private val betas: List?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Return runs created strictly after this time (exclusive). */ + fun createdAtGt(): Optional = Optional.ofNullable(createdAtGt) + + /** Return runs created at or after this time (inclusive). */ + fun createdAtGte(): Optional = Optional.ofNullable(createdAtGte) + + /** Return runs created strictly before this time (exclusive). */ + fun createdAtLt(): Optional = Optional.ofNullable(createdAtLt) + + /** Return runs created at or before this time (inclusive). */ + fun createdAtLte(): Optional = Optional.ofNullable(createdAtLte) + + /** + * Filter to a specific deployment. Omit to list across all deployments in the workspace. + * Filtering by a non-existent deployment_id returns 200 with empty data. + */ + fun deploymentId(): Optional = Optional.ofNullable(deploymentId) + + /** + * Filter: true for runs with non-null error, false for runs with non-null session_id. Omit for + * all. + */ + fun hasError(): Optional = Optional.ofNullable(hasError) + + /** Maximum results per page. Default 20, maximum 1000. */ + fun limit(): Optional = Optional.ofNullable(limit) + + /** + * Opaque pagination cursor. Pass next_page from the previous response. Invalid or expired + * cursors return 400. + */ + fun page(): Optional = Optional.ofNullable(page) + + /** Filter runs by what triggered them. Omit to return all runs. */ + fun triggerType(): Optional = Optional.ofNullable(triggerType) + + /** Optional header to specify the beta version(s) you want to use. */ + fun betas(): Optional> = Optional.ofNullable(betas) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): DeploymentRunListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [DeploymentRunListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DeploymentRunListParams]. */ + class Builder internal constructor() { + + private var createdAtGt: OffsetDateTime? = null + private var createdAtGte: OffsetDateTime? = null + private var createdAtLt: OffsetDateTime? = null + private var createdAtLte: OffsetDateTime? = null + private var deploymentId: String? = null + private var hasError: Boolean? = null + private var limit: Int? = null + private var page: String? = null + private var triggerType: BetaManagedAgentsTriggerType? = null + private var betas: MutableList? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(deploymentRunListParams: DeploymentRunListParams) = apply { + createdAtGt = deploymentRunListParams.createdAtGt + createdAtGte = deploymentRunListParams.createdAtGte + createdAtLt = deploymentRunListParams.createdAtLt + createdAtLte = deploymentRunListParams.createdAtLte + deploymentId = deploymentRunListParams.deploymentId + hasError = deploymentRunListParams.hasError + limit = deploymentRunListParams.limit + page = deploymentRunListParams.page + triggerType = deploymentRunListParams.triggerType + betas = deploymentRunListParams.betas?.toMutableList() + additionalHeaders = deploymentRunListParams.additionalHeaders.toBuilder() + additionalQueryParams = deploymentRunListParams.additionalQueryParams.toBuilder() + } + + /** Return runs created strictly after this time (exclusive). */ + fun createdAtGt(createdAtGt: OffsetDateTime?) = apply { this.createdAtGt = createdAtGt } + + /** Alias for calling [Builder.createdAtGt] with `createdAtGt.orElse(null)`. */ + fun createdAtGt(createdAtGt: Optional) = + createdAtGt(createdAtGt.getOrNull()) + + /** Return runs created at or after this time (inclusive). */ + fun createdAtGte(createdAtGte: OffsetDateTime?) = apply { this.createdAtGte = createdAtGte } + + /** Alias for calling [Builder.createdAtGte] with `createdAtGte.orElse(null)`. */ + fun createdAtGte(createdAtGte: Optional) = + createdAtGte(createdAtGte.getOrNull()) + + /** Return runs created strictly before this time (exclusive). */ + fun createdAtLt(createdAtLt: OffsetDateTime?) = apply { this.createdAtLt = createdAtLt } + + /** Alias for calling [Builder.createdAtLt] with `createdAtLt.orElse(null)`. */ + fun createdAtLt(createdAtLt: Optional) = + createdAtLt(createdAtLt.getOrNull()) + + /** Return runs created at or before this time (inclusive). */ + fun createdAtLte(createdAtLte: OffsetDateTime?) = apply { this.createdAtLte = createdAtLte } + + /** Alias for calling [Builder.createdAtLte] with `createdAtLte.orElse(null)`. */ + fun createdAtLte(createdAtLte: Optional) = + createdAtLte(createdAtLte.getOrNull()) + + /** + * Filter to a specific deployment. Omit to list across all deployments in the workspace. + * Filtering by a non-existent deployment_id returns 200 with empty data. + */ + fun deploymentId(deploymentId: String?) = apply { this.deploymentId = deploymentId } + + /** Alias for calling [Builder.deploymentId] with `deploymentId.orElse(null)`. */ + fun deploymentId(deploymentId: Optional) = deploymentId(deploymentId.getOrNull()) + + /** + * Filter: true for runs with non-null error, false for runs with non-null session_id. Omit + * for all. + */ + fun hasError(hasError: Boolean?) = apply { this.hasError = hasError } + + /** + * Alias for [Builder.hasError]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun hasError(hasError: Boolean) = hasError(hasError as Boolean?) + + /** Alias for calling [Builder.hasError] with `hasError.orElse(null)`. */ + fun hasError(hasError: Optional) = hasError(hasError.getOrNull()) + + /** Maximum results per page. Default 20, maximum 1000. */ + fun limit(limit: Int?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Int) = limit(limit as Int?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + /** + * Opaque pagination cursor. Pass next_page from the previous response. Invalid or expired + * cursors return 400. + */ + fun page(page: String?) = apply { this.page = page } + + /** Alias for calling [Builder.page] with `page.orElse(null)`. */ + fun page(page: Optional) = page(page.getOrNull()) + + /** Filter runs by what triggered them. Omit to return all runs. */ + fun triggerType(triggerType: BetaManagedAgentsTriggerType?) = apply { + this.triggerType = triggerType + } + + /** Alias for calling [Builder.triggerType] with `triggerType.orElse(null)`. */ + fun triggerType(triggerType: Optional) = + triggerType(triggerType.getOrNull()) + + /** Optional header to specify the beta version(s) you want to use. */ + fun betas(betas: List?) = apply { this.betas = betas?.toMutableList() } + + /** Alias for calling [Builder.betas] with `betas.orElse(null)`. */ + fun betas(betas: Optional>) = betas(betas.getOrNull()) + + /** + * Adds a single [AnthropicBeta] to [betas]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBeta(beta: AnthropicBeta) = apply { + betas = (betas ?: mutableListOf()).apply { add(beta) } + } + + /** + * Sets [addBeta] to an arbitrary [String]. + * + * You should usually call [addBeta] with a well-typed [AnthropicBeta] constant instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun addBeta(value: String) = addBeta(AnthropicBeta.of(value)) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DeploymentRunListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DeploymentRunListParams = + DeploymentRunListParams( + createdAtGt, + createdAtGte, + createdAtLt, + createdAtLte, + deploymentId, + hasError, + limit, + page, + triggerType, + betas?.toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = + Headers.builder() + .apply { + betas?.forEach { put("anthropic-beta", it.toString()) } + putAll(additionalHeaders) + } + .build() + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + createdAtGt?.let { + put("created_at[gt]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + createdAtGte?.let { + put("created_at[gte]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + createdAtLt?.let { + put("created_at[lt]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + createdAtLte?.let { + put("created_at[lte]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + deploymentId?.let { put("deployment_id", it) } + hasError?.let { put("has_error", it.toString()) } + limit?.let { put("limit", it.toString()) } + page?.let { put("page", it) } + triggerType?.let { put("trigger_type", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DeploymentRunListParams && + createdAtGt == other.createdAtGt && + createdAtGte == other.createdAtGte && + createdAtLt == other.createdAtLt && + createdAtLte == other.createdAtLte && + deploymentId == other.deploymentId && + hasError == other.hasError && + limit == other.limit && + page == other.page && + triggerType == other.triggerType && + betas == other.betas && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + createdAtGt, + createdAtGte, + createdAtLt, + createdAtLte, + deploymentId, + hasError, + limit, + page, + triggerType, + betas, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "DeploymentRunListParams{createdAtGt=$createdAtGt, createdAtGte=$createdAtGte, createdAtLt=$createdAtLt, createdAtLte=$createdAtLte, deploymentId=$deploymentId, hasError=$hasError, limit=$limit, page=$page, triggerType=$triggerType, betas=$betas, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunRetrieveParams.kt new file mode 100644 index 000000000..eb7711b48 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunRetrieveParams.kt @@ -0,0 +1,239 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.Params +import com.anthropic.core.http.Headers +import com.anthropic.core.http.QueryParams +import com.anthropic.core.toImmutable +import com.anthropic.models.beta.AnthropicBeta +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get Deployment Run */ +class DeploymentRunRetrieveParams +private constructor( + private val deploymentRunId: String?, + private val betas: List?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun deploymentRunId(): Optional = Optional.ofNullable(deploymentRunId) + + /** Optional header to specify the beta version(s) you want to use. */ + fun betas(): Optional> = Optional.ofNullable(betas) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): DeploymentRunRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [DeploymentRunRetrieveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DeploymentRunRetrieveParams]. */ + class Builder internal constructor() { + + private var deploymentRunId: String? = null + private var betas: MutableList? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(deploymentRunRetrieveParams: DeploymentRunRetrieveParams) = apply { + deploymentRunId = deploymentRunRetrieveParams.deploymentRunId + betas = deploymentRunRetrieveParams.betas?.toMutableList() + additionalHeaders = deploymentRunRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = deploymentRunRetrieveParams.additionalQueryParams.toBuilder() + } + + fun deploymentRunId(deploymentRunId: String?) = apply { + this.deploymentRunId = deploymentRunId + } + + /** Alias for calling [Builder.deploymentRunId] with `deploymentRunId.orElse(null)`. */ + fun deploymentRunId(deploymentRunId: Optional) = + deploymentRunId(deploymentRunId.getOrNull()) + + /** Optional header to specify the beta version(s) you want to use. */ + fun betas(betas: List?) = apply { this.betas = betas?.toMutableList() } + + /** Alias for calling [Builder.betas] with `betas.orElse(null)`. */ + fun betas(betas: Optional>) = betas(betas.getOrNull()) + + /** + * Adds a single [AnthropicBeta] to [betas]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBeta(beta: AnthropicBeta) = apply { + betas = (betas ?: mutableListOf()).apply { add(beta) } + } + + /** + * Sets [addBeta] to an arbitrary [String]. + * + * You should usually call [addBeta] with a well-typed [AnthropicBeta] constant instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun addBeta(value: String) = addBeta(AnthropicBeta.of(value)) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DeploymentRunRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DeploymentRunRetrieveParams = + DeploymentRunRetrieveParams( + deploymentRunId, + betas?.toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> deploymentRunId ?: "" + else -> "" + } + + override fun _headers(): Headers = + Headers.builder() + .apply { + betas?.forEach { put("anthropic-beta", it.toString()) } + putAll(additionalHeaders) + } + .build() + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DeploymentRunRetrieveParams && + deploymentRunId == other.deploymentRunId && + betas == other.betas && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(deploymentRunId, betas, additionalHeaders, additionalQueryParams) + + override fun toString() = + "DeploymentRunRetrieveParams{deploymentRunId=$deploymentRunId, betas=$betas, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsAgentArchivedDeploymentPausedReasonError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsAgentArchivedDeploymentPausedReasonError.kt new file mode 100644 index 000000000..82cfaa7a0 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsAgentArchivedDeploymentPausedReasonError.kt @@ -0,0 +1,318 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** The deployment's agent was archived. */ +class BetaManagedAgentsAgentArchivedDeploymentPausedReasonError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsAgentArchivedDeploymentPausedReasonError]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsAgentArchivedDeploymentPausedReasonError]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsAgentArchivedDeploymentPausedReasonError: + BetaManagedAgentsAgentArchivedDeploymentPausedReasonError + ) = apply { + type = betaManagedAgentsAgentArchivedDeploymentPausedReasonError.type + additionalProperties = + betaManagedAgentsAgentArchivedDeploymentPausedReasonError.additionalProperties + .toMutableMap() + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of + * [BetaManagedAgentsAgentArchivedDeploymentPausedReasonError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsAgentArchivedDeploymentPausedReasonError = + BetaManagedAgentsAgentArchivedDeploymentPausedReasonError( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsAgentArchivedDeploymentPausedReasonError = apply { + if (validated) { + return@apply + } + + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AGENT_ARCHIVED_ERROR = of("agent_archived_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + AGENT_ARCHIVED_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AGENT_ARCHIVED_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AGENT_ARCHIVED_ERROR -> Value.AGENT_ARCHIVED_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AGENT_ARCHIVED_ERROR -> Known.AGENT_ARCHIVED_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsAgentArchivedDeploymentPausedReasonError && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsAgentArchivedDeploymentPausedReasonError{type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsCronSchedule.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsCronSchedule.kt new file mode 100644 index 000000000..261fbad57 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsCronSchedule.kt @@ -0,0 +1,511 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkKnown +import com.anthropic.core.checkRequired +import com.anthropic.core.toImmutable +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** 5-field POSIX cron schedule with computed runtime timestamps. */ +class BetaManagedAgentsCronSchedule +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val expression: JsonField, + private val timezone: JsonField, + private val type: JsonField, + private val lastRunAt: JsonField, + private val upcomingRunsAt: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("expression") + @ExcludeMissing + expression: JsonField = JsonMissing.of(), + @JsonProperty("timezone") @ExcludeMissing timezone: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("last_run_at") + @ExcludeMissing + lastRunAt: JsonField = JsonMissing.of(), + @JsonProperty("upcoming_runs_at") + @ExcludeMissing + upcomingRunsAt: JsonField> = JsonMissing.of(), + ) : this(expression, timezone, type, lastRunAt, upcomingRunsAt, mutableMapOf()) + + /** + * 5-field POSIX cron expression: minute hour day-of-month month day-of-week (e.g., "0 9 * * + * 1-5" for weekdays at 9am). Day-of-week is 0-7 where 0 and 7 both mean Sunday. Extended cron + * syntax - seconds or year fields, and the special characters L, W, #, and ? - is not + * supported, nor are predefined shortcuts (@daily). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun expression(): String = expression.getRequired("expression") + + /** + * IANA timezone identifier (e.g., "America/Los_Angeles", "UTC"). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun timezone(): String = timezone.getRequired("timezone") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * A timestamp in RFC 3339 format + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun lastRunAt(): Optional = lastRunAt.getOptional("last_run_at") + + /** + * Up to 5 timestamps of upcoming cron occurrences. Non-empty for active and paused deployments + * (reflects what the schedule would do if unpaused); empty once the deployment is archived + * (`archived_at` set). Each fire is offset by a small per-schedule jitter, so a run will + * actually start at or shortly after its listed time. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun upcomingRunsAt(): Optional> = + upcomingRunsAt.getOptional("upcoming_runs_at") + + /** + * Returns the raw JSON value of [expression]. + * + * Unlike [expression], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expression") @ExcludeMissing fun _expression(): JsonField = expression + + /** + * Returns the raw JSON value of [timezone]. + * + * Unlike [timezone], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timezone") @ExcludeMissing fun _timezone(): JsonField = timezone + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [lastRunAt]. + * + * Unlike [lastRunAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("last_run_at") + @ExcludeMissing + fun _lastRunAt(): JsonField = lastRunAt + + /** + * Returns the raw JSON value of [upcomingRunsAt]. + * + * Unlike [upcomingRunsAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("upcoming_runs_at") + @ExcludeMissing + fun _upcomingRunsAt(): JsonField> = upcomingRunsAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsCronSchedule]. + * + * The following fields are required: + * ```java + * .expression() + * .timezone() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsCronSchedule]. */ + class Builder internal constructor() { + + private var expression: JsonField? = null + private var timezone: JsonField? = null + private var type: JsonField? = null + private var lastRunAt: JsonField = JsonMissing.of() + private var upcomingRunsAt: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaManagedAgentsCronSchedule: BetaManagedAgentsCronSchedule) = apply { + expression = betaManagedAgentsCronSchedule.expression + timezone = betaManagedAgentsCronSchedule.timezone + type = betaManagedAgentsCronSchedule.type + lastRunAt = betaManagedAgentsCronSchedule.lastRunAt + upcomingRunsAt = + betaManagedAgentsCronSchedule.upcomingRunsAt + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + additionalProperties = betaManagedAgentsCronSchedule.additionalProperties.toMutableMap() + } + + /** + * 5-field POSIX cron expression: minute hour day-of-month month day-of-week (e.g., "0 9 * * + * 1-5" for weekdays at 9am). Day-of-week is 0-7 where 0 and 7 both mean Sunday. Extended + * cron syntax - seconds or year fields, and the special characters L, W, #, and ? - is not + * supported, nor are predefined shortcuts (@daily). + */ + fun expression(expression: String) = expression(JsonField.of(expression)) + + /** + * Sets [Builder.expression] to an arbitrary JSON value. + * + * You should usually call [Builder.expression] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun expression(expression: JsonField) = apply { this.expression = expression } + + /** IANA timezone identifier (e.g., "America/Los_Angeles", "UTC"). */ + fun timezone(timezone: String) = timezone(JsonField.of(timezone)) + + /** + * Sets [Builder.timezone] to an arbitrary JSON value. + * + * You should usually call [Builder.timezone] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun timezone(timezone: JsonField) = apply { this.timezone = timezone } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** A timestamp in RFC 3339 format */ + fun lastRunAt(lastRunAt: OffsetDateTime?) = lastRunAt(JsonField.ofNullable(lastRunAt)) + + /** Alias for calling [Builder.lastRunAt] with `lastRunAt.orElse(null)`. */ + fun lastRunAt(lastRunAt: Optional) = lastRunAt(lastRunAt.getOrNull()) + + /** + * Sets [Builder.lastRunAt] to an arbitrary JSON value. + * + * You should usually call [Builder.lastRunAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lastRunAt(lastRunAt: JsonField) = apply { this.lastRunAt = lastRunAt } + + /** + * Up to 5 timestamps of upcoming cron occurrences. Non-empty for active and paused + * deployments (reflects what the schedule would do if unpaused); empty once the deployment + * is archived (`archived_at` set). Each fire is offset by a small per-schedule jitter, so a + * run will actually start at or shortly after its listed time. + */ + fun upcomingRunsAt(upcomingRunsAt: List) = + upcomingRunsAt(JsonField.of(upcomingRunsAt)) + + /** + * Sets [Builder.upcomingRunsAt] to an arbitrary JSON value. + * + * You should usually call [Builder.upcomingRunsAt] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun upcomingRunsAt(upcomingRunsAt: JsonField>) = apply { + this.upcomingRunsAt = upcomingRunsAt.map { it.toMutableList() } + } + + /** + * Adds a single [OffsetDateTime] to [Builder.upcomingRunsAt]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUpcomingRunsAt(upcomingRunsAt: OffsetDateTime) = apply { + this.upcomingRunsAt = + (this.upcomingRunsAt ?: JsonField.of(mutableListOf())).also { + checkKnown("upcomingRunsAt", it).add(upcomingRunsAt) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsCronSchedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .expression() + * .timezone() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsCronSchedule = + BetaManagedAgentsCronSchedule( + checkRequired("expression", expression), + checkRequired("timezone", timezone), + checkRequired("type", type), + lastRunAt, + (upcomingRunsAt ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsCronSchedule = apply { + if (validated) { + return@apply + } + + expression() + timezone() + type().validate() + lastRunAt() + upcomingRunsAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (expression.asKnown().isPresent) 1 else 0) + + (if (timezone.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (lastRunAt.asKnown().isPresent) 1 else 0) + + (upcomingRunsAt.asKnown().getOrNull()?.size ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CRON = of("cron") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CRON + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CRON, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CRON -> Value.CRON + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CRON -> Known.CRON + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsCronSchedule && + expression == other.expression && + timezone == other.timezone && + type == other.type && + lastRunAt == other.lastRunAt && + upcomingRunsAt == other.upcomingRunsAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(expression, timezone, type, lastRunAt, upcomingRunsAt, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsCronSchedule{expression=$expression, timezone=$timezone, type=$type, lastRunAt=$lastRunAt, upcomingRunsAt=$upcomingRunsAt, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsCronScheduleParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsCronScheduleParams.kt new file mode 100644 index 000000000..0f6a0b0db --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsCronScheduleParams.kt @@ -0,0 +1,406 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** 5-field POSIX cron schedule. Literal wall-clock matching in the configured timezone. */ +class BetaManagedAgentsCronScheduleParams +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val expression: JsonField, + private val timezone: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("expression") + @ExcludeMissing + expression: JsonField = JsonMissing.of(), + @JsonProperty("timezone") @ExcludeMissing timezone: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(expression, timezone, type, mutableMapOf()) + + /** + * 5-field POSIX cron expression: minute hour day-of-month month day-of-week (e.g., "0 9 * * + * 1-5" for weekdays at 9am). Day-of-week is 0-7 where 0 and 7 both mean Sunday. Extended cron + * syntax - seconds or year fields, and the special characters L, W, #, and ? - is not + * supported, nor are predefined shortcuts (@daily). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun expression(): String = expression.getRequired("expression") + + /** + * Required. IANA timezone identifier (e.g., "America/Los_Angeles", "UTC"). Validated against + * the IANA timezone database. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun timezone(): String = timezone.getRequired("timezone") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [expression]. + * + * Unlike [expression], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expression") @ExcludeMissing fun _expression(): JsonField = expression + + /** + * Returns the raw JSON value of [timezone]. + * + * Unlike [timezone], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timezone") @ExcludeMissing fun _timezone(): JsonField = timezone + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsCronScheduleParams]. + * + * The following fields are required: + * ```java + * .expression() + * .timezone() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsCronScheduleParams]. */ + class Builder internal constructor() { + + private var expression: JsonField? = null + private var timezone: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsCronScheduleParams: BetaManagedAgentsCronScheduleParams + ) = apply { + expression = betaManagedAgentsCronScheduleParams.expression + timezone = betaManagedAgentsCronScheduleParams.timezone + type = betaManagedAgentsCronScheduleParams.type + additionalProperties = + betaManagedAgentsCronScheduleParams.additionalProperties.toMutableMap() + } + + /** + * 5-field POSIX cron expression: minute hour day-of-month month day-of-week (e.g., "0 9 * * + * 1-5" for weekdays at 9am). Day-of-week is 0-7 where 0 and 7 both mean Sunday. Extended + * cron syntax - seconds or year fields, and the special characters L, W, #, and ? - is not + * supported, nor are predefined shortcuts (@daily). + */ + fun expression(expression: String) = expression(JsonField.of(expression)) + + /** + * Sets [Builder.expression] to an arbitrary JSON value. + * + * You should usually call [Builder.expression] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun expression(expression: JsonField) = apply { this.expression = expression } + + /** + * Required. IANA timezone identifier (e.g., "America/Los_Angeles", "UTC"). Validated + * against the IANA timezone database. + */ + fun timezone(timezone: String) = timezone(JsonField.of(timezone)) + + /** + * Sets [Builder.timezone] to an arbitrary JSON value. + * + * You should usually call [Builder.timezone] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun timezone(timezone: JsonField) = apply { this.timezone = timezone } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsCronScheduleParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .expression() + * .timezone() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsCronScheduleParams = + BetaManagedAgentsCronScheduleParams( + checkRequired("expression", expression), + checkRequired("timezone", timezone), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsCronScheduleParams = apply { + if (validated) { + return@apply + } + + expression() + timezone() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (expression.asKnown().isPresent) 1 else 0) + + (if (timezone.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CRON = of("cron") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CRON + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CRON, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CRON -> Value.CRON + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CRON -> Known.CRON + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsCronScheduleParams && + expression == other.expression && + timezone == other.timezone && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(expression, timezone, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsCronScheduleParams{expression=$expression, timezone=$timezone, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeployment.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeployment.kt new file mode 100644 index 000000000..569310137 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeployment.kt @@ -0,0 +1,1481 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkKnown +import com.anthropic.core.checkRequired +import com.anthropic.core.toImmutable +import com.anthropic.errors.AnthropicInvalidDataException +import com.anthropic.models.beta.agents.BetaManagedAgentsAgentReference +import com.anthropic.models.beta.sessions.BetaManagedAgentsSystemContentBlock +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * A deployment is a configured instance of an agent — it binds the agent to everything needed to + * run it autonomously: an environment, credentials, initial events, and an optional schedule. + */ +class BetaManagedAgentsDeployment +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val agent: JsonField, + private val archivedAt: JsonField, + private val createdAt: JsonField, + private val description: JsonField, + private val environmentId: JsonField, + private val initialEvents: JsonField>, + private val metadata: JsonField, + private val name: JsonField, + private val pausedReason: JsonField, + private val resources: JsonField>, + private val schedule: JsonField, + private val status: JsonField, + private val type: JsonField, + private val updatedAt: JsonField, + private val vaultIds: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("agent") + @ExcludeMissing + agent: JsonField = JsonMissing.of(), + @JsonProperty("archived_at") + @ExcludeMissing + archivedAt: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("environment_id") + @ExcludeMissing + environmentId: JsonField = JsonMissing.of(), + @JsonProperty("initial_events") + @ExcludeMissing + initialEvents: JsonField> = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("paused_reason") + @ExcludeMissing + pausedReason: JsonField = JsonMissing.of(), + @JsonProperty("resources") + @ExcludeMissing + resources: JsonField> = JsonMissing.of(), + @JsonProperty("schedule") + @ExcludeMissing + schedule: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + @JsonProperty("vault_ids") + @ExcludeMissing + vaultIds: JsonField> = JsonMissing.of(), + ) : this( + id, + agent, + archivedAt, + createdAt, + description, + environmentId, + initialEvents, + metadata, + name, + pausedReason, + resources, + schedule, + status, + type, + updatedAt, + vaultIds, + mutableMapOf(), + ) + + /** + * Unique identifier for this deployment. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * A resolved agent reference with a concrete version. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun agent(): BetaManagedAgentsAgentReference = agent.getRequired("agent") + + /** + * A timestamp in RFC 3339 format + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun archivedAt(): Optional = archivedAt.getOptional("archived_at") + + /** + * A timestamp in RFC 3339 format + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * Description of what the deployment does. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * ID of the `environment` where sessions run. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun environmentId(): String = environmentId.getRequired("environment_id") + + /** + * Events sent to each session immediately after creation. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun initialEvents(): List = + initialEvents.getRequired("initial_events") + + /** + * Arbitrary key-value metadata. Maximum 16 pairs. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * Human-readable name. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Why a deployment is paused. Non-null exactly when `status` is `paused`. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun pausedReason(): Optional = + pausedReason.getOptional("paused_reason") + + /** + * Resources attached to sessions created from this deployment. Echoes the input minus + * write-only credentials. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun resources(): List = + resources.getRequired("resources") + + /** + * 5-field POSIX cron schedule with computed runtime timestamps. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun schedule(): Optional = schedule.getOptional("schedule") + + /** + * Lifecycle status of a deployment. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): BetaManagedAgentsDeploymentStatus = status.getRequired("status") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * A timestamp in RFC 3339 format + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + + /** + * Vault IDs supplying stored credentials for sessions created from this deployment. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun vaultIds(): List = vaultIds.getRequired("vault_ids") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [agent]. + * + * Unlike [agent], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("agent") + @ExcludeMissing + fun _agent(): JsonField = agent + + /** + * Returns the raw JSON value of [archivedAt]. + * + * Unlike [archivedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("archived_at") + @ExcludeMissing + fun _archivedAt(): JsonField = archivedAt + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [environmentId]. + * + * Unlike [environmentId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("environment_id") + @ExcludeMissing + fun _environmentId(): JsonField = environmentId + + /** + * Returns the raw JSON value of [initialEvents]. + * + * Unlike [initialEvents], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("initial_events") + @ExcludeMissing + fun _initialEvents(): JsonField> = initialEvents + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [pausedReason]. + * + * Unlike [pausedReason], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("paused_reason") + @ExcludeMissing + fun _pausedReason(): JsonField = pausedReason + + /** + * Returns the raw JSON value of [resources]. + * + * Unlike [resources], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("resources") + @ExcludeMissing + fun _resources(): JsonField> = resources + + /** + * Returns the raw JSON value of [schedule]. + * + * Unlike [schedule], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("schedule") + @ExcludeMissing + fun _schedule(): JsonField = schedule + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt + + /** + * Returns the raw JSON value of [vaultIds]. + * + * Unlike [vaultIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("vault_ids") @ExcludeMissing fun _vaultIds(): JsonField> = vaultIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BetaManagedAgentsDeployment]. + * + * The following fields are required: + * ```java + * .id() + * .agent() + * .archivedAt() + * .createdAt() + * .description() + * .environmentId() + * .initialEvents() + * .metadata() + * .name() + * .pausedReason() + * .resources() + * .schedule() + * .status() + * .type() + * .updatedAt() + * .vaultIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsDeployment]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var agent: JsonField? = null + private var archivedAt: JsonField? = null + private var createdAt: JsonField? = null + private var description: JsonField? = null + private var environmentId: JsonField? = null + private var initialEvents: + JsonField>? = + null + private var metadata: JsonField? = null + private var name: JsonField? = null + private var pausedReason: JsonField? = null + private var resources: JsonField>? = + null + private var schedule: JsonField? = null + private var status: JsonField? = null + private var type: JsonField? = null + private var updatedAt: JsonField? = null + private var vaultIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaManagedAgentsDeployment: BetaManagedAgentsDeployment) = apply { + id = betaManagedAgentsDeployment.id + agent = betaManagedAgentsDeployment.agent + archivedAt = betaManagedAgentsDeployment.archivedAt + createdAt = betaManagedAgentsDeployment.createdAt + description = betaManagedAgentsDeployment.description + environmentId = betaManagedAgentsDeployment.environmentId + initialEvents = + betaManagedAgentsDeployment.initialEvents + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + metadata = betaManagedAgentsDeployment.metadata + name = betaManagedAgentsDeployment.name + pausedReason = betaManagedAgentsDeployment.pausedReason + resources = + betaManagedAgentsDeployment.resources + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + schedule = betaManagedAgentsDeployment.schedule + status = betaManagedAgentsDeployment.status + type = betaManagedAgentsDeployment.type + updatedAt = betaManagedAgentsDeployment.updatedAt + vaultIds = + betaManagedAgentsDeployment.vaultIds + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + additionalProperties = betaManagedAgentsDeployment.additionalProperties.toMutableMap() + } + + /** Unique identifier for this deployment. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** A resolved agent reference with a concrete version. */ + fun agent(agent: BetaManagedAgentsAgentReference) = agent(JsonField.of(agent)) + + /** + * Sets [Builder.agent] to an arbitrary JSON value. + * + * You should usually call [Builder.agent] with a well-typed + * [BetaManagedAgentsAgentReference] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun agent(agent: JsonField) = apply { this.agent = agent } + + /** A timestamp in RFC 3339 format */ + fun archivedAt(archivedAt: OffsetDateTime?) = archivedAt(JsonField.ofNullable(archivedAt)) + + /** Alias for calling [Builder.archivedAt] with `archivedAt.orElse(null)`. */ + fun archivedAt(archivedAt: Optional) = archivedAt(archivedAt.getOrNull()) + + /** + * Sets [Builder.archivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.archivedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun archivedAt(archivedAt: JsonField) = apply { + this.archivedAt = archivedAt + } + + /** A timestamp in RFC 3339 format */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** Description of what the deployment does. */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { this.description = description } + + /** ID of the `environment` where sessions run. */ + fun environmentId(environmentId: String) = environmentId(JsonField.of(environmentId)) + + /** + * Sets [Builder.environmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.environmentId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun environmentId(environmentId: JsonField) = apply { + this.environmentId = environmentId + } + + /** Events sent to each session immediately after creation. */ + fun initialEvents(initialEvents: List) = + initialEvents(JsonField.of(initialEvents)) + + /** + * Sets [Builder.initialEvents] to an arbitrary JSON value. + * + * You should usually call [Builder.initialEvents] with a well-typed + * `List` value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun initialEvents(initialEvents: JsonField>) = + apply { + this.initialEvents = initialEvents.map { it.toMutableList() } + } + + /** + * Adds a single [BetaManagedAgentsDeploymentInitialEvent] to [initialEvents]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addInitialEvent(initialEvent: BetaManagedAgentsDeploymentInitialEvent) = apply { + initialEvents = + (initialEvents ?: JsonField.of(mutableListOf())).also { + checkKnown("initialEvents", it).add(initialEvent) + } + } + + /** + * Alias for calling [addInitialEvent] with + * `BetaManagedAgentsDeploymentInitialEvent.ofUserMessage(userMessage)`. + */ + fun addInitialEvent(userMessage: BetaManagedAgentsDeploymentUserMessageEvent) = + addInitialEvent(BetaManagedAgentsDeploymentInitialEvent.ofUserMessage(userMessage)) + + /** + * Alias for calling [addInitialEvent] with the following: + * ```java + * BetaManagedAgentsDeploymentUserMessageEvent.builder() + * .type(BetaManagedAgentsDeploymentUserMessageEvent.Type.USER_MESSAGE) + * .content(content) + * .build() + * ``` + */ + fun addUserMessageInitialEvent( + content: List + ) = + addInitialEvent( + BetaManagedAgentsDeploymentUserMessageEvent.builder() + .type(BetaManagedAgentsDeploymentUserMessageEvent.Type.USER_MESSAGE) + .content(content) + .build() + ) + + /** + * Alias for calling [addInitialEvent] with + * `BetaManagedAgentsDeploymentInitialEvent.ofUserDefineOutcome(userDefineOutcome)`. + */ + fun addInitialEvent(userDefineOutcome: BetaManagedAgentsDeploymentUserDefineOutcomeEvent) = + addInitialEvent( + BetaManagedAgentsDeploymentInitialEvent.ofUserDefineOutcome(userDefineOutcome) + ) + + /** + * Alias for calling [addInitialEvent] with + * `BetaManagedAgentsDeploymentInitialEvent.ofSystemMessage(systemMessage)`. + */ + fun addInitialEvent(systemMessage: BetaManagedAgentsDeploymentSystemMessageEvent) = + addInitialEvent(BetaManagedAgentsDeploymentInitialEvent.ofSystemMessage(systemMessage)) + + /** + * Alias for calling [addInitialEvent] with the following: + * ```java + * BetaManagedAgentsDeploymentSystemMessageEvent.builder() + * .type(BetaManagedAgentsDeploymentSystemMessageEvent.Type.SYSTEM_MESSAGE) + * .content(content) + * .build() + * ``` + */ + fun addSystemMessageInitialEvent(content: List) = + addInitialEvent( + BetaManagedAgentsDeploymentSystemMessageEvent.builder() + .type(BetaManagedAgentsDeploymentSystemMessageEvent.Type.SYSTEM_MESSAGE) + .content(content) + .build() + ) + + /** Arbitrary key-value metadata. Maximum 16 pairs. */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** Human-readable name. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Why a deployment is paused. Non-null exactly when `status` is `paused`. */ + fun pausedReason(pausedReason: BetaManagedAgentsDeploymentPausedReason?) = + pausedReason(JsonField.ofNullable(pausedReason)) + + /** Alias for calling [Builder.pausedReason] with `pausedReason.orElse(null)`. */ + fun pausedReason(pausedReason: Optional) = + pausedReason(pausedReason.getOrNull()) + + /** + * Sets [Builder.pausedReason] to an arbitrary JSON value. + * + * You should usually call [Builder.pausedReason] with a well-typed + * [BetaManagedAgentsDeploymentPausedReason] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun pausedReason(pausedReason: JsonField) = apply { + this.pausedReason = pausedReason + } + + /** + * Alias for calling [pausedReason] with + * `BetaManagedAgentsDeploymentPausedReason.ofManual(manual)`. + */ + fun pausedReason(manual: BetaManagedAgentsManualDeploymentPausedReason) = + pausedReason(BetaManagedAgentsDeploymentPausedReason.ofManual(manual)) + + /** + * Alias for calling [pausedReason] with + * `BetaManagedAgentsDeploymentPausedReason.ofError(error)`. + */ + fun pausedReason(error: BetaManagedAgentsErrorDeploymentPausedReason) = + pausedReason(BetaManagedAgentsDeploymentPausedReason.ofError(error)) + + /** + * Alias for calling [pausedReason] with the following: + * ```java + * BetaManagedAgentsErrorDeploymentPausedReason.builder() + * .type(BetaManagedAgentsErrorDeploymentPausedReason.Type.ERROR) + * .error(error) + * .build() + * ``` + */ + fun errorPausedReason(error: BetaManagedAgentsDeploymentPausedReasonError) = + pausedReason( + BetaManagedAgentsErrorDeploymentPausedReason.builder() + .type(BetaManagedAgentsErrorDeploymentPausedReason.Type.ERROR) + .error(error) + .build() + ) + + /** + * Alias for calling [errorPausedReason] with + * `BetaManagedAgentsDeploymentPausedReasonError.ofEnvironmentArchived(environmentArchived)`. + */ + fun errorPausedReason( + environmentArchived: BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError + ) = + errorPausedReason( + BetaManagedAgentsDeploymentPausedReasonError.ofEnvironmentArchived( + environmentArchived + ) + ) + + /** + * Alias for calling [errorPausedReason] with + * `BetaManagedAgentsDeploymentPausedReasonError.ofAgentArchived(agentArchived)`. + */ + fun errorPausedReason( + agentArchived: BetaManagedAgentsAgentArchivedDeploymentPausedReasonError + ) = + errorPausedReason( + BetaManagedAgentsDeploymentPausedReasonError.ofAgentArchived(agentArchived) + ) + + /** + * Alias for calling [errorPausedReason] with + * `BetaManagedAgentsDeploymentPausedReasonError.ofEnvironmentNotFound(environmentNotFound)`. + */ + fun errorPausedReason( + environmentNotFound: BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError + ) = + errorPausedReason( + BetaManagedAgentsDeploymentPausedReasonError.ofEnvironmentNotFound( + environmentNotFound + ) + ) + + /** + * Alias for calling [errorPausedReason] with + * `BetaManagedAgentsDeploymentPausedReasonError.ofVaultNotFound(vaultNotFound)`. + */ + fun errorPausedReason( + vaultNotFound: BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError + ) = + errorPausedReason( + BetaManagedAgentsDeploymentPausedReasonError.ofVaultNotFound(vaultNotFound) + ) + + /** + * Alias for calling [errorPausedReason] with + * `BetaManagedAgentsDeploymentPausedReasonError.ofFileNotFound(fileNotFound)`. + */ + fun errorPausedReason( + fileNotFound: BetaManagedAgentsFileNotFoundDeploymentPausedReasonError + ) = + errorPausedReason( + BetaManagedAgentsDeploymentPausedReasonError.ofFileNotFound(fileNotFound) + ) + + /** + * Alias for calling [errorPausedReason] with + * `BetaManagedAgentsDeploymentPausedReasonError.ofSessionResourceNotFound(sessionResourceNotFound)`. + */ + fun errorPausedReason( + sessionResourceNotFound: + BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError + ) = + errorPausedReason( + BetaManagedAgentsDeploymentPausedReasonError.ofSessionResourceNotFound( + sessionResourceNotFound + ) + ) + + /** + * Alias for calling [errorPausedReason] with + * `BetaManagedAgentsDeploymentPausedReasonError.ofWorkspaceArchived(workspaceArchived)`. + */ + fun errorPausedReason( + workspaceArchived: BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError + ) = + errorPausedReason( + BetaManagedAgentsDeploymentPausedReasonError.ofWorkspaceArchived(workspaceArchived) + ) + + /** + * Alias for calling [errorPausedReason] with + * `BetaManagedAgentsDeploymentPausedReasonError.ofOrganizationDisabled(organizationDisabled)`. + */ + fun errorPausedReason( + organizationDisabled: BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError + ) = + errorPausedReason( + BetaManagedAgentsDeploymentPausedReasonError.ofOrganizationDisabled( + organizationDisabled + ) + ) + + /** + * Alias for calling [errorPausedReason] with + * `BetaManagedAgentsDeploymentPausedReasonError.ofMemoryStoreArchived(memoryStoreArchived)`. + */ + fun errorPausedReason( + memoryStoreArchived: BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError + ) = + errorPausedReason( + BetaManagedAgentsDeploymentPausedReasonError.ofMemoryStoreArchived( + memoryStoreArchived + ) + ) + + /** + * Alias for calling [errorPausedReason] with + * `BetaManagedAgentsDeploymentPausedReasonError.ofSkillNotFound(skillNotFound)`. + */ + fun errorPausedReason( + skillNotFound: BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError + ) = + errorPausedReason( + BetaManagedAgentsDeploymentPausedReasonError.ofSkillNotFound(skillNotFound) + ) + + /** + * Alias for calling [errorPausedReason] with + * `BetaManagedAgentsDeploymentPausedReasonError.ofVaultArchived(vaultArchived)`. + */ + fun errorPausedReason( + vaultArchived: BetaManagedAgentsVaultArchivedDeploymentPausedReasonError + ) = + errorPausedReason( + BetaManagedAgentsDeploymentPausedReasonError.ofVaultArchived(vaultArchived) + ) + + /** + * Alias for calling [errorPausedReason] with + * `BetaManagedAgentsDeploymentPausedReasonError.ofUnknown(unknown)`. + */ + fun errorPausedReason(unknown: BetaManagedAgentsUnknownDeploymentPausedReasonError) = + errorPausedReason(BetaManagedAgentsDeploymentPausedReasonError.ofUnknown(unknown)) + + /** + * Alias for calling [errorPausedReason] with + * `BetaManagedAgentsDeploymentPausedReasonError.ofSelfHostedResourcesUnsupported(selfHostedResourcesUnsupported)`. + */ + fun errorPausedReason( + selfHostedResourcesUnsupported: + BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError + ) = + errorPausedReason( + BetaManagedAgentsDeploymentPausedReasonError.ofSelfHostedResourcesUnsupported( + selfHostedResourcesUnsupported + ) + ) + + /** + * Alias for calling [errorPausedReason] with + * `BetaManagedAgentsDeploymentPausedReasonError.ofMcpEgressBlocked(mcpEgressBlocked)`. + */ + fun errorPausedReason( + mcpEgressBlocked: BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError + ) = + errorPausedReason( + BetaManagedAgentsDeploymentPausedReasonError.ofMcpEgressBlocked(mcpEgressBlocked) + ) + + /** + * Resources attached to sessions created from this deployment. Echoes the input minus + * write-only credentials. + */ + fun resources(resources: List) = + resources(JsonField.of(resources)) + + /** + * Sets [Builder.resources] to an arbitrary JSON value. + * + * You should usually call [Builder.resources] with a well-typed + * `List` value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun resources(resources: JsonField>) = apply { + this.resources = resources.map { it.toMutableList() } + } + + /** + * Adds a single [BetaManagedAgentsSessionResourceConfig] to [resources]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResource(resource: BetaManagedAgentsSessionResourceConfig) = apply { + resources = + (resources ?: JsonField.of(mutableListOf())).also { + checkKnown("resources", it).add(resource) + } + } + + /** + * Alias for calling [addResource] with + * `BetaManagedAgentsSessionResourceConfig.ofGitHubRepository(githubRepository)`. + */ + fun addResource(githubRepository: BetaManagedAgentsGitHubRepositoryResourceConfig) = + addResource(BetaManagedAgentsSessionResourceConfig.ofGitHubRepository(githubRepository)) + + /** + * Alias for calling [addResource] with the following: + * ```java + * BetaManagedAgentsGitHubRepositoryResourceConfig.builder() + * .type(BetaManagedAgentsGitHubRepositoryResourceConfig.Type.GITHUB_REPOSITORY) + * .url(url) + * .build() + * ``` + */ + fun addGitHubRepositoryResource(url: String) = + addResource( + BetaManagedAgentsGitHubRepositoryResourceConfig.builder() + .type(BetaManagedAgentsGitHubRepositoryResourceConfig.Type.GITHUB_REPOSITORY) + .url(url) + .build() + ) + + /** + * Alias for calling [addResource] with + * `BetaManagedAgentsSessionResourceConfig.ofFile(file)`. + */ + fun addResource(file: BetaManagedAgentsFileResourceConfig) = + addResource(BetaManagedAgentsSessionResourceConfig.ofFile(file)) + + /** + * Alias for calling [addResource] with the following: + * ```java + * BetaManagedAgentsFileResourceConfig.builder() + * .type(BetaManagedAgentsFileResourceConfig.Type.FILE) + * .fileId(fileId) + * .build() + * ``` + */ + fun addFileResource(fileId: String) = + addResource( + BetaManagedAgentsFileResourceConfig.builder() + .type(BetaManagedAgentsFileResourceConfig.Type.FILE) + .fileId(fileId) + .build() + ) + + /** + * Alias for calling [addResource] with + * `BetaManagedAgentsSessionResourceConfig.ofMemoryStore(memoryStore)`. + */ + fun addResource(memoryStore: BetaManagedAgentsMemoryStoreResourceConfig) = + addResource(BetaManagedAgentsSessionResourceConfig.ofMemoryStore(memoryStore)) + + /** + * Alias for calling [addResource] with the following: + * ```java + * BetaManagedAgentsMemoryStoreResourceConfig.builder() + * .type(BetaManagedAgentsMemoryStoreResourceConfig.Type.MEMORY_STORE) + * .memoryStoreId(memoryStoreId) + * .build() + * ``` + */ + fun addMemoryStoreResource(memoryStoreId: String) = + addResource( + BetaManagedAgentsMemoryStoreResourceConfig.builder() + .type(BetaManagedAgentsMemoryStoreResourceConfig.Type.MEMORY_STORE) + .memoryStoreId(memoryStoreId) + .build() + ) + + /** 5-field POSIX cron schedule with computed runtime timestamps. */ + fun schedule(schedule: BetaManagedAgentsSchedule?) = + schedule(JsonField.ofNullable(schedule)) + + /** Alias for calling [Builder.schedule] with `schedule.orElse(null)`. */ + fun schedule(schedule: Optional) = schedule(schedule.getOrNull()) + + /** + * Sets [Builder.schedule] to an arbitrary JSON value. + * + * You should usually call [Builder.schedule] with a well-typed [BetaManagedAgentsSchedule] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun schedule(schedule: JsonField) = apply { + this.schedule = schedule + } + + /** Lifecycle status of a deployment. */ + fun status(status: BetaManagedAgentsDeploymentStatus) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed + * [BetaManagedAgentsDeploymentStatus] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { + this.status = status + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** A timestamp in RFC 3339 format */ + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } + + /** Vault IDs supplying stored credentials for sessions created from this deployment. */ + fun vaultIds(vaultIds: List) = vaultIds(JsonField.of(vaultIds)) + + /** + * Sets [Builder.vaultIds] to an arbitrary JSON value. + * + * You should usually call [Builder.vaultIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun vaultIds(vaultIds: JsonField>) = apply { + this.vaultIds = vaultIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [vaultIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVaultId(vaultId: String) = apply { + vaultIds = + (vaultIds ?: JsonField.of(mutableListOf())).also { + checkKnown("vaultIds", it).add(vaultId) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsDeployment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .agent() + * .archivedAt() + * .createdAt() + * .description() + * .environmentId() + * .initialEvents() + * .metadata() + * .name() + * .pausedReason() + * .resources() + * .schedule() + * .status() + * .type() + * .updatedAt() + * .vaultIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsDeployment = + BetaManagedAgentsDeployment( + checkRequired("id", id), + checkRequired("agent", agent), + checkRequired("archivedAt", archivedAt), + checkRequired("createdAt", createdAt), + checkRequired("description", description), + checkRequired("environmentId", environmentId), + checkRequired("initialEvents", initialEvents).map { it.toImmutable() }, + checkRequired("metadata", metadata), + checkRequired("name", name), + checkRequired("pausedReason", pausedReason), + checkRequired("resources", resources).map { it.toImmutable() }, + checkRequired("schedule", schedule), + checkRequired("status", status), + checkRequired("type", type), + checkRequired("updatedAt", updatedAt), + checkRequired("vaultIds", vaultIds).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsDeployment = apply { + if (validated) { + return@apply + } + + id() + agent().validate() + archivedAt() + createdAt() + description() + environmentId() + initialEvents().forEach { it.validate() } + metadata().validate() + name() + pausedReason().ifPresent { it.validate() } + resources().forEach { it.validate() } + schedule().ifPresent { it.validate() } + status().validate() + type().validate() + updatedAt() + vaultIds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (agent.asKnown().getOrNull()?.validity() ?: 0) + + (if (archivedAt.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (environmentId.asKnown().isPresent) 1 else 0) + + (initialEvents.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (pausedReason.asKnown().getOrNull()?.validity() ?: 0) + + (resources.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (schedule.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (vaultIds.asKnown().getOrNull()?.size ?: 0) + + /** Arbitrary key-value metadata. Maximum 16 pairs. */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val DEPLOYMENT = of("deployment") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + DEPLOYMENT + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + DEPLOYMENT, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + DEPLOYMENT -> Value.DEPLOYMENT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + DEPLOYMENT -> Known.DEPLOYMENT + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsDeployment && + id == other.id && + agent == other.agent && + archivedAt == other.archivedAt && + createdAt == other.createdAt && + description == other.description && + environmentId == other.environmentId && + initialEvents == other.initialEvents && + metadata == other.metadata && + name == other.name && + pausedReason == other.pausedReason && + resources == other.resources && + schedule == other.schedule && + status == other.status && + type == other.type && + updatedAt == other.updatedAt && + vaultIds == other.vaultIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + agent, + archivedAt, + createdAt, + description, + environmentId, + initialEvents, + metadata, + name, + pausedReason, + resources, + schedule, + status, + type, + updatedAt, + vaultIds, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsDeployment{id=$id, agent=$agent, archivedAt=$archivedAt, createdAt=$createdAt, description=$description, environmentId=$environmentId, initialEvents=$initialEvents, metadata=$metadata, name=$name, pausedReason=$pausedReason, resources=$resources, schedule=$schedule, status=$status, type=$type, updatedAt=$updatedAt, vaultIds=$vaultIds, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentInitialEvent.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentInitialEvent.kt new file mode 100644 index 000000000..539709838 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentInitialEvent.kt @@ -0,0 +1,342 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.BaseDeserializer +import com.anthropic.core.BaseSerializer +import com.anthropic.core.JsonValue +import com.anthropic.core.getOrThrow +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * An event sent to a session immediately after it is created. Supports `user.message`, + * `user.define_outcome`, and `system.message`. + */ +@JsonDeserialize(using = BetaManagedAgentsDeploymentInitialEvent.Deserializer::class) +@JsonSerialize(using = BetaManagedAgentsDeploymentInitialEvent.Serializer::class) +class BetaManagedAgentsDeploymentInitialEvent +private constructor( + private val userMessage: BetaManagedAgentsDeploymentUserMessageEvent? = null, + private val userDefineOutcome: BetaManagedAgentsDeploymentUserDefineOutcomeEvent? = null, + private val systemMessage: BetaManagedAgentsDeploymentSystemMessageEvent? = null, + private val _json: JsonValue? = null, +) { + + /** A user message sent to the session. */ + fun userMessage(): Optional = + Optional.ofNullable(userMessage) + + /** An outcome the agent should work toward. The agent begins work on receipt. */ + fun userDefineOutcome(): Optional = + Optional.ofNullable(userDefineOutcome) + + /** + * Privileged context for the accompanying turn and all subsequent turns, appended to the + * session's system context as a `role: "system"` turn rather than replacing the top-level + * system prompt. + */ + fun systemMessage(): Optional = + Optional.ofNullable(systemMessage) + + fun isUserMessage(): Boolean = userMessage != null + + fun isUserDefineOutcome(): Boolean = userDefineOutcome != null + + fun isSystemMessage(): Boolean = systemMessage != null + + /** A user message sent to the session. */ + fun asUserMessage(): BetaManagedAgentsDeploymentUserMessageEvent = + userMessage.getOrThrow("userMessage") + + /** An outcome the agent should work toward. The agent begins work on receipt. */ + fun asUserDefineOutcome(): BetaManagedAgentsDeploymentUserDefineOutcomeEvent = + userDefineOutcome.getOrThrow("userDefineOutcome") + + /** + * Privileged context for the accompanying turn and all subsequent turns, appended to the + * session's system context as a `role: "system"` turn rather than replacing the top-level + * system prompt. + */ + fun asSystemMessage(): BetaManagedAgentsDeploymentSystemMessageEvent = + systemMessage.getOrThrow("systemMessage") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.anthropic.core.JsonValue; + * import java.util.Optional; + * + * Optional result = betaManagedAgentsDeploymentInitialEvent.accept(new BetaManagedAgentsDeploymentInitialEvent.Visitor>() { + * @Override + * public Optional visitUserMessage(BetaManagedAgentsDeploymentUserMessageEvent userMessage) { + * return Optional.of(userMessage.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws AnthropicInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + userMessage != null -> visitor.visitUserMessage(userMessage) + userDefineOutcome != null -> visitor.visitUserDefineOutcome(userDefineOutcome) + systemMessage != null -> visitor.visitSystemMessage(systemMessage) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsDeploymentInitialEvent = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUserMessage( + userMessage: BetaManagedAgentsDeploymentUserMessageEvent + ) { + userMessage.validate() + } + + override fun visitUserDefineOutcome( + userDefineOutcome: BetaManagedAgentsDeploymentUserDefineOutcomeEvent + ) { + userDefineOutcome.validate() + } + + override fun visitSystemMessage( + systemMessage: BetaManagedAgentsDeploymentSystemMessageEvent + ) { + systemMessage.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUserMessage( + userMessage: BetaManagedAgentsDeploymentUserMessageEvent + ) = userMessage.validity() + + override fun visitUserDefineOutcome( + userDefineOutcome: BetaManagedAgentsDeploymentUserDefineOutcomeEvent + ) = userDefineOutcome.validity() + + override fun visitSystemMessage( + systemMessage: BetaManagedAgentsDeploymentSystemMessageEvent + ) = systemMessage.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsDeploymentInitialEvent && + userMessage == other.userMessage && + userDefineOutcome == other.userDefineOutcome && + systemMessage == other.systemMessage + } + + override fun hashCode(): Int = Objects.hash(userMessage, userDefineOutcome, systemMessage) + + override fun toString(): String = + when { + userMessage != null -> + "BetaManagedAgentsDeploymentInitialEvent{userMessage=$userMessage}" + userDefineOutcome != null -> + "BetaManagedAgentsDeploymentInitialEvent{userDefineOutcome=$userDefineOutcome}" + systemMessage != null -> + "BetaManagedAgentsDeploymentInitialEvent{systemMessage=$systemMessage}" + _json != null -> "BetaManagedAgentsDeploymentInitialEvent{_unknown=$_json}" + else -> throw IllegalStateException("Invalid BetaManagedAgentsDeploymentInitialEvent") + } + + companion object { + + /** A user message sent to the session. */ + @JvmStatic + fun ofUserMessage(userMessage: BetaManagedAgentsDeploymentUserMessageEvent) = + BetaManagedAgentsDeploymentInitialEvent(userMessage = userMessage) + + /** An outcome the agent should work toward. The agent begins work on receipt. */ + @JvmStatic + fun ofUserDefineOutcome( + userDefineOutcome: BetaManagedAgentsDeploymentUserDefineOutcomeEvent + ) = BetaManagedAgentsDeploymentInitialEvent(userDefineOutcome = userDefineOutcome) + + /** + * Privileged context for the accompanying turn and all subsequent turns, appended to the + * session's system context as a `role: "system"` turn rather than replacing the top-level + * system prompt. + */ + @JvmStatic + fun ofSystemMessage(systemMessage: BetaManagedAgentsDeploymentSystemMessageEvent) = + BetaManagedAgentsDeploymentInitialEvent(systemMessage = systemMessage) + } + + /** + * An interface that defines how to map each variant of + * [BetaManagedAgentsDeploymentInitialEvent] to a value of type [T]. + */ + interface Visitor { + + /** A user message sent to the session. */ + fun visitUserMessage(userMessage: BetaManagedAgentsDeploymentUserMessageEvent): T + + /** An outcome the agent should work toward. The agent begins work on receipt. */ + fun visitUserDefineOutcome( + userDefineOutcome: BetaManagedAgentsDeploymentUserDefineOutcomeEvent + ): T + + /** + * Privileged context for the accompanying turn and all subsequent turns, appended to the + * session's system context as a `role: "system"` turn rather than replacing the top-level + * system prompt. + */ + fun visitSystemMessage(systemMessage: BetaManagedAgentsDeploymentSystemMessageEvent): T + + /** + * Maps an unknown variant of [BetaManagedAgentsDeploymentInitialEvent] to a value of type + * [T]. + * + * An instance of [BetaManagedAgentsDeploymentInitialEvent] can contain an unknown variant + * if it was deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with new variants + * that the SDK is unaware of. + * + * @throws AnthropicInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw AnthropicInvalidDataException( + "Unknown BetaManagedAgentsDeploymentInitialEvent: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + BetaManagedAgentsDeploymentInitialEvent::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): BetaManagedAgentsDeploymentInitialEvent { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "user.message" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + BetaManagedAgentsDeploymentInitialEvent(userMessage = it, _json = json) + } ?: BetaManagedAgentsDeploymentInitialEvent(_json = json) + } + "user.define_outcome" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + BetaManagedAgentsDeploymentInitialEvent( + userDefineOutcome = it, + _json = json, + ) + } ?: BetaManagedAgentsDeploymentInitialEvent(_json = json) + } + "system.message" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + BetaManagedAgentsDeploymentInitialEvent( + systemMessage = it, + _json = json, + ) + } ?: BetaManagedAgentsDeploymentInitialEvent(_json = json) + } + } + + return BetaManagedAgentsDeploymentInitialEvent(_json = json) + } + } + + internal class Serializer : + BaseSerializer( + BetaManagedAgentsDeploymentInitialEvent::class + ) { + + override fun serialize( + value: BetaManagedAgentsDeploymentInitialEvent, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.userMessage != null -> generator.writeObject(value.userMessage) + value.userDefineOutcome != null -> generator.writeObject(value.userDefineOutcome) + value.systemMessage != null -> generator.writeObject(value.systemMessage) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException("Invalid BetaManagedAgentsDeploymentInitialEvent") + } + } + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentInitialEventParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentInitialEventParams.kt new file mode 100644 index 000000000..1d81eb8dc --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentInitialEventParams.kt @@ -0,0 +1,370 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.BaseDeserializer +import com.anthropic.core.BaseSerializer +import com.anthropic.core.JsonValue +import com.anthropic.core.getOrThrow +import com.anthropic.errors.AnthropicInvalidDataException +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsSystemMessageEventParams +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsUserDefineOutcomeEventParams +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsUserMessageEventParams +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * An event sent to a session immediately after it is created. Supports `user.message`, + * `user.define_outcome`, and `system.message`. + */ +@JsonDeserialize(using = BetaManagedAgentsDeploymentInitialEventParams.Deserializer::class) +@JsonSerialize(using = BetaManagedAgentsDeploymentInitialEventParams.Serializer::class) +class BetaManagedAgentsDeploymentInitialEventParams +private constructor( + private val userMessage: BetaManagedAgentsUserMessageEventParams? = null, + private val userDefineOutcome: BetaManagedAgentsUserDefineOutcomeEventParams? = null, + private val systemMessage: BetaManagedAgentsSystemMessageEventParams? = null, + private val _json: JsonValue? = null, +) { + + /** Parameters for sending a user message to the session. */ + fun userMessage(): Optional = + Optional.ofNullable(userMessage) + + /** + * Parameters for defining an outcome the agent should work toward. The agent begins work on + * receipt. + */ + fun userDefineOutcome(): Optional = + Optional.ofNullable(userDefineOutcome) + + /** + * Privileged context for the accompanying turn and all subsequent turns, appended to the + * session's system context as a `role: "system"` turn rather than replacing the top-level + * system prompt. At most one per request: it must be the final event and immediately follow the + * `user.message`, `user.tool_result`, or `user.custom_tool_result` it accompanies. Only + * supported on models that accept mid-conversation system messages. + */ + fun systemMessage(): Optional = + Optional.ofNullable(systemMessage) + + fun isUserMessage(): Boolean = userMessage != null + + fun isUserDefineOutcome(): Boolean = userDefineOutcome != null + + fun isSystemMessage(): Boolean = systemMessage != null + + /** Parameters for sending a user message to the session. */ + fun asUserMessage(): BetaManagedAgentsUserMessageEventParams = + userMessage.getOrThrow("userMessage") + + /** + * Parameters for defining an outcome the agent should work toward. The agent begins work on + * receipt. + */ + fun asUserDefineOutcome(): BetaManagedAgentsUserDefineOutcomeEventParams = + userDefineOutcome.getOrThrow("userDefineOutcome") + + /** + * Privileged context for the accompanying turn and all subsequent turns, appended to the + * session's system context as a `role: "system"` turn rather than replacing the top-level + * system prompt. At most one per request: it must be the final event and immediately follow the + * `user.message`, `user.tool_result`, or `user.custom_tool_result` it accompanies. Only + * supported on models that accept mid-conversation system messages. + */ + fun asSystemMessage(): BetaManagedAgentsSystemMessageEventParams = + systemMessage.getOrThrow("systemMessage") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.anthropic.core.JsonValue; + * import java.util.Optional; + * + * Optional result = betaManagedAgentsDeploymentInitialEventParams.accept(new BetaManagedAgentsDeploymentInitialEventParams.Visitor>() { + * @Override + * public Optional visitUserMessage(BetaManagedAgentsUserMessageEventParams userMessage) { + * return Optional.of(userMessage.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws AnthropicInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + userMessage != null -> visitor.visitUserMessage(userMessage) + userDefineOutcome != null -> visitor.visitUserDefineOutcome(userDefineOutcome) + systemMessage != null -> visitor.visitSystemMessage(systemMessage) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsDeploymentInitialEventParams = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUserMessage( + userMessage: BetaManagedAgentsUserMessageEventParams + ) { + userMessage.validate() + } + + override fun visitUserDefineOutcome( + userDefineOutcome: BetaManagedAgentsUserDefineOutcomeEventParams + ) { + userDefineOutcome.validate() + } + + override fun visitSystemMessage( + systemMessage: BetaManagedAgentsSystemMessageEventParams + ) { + systemMessage.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUserMessage( + userMessage: BetaManagedAgentsUserMessageEventParams + ) = userMessage.validity() + + override fun visitUserDefineOutcome( + userDefineOutcome: BetaManagedAgentsUserDefineOutcomeEventParams + ) = userDefineOutcome.validity() + + override fun visitSystemMessage( + systemMessage: BetaManagedAgentsSystemMessageEventParams + ) = systemMessage.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsDeploymentInitialEventParams && + userMessage == other.userMessage && + userDefineOutcome == other.userDefineOutcome && + systemMessage == other.systemMessage + } + + override fun hashCode(): Int = Objects.hash(userMessage, userDefineOutcome, systemMessage) + + override fun toString(): String = + when { + userMessage != null -> + "BetaManagedAgentsDeploymentInitialEventParams{userMessage=$userMessage}" + userDefineOutcome != null -> + "BetaManagedAgentsDeploymentInitialEventParams{userDefineOutcome=$userDefineOutcome}" + systemMessage != null -> + "BetaManagedAgentsDeploymentInitialEventParams{systemMessage=$systemMessage}" + _json != null -> "BetaManagedAgentsDeploymentInitialEventParams{_unknown=$_json}" + else -> + throw IllegalStateException("Invalid BetaManagedAgentsDeploymentInitialEventParams") + } + + companion object { + + /** Parameters for sending a user message to the session. */ + @JvmStatic + fun ofUserMessage(userMessage: BetaManagedAgentsUserMessageEventParams) = + BetaManagedAgentsDeploymentInitialEventParams(userMessage = userMessage) + + /** + * Parameters for defining an outcome the agent should work toward. The agent begins work on + * receipt. + */ + @JvmStatic + fun ofUserDefineOutcome(userDefineOutcome: BetaManagedAgentsUserDefineOutcomeEventParams) = + BetaManagedAgentsDeploymentInitialEventParams(userDefineOutcome = userDefineOutcome) + + /** + * Privileged context for the accompanying turn and all subsequent turns, appended to the + * session's system context as a `role: "system"` turn rather than replacing the top-level + * system prompt. At most one per request: it must be the final event and immediately follow + * the `user.message`, `user.tool_result`, or `user.custom_tool_result` it accompanies. Only + * supported on models that accept mid-conversation system messages. + */ + @JvmStatic + fun ofSystemMessage(systemMessage: BetaManagedAgentsSystemMessageEventParams) = + BetaManagedAgentsDeploymentInitialEventParams(systemMessage = systemMessage) + } + + /** + * An interface that defines how to map each variant of + * [BetaManagedAgentsDeploymentInitialEventParams] to a value of type [T]. + */ + interface Visitor { + + /** Parameters for sending a user message to the session. */ + fun visitUserMessage(userMessage: BetaManagedAgentsUserMessageEventParams): T + + /** + * Parameters for defining an outcome the agent should work toward. The agent begins work on + * receipt. + */ + fun visitUserDefineOutcome( + userDefineOutcome: BetaManagedAgentsUserDefineOutcomeEventParams + ): T + + /** + * Privileged context for the accompanying turn and all subsequent turns, appended to the + * session's system context as a `role: "system"` turn rather than replacing the top-level + * system prompt. At most one per request: it must be the final event and immediately follow + * the `user.message`, `user.tool_result`, or `user.custom_tool_result` it accompanies. Only + * supported on models that accept mid-conversation system messages. + */ + fun visitSystemMessage(systemMessage: BetaManagedAgentsSystemMessageEventParams): T + + /** + * Maps an unknown variant of [BetaManagedAgentsDeploymentInitialEventParams] to a value of + * type [T]. + * + * An instance of [BetaManagedAgentsDeploymentInitialEventParams] can contain an unknown + * variant if it was deserialized from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws AnthropicInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw AnthropicInvalidDataException( + "Unknown BetaManagedAgentsDeploymentInitialEventParams: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + BetaManagedAgentsDeploymentInitialEventParams::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): BetaManagedAgentsDeploymentInitialEventParams { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "user.message" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + BetaManagedAgentsDeploymentInitialEventParams( + userMessage = it, + _json = json, + ) + } ?: BetaManagedAgentsDeploymentInitialEventParams(_json = json) + } + "user.define_outcome" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + BetaManagedAgentsDeploymentInitialEventParams( + userDefineOutcome = it, + _json = json, + ) + } ?: BetaManagedAgentsDeploymentInitialEventParams(_json = json) + } + "system.message" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + BetaManagedAgentsDeploymentInitialEventParams( + systemMessage = it, + _json = json, + ) + } ?: BetaManagedAgentsDeploymentInitialEventParams(_json = json) + } + } + + return BetaManagedAgentsDeploymentInitialEventParams(_json = json) + } + } + + internal class Serializer : + BaseSerializer( + BetaManagedAgentsDeploymentInitialEventParams::class + ) { + + override fun serialize( + value: BetaManagedAgentsDeploymentInitialEventParams, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.userMessage != null -> generator.writeObject(value.userMessage) + value.userDefineOutcome != null -> generator.writeObject(value.userDefineOutcome) + value.systemMessage != null -> generator.writeObject(value.systemMessage) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid BetaManagedAgentsDeploymentInitialEventParams" + ) + } + } + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentPausedReason.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentPausedReason.kt new file mode 100644 index 000000000..52827ce9b --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentPausedReason.kt @@ -0,0 +1,258 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.BaseDeserializer +import com.anthropic.core.BaseSerializer +import com.anthropic.core.JsonValue +import com.anthropic.core.getOrThrow +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Why a deployment is paused. Non-null exactly when `status` is `paused`. */ +@JsonDeserialize(using = BetaManagedAgentsDeploymentPausedReason.Deserializer::class) +@JsonSerialize(using = BetaManagedAgentsDeploymentPausedReason.Serializer::class) +class BetaManagedAgentsDeploymentPausedReason +private constructor( + private val manual: BetaManagedAgentsManualDeploymentPausedReason? = null, + private val error: BetaManagedAgentsErrorDeploymentPausedReason? = null, + private val _json: JsonValue? = null, +) { + + /** The caller invoked the pause endpoint on the deployment. */ + fun manual(): Optional = + Optional.ofNullable(manual) + + /** A scheduled fire recorded a failed run whose error auto-pauses the deployment. */ + fun error(): Optional = Optional.ofNullable(error) + + fun isManual(): Boolean = manual != null + + fun isError(): Boolean = error != null + + /** The caller invoked the pause endpoint on the deployment. */ + fun asManual(): BetaManagedAgentsManualDeploymentPausedReason = manual.getOrThrow("manual") + + /** A scheduled fire recorded a failed run whose error auto-pauses the deployment. */ + fun asError(): BetaManagedAgentsErrorDeploymentPausedReason = error.getOrThrow("error") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.anthropic.core.JsonValue; + * import java.util.Optional; + * + * Optional result = betaManagedAgentsDeploymentPausedReason.accept(new BetaManagedAgentsDeploymentPausedReason.Visitor>() { + * @Override + * public Optional visitManual(BetaManagedAgentsManualDeploymentPausedReason manual) { + * return Optional.of(manual.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws AnthropicInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + manual != null -> visitor.visitManual(manual) + error != null -> visitor.visitError(error) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsDeploymentPausedReason = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitManual(manual: BetaManagedAgentsManualDeploymentPausedReason) { + manual.validate() + } + + override fun visitError(error: BetaManagedAgentsErrorDeploymentPausedReason) { + error.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitManual(manual: BetaManagedAgentsManualDeploymentPausedReason) = + manual.validity() + + override fun visitError(error: BetaManagedAgentsErrorDeploymentPausedReason) = + error.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsDeploymentPausedReason && + manual == other.manual && + error == other.error + } + + override fun hashCode(): Int = Objects.hash(manual, error) + + override fun toString(): String = + when { + manual != null -> "BetaManagedAgentsDeploymentPausedReason{manual=$manual}" + error != null -> "BetaManagedAgentsDeploymentPausedReason{error=$error}" + _json != null -> "BetaManagedAgentsDeploymentPausedReason{_unknown=$_json}" + else -> throw IllegalStateException("Invalid BetaManagedAgentsDeploymentPausedReason") + } + + companion object { + + /** The caller invoked the pause endpoint on the deployment. */ + @JvmStatic + fun ofManual(manual: BetaManagedAgentsManualDeploymentPausedReason) = + BetaManagedAgentsDeploymentPausedReason(manual = manual) + + /** A scheduled fire recorded a failed run whose error auto-pauses the deployment. */ + @JvmStatic + fun ofError(error: BetaManagedAgentsErrorDeploymentPausedReason) = + BetaManagedAgentsDeploymentPausedReason(error = error) + } + + /** + * An interface that defines how to map each variant of + * [BetaManagedAgentsDeploymentPausedReason] to a value of type [T]. + */ + interface Visitor { + + /** The caller invoked the pause endpoint on the deployment. */ + fun visitManual(manual: BetaManagedAgentsManualDeploymentPausedReason): T + + /** A scheduled fire recorded a failed run whose error auto-pauses the deployment. */ + fun visitError(error: BetaManagedAgentsErrorDeploymentPausedReason): T + + /** + * Maps an unknown variant of [BetaManagedAgentsDeploymentPausedReason] to a value of type + * [T]. + * + * An instance of [BetaManagedAgentsDeploymentPausedReason] can contain an unknown variant + * if it was deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with new variants + * that the SDK is unaware of. + * + * @throws AnthropicInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw AnthropicInvalidDataException( + "Unknown BetaManagedAgentsDeploymentPausedReason: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + BetaManagedAgentsDeploymentPausedReason::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): BetaManagedAgentsDeploymentPausedReason { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "manual" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { BetaManagedAgentsDeploymentPausedReason(manual = it, _json = json) } + ?: BetaManagedAgentsDeploymentPausedReason(_json = json) + } + "error" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { BetaManagedAgentsDeploymentPausedReason(error = it, _json = json) } + ?: BetaManagedAgentsDeploymentPausedReason(_json = json) + } + } + + return BetaManagedAgentsDeploymentPausedReason(_json = json) + } + } + + internal class Serializer : + BaseSerializer( + BetaManagedAgentsDeploymentPausedReason::class + ) { + + override fun serialize( + value: BetaManagedAgentsDeploymentPausedReason, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.manual != null -> generator.writeObject(value.manual) + value.error != null -> generator.writeObject(value.error) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException("Invalid BetaManagedAgentsDeploymentPausedReason") + } + } + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentPausedReasonError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentPausedReasonError.kt new file mode 100644 index 000000000..6a3d9eee8 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentPausedReasonError.kt @@ -0,0 +1,1000 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.BaseDeserializer +import com.anthropic.core.BaseSerializer +import com.anthropic.core.JsonValue +import com.anthropic.core.getOrThrow +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** The error that triggered an auto-pause. Matches the failed run's `error.type`. */ +@JsonDeserialize(using = BetaManagedAgentsDeploymentPausedReasonError.Deserializer::class) +@JsonSerialize(using = BetaManagedAgentsDeploymentPausedReasonError.Serializer::class) +class BetaManagedAgentsDeploymentPausedReasonError +private constructor( + private val environmentArchived: + BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError? = + null, + private val agentArchived: BetaManagedAgentsAgentArchivedDeploymentPausedReasonError? = null, + private val environmentNotFound: + BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError? = + null, + private val vaultNotFound: BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError? = null, + private val fileNotFound: BetaManagedAgentsFileNotFoundDeploymentPausedReasonError? = null, + private val sessionResourceNotFound: + BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError? = + null, + private val workspaceArchived: BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError? = + null, + private val organizationDisabled: + BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError? = + null, + private val memoryStoreArchived: + BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError? = + null, + private val skillNotFound: BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError? = null, + private val vaultArchived: BetaManagedAgentsVaultArchivedDeploymentPausedReasonError? = null, + private val unknown: BetaManagedAgentsUnknownDeploymentPausedReasonError? = null, + private val selfHostedResourcesUnsupported: + BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError? = + null, + private val mcpEgressBlocked: BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError? = + null, + private val _json: JsonValue? = null, +) { + + /** The deployment's environment was archived. */ + fun environmentArchived(): + Optional = + Optional.ofNullable(environmentArchived) + + /** The deployment's agent was archived. */ + fun agentArchived(): Optional = + Optional.ofNullable(agentArchived) + + /** The deployment's environment no longer exists. */ + fun environmentNotFound(): + Optional = + Optional.ofNullable(environmentNotFound) + + /** A vault referenced by the deployment no longer exists. */ + fun vaultNotFound(): Optional = + Optional.ofNullable(vaultNotFound) + + /** A file resource referenced by the deployment no longer exists. */ + fun fileNotFound(): Optional = + Optional.ofNullable(fileNotFound) + + /** A referenced resource no longer exists and its kind was not reported. */ + fun sessionResourceNotFound(): + Optional = + Optional.ofNullable(sessionResourceNotFound) + + /** The deployment's workspace was archived. */ + fun workspaceArchived(): + Optional = + Optional.ofNullable(workspaceArchived) + + /** The deployment's organization is disabled. */ + fun organizationDisabled(): + Optional = + Optional.ofNullable(organizationDisabled) + + /** A memory store referenced by the deployment is archived. */ + fun memoryStoreArchived(): + Optional = + Optional.ofNullable(memoryStoreArchived) + + /** A skill referenced by the deployment's agent no longer exists. */ + fun skillNotFound(): Optional = + Optional.ofNullable(skillNotFound) + + /** A vault referenced by the deployment is archived. */ + fun vaultArchived(): Optional = + Optional.ofNullable(vaultArchived) + + /** + * An unrecognized error auto-paused the deployment. A fallback variant; matches a run whose + * `error.type` is `unknown_error`. + */ + fun unknown(): Optional = + Optional.ofNullable(unknown) + + /** + * The deployment configures resources, but its environment is self-hosted and cannot mount + * them. + */ + fun selfHostedResourcesUnsupported(): + Optional = + Optional.ofNullable(selfHostedResourcesUnsupported) + + /** + * An MCP server host used by the deployment's agent is blocked by the environment's network + * policy. + */ + fun mcpEgressBlocked(): Optional = + Optional.ofNullable(mcpEgressBlocked) + + fun isEnvironmentArchived(): Boolean = environmentArchived != null + + fun isAgentArchived(): Boolean = agentArchived != null + + fun isEnvironmentNotFound(): Boolean = environmentNotFound != null + + fun isVaultNotFound(): Boolean = vaultNotFound != null + + fun isFileNotFound(): Boolean = fileNotFound != null + + fun isSessionResourceNotFound(): Boolean = sessionResourceNotFound != null + + fun isWorkspaceArchived(): Boolean = workspaceArchived != null + + fun isOrganizationDisabled(): Boolean = organizationDisabled != null + + fun isMemoryStoreArchived(): Boolean = memoryStoreArchived != null + + fun isSkillNotFound(): Boolean = skillNotFound != null + + fun isVaultArchived(): Boolean = vaultArchived != null + + fun isUnknown(): Boolean = unknown != null + + fun isSelfHostedResourcesUnsupported(): Boolean = selfHostedResourcesUnsupported != null + + fun isMcpEgressBlocked(): Boolean = mcpEgressBlocked != null + + /** The deployment's environment was archived. */ + fun asEnvironmentArchived(): BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError = + environmentArchived.getOrThrow("environmentArchived") + + /** The deployment's agent was archived. */ + fun asAgentArchived(): BetaManagedAgentsAgentArchivedDeploymentPausedReasonError = + agentArchived.getOrThrow("agentArchived") + + /** The deployment's environment no longer exists. */ + fun asEnvironmentNotFound(): BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError = + environmentNotFound.getOrThrow("environmentNotFound") + + /** A vault referenced by the deployment no longer exists. */ + fun asVaultNotFound(): BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError = + vaultNotFound.getOrThrow("vaultNotFound") + + /** A file resource referenced by the deployment no longer exists. */ + fun asFileNotFound(): BetaManagedAgentsFileNotFoundDeploymentPausedReasonError = + fileNotFound.getOrThrow("fileNotFound") + + /** A referenced resource no longer exists and its kind was not reported. */ + fun asSessionResourceNotFound(): + BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError = + sessionResourceNotFound.getOrThrow("sessionResourceNotFound") + + /** The deployment's workspace was archived. */ + fun asWorkspaceArchived(): BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError = + workspaceArchived.getOrThrow("workspaceArchived") + + /** The deployment's organization is disabled. */ + fun asOrganizationDisabled(): BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError = + organizationDisabled.getOrThrow("organizationDisabled") + + /** A memory store referenced by the deployment is archived. */ + fun asMemoryStoreArchived(): BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError = + memoryStoreArchived.getOrThrow("memoryStoreArchived") + + /** A skill referenced by the deployment's agent no longer exists. */ + fun asSkillNotFound(): BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError = + skillNotFound.getOrThrow("skillNotFound") + + /** A vault referenced by the deployment is archived. */ + fun asVaultArchived(): BetaManagedAgentsVaultArchivedDeploymentPausedReasonError = + vaultArchived.getOrThrow("vaultArchived") + + /** + * An unrecognized error auto-paused the deployment. A fallback variant; matches a run whose + * `error.type` is `unknown_error`. + */ + fun asUnknown(): BetaManagedAgentsUnknownDeploymentPausedReasonError = + unknown.getOrThrow("unknown") + + /** + * The deployment configures resources, but its environment is self-hosted and cannot mount + * them. + */ + fun asSelfHostedResourcesUnsupported(): + BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError = + selfHostedResourcesUnsupported.getOrThrow("selfHostedResourcesUnsupported") + + /** + * An MCP server host used by the deployment's agent is blocked by the environment's network + * policy. + */ + fun asMcpEgressBlocked(): BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError = + mcpEgressBlocked.getOrThrow("mcpEgressBlocked") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.anthropic.core.JsonValue; + * import java.util.Optional; + * + * Optional result = betaManagedAgentsDeploymentPausedReasonError.accept(new BetaManagedAgentsDeploymentPausedReasonError.Visitor>() { + * @Override + * public Optional visitEnvironmentArchived(BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError environmentArchived) { + * return Optional.of(environmentArchived.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws AnthropicInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + environmentArchived != null -> visitor.visitEnvironmentArchived(environmentArchived) + agentArchived != null -> visitor.visitAgentArchived(agentArchived) + environmentNotFound != null -> visitor.visitEnvironmentNotFound(environmentNotFound) + vaultNotFound != null -> visitor.visitVaultNotFound(vaultNotFound) + fileNotFound != null -> visitor.visitFileNotFound(fileNotFound) + sessionResourceNotFound != null -> + visitor.visitSessionResourceNotFound(sessionResourceNotFound) + workspaceArchived != null -> visitor.visitWorkspaceArchived(workspaceArchived) + organizationDisabled != null -> visitor.visitOrganizationDisabled(organizationDisabled) + memoryStoreArchived != null -> visitor.visitMemoryStoreArchived(memoryStoreArchived) + skillNotFound != null -> visitor.visitSkillNotFound(skillNotFound) + vaultArchived != null -> visitor.visitVaultArchived(vaultArchived) + unknown != null -> visitor.visitUnknown(unknown) + selfHostedResourcesUnsupported != null -> + visitor.visitSelfHostedResourcesUnsupported(selfHostedResourcesUnsupported) + mcpEgressBlocked != null -> visitor.visitMcpEgressBlocked(mcpEgressBlocked) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsDeploymentPausedReasonError = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitEnvironmentArchived( + environmentArchived: + BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError + ) { + environmentArchived.validate() + } + + override fun visitAgentArchived( + agentArchived: BetaManagedAgentsAgentArchivedDeploymentPausedReasonError + ) { + agentArchived.validate() + } + + override fun visitEnvironmentNotFound( + environmentNotFound: + BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError + ) { + environmentNotFound.validate() + } + + override fun visitVaultNotFound( + vaultNotFound: BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError + ) { + vaultNotFound.validate() + } + + override fun visitFileNotFound( + fileNotFound: BetaManagedAgentsFileNotFoundDeploymentPausedReasonError + ) { + fileNotFound.validate() + } + + override fun visitSessionResourceNotFound( + sessionResourceNotFound: + BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError + ) { + sessionResourceNotFound.validate() + } + + override fun visitWorkspaceArchived( + workspaceArchived: BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError + ) { + workspaceArchived.validate() + } + + override fun visitOrganizationDisabled( + organizationDisabled: + BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError + ) { + organizationDisabled.validate() + } + + override fun visitMemoryStoreArchived( + memoryStoreArchived: + BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError + ) { + memoryStoreArchived.validate() + } + + override fun visitSkillNotFound( + skillNotFound: BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError + ) { + skillNotFound.validate() + } + + override fun visitVaultArchived( + vaultArchived: BetaManagedAgentsVaultArchivedDeploymentPausedReasonError + ) { + vaultArchived.validate() + } + + override fun visitUnknown( + unknown: BetaManagedAgentsUnknownDeploymentPausedReasonError + ) { + unknown.validate() + } + + override fun visitSelfHostedResourcesUnsupported( + selfHostedResourcesUnsupported: + BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError + ) { + selfHostedResourcesUnsupported.validate() + } + + override fun visitMcpEgressBlocked( + mcpEgressBlocked: BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError + ) { + mcpEgressBlocked.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitEnvironmentArchived( + environmentArchived: + BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError + ) = environmentArchived.validity() + + override fun visitAgentArchived( + agentArchived: BetaManagedAgentsAgentArchivedDeploymentPausedReasonError + ) = agentArchived.validity() + + override fun visitEnvironmentNotFound( + environmentNotFound: + BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError + ) = environmentNotFound.validity() + + override fun visitVaultNotFound( + vaultNotFound: BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError + ) = vaultNotFound.validity() + + override fun visitFileNotFound( + fileNotFound: BetaManagedAgentsFileNotFoundDeploymentPausedReasonError + ) = fileNotFound.validity() + + override fun visitSessionResourceNotFound( + sessionResourceNotFound: + BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError + ) = sessionResourceNotFound.validity() + + override fun visitWorkspaceArchived( + workspaceArchived: BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError + ) = workspaceArchived.validity() + + override fun visitOrganizationDisabled( + organizationDisabled: + BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError + ) = organizationDisabled.validity() + + override fun visitMemoryStoreArchived( + memoryStoreArchived: + BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError + ) = memoryStoreArchived.validity() + + override fun visitSkillNotFound( + skillNotFound: BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError + ) = skillNotFound.validity() + + override fun visitVaultArchived( + vaultArchived: BetaManagedAgentsVaultArchivedDeploymentPausedReasonError + ) = vaultArchived.validity() + + override fun visitUnknown( + unknown: BetaManagedAgentsUnknownDeploymentPausedReasonError + ) = unknown.validity() + + override fun visitSelfHostedResourcesUnsupported( + selfHostedResourcesUnsupported: + BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError + ) = selfHostedResourcesUnsupported.validity() + + override fun visitMcpEgressBlocked( + mcpEgressBlocked: BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError + ) = mcpEgressBlocked.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsDeploymentPausedReasonError && + environmentArchived == other.environmentArchived && + agentArchived == other.agentArchived && + environmentNotFound == other.environmentNotFound && + vaultNotFound == other.vaultNotFound && + fileNotFound == other.fileNotFound && + sessionResourceNotFound == other.sessionResourceNotFound && + workspaceArchived == other.workspaceArchived && + organizationDisabled == other.organizationDisabled && + memoryStoreArchived == other.memoryStoreArchived && + skillNotFound == other.skillNotFound && + vaultArchived == other.vaultArchived && + unknown == other.unknown && + selfHostedResourcesUnsupported == other.selfHostedResourcesUnsupported && + mcpEgressBlocked == other.mcpEgressBlocked + } + + override fun hashCode(): Int = + Objects.hash( + environmentArchived, + agentArchived, + environmentNotFound, + vaultNotFound, + fileNotFound, + sessionResourceNotFound, + workspaceArchived, + organizationDisabled, + memoryStoreArchived, + skillNotFound, + vaultArchived, + unknown, + selfHostedResourcesUnsupported, + mcpEgressBlocked, + ) + + override fun toString(): String = + when { + environmentArchived != null -> + "BetaManagedAgentsDeploymentPausedReasonError{environmentArchived=$environmentArchived}" + agentArchived != null -> + "BetaManagedAgentsDeploymentPausedReasonError{agentArchived=$agentArchived}" + environmentNotFound != null -> + "BetaManagedAgentsDeploymentPausedReasonError{environmentNotFound=$environmentNotFound}" + vaultNotFound != null -> + "BetaManagedAgentsDeploymentPausedReasonError{vaultNotFound=$vaultNotFound}" + fileNotFound != null -> + "BetaManagedAgentsDeploymentPausedReasonError{fileNotFound=$fileNotFound}" + sessionResourceNotFound != null -> + "BetaManagedAgentsDeploymentPausedReasonError{sessionResourceNotFound=$sessionResourceNotFound}" + workspaceArchived != null -> + "BetaManagedAgentsDeploymentPausedReasonError{workspaceArchived=$workspaceArchived}" + organizationDisabled != null -> + "BetaManagedAgentsDeploymentPausedReasonError{organizationDisabled=$organizationDisabled}" + memoryStoreArchived != null -> + "BetaManagedAgentsDeploymentPausedReasonError{memoryStoreArchived=$memoryStoreArchived}" + skillNotFound != null -> + "BetaManagedAgentsDeploymentPausedReasonError{skillNotFound=$skillNotFound}" + vaultArchived != null -> + "BetaManagedAgentsDeploymentPausedReasonError{vaultArchived=$vaultArchived}" + unknown != null -> "BetaManagedAgentsDeploymentPausedReasonError{unknown=$unknown}" + selfHostedResourcesUnsupported != null -> + "BetaManagedAgentsDeploymentPausedReasonError{selfHostedResourcesUnsupported=$selfHostedResourcesUnsupported}" + mcpEgressBlocked != null -> + "BetaManagedAgentsDeploymentPausedReasonError{mcpEgressBlocked=$mcpEgressBlocked}" + _json != null -> "BetaManagedAgentsDeploymentPausedReasonError{_unknown=$_json}" + else -> + throw IllegalStateException("Invalid BetaManagedAgentsDeploymentPausedReasonError") + } + + companion object { + + /** The deployment's environment was archived. */ + @JvmStatic + fun ofEnvironmentArchived( + environmentArchived: BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError + ) = BetaManagedAgentsDeploymentPausedReasonError(environmentArchived = environmentArchived) + + /** The deployment's agent was archived. */ + @JvmStatic + fun ofAgentArchived( + agentArchived: BetaManagedAgentsAgentArchivedDeploymentPausedReasonError + ) = BetaManagedAgentsDeploymentPausedReasonError(agentArchived = agentArchived) + + /** The deployment's environment no longer exists. */ + @JvmStatic + fun ofEnvironmentNotFound( + environmentNotFound: BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError + ) = BetaManagedAgentsDeploymentPausedReasonError(environmentNotFound = environmentNotFound) + + /** A vault referenced by the deployment no longer exists. */ + @JvmStatic + fun ofVaultNotFound( + vaultNotFound: BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError + ) = BetaManagedAgentsDeploymentPausedReasonError(vaultNotFound = vaultNotFound) + + /** A file resource referenced by the deployment no longer exists. */ + @JvmStatic + fun ofFileNotFound(fileNotFound: BetaManagedAgentsFileNotFoundDeploymentPausedReasonError) = + BetaManagedAgentsDeploymentPausedReasonError(fileNotFound = fileNotFound) + + /** A referenced resource no longer exists and its kind was not reported. */ + @JvmStatic + fun ofSessionResourceNotFound( + sessionResourceNotFound: + BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError + ) = + BetaManagedAgentsDeploymentPausedReasonError( + sessionResourceNotFound = sessionResourceNotFound + ) + + /** The deployment's workspace was archived. */ + @JvmStatic + fun ofWorkspaceArchived( + workspaceArchived: BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError + ) = BetaManagedAgentsDeploymentPausedReasonError(workspaceArchived = workspaceArchived) + + /** The deployment's organization is disabled. */ + @JvmStatic + fun ofOrganizationDisabled( + organizationDisabled: BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError + ) = + BetaManagedAgentsDeploymentPausedReasonError( + organizationDisabled = organizationDisabled + ) + + /** A memory store referenced by the deployment is archived. */ + @JvmStatic + fun ofMemoryStoreArchived( + memoryStoreArchived: BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError + ) = BetaManagedAgentsDeploymentPausedReasonError(memoryStoreArchived = memoryStoreArchived) + + /** A skill referenced by the deployment's agent no longer exists. */ + @JvmStatic + fun ofSkillNotFound( + skillNotFound: BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError + ) = BetaManagedAgentsDeploymentPausedReasonError(skillNotFound = skillNotFound) + + /** A vault referenced by the deployment is archived. */ + @JvmStatic + fun ofVaultArchived( + vaultArchived: BetaManagedAgentsVaultArchivedDeploymentPausedReasonError + ) = BetaManagedAgentsDeploymentPausedReasonError(vaultArchived = vaultArchived) + + /** + * An unrecognized error auto-paused the deployment. A fallback variant; matches a run whose + * `error.type` is `unknown_error`. + */ + @JvmStatic + fun ofUnknown(unknown: BetaManagedAgentsUnknownDeploymentPausedReasonError) = + BetaManagedAgentsDeploymentPausedReasonError(unknown = unknown) + + /** + * The deployment configures resources, but its environment is self-hosted and cannot mount + * them. + */ + @JvmStatic + fun ofSelfHostedResourcesUnsupported( + selfHostedResourcesUnsupported: + BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError + ) = + BetaManagedAgentsDeploymentPausedReasonError( + selfHostedResourcesUnsupported = selfHostedResourcesUnsupported + ) + + /** + * An MCP server host used by the deployment's agent is blocked by the environment's network + * policy. + */ + @JvmStatic + fun ofMcpEgressBlocked( + mcpEgressBlocked: BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError + ) = BetaManagedAgentsDeploymentPausedReasonError(mcpEgressBlocked = mcpEgressBlocked) + } + + /** + * An interface that defines how to map each variant of + * [BetaManagedAgentsDeploymentPausedReasonError] to a value of type [T]. + */ + interface Visitor { + + /** The deployment's environment was archived. */ + fun visitEnvironmentArchived( + environmentArchived: BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError + ): T + + /** The deployment's agent was archived. */ + fun visitAgentArchived( + agentArchived: BetaManagedAgentsAgentArchivedDeploymentPausedReasonError + ): T + + /** The deployment's environment no longer exists. */ + fun visitEnvironmentNotFound( + environmentNotFound: BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError + ): T + + /** A vault referenced by the deployment no longer exists. */ + fun visitVaultNotFound( + vaultNotFound: BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError + ): T + + /** A file resource referenced by the deployment no longer exists. */ + fun visitFileNotFound( + fileNotFound: BetaManagedAgentsFileNotFoundDeploymentPausedReasonError + ): T + + /** A referenced resource no longer exists and its kind was not reported. */ + fun visitSessionResourceNotFound( + sessionResourceNotFound: + BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError + ): T + + /** The deployment's workspace was archived. */ + fun visitWorkspaceArchived( + workspaceArchived: BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError + ): T + + /** The deployment's organization is disabled. */ + fun visitOrganizationDisabled( + organizationDisabled: BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError + ): T + + /** A memory store referenced by the deployment is archived. */ + fun visitMemoryStoreArchived( + memoryStoreArchived: BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError + ): T + + /** A skill referenced by the deployment's agent no longer exists. */ + fun visitSkillNotFound( + skillNotFound: BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError + ): T + + /** A vault referenced by the deployment is archived. */ + fun visitVaultArchived( + vaultArchived: BetaManagedAgentsVaultArchivedDeploymentPausedReasonError + ): T + + /** + * An unrecognized error auto-paused the deployment. A fallback variant; matches a run whose + * `error.type` is `unknown_error`. + */ + fun visitUnknown(unknown: BetaManagedAgentsUnknownDeploymentPausedReasonError): T + + /** + * The deployment configures resources, but its environment is self-hosted and cannot mount + * them. + */ + fun visitSelfHostedResourcesUnsupported( + selfHostedResourcesUnsupported: + BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError + ): T + + /** + * An MCP server host used by the deployment's agent is blocked by the environment's network + * policy. + */ + fun visitMcpEgressBlocked( + mcpEgressBlocked: BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError + ): T + + /** + * Maps an unknown variant of [BetaManagedAgentsDeploymentPausedReasonError] to a value of + * type [T]. + * + * An instance of [BetaManagedAgentsDeploymentPausedReasonError] can contain an unknown + * variant if it was deserialized from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws AnthropicInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw AnthropicInvalidDataException( + "Unknown BetaManagedAgentsDeploymentPausedReasonError: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + BetaManagedAgentsDeploymentPausedReasonError::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): BetaManagedAgentsDeploymentPausedReasonError { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "environment_archived_error" -> { + return tryDeserialize( + node, + jacksonTypeRef< + BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError + >(), + ) + ?.let { + BetaManagedAgentsDeploymentPausedReasonError( + environmentArchived = it, + _json = json, + ) + } ?: BetaManagedAgentsDeploymentPausedReasonError(_json = json) + } + "agent_archived_error" -> { + return tryDeserialize( + node, + jacksonTypeRef< + BetaManagedAgentsAgentArchivedDeploymentPausedReasonError + >(), + ) + ?.let { + BetaManagedAgentsDeploymentPausedReasonError( + agentArchived = it, + _json = json, + ) + } ?: BetaManagedAgentsDeploymentPausedReasonError(_json = json) + } + "environment_not_found_error" -> { + return tryDeserialize( + node, + jacksonTypeRef< + BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError + >(), + ) + ?.let { + BetaManagedAgentsDeploymentPausedReasonError( + environmentNotFound = it, + _json = json, + ) + } ?: BetaManagedAgentsDeploymentPausedReasonError(_json = json) + } + "vault_not_found_error" -> { + return tryDeserialize( + node, + jacksonTypeRef< + BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError + >(), + ) + ?.let { + BetaManagedAgentsDeploymentPausedReasonError( + vaultNotFound = it, + _json = json, + ) + } ?: BetaManagedAgentsDeploymentPausedReasonError(_json = json) + } + "file_not_found_error" -> { + return tryDeserialize( + node, + jacksonTypeRef< + BetaManagedAgentsFileNotFoundDeploymentPausedReasonError + >(), + ) + ?.let { + BetaManagedAgentsDeploymentPausedReasonError( + fileNotFound = it, + _json = json, + ) + } ?: BetaManagedAgentsDeploymentPausedReasonError(_json = json) + } + "session_resource_not_found_error" -> { + return tryDeserialize( + node, + jacksonTypeRef< + BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError + >(), + ) + ?.let { + BetaManagedAgentsDeploymentPausedReasonError( + sessionResourceNotFound = it, + _json = json, + ) + } ?: BetaManagedAgentsDeploymentPausedReasonError(_json = json) + } + "workspace_archived_error" -> { + return tryDeserialize( + node, + jacksonTypeRef< + BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError + >(), + ) + ?.let { + BetaManagedAgentsDeploymentPausedReasonError( + workspaceArchived = it, + _json = json, + ) + } ?: BetaManagedAgentsDeploymentPausedReasonError(_json = json) + } + "organization_disabled_error" -> { + return tryDeserialize( + node, + jacksonTypeRef< + BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError + >(), + ) + ?.let { + BetaManagedAgentsDeploymentPausedReasonError( + organizationDisabled = it, + _json = json, + ) + } ?: BetaManagedAgentsDeploymentPausedReasonError(_json = json) + } + "memory_store_archived_error" -> { + return tryDeserialize( + node, + jacksonTypeRef< + BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError + >(), + ) + ?.let { + BetaManagedAgentsDeploymentPausedReasonError( + memoryStoreArchived = it, + _json = json, + ) + } ?: BetaManagedAgentsDeploymentPausedReasonError(_json = json) + } + "skill_not_found_error" -> { + return tryDeserialize( + node, + jacksonTypeRef< + BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError + >(), + ) + ?.let { + BetaManagedAgentsDeploymentPausedReasonError( + skillNotFound = it, + _json = json, + ) + } ?: BetaManagedAgentsDeploymentPausedReasonError(_json = json) + } + "vault_archived_error" -> { + return tryDeserialize( + node, + jacksonTypeRef< + BetaManagedAgentsVaultArchivedDeploymentPausedReasonError + >(), + ) + ?.let { + BetaManagedAgentsDeploymentPausedReasonError( + vaultArchived = it, + _json = json, + ) + } ?: BetaManagedAgentsDeploymentPausedReasonError(_json = json) + } + "unknown_error" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + BetaManagedAgentsDeploymentPausedReasonError(unknown = it, _json = json) + } ?: BetaManagedAgentsDeploymentPausedReasonError(_json = json) + } + "self_hosted_resources_unsupported_error" -> { + return tryDeserialize( + node, + jacksonTypeRef< + BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError + >(), + ) + ?.let { + BetaManagedAgentsDeploymentPausedReasonError( + selfHostedResourcesUnsupported = it, + _json = json, + ) + } ?: BetaManagedAgentsDeploymentPausedReasonError(_json = json) + } + "mcp_egress_blocked_error" -> { + return tryDeserialize( + node, + jacksonTypeRef< + BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError + >(), + ) + ?.let { + BetaManagedAgentsDeploymentPausedReasonError( + mcpEgressBlocked = it, + _json = json, + ) + } ?: BetaManagedAgentsDeploymentPausedReasonError(_json = json) + } + } + + return BetaManagedAgentsDeploymentPausedReasonError(_json = json) + } + } + + internal class Serializer : + BaseSerializer( + BetaManagedAgentsDeploymentPausedReasonError::class + ) { + + override fun serialize( + value: BetaManagedAgentsDeploymentPausedReasonError, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.environmentArchived != null -> + generator.writeObject(value.environmentArchived) + value.agentArchived != null -> generator.writeObject(value.agentArchived) + value.environmentNotFound != null -> + generator.writeObject(value.environmentNotFound) + value.vaultNotFound != null -> generator.writeObject(value.vaultNotFound) + value.fileNotFound != null -> generator.writeObject(value.fileNotFound) + value.sessionResourceNotFound != null -> + generator.writeObject(value.sessionResourceNotFound) + value.workspaceArchived != null -> generator.writeObject(value.workspaceArchived) + value.organizationDisabled != null -> + generator.writeObject(value.organizationDisabled) + value.memoryStoreArchived != null -> + generator.writeObject(value.memoryStoreArchived) + value.skillNotFound != null -> generator.writeObject(value.skillNotFound) + value.vaultArchived != null -> generator.writeObject(value.vaultArchived) + value.unknown != null -> generator.writeObject(value.unknown) + value.selfHostedResourcesUnsupported != null -> + generator.writeObject(value.selfHostedResourcesUnsupported) + value.mcpEgressBlocked != null -> generator.writeObject(value.mcpEgressBlocked) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid BetaManagedAgentsDeploymentPausedReasonError" + ) + } + } + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentStatus.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentStatus.kt new file mode 100644 index 000000000..9af081105 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentStatus.kt @@ -0,0 +1,149 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.Enum +import com.anthropic.core.JsonField +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator + +/** Lifecycle status of a deployment. */ +class BetaManagedAgentsDeploymentStatus +@JsonCreator +private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACTIVE = of("active") + + @JvmField val PAUSED = of("paused") + + @JvmStatic fun of(value: String) = BetaManagedAgentsDeploymentStatus(JsonField.of(value)) + } + + /** An enum containing [BetaManagedAgentsDeploymentStatus]'s known values. */ + enum class Known { + ACTIVE, + PAUSED, + } + + /** + * An enum containing [BetaManagedAgentsDeploymentStatus]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [BetaManagedAgentsDeploymentStatus] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTIVE, + PAUSED, + /** + * An enum member indicating that [BetaManagedAgentsDeploymentStatus] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + PAUSED -> Value.PAUSED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + PAUSED -> Known.PAUSED + else -> + throw AnthropicInvalidDataException( + "Unknown BetaManagedAgentsDeploymentStatus: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { AnthropicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsDeploymentStatus = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsDeploymentStatus && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentSystemMessageEvent.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentSystemMessageEvent.kt new file mode 100644 index 000000000..e27cfdd4b --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentSystemMessageEvent.kt @@ -0,0 +1,400 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkKnown +import com.anthropic.core.checkRequired +import com.anthropic.core.toImmutable +import com.anthropic.errors.AnthropicInvalidDataException +import com.anthropic.models.beta.sessions.BetaManagedAgentsSystemContentBlock +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** + * Privileged context for the accompanying turn and all subsequent turns, appended to the session's + * system context as a `role: "system"` turn rather than replacing the top-level system prompt. + */ +class BetaManagedAgentsDeploymentSystemMessageEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val content: JsonField>, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("content") + @ExcludeMissing + content: JsonField> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(content, type, mutableMapOf()) + + /** + * System content blocks to append. Text-only. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun content(): List = content.getRequired("content") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") + @ExcludeMissing + fun _content(): JsonField> = content + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsDeploymentSystemMessageEvent]. + * + * The following fields are required: + * ```java + * .content() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsDeploymentSystemMessageEvent]. */ + class Builder internal constructor() { + + private var content: JsonField>? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsDeploymentSystemMessageEvent: + BetaManagedAgentsDeploymentSystemMessageEvent + ) = apply { + content = + betaManagedAgentsDeploymentSystemMessageEvent.content + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + type = betaManagedAgentsDeploymentSystemMessageEvent.type + additionalProperties = + betaManagedAgentsDeploymentSystemMessageEvent.additionalProperties.toMutableMap() + } + + /** System content blocks to append. Text-only. */ + fun content(content: List) = + content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun content(content: JsonField>) = apply { + this.content = content.map { it.toMutableList() } + } + + /** + * Adds a single [BetaManagedAgentsSystemContentBlock] to [Builder.content]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addContent(content: BetaManagedAgentsSystemContentBlock) = apply { + this.content = + (this.content ?: JsonField.of(mutableListOf())).also { + checkKnown("content", it).add(content) + } + } + + /** + * Alias for calling [addContent] with the following: + * ```java + * BetaManagedAgentsSystemContentBlock.builder() + * .type(BetaManagedAgentsSystemContentBlock.Type.TEXT) + * .text(text) + * .build() + * ``` + */ + fun addTextContent(text: String) = + addContent( + BetaManagedAgentsSystemContentBlock.builder() + .type(BetaManagedAgentsSystemContentBlock.Type.TEXT) + .text(text) + .build() + ) + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsDeploymentSystemMessageEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsDeploymentSystemMessageEvent = + BetaManagedAgentsDeploymentSystemMessageEvent( + checkRequired("content", content).map { it.toImmutable() }, + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsDeploymentSystemMessageEvent = apply { + if (validated) { + return@apply + } + + content().forEach { it.validate() } + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (content.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SYSTEM_MESSAGE = of("system.message") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + SYSTEM_MESSAGE + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SYSTEM_MESSAGE, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SYSTEM_MESSAGE -> Value.SYSTEM_MESSAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SYSTEM_MESSAGE -> Known.SYSTEM_MESSAGE + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsDeploymentSystemMessageEvent && + content == other.content && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(content, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsDeploymentSystemMessageEvent{content=$content, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentUserDefineOutcomeEvent.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentUserDefineOutcomeEvent.kt new file mode 100644 index 000000000..ea9a27a19 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentUserDefineOutcomeEvent.kt @@ -0,0 +1,709 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.BaseDeserializer +import com.anthropic.core.BaseSerializer +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.core.getOrThrow +import com.anthropic.errors.AnthropicInvalidDataException +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsFileRubric +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsTextRubric +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** An outcome the agent should work toward. The agent begins work on receipt. */ +class BetaManagedAgentsDeploymentUserDefineOutcomeEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val description: JsonField, + private val rubric: JsonField, + private val type: JsonField, + private val maxIterations: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("rubric") @ExcludeMissing rubric: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("max_iterations") + @ExcludeMissing + maxIterations: JsonField = JsonMissing.of(), + ) : this(description, rubric, type, maxIterations, mutableMapOf()) + + /** + * What the agent should produce. This is the task specification. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun description(): String = description.getRequired("description") + + /** + * Rubric for grading the quality of an outcome. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun rubric(): Rubric = rubric.getRequired("rubric") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Eval→revision cycles before giving up. Default 3, max 20. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maxIterations(): Optional = maxIterations.getOptional("max_iterations") + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [rubric]. + * + * Unlike [rubric], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rubric") @ExcludeMissing fun _rubric(): JsonField = rubric + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [maxIterations]. + * + * Unlike [maxIterations], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("max_iterations") + @ExcludeMissing + fun _maxIterations(): JsonField = maxIterations + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsDeploymentUserDefineOutcomeEvent]. + * + * The following fields are required: + * ```java + * .description() + * .rubric() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsDeploymentUserDefineOutcomeEvent]. */ + class Builder internal constructor() { + + private var description: JsonField? = null + private var rubric: JsonField? = null + private var type: JsonField? = null + private var maxIterations: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsDeploymentUserDefineOutcomeEvent: + BetaManagedAgentsDeploymentUserDefineOutcomeEvent + ) = apply { + description = betaManagedAgentsDeploymentUserDefineOutcomeEvent.description + rubric = betaManagedAgentsDeploymentUserDefineOutcomeEvent.rubric + type = betaManagedAgentsDeploymentUserDefineOutcomeEvent.type + maxIterations = betaManagedAgentsDeploymentUserDefineOutcomeEvent.maxIterations + additionalProperties = + betaManagedAgentsDeploymentUserDefineOutcomeEvent.additionalProperties + .toMutableMap() + } + + /** What the agent should produce. This is the task specification. */ + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { this.description = description } + + /** Rubric for grading the quality of an outcome. */ + fun rubric(rubric: Rubric) = rubric(JsonField.of(rubric)) + + /** + * Sets [Builder.rubric] to an arbitrary JSON value. + * + * You should usually call [Builder.rubric] with a well-typed [Rubric] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun rubric(rubric: JsonField) = apply { this.rubric = rubric } + + /** Alias for calling [rubric] with `Rubric.ofFile(file)`. */ + fun rubric(file: BetaManagedAgentsFileRubric) = rubric(Rubric.ofFile(file)) + + /** + * Alias for calling [rubric] with the following: + * ```java + * BetaManagedAgentsFileRubric.builder() + * .type(BetaManagedAgentsFileRubric.Type.FILE) + * .fileId(fileId) + * .build() + * ``` + */ + fun fileRubric(fileId: String) = + rubric( + BetaManagedAgentsFileRubric.builder() + .type(BetaManagedAgentsFileRubric.Type.FILE) + .fileId(fileId) + .build() + ) + + /** Alias for calling [rubric] with `Rubric.ofText(text)`. */ + fun rubric(text: BetaManagedAgentsTextRubric) = rubric(Rubric.ofText(text)) + + /** + * Alias for calling [rubric] with the following: + * ```java + * BetaManagedAgentsTextRubric.builder() + * .type(BetaManagedAgentsTextRubric.Type.TEXT) + * .content(content) + * .build() + * ``` + */ + fun textRubric(content: String) = + rubric( + BetaManagedAgentsTextRubric.builder() + .type(BetaManagedAgentsTextRubric.Type.TEXT) + .content(content) + .build() + ) + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** Eval→revision cycles before giving up. Default 3, max 20. */ + fun maxIterations(maxIterations: Int?) = maxIterations(JsonField.ofNullable(maxIterations)) + + /** + * Alias for [Builder.maxIterations]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxIterations(maxIterations: Int) = maxIterations(maxIterations as Int?) + + /** Alias for calling [Builder.maxIterations] with `maxIterations.orElse(null)`. */ + fun maxIterations(maxIterations: Optional) = maxIterations(maxIterations.getOrNull()) + + /** + * Sets [Builder.maxIterations] to an arbitrary JSON value. + * + * You should usually call [Builder.maxIterations] with a well-typed [Int] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun maxIterations(maxIterations: JsonField) = apply { + this.maxIterations = maxIterations + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsDeploymentUserDefineOutcomeEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .description() + * .rubric() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsDeploymentUserDefineOutcomeEvent = + BetaManagedAgentsDeploymentUserDefineOutcomeEvent( + checkRequired("description", description), + checkRequired("rubric", rubric), + checkRequired("type", type), + maxIterations, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsDeploymentUserDefineOutcomeEvent = apply { + if (validated) { + return@apply + } + + description() + rubric().validate() + type().validate() + maxIterations() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (description.asKnown().isPresent) 1 else 0) + + (rubric.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (maxIterations.asKnown().isPresent) 1 else 0) + + /** Rubric for grading the quality of an outcome. */ + @JsonDeserialize(using = Rubric.Deserializer::class) + @JsonSerialize(using = Rubric.Serializer::class) + class Rubric + private constructor( + private val file: BetaManagedAgentsFileRubric? = null, + private val text: BetaManagedAgentsTextRubric? = null, + private val _json: JsonValue? = null, + ) { + + /** Rubric referenced by a file uploaded via the Files API. */ + fun file(): Optional = Optional.ofNullable(file) + + /** Rubric content provided inline as text. */ + fun text(): Optional = Optional.ofNullable(text) + + fun isFile(): Boolean = file != null + + fun isText(): Boolean = text != null + + /** Rubric referenced by a file uploaded via the Files API. */ + fun asFile(): BetaManagedAgentsFileRubric = file.getOrThrow("file") + + /** Rubric content provided inline as text. */ + fun asText(): BetaManagedAgentsTextRubric = text.getOrThrow("text") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.anthropic.core.JsonValue; + * import java.util.Optional; + * + * Optional result = rubric.accept(new Rubric.Visitor>() { + * @Override + * public Optional visitFile(BetaManagedAgentsFileRubric file) { + * return Optional.of(file.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws AnthropicInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + file != null -> visitor.visitFile(file) + text != null -> visitor.visitText(text) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Rubric = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitFile(file: BetaManagedAgentsFileRubric) { + file.validate() + } + + override fun visitText(text: BetaManagedAgentsTextRubric) { + text.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitFile(file: BetaManagedAgentsFileRubric) = file.validity() + + override fun visitText(text: BetaManagedAgentsTextRubric) = text.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Rubric && file == other.file && text == other.text + } + + override fun hashCode(): Int = Objects.hash(file, text) + + override fun toString(): String = + when { + file != null -> "Rubric{file=$file}" + text != null -> "Rubric{text=$text}" + _json != null -> "Rubric{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Rubric") + } + + companion object { + + /** Rubric referenced by a file uploaded via the Files API. */ + @JvmStatic fun ofFile(file: BetaManagedAgentsFileRubric) = Rubric(file = file) + + /** Rubric content provided inline as text. */ + @JvmStatic fun ofText(text: BetaManagedAgentsTextRubric) = Rubric(text = text) + } + + /** An interface that defines how to map each variant of [Rubric] to a value of type [T]. */ + interface Visitor { + + /** Rubric referenced by a file uploaded via the Files API. */ + fun visitFile(file: BetaManagedAgentsFileRubric): T + + /** Rubric content provided inline as text. */ + fun visitText(text: BetaManagedAgentsTextRubric): T + + /** + * Maps an unknown variant of [Rubric] to a value of type [T]. + * + * An instance of [Rubric] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws AnthropicInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw AnthropicInvalidDataException("Unknown Rubric: $json") + } + } + + internal class Deserializer : BaseDeserializer(Rubric::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Rubric { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "file" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Rubric(file = it, _json = json) } ?: Rubric(_json = json) + } + "text" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Rubric(text = it, _json = json) } ?: Rubric(_json = json) + } + } + + return Rubric(_json = json) + } + } + + internal class Serializer : BaseSerializer(Rubric::class) { + + override fun serialize( + value: Rubric, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.file != null -> generator.writeObject(value.file) + value.text != null -> generator.writeObject(value.text) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Rubric") + } + } + } + } + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USER_DEFINE_OUTCOME = of("user.define_outcome") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + USER_DEFINE_OUTCOME + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USER_DEFINE_OUTCOME, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USER_DEFINE_OUTCOME -> Value.USER_DEFINE_OUTCOME + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USER_DEFINE_OUTCOME -> Known.USER_DEFINE_OUTCOME + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsDeploymentUserDefineOutcomeEvent && + description == other.description && + rubric == other.rubric && + type == other.type && + maxIterations == other.maxIterations && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(description, rubric, type, maxIterations, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsDeploymentUserDefineOutcomeEvent{description=$description, rubric=$rubric, type=$type, maxIterations=$maxIterations, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentUserMessageEvent.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentUserMessageEvent.kt new file mode 100644 index 000000000..f8712036b --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentUserMessageEvent.kt @@ -0,0 +1,832 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.BaseDeserializer +import com.anthropic.core.BaseSerializer +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkKnown +import com.anthropic.core.checkRequired +import com.anthropic.core.getOrThrow +import com.anthropic.core.toImmutable +import com.anthropic.errors.AnthropicInvalidDataException +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsBase64DocumentSource +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsBase64ImageSource +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsDocumentBlock +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsFileDocumentSource +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsFileImageSource +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsImageBlock +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsPlainTextDocumentSource +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsTextBlock +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsUrlDocumentSource +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsUrlImageSource +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** A user message sent to the session. */ +class BetaManagedAgentsDeploymentUserMessageEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val content: JsonField>, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("content") + @ExcludeMissing + content: JsonField> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(content, type, mutableMapOf()) + + /** + * Array of content blocks for the user message. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun content(): List = content.getRequired("content") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField> = content + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsDeploymentUserMessageEvent]. + * + * The following fields are required: + * ```java + * .content() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsDeploymentUserMessageEvent]. */ + class Builder internal constructor() { + + private var content: JsonField>? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsDeploymentUserMessageEvent: BetaManagedAgentsDeploymentUserMessageEvent + ) = apply { + content = + betaManagedAgentsDeploymentUserMessageEvent.content + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + type = betaManagedAgentsDeploymentUserMessageEvent.type + additionalProperties = + betaManagedAgentsDeploymentUserMessageEvent.additionalProperties.toMutableMap() + } + + /** Array of content blocks for the user message. */ + fun content(content: List) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun content(content: JsonField>) = apply { + this.content = content.map { it.toMutableList() } + } + + /** + * Adds a single [Content] to [Builder.content]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addContent(content: Content) = apply { + this.content = + (this.content ?: JsonField.of(mutableListOf())).also { + checkKnown("content", it).add(content) + } + } + + /** Alias for calling [addContent] with `Content.ofText(text)`. */ + fun addContent(text: BetaManagedAgentsTextBlock) = addContent(Content.ofText(text)) + + /** + * Alias for calling [addContent] with the following: + * ```java + * BetaManagedAgentsTextBlock.builder() + * .type(BetaManagedAgentsTextBlock.Type.TEXT) + * .text(text) + * .build() + * ``` + */ + fun addTextContent(text: String) = + addContent( + BetaManagedAgentsTextBlock.builder() + .type(BetaManagedAgentsTextBlock.Type.TEXT) + .text(text) + .build() + ) + + /** Alias for calling [addContent] with `Content.ofImage(image)`. */ + fun addContent(image: BetaManagedAgentsImageBlock) = addContent(Content.ofImage(image)) + + /** + * Alias for calling [addContent] with the following: + * ```java + * BetaManagedAgentsImageBlock.builder() + * .type(BetaManagedAgentsImageBlock.Type.IMAGE) + * .source(source) + * .build() + * ``` + */ + fun addImageContent(source: BetaManagedAgentsImageBlock.Source) = + addContent( + BetaManagedAgentsImageBlock.builder() + .type(BetaManagedAgentsImageBlock.Type.IMAGE) + .source(source) + .build() + ) + + /** + * Alias for calling [addImageContent] with + * `BetaManagedAgentsImageBlock.Source.ofBase64(base64)`. + */ + fun addImageContent(base64: BetaManagedAgentsBase64ImageSource) = + addImageContent(BetaManagedAgentsImageBlock.Source.ofBase64(base64)) + + /** + * Alias for calling [addImageContent] with `BetaManagedAgentsImageBlock.Source.ofUrl(url)`. + */ + fun addImageContent(url: BetaManagedAgentsUrlImageSource) = + addImageContent(BetaManagedAgentsImageBlock.Source.ofUrl(url)) + + /** + * Alias for calling [addImageContent] with the following: + * ```java + * BetaManagedAgentsUrlImageSource.builder() + * .type(BetaManagedAgentsUrlImageSource.Type.URL) + * .url(url) + * .build() + * ``` + */ + fun addUrlImageContent(url: String) = + addImageContent( + BetaManagedAgentsUrlImageSource.builder() + .type(BetaManagedAgentsUrlImageSource.Type.URL) + .url(url) + .build() + ) + + /** + * Alias for calling [addImageContent] with + * `BetaManagedAgentsImageBlock.Source.ofFile(file)`. + */ + fun addImageContent(file: BetaManagedAgentsFileImageSource) = + addImageContent(BetaManagedAgentsImageBlock.Source.ofFile(file)) + + /** + * Alias for calling [addImageContent] with the following: + * ```java + * BetaManagedAgentsFileImageSource.builder() + * .type(BetaManagedAgentsFileImageSource.Type.FILE) + * .fileId(fileId) + * .build() + * ``` + */ + fun addFileImageContent(fileId: String) = + addImageContent( + BetaManagedAgentsFileImageSource.builder() + .type(BetaManagedAgentsFileImageSource.Type.FILE) + .fileId(fileId) + .build() + ) + + /** Alias for calling [addContent] with `Content.ofDocument(document)`. */ + fun addContent(document: BetaManagedAgentsDocumentBlock) = + addContent(Content.ofDocument(document)) + + /** + * Alias for calling [addContent] with the following: + * ```java + * BetaManagedAgentsDocumentBlock.builder() + * .type(BetaManagedAgentsDocumentBlock.Type.DOCUMENT) + * .source(source) + * .build() + * ``` + */ + fun addDocumentContent(source: BetaManagedAgentsDocumentBlock.Source) = + addContent( + BetaManagedAgentsDocumentBlock.builder() + .type(BetaManagedAgentsDocumentBlock.Type.DOCUMENT) + .source(source) + .build() + ) + + /** + * Alias for calling [addDocumentContent] with + * `BetaManagedAgentsDocumentBlock.Source.ofBase64(base64)`. + */ + fun addDocumentContent(base64: BetaManagedAgentsBase64DocumentSource) = + addDocumentContent(BetaManagedAgentsDocumentBlock.Source.ofBase64(base64)) + + /** + * Alias for calling [addDocumentContent] with + * `BetaManagedAgentsDocumentBlock.Source.ofText(text)`. + */ + fun addDocumentContent(text: BetaManagedAgentsPlainTextDocumentSource) = + addDocumentContent(BetaManagedAgentsDocumentBlock.Source.ofText(text)) + + /** + * Alias for calling [addDocumentContent] with + * `BetaManagedAgentsDocumentBlock.Source.ofUrl(url)`. + */ + fun addDocumentContent(url: BetaManagedAgentsUrlDocumentSource) = + addDocumentContent(BetaManagedAgentsDocumentBlock.Source.ofUrl(url)) + + /** + * Alias for calling [addDocumentContent] with the following: + * ```java + * BetaManagedAgentsUrlDocumentSource.builder() + * .type(BetaManagedAgentsUrlDocumentSource.Type.URL) + * .url(url) + * .build() + * ``` + */ + fun addUrlDocumentContent(url: String) = + addDocumentContent( + BetaManagedAgentsUrlDocumentSource.builder() + .type(BetaManagedAgentsUrlDocumentSource.Type.URL) + .url(url) + .build() + ) + + /** + * Alias for calling [addDocumentContent] with + * `BetaManagedAgentsDocumentBlock.Source.ofFile(file)`. + */ + fun addDocumentContent(file: BetaManagedAgentsFileDocumentSource) = + addDocumentContent(BetaManagedAgentsDocumentBlock.Source.ofFile(file)) + + /** + * Alias for calling [addDocumentContent] with the following: + * ```java + * BetaManagedAgentsFileDocumentSource.builder() + * .type(BetaManagedAgentsFileDocumentSource.Type.FILE) + * .fileId(fileId) + * .build() + * ``` + */ + fun addFileDocumentContent(fileId: String) = + addDocumentContent( + BetaManagedAgentsFileDocumentSource.builder() + .type(BetaManagedAgentsFileDocumentSource.Type.FILE) + .fileId(fileId) + .build() + ) + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsDeploymentUserMessageEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsDeploymentUserMessageEvent = + BetaManagedAgentsDeploymentUserMessageEvent( + checkRequired("content", content).map { it.toImmutable() }, + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsDeploymentUserMessageEvent = apply { + if (validated) { + return@apply + } + + content().forEach { it.validate() } + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (content.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + /** Content block in a user message. Can be `text`, `image`, or `document`. */ + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val text: BetaManagedAgentsTextBlock? = null, + private val image: BetaManagedAgentsImageBlock? = null, + private val document: BetaManagedAgentsDocumentBlock? = null, + private val _json: JsonValue? = null, + ) { + + /** Regular text content. */ + fun text(): Optional = Optional.ofNullable(text) + + /** Image content specified directly as base64 data or as a reference via a URL. */ + fun image(): Optional = Optional.ofNullable(image) + + /** + * Document content, either specified directly as base64 data, as text, or as a reference + * via a URL. + */ + fun document(): Optional = Optional.ofNullable(document) + + fun isText(): Boolean = text != null + + fun isImage(): Boolean = image != null + + fun isDocument(): Boolean = document != null + + /** Regular text content. */ + fun asText(): BetaManagedAgentsTextBlock = text.getOrThrow("text") + + /** Image content specified directly as base64 data or as a reference via a URL. */ + fun asImage(): BetaManagedAgentsImageBlock = image.getOrThrow("image") + + /** + * Document content, either specified directly as base64 data, as text, or as a reference + * via a URL. + */ + fun asDocument(): BetaManagedAgentsDocumentBlock = document.getOrThrow("document") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.anthropic.core.JsonValue; + * import java.util.Optional; + * + * Optional result = content.accept(new Content.Visitor>() { + * @Override + * public Optional visitText(BetaManagedAgentsTextBlock text) { + * return Optional.of(text.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws AnthropicInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + text != null -> visitor.visitText(text) + image != null -> visitor.visitImage(image) + document != null -> visitor.visitDocument(document) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Content = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitText(text: BetaManagedAgentsTextBlock) { + text.validate() + } + + override fun visitImage(image: BetaManagedAgentsImageBlock) { + image.validate() + } + + override fun visitDocument(document: BetaManagedAgentsDocumentBlock) { + document.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitText(text: BetaManagedAgentsTextBlock) = text.validity() + + override fun visitImage(image: BetaManagedAgentsImageBlock) = image.validity() + + override fun visitDocument(document: BetaManagedAgentsDocumentBlock) = + document.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + text == other.text && + image == other.image && + document == other.document + } + + override fun hashCode(): Int = Objects.hash(text, image, document) + + override fun toString(): String = + when { + text != null -> "Content{text=$text}" + image != null -> "Content{image=$image}" + document != null -> "Content{document=$document}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + + companion object { + + /** Regular text content. */ + @JvmStatic fun ofText(text: BetaManagedAgentsTextBlock) = Content(text = text) + + /** Image content specified directly as base64 data or as a reference via a URL. */ + @JvmStatic fun ofImage(image: BetaManagedAgentsImageBlock) = Content(image = image) + + /** + * Document content, either specified directly as base64 data, as text, or as a + * reference via a URL. + */ + @JvmStatic + fun ofDocument(document: BetaManagedAgentsDocumentBlock) = Content(document = document) + } + + /** + * An interface that defines how to map each variant of [Content] to a value of type [T]. + */ + interface Visitor { + + /** Regular text content. */ + fun visitText(text: BetaManagedAgentsTextBlock): T + + /** Image content specified directly as base64 data or as a reference via a URL. */ + fun visitImage(image: BetaManagedAgentsImageBlock): T + + /** + * Document content, either specified directly as base64 data, as text, or as a + * reference via a URL. + */ + fun visitDocument(document: BetaManagedAgentsDocumentBlock): T + + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws AnthropicInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw AnthropicInvalidDataException("Unknown Content: $json") + } + } + + internal class Deserializer : BaseDeserializer(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "text" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Content(text = it, _json = json) } ?: Content(_json = json) + } + "image" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Content(image = it, _json = json) } ?: Content(_json = json) + } + "document" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Content(document = it, _json = json) } ?: Content(_json = json) + } + } + + return Content(_json = json) + } + } + + internal class Serializer : BaseSerializer(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.text != null -> generator.writeObject(value.text) + value.image != null -> generator.writeObject(value.image) + value.document != null -> generator.writeObject(value.document) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + } + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USER_MESSAGE = of("user.message") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + USER_MESSAGE + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USER_MESSAGE, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USER_MESSAGE -> Value.USER_MESSAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USER_MESSAGE -> Known.USER_MESSAGE + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsDeploymentUserMessageEvent && + content == other.content && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(content, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsDeploymentUserMessageEvent{content=$content, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError.kt new file mode 100644 index 000000000..5c6622cd7 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError.kt @@ -0,0 +1,318 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** The deployment's environment was archived. */ +class BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError: + BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError + ) = apply { + type = betaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError.type + additionalProperties = + betaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError.additionalProperties + .toMutableMap() + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of + * [BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError = + BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError = apply { + if (validated) { + return@apply + } + + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ENVIRONMENT_ARCHIVED_ERROR = of("environment_archived_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ENVIRONMENT_ARCHIVED_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ENVIRONMENT_ARCHIVED_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ENVIRONMENT_ARCHIVED_ERROR -> Value.ENVIRONMENT_ARCHIVED_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ENVIRONMENT_ARCHIVED_ERROR -> Known.ENVIRONMENT_ARCHIVED_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError{type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError.kt new file mode 100644 index 000000000..fa0cb46cf --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError.kt @@ -0,0 +1,318 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** The deployment's environment no longer exists. */ +class BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError: + BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError + ) = apply { + type = betaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError.type + additionalProperties = + betaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError.additionalProperties + .toMutableMap() + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of + * [BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError = + BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError = apply { + if (validated) { + return@apply + } + + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ENVIRONMENT_NOT_FOUND_ERROR = of("environment_not_found_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ENVIRONMENT_NOT_FOUND_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ENVIRONMENT_NOT_FOUND_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ENVIRONMENT_NOT_FOUND_ERROR -> Value.ENVIRONMENT_NOT_FOUND_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ENVIRONMENT_NOT_FOUND_ERROR -> Known.ENVIRONMENT_NOT_FOUND_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError{type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsErrorDeploymentPausedReason.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsErrorDeploymentPausedReason.kt new file mode 100644 index 000000000..becc74273 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsErrorDeploymentPausedReason.kt @@ -0,0 +1,501 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** A scheduled fire recorded a failed run whose error auto-pauses the deployment. */ +class BetaManagedAgentsErrorDeploymentPausedReason +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val error: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("error") + @ExcludeMissing + error: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(error, type, mutableMapOf()) + + /** + * The error that triggered an auto-pause. Matches the failed run's `error.type`. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun error(): BetaManagedAgentsDeploymentPausedReasonError = error.getRequired("error") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") + @ExcludeMissing + fun _error(): JsonField = error + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsErrorDeploymentPausedReason]. + * + * The following fields are required: + * ```java + * .error() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsErrorDeploymentPausedReason]. */ + class Builder internal constructor() { + + private var error: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsErrorDeploymentPausedReason: + BetaManagedAgentsErrorDeploymentPausedReason + ) = apply { + error = betaManagedAgentsErrorDeploymentPausedReason.error + type = betaManagedAgentsErrorDeploymentPausedReason.type + additionalProperties = + betaManagedAgentsErrorDeploymentPausedReason.additionalProperties.toMutableMap() + } + + /** The error that triggered an auto-pause. Matches the failed run's `error.type`. */ + fun error(error: BetaManagedAgentsDeploymentPausedReasonError) = error(JsonField.of(error)) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed + * [BetaManagedAgentsDeploymentPausedReasonError] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun error(error: JsonField) = apply { + this.error = error + } + + /** + * Alias for calling [error] with + * `BetaManagedAgentsDeploymentPausedReasonError.ofEnvironmentArchived(environmentArchived)`. + */ + fun error( + environmentArchived: BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError + ) = + error( + BetaManagedAgentsDeploymentPausedReasonError.ofEnvironmentArchived( + environmentArchived + ) + ) + + /** + * Alias for calling [error] with + * `BetaManagedAgentsDeploymentPausedReasonError.ofAgentArchived(agentArchived)`. + */ + fun error(agentArchived: BetaManagedAgentsAgentArchivedDeploymentPausedReasonError) = + error(BetaManagedAgentsDeploymentPausedReasonError.ofAgentArchived(agentArchived)) + + /** + * Alias for calling [error] with + * `BetaManagedAgentsDeploymentPausedReasonError.ofEnvironmentNotFound(environmentNotFound)`. + */ + fun error( + environmentNotFound: BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError + ) = + error( + BetaManagedAgentsDeploymentPausedReasonError.ofEnvironmentNotFound( + environmentNotFound + ) + ) + + /** + * Alias for calling [error] with + * `BetaManagedAgentsDeploymentPausedReasonError.ofVaultNotFound(vaultNotFound)`. + */ + fun error(vaultNotFound: BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError) = + error(BetaManagedAgentsDeploymentPausedReasonError.ofVaultNotFound(vaultNotFound)) + + /** + * Alias for calling [error] with + * `BetaManagedAgentsDeploymentPausedReasonError.ofFileNotFound(fileNotFound)`. + */ + fun error(fileNotFound: BetaManagedAgentsFileNotFoundDeploymentPausedReasonError) = + error(BetaManagedAgentsDeploymentPausedReasonError.ofFileNotFound(fileNotFound)) + + /** + * Alias for calling [error] with + * `BetaManagedAgentsDeploymentPausedReasonError.ofSessionResourceNotFound(sessionResourceNotFound)`. + */ + fun error( + sessionResourceNotFound: + BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError + ) = + error( + BetaManagedAgentsDeploymentPausedReasonError.ofSessionResourceNotFound( + sessionResourceNotFound + ) + ) + + /** + * Alias for calling [error] with + * `BetaManagedAgentsDeploymentPausedReasonError.ofWorkspaceArchived(workspaceArchived)`. + */ + fun error( + workspaceArchived: BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError + ) = + error( + BetaManagedAgentsDeploymentPausedReasonError.ofWorkspaceArchived(workspaceArchived) + ) + + /** + * Alias for calling [error] with + * `BetaManagedAgentsDeploymentPausedReasonError.ofOrganizationDisabled(organizationDisabled)`. + */ + fun error( + organizationDisabled: BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError + ) = + error( + BetaManagedAgentsDeploymentPausedReasonError.ofOrganizationDisabled( + organizationDisabled + ) + ) + + /** + * Alias for calling [error] with + * `BetaManagedAgentsDeploymentPausedReasonError.ofMemoryStoreArchived(memoryStoreArchived)`. + */ + fun error( + memoryStoreArchived: BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError + ) = + error( + BetaManagedAgentsDeploymentPausedReasonError.ofMemoryStoreArchived( + memoryStoreArchived + ) + ) + + /** + * Alias for calling [error] with + * `BetaManagedAgentsDeploymentPausedReasonError.ofSkillNotFound(skillNotFound)`. + */ + fun error(skillNotFound: BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError) = + error(BetaManagedAgentsDeploymentPausedReasonError.ofSkillNotFound(skillNotFound)) + + /** + * Alias for calling [error] with + * `BetaManagedAgentsDeploymentPausedReasonError.ofVaultArchived(vaultArchived)`. + */ + fun error(vaultArchived: BetaManagedAgentsVaultArchivedDeploymentPausedReasonError) = + error(BetaManagedAgentsDeploymentPausedReasonError.ofVaultArchived(vaultArchived)) + + /** + * Alias for calling [error] with + * `BetaManagedAgentsDeploymentPausedReasonError.ofUnknown(unknown)`. + */ + fun error(unknown: BetaManagedAgentsUnknownDeploymentPausedReasonError) = + error(BetaManagedAgentsDeploymentPausedReasonError.ofUnknown(unknown)) + + /** + * Alias for calling [error] with + * `BetaManagedAgentsDeploymentPausedReasonError.ofSelfHostedResourcesUnsupported(selfHostedResourcesUnsupported)`. + */ + fun error( + selfHostedResourcesUnsupported: + BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError + ) = + error( + BetaManagedAgentsDeploymentPausedReasonError.ofSelfHostedResourcesUnsupported( + selfHostedResourcesUnsupported + ) + ) + + /** + * Alias for calling [error] with + * `BetaManagedAgentsDeploymentPausedReasonError.ofMcpEgressBlocked(mcpEgressBlocked)`. + */ + fun error(mcpEgressBlocked: BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError) = + error(BetaManagedAgentsDeploymentPausedReasonError.ofMcpEgressBlocked(mcpEgressBlocked)) + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsErrorDeploymentPausedReason]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .error() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsErrorDeploymentPausedReason = + BetaManagedAgentsErrorDeploymentPausedReason( + checkRequired("error", error), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsErrorDeploymentPausedReason = apply { + if (validated) { + return@apply + } + + error().validate() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (error.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ERROR = of("error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ERROR -> Value.ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ERROR -> Known.ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsErrorDeploymentPausedReason && + error == other.error && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(error, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsErrorDeploymentPausedReason{error=$error, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsFileNotFoundDeploymentPausedReasonError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsFileNotFoundDeploymentPausedReasonError.kt new file mode 100644 index 000000000..26d7ce786 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsFileNotFoundDeploymentPausedReasonError.kt @@ -0,0 +1,318 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** A file resource referenced by the deployment no longer exists. */ +class BetaManagedAgentsFileNotFoundDeploymentPausedReasonError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsFileNotFoundDeploymentPausedReasonError]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsFileNotFoundDeploymentPausedReasonError]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsFileNotFoundDeploymentPausedReasonError: + BetaManagedAgentsFileNotFoundDeploymentPausedReasonError + ) = apply { + type = betaManagedAgentsFileNotFoundDeploymentPausedReasonError.type + additionalProperties = + betaManagedAgentsFileNotFoundDeploymentPausedReasonError.additionalProperties + .toMutableMap() + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of + * [BetaManagedAgentsFileNotFoundDeploymentPausedReasonError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsFileNotFoundDeploymentPausedReasonError = + BetaManagedAgentsFileNotFoundDeploymentPausedReasonError( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsFileNotFoundDeploymentPausedReasonError = apply { + if (validated) { + return@apply + } + + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val FILE_NOT_FOUND_ERROR = of("file_not_found_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + FILE_NOT_FOUND_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + FILE_NOT_FOUND_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + FILE_NOT_FOUND_ERROR -> Value.FILE_NOT_FOUND_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + FILE_NOT_FOUND_ERROR -> Known.FILE_NOT_FOUND_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsFileNotFoundDeploymentPausedReasonError && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsFileNotFoundDeploymentPausedReasonError{type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsFileResourceConfig.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsFileResourceConfig.kt new file mode 100644 index 000000000..638cd9d88 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsFileResourceConfig.kt @@ -0,0 +1,394 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** A file mounted into each session's container. */ +class BetaManagedAgentsFileResourceConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val fileId: JsonField, + private val type: JsonField, + private val mountPath: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("file_id") @ExcludeMissing fileId: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("mount_path") @ExcludeMissing mountPath: JsonField = JsonMissing.of(), + ) : this(fileId, type, mountPath, mutableMapOf()) + + /** + * ID of a previously uploaded file. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun fileId(): String = fileId.getRequired("file_id") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Mount path in the container. Defaults to `/mnt/session/uploads/`. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mountPath(): Optional = mountPath.getOptional("mount_path") + + /** + * Returns the raw JSON value of [fileId]. + * + * Unlike [fileId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("file_id") @ExcludeMissing fun _fileId(): JsonField = fileId + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [mountPath]. + * + * Unlike [mountPath], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mount_path") @ExcludeMissing fun _mountPath(): JsonField = mountPath + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsFileResourceConfig]. + * + * The following fields are required: + * ```java + * .fileId() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsFileResourceConfig]. */ + class Builder internal constructor() { + + private var fileId: JsonField? = null + private var type: JsonField? = null + private var mountPath: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsFileResourceConfig: BetaManagedAgentsFileResourceConfig + ) = apply { + fileId = betaManagedAgentsFileResourceConfig.fileId + type = betaManagedAgentsFileResourceConfig.type + mountPath = betaManagedAgentsFileResourceConfig.mountPath + additionalProperties = + betaManagedAgentsFileResourceConfig.additionalProperties.toMutableMap() + } + + /** ID of a previously uploaded file. */ + fun fileId(fileId: String) = fileId(JsonField.of(fileId)) + + /** + * Sets [Builder.fileId] to an arbitrary JSON value. + * + * You should usually call [Builder.fileId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fileId(fileId: JsonField) = apply { this.fileId = fileId } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** Mount path in the container. Defaults to `/mnt/session/uploads/`. */ + fun mountPath(mountPath: String?) = mountPath(JsonField.ofNullable(mountPath)) + + /** Alias for calling [Builder.mountPath] with `mountPath.orElse(null)`. */ + fun mountPath(mountPath: Optional) = mountPath(mountPath.getOrNull()) + + /** + * Sets [Builder.mountPath] to an arbitrary JSON value. + * + * You should usually call [Builder.mountPath] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun mountPath(mountPath: JsonField) = apply { this.mountPath = mountPath } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsFileResourceConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .fileId() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsFileResourceConfig = + BetaManagedAgentsFileResourceConfig( + checkRequired("fileId", fileId), + checkRequired("type", type), + mountPath, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsFileResourceConfig = apply { + if (validated) { + return@apply + } + + fileId() + type().validate() + mountPath() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (fileId.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (mountPath.asKnown().isPresent) 1 else 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val FILE = of("file") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + FILE + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + FILE, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + FILE -> Value.FILE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + FILE -> Known.FILE + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsFileResourceConfig && + fileId == other.fileId && + type == other.type && + mountPath == other.mountPath && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(fileId, type, mountPath, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsFileResourceConfig{fileId=$fileId, type=$type, mountPath=$mountPath, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsGitHubRepositoryResourceConfig.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsGitHubRepositoryResourceConfig.kt new file mode 100644 index 000000000..9a9370d2f --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsGitHubRepositoryResourceConfig.kt @@ -0,0 +1,701 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.BaseDeserializer +import com.anthropic.core.BaseSerializer +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.core.getOrThrow +import com.anthropic.errors.AnthropicInvalidDataException +import com.anthropic.models.beta.sessions.BetaManagedAgentsBranchCheckout +import com.anthropic.models.beta.sessions.BetaManagedAgentsCommitCheckout +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * A GitHub repository mounted into each session's container. The authorization token is write-only + * and never returned. + */ +class BetaManagedAgentsGitHubRepositoryResourceConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val type: JsonField, + private val url: JsonField, + private val checkout: JsonField, + private val mountPath: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("checkout") @ExcludeMissing checkout: JsonField = JsonMissing.of(), + @JsonProperty("mount_path") @ExcludeMissing mountPath: JsonField = JsonMissing.of(), + ) : this(type, url, checkout, mountPath, mutableMapOf()) + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Github URL of the repository + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun url(): String = url.getRequired("url") + + /** + * Branch or commit to check out. Defaults to the repository's default branch. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun checkout(): Optional = checkout.getOptional("checkout") + + /** + * Mount path in the container. Defaults to `/workspace/`. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mountPath(): Optional = mountPath.getOptional("mount_path") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [checkout]. + * + * Unlike [checkout], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("checkout") @ExcludeMissing fun _checkout(): JsonField = checkout + + /** + * Returns the raw JSON value of [mountPath]. + * + * Unlike [mountPath], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mount_path") @ExcludeMissing fun _mountPath(): JsonField = mountPath + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsGitHubRepositoryResourceConfig]. + * + * The following fields are required: + * ```java + * .type() + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsGitHubRepositoryResourceConfig]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var url: JsonField? = null + private var checkout: JsonField = JsonMissing.of() + private var mountPath: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsGitHubRepositoryResourceConfig: + BetaManagedAgentsGitHubRepositoryResourceConfig + ) = apply { + type = betaManagedAgentsGitHubRepositoryResourceConfig.type + url = betaManagedAgentsGitHubRepositoryResourceConfig.url + checkout = betaManagedAgentsGitHubRepositoryResourceConfig.checkout + mountPath = betaManagedAgentsGitHubRepositoryResourceConfig.mountPath + additionalProperties = + betaManagedAgentsGitHubRepositoryResourceConfig.additionalProperties.toMutableMap() + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** Github URL of the repository */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + /** Branch or commit to check out. Defaults to the repository's default branch. */ + fun checkout(checkout: Checkout?) = checkout(JsonField.ofNullable(checkout)) + + /** Alias for calling [Builder.checkout] with `checkout.orElse(null)`. */ + fun checkout(checkout: Optional) = checkout(checkout.getOrNull()) + + /** + * Sets [Builder.checkout] to an arbitrary JSON value. + * + * You should usually call [Builder.checkout] with a well-typed [Checkout] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun checkout(checkout: JsonField) = apply { this.checkout = checkout } + + /** Alias for calling [checkout] with `Checkout.ofBranch(branch)`. */ + fun checkout(branch: BetaManagedAgentsBranchCheckout) = checkout(Checkout.ofBranch(branch)) + + /** + * Alias for calling [checkout] with the following: + * ```java + * BetaManagedAgentsBranchCheckout.builder() + * .type(BetaManagedAgentsBranchCheckout.Type.BRANCH) + * .name(name) + * .build() + * ``` + */ + fun branchCheckout(name: String) = + checkout( + BetaManagedAgentsBranchCheckout.builder() + .type(BetaManagedAgentsBranchCheckout.Type.BRANCH) + .name(name) + .build() + ) + + /** Alias for calling [checkout] with `Checkout.ofCommit(commit)`. */ + fun checkout(commit: BetaManagedAgentsCommitCheckout) = checkout(Checkout.ofCommit(commit)) + + /** + * Alias for calling [checkout] with the following: + * ```java + * BetaManagedAgentsCommitCheckout.builder() + * .type(BetaManagedAgentsCommitCheckout.Type.COMMIT) + * .sha(sha) + * .build() + * ``` + */ + fun commitCheckout(sha: String) = + checkout( + BetaManagedAgentsCommitCheckout.builder() + .type(BetaManagedAgentsCommitCheckout.Type.COMMIT) + .sha(sha) + .build() + ) + + /** Mount path in the container. Defaults to `/workspace/`. */ + fun mountPath(mountPath: String?) = mountPath(JsonField.ofNullable(mountPath)) + + /** Alias for calling [Builder.mountPath] with `mountPath.orElse(null)`. */ + fun mountPath(mountPath: Optional) = mountPath(mountPath.getOrNull()) + + /** + * Sets [Builder.mountPath] to an arbitrary JSON value. + * + * You should usually call [Builder.mountPath] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun mountPath(mountPath: JsonField) = apply { this.mountPath = mountPath } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsGitHubRepositoryResourceConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsGitHubRepositoryResourceConfig = + BetaManagedAgentsGitHubRepositoryResourceConfig( + checkRequired("type", type), + checkRequired("url", url), + checkout, + mountPath, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsGitHubRepositoryResourceConfig = apply { + if (validated) { + return@apply + } + + type().validate() + url() + checkout().ifPresent { it.validate() } + mountPath() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (checkout.asKnown().getOrNull()?.validity() ?: 0) + + (if (mountPath.asKnown().isPresent) 1 else 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GITHUB_REPOSITORY = of("github_repository") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + GITHUB_REPOSITORY + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GITHUB_REPOSITORY, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GITHUB_REPOSITORY -> Value.GITHUB_REPOSITORY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + GITHUB_REPOSITORY -> Known.GITHUB_REPOSITORY + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Branch or commit to check out. Defaults to the repository's default branch. */ + @JsonDeserialize(using = Checkout.Deserializer::class) + @JsonSerialize(using = Checkout.Serializer::class) + class Checkout + private constructor( + private val branch: BetaManagedAgentsBranchCheckout? = null, + private val commit: BetaManagedAgentsCommitCheckout? = null, + private val _json: JsonValue? = null, + ) { + + fun branch(): Optional = Optional.ofNullable(branch) + + fun commit(): Optional = Optional.ofNullable(commit) + + fun isBranch(): Boolean = branch != null + + fun isCommit(): Boolean = commit != null + + fun asBranch(): BetaManagedAgentsBranchCheckout = branch.getOrThrow("branch") + + fun asCommit(): BetaManagedAgentsCommitCheckout = commit.getOrThrow("commit") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.anthropic.core.JsonValue; + * import java.util.Optional; + * + * Optional result = checkout.accept(new Checkout.Visitor>() { + * @Override + * public Optional visitBranch(BetaManagedAgentsBranchCheckout branch) { + * return Optional.of(branch.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws AnthropicInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + branch != null -> visitor.visitBranch(branch) + commit != null -> visitor.visitCommit(commit) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Checkout = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitBranch(branch: BetaManagedAgentsBranchCheckout) { + branch.validate() + } + + override fun visitCommit(commit: BetaManagedAgentsCommitCheckout) { + commit.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitBranch(branch: BetaManagedAgentsBranchCheckout) = + branch.validity() + + override fun visitCommit(commit: BetaManagedAgentsCommitCheckout) = + commit.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Checkout && branch == other.branch && commit == other.commit + } + + override fun hashCode(): Int = Objects.hash(branch, commit) + + override fun toString(): String = + when { + branch != null -> "Checkout{branch=$branch}" + commit != null -> "Checkout{commit=$commit}" + _json != null -> "Checkout{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Checkout") + } + + companion object { + + @JvmStatic + fun ofBranch(branch: BetaManagedAgentsBranchCheckout) = Checkout(branch = branch) + + @JvmStatic + fun ofCommit(commit: BetaManagedAgentsCommitCheckout) = Checkout(commit = commit) + } + + /** + * An interface that defines how to map each variant of [Checkout] to a value of type [T]. + */ + interface Visitor { + + fun visitBranch(branch: BetaManagedAgentsBranchCheckout): T + + fun visitCommit(commit: BetaManagedAgentsCommitCheckout): T + + /** + * Maps an unknown variant of [Checkout] to a value of type [T]. + * + * An instance of [Checkout] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws AnthropicInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw AnthropicInvalidDataException("Unknown Checkout: $json") + } + } + + internal class Deserializer : BaseDeserializer(Checkout::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Checkout { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "branch" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Checkout(branch = it, _json = json) } ?: Checkout(_json = json) + } + "commit" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Checkout(commit = it, _json = json) } ?: Checkout(_json = json) + } + } + + return Checkout(_json = json) + } + } + + internal class Serializer : BaseSerializer(Checkout::class) { + + override fun serialize( + value: Checkout, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.branch != null -> generator.writeObject(value.branch) + value.commit != null -> generator.writeObject(value.commit) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Checkout") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsGitHubRepositoryResourceConfig && + type == other.type && + url == other.url && + checkout == other.checkout && + mountPath == other.mountPath && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, url, checkout, mountPath, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsGitHubRepositoryResourceConfig{type=$type, url=$url, checkout=$checkout, mountPath=$mountPath, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsManualDeploymentPausedReason.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsManualDeploymentPausedReason.kt new file mode 100644 index 000000000..cc7ffc801 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsManualDeploymentPausedReason.kt @@ -0,0 +1,316 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** The caller invoked the pause endpoint on the deployment. */ +class BetaManagedAgentsManualDeploymentPausedReason +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsManualDeploymentPausedReason]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsManualDeploymentPausedReason]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsManualDeploymentPausedReason: + BetaManagedAgentsManualDeploymentPausedReason + ) = apply { + type = betaManagedAgentsManualDeploymentPausedReason.type + additionalProperties = + betaManagedAgentsManualDeploymentPausedReason.additionalProperties.toMutableMap() + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsManualDeploymentPausedReason]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsManualDeploymentPausedReason = + BetaManagedAgentsManualDeploymentPausedReason( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsManualDeploymentPausedReason = apply { + if (validated) { + return@apply + } + + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MANUAL = of("manual") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + MANUAL + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MANUAL, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MANUAL -> Value.MANUAL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MANUAL -> Known.MANUAL + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsManualDeploymentPausedReason && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsManualDeploymentPausedReason{type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError.kt new file mode 100644 index 000000000..7e6216884 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError.kt @@ -0,0 +1,320 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** + * An MCP server host used by the deployment's agent is blocked by the environment's network policy. + */ +class BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError: + BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError + ) = apply { + type = betaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError.type + additionalProperties = + betaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError.additionalProperties + .toMutableMap() + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of + * [BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError = + BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError = apply { + if (validated) { + return@apply + } + + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MCP_EGRESS_BLOCKED_ERROR = of("mcp_egress_blocked_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + MCP_EGRESS_BLOCKED_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MCP_EGRESS_BLOCKED_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MCP_EGRESS_BLOCKED_ERROR -> Value.MCP_EGRESS_BLOCKED_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MCP_EGRESS_BLOCKED_ERROR -> Known.MCP_EGRESS_BLOCKED_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError{type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError.kt new file mode 100644 index 000000000..07b3679d2 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError.kt @@ -0,0 +1,318 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** A memory store referenced by the deployment is archived. */ +class BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError: + BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError + ) = apply { + type = betaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError.type + additionalProperties = + betaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError.additionalProperties + .toMutableMap() + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of + * [BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError = + BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError = apply { + if (validated) { + return@apply + } + + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MEMORY_STORE_ARCHIVED_ERROR = of("memory_store_archived_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + MEMORY_STORE_ARCHIVED_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MEMORY_STORE_ARCHIVED_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MEMORY_STORE_ARCHIVED_ERROR -> Value.MEMORY_STORE_ARCHIVED_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MEMORY_STORE_ARCHIVED_ERROR -> Known.MEMORY_STORE_ARCHIVED_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError{type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsMemoryStoreResourceConfig.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsMemoryStoreResourceConfig.kt new file mode 100644 index 000000000..6e288ea4f --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsMemoryStoreResourceConfig.kt @@ -0,0 +1,588 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** A memory store attached to each session created from this deployment. */ +class BetaManagedAgentsMemoryStoreResourceConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val memoryStoreId: JsonField, + private val type: JsonField, + private val access: JsonField, + private val instructions: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("memory_store_id") + @ExcludeMissing + memoryStoreId: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("access") @ExcludeMissing access: JsonField = JsonMissing.of(), + @JsonProperty("instructions") + @ExcludeMissing + instructions: JsonField = JsonMissing.of(), + ) : this(memoryStoreId, type, access, instructions, mutableMapOf()) + + /** + * The memory store ID (memstore_...). Must belong to the caller's organization and workspace. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun memoryStoreId(): String = memoryStoreId.getRequired("memory_store_id") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Access mode for an attached memory store. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun access(): Optional = access.getOptional("access") + + /** + * Per-attachment guidance for the agent on how to use this store. Rendered into the memory + * section of the system prompt. Max 4096 chars. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun instructions(): Optional = instructions.getOptional("instructions") + + /** + * Returns the raw JSON value of [memoryStoreId]. + * + * Unlike [memoryStoreId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("memory_store_id") + @ExcludeMissing + fun _memoryStoreId(): JsonField = memoryStoreId + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [access]. + * + * Unlike [access], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("access") @ExcludeMissing fun _access(): JsonField = access + + /** + * Returns the raw JSON value of [instructions]. + * + * Unlike [instructions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("instructions") + @ExcludeMissing + fun _instructions(): JsonField = instructions + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsMemoryStoreResourceConfig]. + * + * The following fields are required: + * ```java + * .memoryStoreId() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsMemoryStoreResourceConfig]. */ + class Builder internal constructor() { + + private var memoryStoreId: JsonField? = null + private var type: JsonField? = null + private var access: JsonField = JsonMissing.of() + private var instructions: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsMemoryStoreResourceConfig: BetaManagedAgentsMemoryStoreResourceConfig + ) = apply { + memoryStoreId = betaManagedAgentsMemoryStoreResourceConfig.memoryStoreId + type = betaManagedAgentsMemoryStoreResourceConfig.type + access = betaManagedAgentsMemoryStoreResourceConfig.access + instructions = betaManagedAgentsMemoryStoreResourceConfig.instructions + additionalProperties = + betaManagedAgentsMemoryStoreResourceConfig.additionalProperties.toMutableMap() + } + + /** + * The memory store ID (memstore_...). Must belong to the caller's organization and + * workspace. + */ + fun memoryStoreId(memoryStoreId: String) = memoryStoreId(JsonField.of(memoryStoreId)) + + /** + * Sets [Builder.memoryStoreId] to an arbitrary JSON value. + * + * You should usually call [Builder.memoryStoreId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun memoryStoreId(memoryStoreId: JsonField) = apply { + this.memoryStoreId = memoryStoreId + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** Access mode for an attached memory store. */ + fun access(access: Access?) = access(JsonField.ofNullable(access)) + + /** Alias for calling [Builder.access] with `access.orElse(null)`. */ + fun access(access: Optional) = access(access.getOrNull()) + + /** + * Sets [Builder.access] to an arbitrary JSON value. + * + * You should usually call [Builder.access] with a well-typed [Access] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun access(access: JsonField) = apply { this.access = access } + + /** + * Per-attachment guidance for the agent on how to use this store. Rendered into the memory + * section of the system prompt. Max 4096 chars. + */ + fun instructions(instructions: String?) = instructions(JsonField.ofNullable(instructions)) + + /** Alias for calling [Builder.instructions] with `instructions.orElse(null)`. */ + fun instructions(instructions: Optional) = instructions(instructions.getOrNull()) + + /** + * Sets [Builder.instructions] to an arbitrary JSON value. + * + * You should usually call [Builder.instructions] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun instructions(instructions: JsonField) = apply { + this.instructions = instructions + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsMemoryStoreResourceConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .memoryStoreId() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsMemoryStoreResourceConfig = + BetaManagedAgentsMemoryStoreResourceConfig( + checkRequired("memoryStoreId", memoryStoreId), + checkRequired("type", type), + access, + instructions, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsMemoryStoreResourceConfig = apply { + if (validated) { + return@apply + } + + memoryStoreId() + type().validate() + access().ifPresent { it.validate() } + instructions() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (memoryStoreId.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (access.asKnown().getOrNull()?.validity() ?: 0) + + (if (instructions.asKnown().isPresent) 1 else 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MEMORY_STORE = of("memory_store") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + MEMORY_STORE + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MEMORY_STORE, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MEMORY_STORE -> Value.MEMORY_STORE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MEMORY_STORE -> Known.MEMORY_STORE + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Access mode for an attached memory store. */ + class Access @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val READ_WRITE = of("read_write") + + @JvmField val READ_ONLY = of("read_only") + + @JvmStatic fun of(value: String) = Access(JsonField.of(value)) + } + + /** An enum containing [Access]'s known values. */ + enum class Known { + READ_WRITE, + READ_ONLY, + } + + /** + * An enum containing [Access]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Access] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + READ_WRITE, + READ_ONLY, + /** An enum member indicating that [Access] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + READ_WRITE -> Value.READ_WRITE + READ_ONLY -> Value.READ_ONLY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + READ_WRITE -> Known.READ_WRITE + READ_ONLY -> Known.READ_ONLY + else -> throw AnthropicInvalidDataException("Unknown Access: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Access = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Access && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsMemoryStoreResourceConfig && + memoryStoreId == other.memoryStoreId && + type == other.type && + access == other.access && + instructions == other.instructions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(memoryStoreId, type, access, instructions, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsMemoryStoreResourceConfig{memoryStoreId=$memoryStoreId, type=$type, access=$access, instructions=$instructions, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError.kt new file mode 100644 index 000000000..ecc2bb695 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError.kt @@ -0,0 +1,319 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** The deployment's organization is disabled. */ +class BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsOrganizationDisabledDeploymentPausedReasonError: + BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError + ) = apply { + type = betaManagedAgentsOrganizationDisabledDeploymentPausedReasonError.type + additionalProperties = + betaManagedAgentsOrganizationDisabledDeploymentPausedReasonError + .additionalProperties + .toMutableMap() + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of + * [BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError = + BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError = apply { + if (validated) { + return@apply + } + + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ORGANIZATION_DISABLED_ERROR = of("organization_disabled_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ORGANIZATION_DISABLED_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ORGANIZATION_DISABLED_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ORGANIZATION_DISABLED_ERROR -> Value.ORGANIZATION_DISABLED_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ORGANIZATION_DISABLED_ERROR -> Known.ORGANIZATION_DISABLED_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError{type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsSchedule.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsSchedule.kt new file mode 100644 index 000000000..634f5fc50 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsSchedule.kt @@ -0,0 +1,510 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkKnown +import com.anthropic.core.checkRequired +import com.anthropic.core.toImmutable +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** 5-field POSIX cron schedule with computed runtime timestamps. */ +class BetaManagedAgentsSchedule +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val expression: JsonField, + private val timezone: JsonField, + private val type: JsonField, + private val lastRunAt: JsonField, + private val upcomingRunsAt: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("expression") + @ExcludeMissing + expression: JsonField = JsonMissing.of(), + @JsonProperty("timezone") @ExcludeMissing timezone: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("last_run_at") + @ExcludeMissing + lastRunAt: JsonField = JsonMissing.of(), + @JsonProperty("upcoming_runs_at") + @ExcludeMissing + upcomingRunsAt: JsonField> = JsonMissing.of(), + ) : this(expression, timezone, type, lastRunAt, upcomingRunsAt, mutableMapOf()) + + /** + * 5-field POSIX cron expression: minute hour day-of-month month day-of-week (e.g., "0 9 * * + * 1-5" for weekdays at 9am). Day-of-week is 0-7 where 0 and 7 both mean Sunday. Extended cron + * syntax - seconds or year fields, and the special characters L, W, #, and ? - is not + * supported, nor are predefined shortcuts (@daily). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun expression(): String = expression.getRequired("expression") + + /** + * IANA timezone identifier (e.g., "America/Los_Angeles", "UTC"). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun timezone(): String = timezone.getRequired("timezone") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * A timestamp in RFC 3339 format + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun lastRunAt(): Optional = lastRunAt.getOptional("last_run_at") + + /** + * Up to 5 timestamps of upcoming cron occurrences. Non-empty for active and paused deployments + * (reflects what the schedule would do if unpaused); empty once the deployment is archived + * (`archived_at` set). Each fire is offset by a small per-schedule jitter, so a run will + * actually start at or shortly after its listed time. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun upcomingRunsAt(): Optional> = + upcomingRunsAt.getOptional("upcoming_runs_at") + + /** + * Returns the raw JSON value of [expression]. + * + * Unlike [expression], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expression") @ExcludeMissing fun _expression(): JsonField = expression + + /** + * Returns the raw JSON value of [timezone]. + * + * Unlike [timezone], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timezone") @ExcludeMissing fun _timezone(): JsonField = timezone + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [lastRunAt]. + * + * Unlike [lastRunAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("last_run_at") + @ExcludeMissing + fun _lastRunAt(): JsonField = lastRunAt + + /** + * Returns the raw JSON value of [upcomingRunsAt]. + * + * Unlike [upcomingRunsAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("upcoming_runs_at") + @ExcludeMissing + fun _upcomingRunsAt(): JsonField> = upcomingRunsAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BetaManagedAgentsSchedule]. + * + * The following fields are required: + * ```java + * .expression() + * .timezone() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsSchedule]. */ + class Builder internal constructor() { + + private var expression: JsonField? = null + private var timezone: JsonField? = null + private var type: JsonField? = null + private var lastRunAt: JsonField = JsonMissing.of() + private var upcomingRunsAt: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaManagedAgentsSchedule: BetaManagedAgentsSchedule) = apply { + expression = betaManagedAgentsSchedule.expression + timezone = betaManagedAgentsSchedule.timezone + type = betaManagedAgentsSchedule.type + lastRunAt = betaManagedAgentsSchedule.lastRunAt + upcomingRunsAt = + betaManagedAgentsSchedule.upcomingRunsAt + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + additionalProperties = betaManagedAgentsSchedule.additionalProperties.toMutableMap() + } + + /** + * 5-field POSIX cron expression: minute hour day-of-month month day-of-week (e.g., "0 9 * * + * 1-5" for weekdays at 9am). Day-of-week is 0-7 where 0 and 7 both mean Sunday. Extended + * cron syntax - seconds or year fields, and the special characters L, W, #, and ? - is not + * supported, nor are predefined shortcuts (@daily). + */ + fun expression(expression: String) = expression(JsonField.of(expression)) + + /** + * Sets [Builder.expression] to an arbitrary JSON value. + * + * You should usually call [Builder.expression] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun expression(expression: JsonField) = apply { this.expression = expression } + + /** IANA timezone identifier (e.g., "America/Los_Angeles", "UTC"). */ + fun timezone(timezone: String) = timezone(JsonField.of(timezone)) + + /** + * Sets [Builder.timezone] to an arbitrary JSON value. + * + * You should usually call [Builder.timezone] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun timezone(timezone: JsonField) = apply { this.timezone = timezone } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** A timestamp in RFC 3339 format */ + fun lastRunAt(lastRunAt: OffsetDateTime?) = lastRunAt(JsonField.ofNullable(lastRunAt)) + + /** Alias for calling [Builder.lastRunAt] with `lastRunAt.orElse(null)`. */ + fun lastRunAt(lastRunAt: Optional) = lastRunAt(lastRunAt.getOrNull()) + + /** + * Sets [Builder.lastRunAt] to an arbitrary JSON value. + * + * You should usually call [Builder.lastRunAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lastRunAt(lastRunAt: JsonField) = apply { this.lastRunAt = lastRunAt } + + /** + * Up to 5 timestamps of upcoming cron occurrences. Non-empty for active and paused + * deployments (reflects what the schedule would do if unpaused); empty once the deployment + * is archived (`archived_at` set). Each fire is offset by a small per-schedule jitter, so a + * run will actually start at or shortly after its listed time. + */ + fun upcomingRunsAt(upcomingRunsAt: List) = + upcomingRunsAt(JsonField.of(upcomingRunsAt)) + + /** + * Sets [Builder.upcomingRunsAt] to an arbitrary JSON value. + * + * You should usually call [Builder.upcomingRunsAt] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun upcomingRunsAt(upcomingRunsAt: JsonField>) = apply { + this.upcomingRunsAt = upcomingRunsAt.map { it.toMutableList() } + } + + /** + * Adds a single [OffsetDateTime] to [Builder.upcomingRunsAt]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUpcomingRunsAt(upcomingRunsAt: OffsetDateTime) = apply { + this.upcomingRunsAt = + (this.upcomingRunsAt ?: JsonField.of(mutableListOf())).also { + checkKnown("upcomingRunsAt", it).add(upcomingRunsAt) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsSchedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .expression() + * .timezone() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsSchedule = + BetaManagedAgentsSchedule( + checkRequired("expression", expression), + checkRequired("timezone", timezone), + checkRequired("type", type), + lastRunAt, + (upcomingRunsAt ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsSchedule = apply { + if (validated) { + return@apply + } + + expression() + timezone() + type().validate() + lastRunAt() + upcomingRunsAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (expression.asKnown().isPresent) 1 else 0) + + (if (timezone.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (lastRunAt.asKnown().isPresent) 1 else 0) + + (upcomingRunsAt.asKnown().getOrNull()?.size ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CRON = of("cron") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CRON + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CRON, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CRON -> Value.CRON + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CRON -> Known.CRON + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsSchedule && + expression == other.expression && + timezone == other.timezone && + type == other.type && + lastRunAt == other.lastRunAt && + upcomingRunsAt == other.upcomingRunsAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(expression, timezone, type, lastRunAt, upcomingRunsAt, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsSchedule{expression=$expression, timezone=$timezone, type=$type, lastRunAt=$lastRunAt, upcomingRunsAt=$upcomingRunsAt, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsScheduleParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsScheduleParams.kt new file mode 100644 index 000000000..9583145cb --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsScheduleParams.kt @@ -0,0 +1,405 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** 5-field POSIX cron schedule. Literal wall-clock matching in the configured timezone. */ +class BetaManagedAgentsScheduleParams +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val expression: JsonField, + private val timezone: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("expression") + @ExcludeMissing + expression: JsonField = JsonMissing.of(), + @JsonProperty("timezone") @ExcludeMissing timezone: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(expression, timezone, type, mutableMapOf()) + + /** + * 5-field POSIX cron expression: minute hour day-of-month month day-of-week (e.g., "0 9 * * + * 1-5" for weekdays at 9am). Day-of-week is 0-7 where 0 and 7 both mean Sunday. Extended cron + * syntax - seconds or year fields, and the special characters L, W, #, and ? - is not + * supported, nor are predefined shortcuts (@daily). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun expression(): String = expression.getRequired("expression") + + /** + * Required. IANA timezone identifier (e.g., "America/Los_Angeles", "UTC"). Validated against + * the IANA timezone database. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun timezone(): String = timezone.getRequired("timezone") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [expression]. + * + * Unlike [expression], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expression") @ExcludeMissing fun _expression(): JsonField = expression + + /** + * Returns the raw JSON value of [timezone]. + * + * Unlike [timezone], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timezone") @ExcludeMissing fun _timezone(): JsonField = timezone + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsScheduleParams]. + * + * The following fields are required: + * ```java + * .expression() + * .timezone() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsScheduleParams]. */ + class Builder internal constructor() { + + private var expression: JsonField? = null + private var timezone: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaManagedAgentsScheduleParams: BetaManagedAgentsScheduleParams) = + apply { + expression = betaManagedAgentsScheduleParams.expression + timezone = betaManagedAgentsScheduleParams.timezone + type = betaManagedAgentsScheduleParams.type + additionalProperties = + betaManagedAgentsScheduleParams.additionalProperties.toMutableMap() + } + + /** + * 5-field POSIX cron expression: minute hour day-of-month month day-of-week (e.g., "0 9 * * + * 1-5" for weekdays at 9am). Day-of-week is 0-7 where 0 and 7 both mean Sunday. Extended + * cron syntax - seconds or year fields, and the special characters L, W, #, and ? - is not + * supported, nor are predefined shortcuts (@daily). + */ + fun expression(expression: String) = expression(JsonField.of(expression)) + + /** + * Sets [Builder.expression] to an arbitrary JSON value. + * + * You should usually call [Builder.expression] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun expression(expression: JsonField) = apply { this.expression = expression } + + /** + * Required. IANA timezone identifier (e.g., "America/Los_Angeles", "UTC"). Validated + * against the IANA timezone database. + */ + fun timezone(timezone: String) = timezone(JsonField.of(timezone)) + + /** + * Sets [Builder.timezone] to an arbitrary JSON value. + * + * You should usually call [Builder.timezone] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun timezone(timezone: JsonField) = apply { this.timezone = timezone } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsScheduleParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .expression() + * .timezone() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsScheduleParams = + BetaManagedAgentsScheduleParams( + checkRequired("expression", expression), + checkRequired("timezone", timezone), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsScheduleParams = apply { + if (validated) { + return@apply + } + + expression() + timezone() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (expression.asKnown().isPresent) 1 else 0) + + (if (timezone.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CRON = of("cron") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CRON + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CRON, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CRON -> Value.CRON + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CRON -> Known.CRON + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsScheduleParams && + expression == other.expression && + timezone == other.timezone && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(expression, timezone, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsScheduleParams{expression=$expression, timezone=$timezone, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError.kt new file mode 100644 index 000000000..38baec23b --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError.kt @@ -0,0 +1,329 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** + * The deployment configures resources, but its environment is self-hosted and cannot mount them. + */ +class BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** + * A builder for [BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError]. + */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError: + BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError + ) = apply { + type = betaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError.type + additionalProperties = + betaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError + .additionalProperties + .toMutableMap() + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of + * [BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError = + BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError = + apply { + if (validated) { + return@apply + } + + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField + val SELF_HOSTED_RESOURCES_UNSUPPORTED_ERROR = + of("self_hosted_resources_unsupported_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + SELF_HOSTED_RESOURCES_UNSUPPORTED_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SELF_HOSTED_RESOURCES_UNSUPPORTED_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SELF_HOSTED_RESOURCES_UNSUPPORTED_ERROR -> + Value.SELF_HOSTED_RESOURCES_UNSUPPORTED_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SELF_HOSTED_RESOURCES_UNSUPPORTED_ERROR -> + Known.SELF_HOSTED_RESOURCES_UNSUPPORTED_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is + BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError{type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsSessionResourceConfig.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsSessionResourceConfig.kt new file mode 100644 index 000000000..fce974421 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsSessionResourceConfig.kt @@ -0,0 +1,323 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.BaseDeserializer +import com.anthropic.core.BaseSerializer +import com.anthropic.core.JsonValue +import com.anthropic.core.getOrThrow +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** A configured session resource. Echoes the input minus write-only credentials. */ +@JsonDeserialize(using = BetaManagedAgentsSessionResourceConfig.Deserializer::class) +@JsonSerialize(using = BetaManagedAgentsSessionResourceConfig.Serializer::class) +class BetaManagedAgentsSessionResourceConfig +private constructor( + private val githubRepository: BetaManagedAgentsGitHubRepositoryResourceConfig? = null, + private val file: BetaManagedAgentsFileResourceConfig? = null, + private val memoryStore: BetaManagedAgentsMemoryStoreResourceConfig? = null, + private val _json: JsonValue? = null, +) { + + /** + * A GitHub repository mounted into each session's container. The authorization token is + * write-only and never returned. + */ + fun githubRepository(): Optional = + Optional.ofNullable(githubRepository) + + /** A file mounted into each session's container. */ + fun file(): Optional = Optional.ofNullable(file) + + /** A memory store attached to each session created from this deployment. */ + fun memoryStore(): Optional = + Optional.ofNullable(memoryStore) + + fun isGitHubRepository(): Boolean = githubRepository != null + + fun isFile(): Boolean = file != null + + fun isMemoryStore(): Boolean = memoryStore != null + + /** + * A GitHub repository mounted into each session's container. The authorization token is + * write-only and never returned. + */ + fun asGitHubRepository(): BetaManagedAgentsGitHubRepositoryResourceConfig = + githubRepository.getOrThrow("githubRepository") + + /** A file mounted into each session's container. */ + fun asFile(): BetaManagedAgentsFileResourceConfig = file.getOrThrow("file") + + /** A memory store attached to each session created from this deployment. */ + fun asMemoryStore(): BetaManagedAgentsMemoryStoreResourceConfig = + memoryStore.getOrThrow("memoryStore") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.anthropic.core.JsonValue; + * import java.util.Optional; + * + * Optional result = betaManagedAgentsSessionResourceConfig.accept(new BetaManagedAgentsSessionResourceConfig.Visitor>() { + * @Override + * public Optional visitGitHubRepository(BetaManagedAgentsGitHubRepositoryResourceConfig githubRepository) { + * return Optional.of(githubRepository.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws AnthropicInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + githubRepository != null -> visitor.visitGitHubRepository(githubRepository) + file != null -> visitor.visitFile(file) + memoryStore != null -> visitor.visitMemoryStore(memoryStore) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsSessionResourceConfig = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitGitHubRepository( + githubRepository: BetaManagedAgentsGitHubRepositoryResourceConfig + ) { + githubRepository.validate() + } + + override fun visitFile(file: BetaManagedAgentsFileResourceConfig) { + file.validate() + } + + override fun visitMemoryStore( + memoryStore: BetaManagedAgentsMemoryStoreResourceConfig + ) { + memoryStore.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitGitHubRepository( + githubRepository: BetaManagedAgentsGitHubRepositoryResourceConfig + ) = githubRepository.validity() + + override fun visitFile(file: BetaManagedAgentsFileResourceConfig) = file.validity() + + override fun visitMemoryStore( + memoryStore: BetaManagedAgentsMemoryStoreResourceConfig + ) = memoryStore.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsSessionResourceConfig && + githubRepository == other.githubRepository && + file == other.file && + memoryStore == other.memoryStore + } + + override fun hashCode(): Int = Objects.hash(githubRepository, file, memoryStore) + + override fun toString(): String = + when { + githubRepository != null -> + "BetaManagedAgentsSessionResourceConfig{githubRepository=$githubRepository}" + file != null -> "BetaManagedAgentsSessionResourceConfig{file=$file}" + memoryStore != null -> + "BetaManagedAgentsSessionResourceConfig{memoryStore=$memoryStore}" + _json != null -> "BetaManagedAgentsSessionResourceConfig{_unknown=$_json}" + else -> throw IllegalStateException("Invalid BetaManagedAgentsSessionResourceConfig") + } + + companion object { + + /** + * A GitHub repository mounted into each session's container. The authorization token is + * write-only and never returned. + */ + @JvmStatic + fun ofGitHubRepository(githubRepository: BetaManagedAgentsGitHubRepositoryResourceConfig) = + BetaManagedAgentsSessionResourceConfig(githubRepository = githubRepository) + + /** A file mounted into each session's container. */ + @JvmStatic + fun ofFile(file: BetaManagedAgentsFileResourceConfig) = + BetaManagedAgentsSessionResourceConfig(file = file) + + /** A memory store attached to each session created from this deployment. */ + @JvmStatic + fun ofMemoryStore(memoryStore: BetaManagedAgentsMemoryStoreResourceConfig) = + BetaManagedAgentsSessionResourceConfig(memoryStore = memoryStore) + } + + /** + * An interface that defines how to map each variant of [BetaManagedAgentsSessionResourceConfig] + * to a value of type [T]. + */ + interface Visitor { + + /** + * A GitHub repository mounted into each session's container. The authorization token is + * write-only and never returned. + */ + fun visitGitHubRepository( + githubRepository: BetaManagedAgentsGitHubRepositoryResourceConfig + ): T + + /** A file mounted into each session's container. */ + fun visitFile(file: BetaManagedAgentsFileResourceConfig): T + + /** A memory store attached to each session created from this deployment. */ + fun visitMemoryStore(memoryStore: BetaManagedAgentsMemoryStoreResourceConfig): T + + /** + * Maps an unknown variant of [BetaManagedAgentsSessionResourceConfig] to a value of type + * [T]. + * + * An instance of [BetaManagedAgentsSessionResourceConfig] can contain an unknown variant if + * it was deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new variants that + * the SDK is unaware of. + * + * @throws AnthropicInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw AnthropicInvalidDataException( + "Unknown BetaManagedAgentsSessionResourceConfig: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + BetaManagedAgentsSessionResourceConfig::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): BetaManagedAgentsSessionResourceConfig { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "github_repository" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + BetaManagedAgentsSessionResourceConfig( + githubRepository = it, + _json = json, + ) + } ?: BetaManagedAgentsSessionResourceConfig(_json = json) + } + "file" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { BetaManagedAgentsSessionResourceConfig(file = it, _json = json) } + ?: BetaManagedAgentsSessionResourceConfig(_json = json) + } + "memory_store" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + BetaManagedAgentsSessionResourceConfig(memoryStore = it, _json = json) + } ?: BetaManagedAgentsSessionResourceConfig(_json = json) + } + } + + return BetaManagedAgentsSessionResourceConfig(_json = json) + } + } + + internal class Serializer : + BaseSerializer( + BetaManagedAgentsSessionResourceConfig::class + ) { + + override fun serialize( + value: BetaManagedAgentsSessionResourceConfig, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.githubRepository != null -> generator.writeObject(value.githubRepository) + value.file != null -> generator.writeObject(value.file) + value.memoryStore != null -> generator.writeObject(value.memoryStore) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException("Invalid BetaManagedAgentsSessionResourceConfig") + } + } + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError.kt new file mode 100644 index 000000000..0195e33e9 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError.kt @@ -0,0 +1,319 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** A referenced resource no longer exists and its kind was not reported. */ +class BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError: + BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError + ) = apply { + type = betaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError.type + additionalProperties = + betaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError + .additionalProperties + .toMutableMap() + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of + * [BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError = + BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError = apply { + if (validated) { + return@apply + } + + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SESSION_RESOURCE_NOT_FOUND_ERROR = of("session_resource_not_found_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + SESSION_RESOURCE_NOT_FOUND_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SESSION_RESOURCE_NOT_FOUND_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SESSION_RESOURCE_NOT_FOUND_ERROR -> Value.SESSION_RESOURCE_NOT_FOUND_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SESSION_RESOURCE_NOT_FOUND_ERROR -> Known.SESSION_RESOURCE_NOT_FOUND_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError{type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError.kt new file mode 100644 index 000000000..924f71207 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError.kt @@ -0,0 +1,318 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** A skill referenced by the deployment's agent no longer exists. */ +class BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsSkillNotFoundDeploymentPausedReasonError: + BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError + ) = apply { + type = betaManagedAgentsSkillNotFoundDeploymentPausedReasonError.type + additionalProperties = + betaManagedAgentsSkillNotFoundDeploymentPausedReasonError.additionalProperties + .toMutableMap() + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of + * [BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError = + BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError = apply { + if (validated) { + return@apply + } + + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SKILL_NOT_FOUND_ERROR = of("skill_not_found_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + SKILL_NOT_FOUND_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SKILL_NOT_FOUND_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SKILL_NOT_FOUND_ERROR -> Value.SKILL_NOT_FOUND_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SKILL_NOT_FOUND_ERROR -> Known.SKILL_NOT_FOUND_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError{type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsUnknownDeploymentPausedReasonError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsUnknownDeploymentPausedReasonError.kt new file mode 100644 index 000000000..2900d51fc --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsUnknownDeploymentPausedReasonError.kt @@ -0,0 +1,320 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** + * An unrecognized error auto-paused the deployment. A fallback variant; matches a run whose + * `error.type` is `unknown_error`. + */ +class BetaManagedAgentsUnknownDeploymentPausedReasonError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsUnknownDeploymentPausedReasonError]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsUnknownDeploymentPausedReasonError]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsUnknownDeploymentPausedReasonError: + BetaManagedAgentsUnknownDeploymentPausedReasonError + ) = apply { + type = betaManagedAgentsUnknownDeploymentPausedReasonError.type + additionalProperties = + betaManagedAgentsUnknownDeploymentPausedReasonError.additionalProperties + .toMutableMap() + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsUnknownDeploymentPausedReasonError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsUnknownDeploymentPausedReasonError = + BetaManagedAgentsUnknownDeploymentPausedReasonError( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsUnknownDeploymentPausedReasonError = apply { + if (validated) { + return@apply + } + + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val UNKNOWN_ERROR = of("unknown_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + UNKNOWN_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + UNKNOWN_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + UNKNOWN_ERROR -> Value.UNKNOWN_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + UNKNOWN_ERROR -> Known.UNKNOWN_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsUnknownDeploymentPausedReasonError && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsUnknownDeploymentPausedReasonError{type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsVaultArchivedDeploymentPausedReasonError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsVaultArchivedDeploymentPausedReasonError.kt new file mode 100644 index 000000000..fe7c73528 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsVaultArchivedDeploymentPausedReasonError.kt @@ -0,0 +1,318 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** A vault referenced by the deployment is archived. */ +class BetaManagedAgentsVaultArchivedDeploymentPausedReasonError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsVaultArchivedDeploymentPausedReasonError]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsVaultArchivedDeploymentPausedReasonError]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsVaultArchivedDeploymentPausedReasonError: + BetaManagedAgentsVaultArchivedDeploymentPausedReasonError + ) = apply { + type = betaManagedAgentsVaultArchivedDeploymentPausedReasonError.type + additionalProperties = + betaManagedAgentsVaultArchivedDeploymentPausedReasonError.additionalProperties + .toMutableMap() + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of + * [BetaManagedAgentsVaultArchivedDeploymentPausedReasonError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsVaultArchivedDeploymentPausedReasonError = + BetaManagedAgentsVaultArchivedDeploymentPausedReasonError( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsVaultArchivedDeploymentPausedReasonError = apply { + if (validated) { + return@apply + } + + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val VAULT_ARCHIVED_ERROR = of("vault_archived_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + VAULT_ARCHIVED_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + VAULT_ARCHIVED_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + VAULT_ARCHIVED_ERROR -> Value.VAULT_ARCHIVED_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + VAULT_ARCHIVED_ERROR -> Known.VAULT_ARCHIVED_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsVaultArchivedDeploymentPausedReasonError && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsVaultArchivedDeploymentPausedReasonError{type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError.kt new file mode 100644 index 000000000..2ea6c8aa9 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError.kt @@ -0,0 +1,318 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** A vault referenced by the deployment no longer exists. */ +class BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsVaultNotFoundDeploymentPausedReasonError: + BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError + ) = apply { + type = betaManagedAgentsVaultNotFoundDeploymentPausedReasonError.type + additionalProperties = + betaManagedAgentsVaultNotFoundDeploymentPausedReasonError.additionalProperties + .toMutableMap() + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of + * [BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError = + BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError = apply { + if (validated) { + return@apply + } + + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val VAULT_NOT_FOUND_ERROR = of("vault_not_found_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + VAULT_NOT_FOUND_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + VAULT_NOT_FOUND_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + VAULT_NOT_FOUND_ERROR -> Value.VAULT_NOT_FOUND_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + VAULT_NOT_FOUND_ERROR -> Known.VAULT_NOT_FOUND_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError{type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError.kt new file mode 100644 index 000000000..0453d172e --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError.kt @@ -0,0 +1,318 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** The deployment's workspace was archived. */ +class BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError: + BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError + ) = apply { + type = betaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError.type + additionalProperties = + betaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError.additionalProperties + .toMutableMap() + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of + * [BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError = + BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError = apply { + if (validated) { + return@apply + } + + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val WORKSPACE_ARCHIVED_ERROR = of("workspace_archived_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + WORKSPACE_ARCHIVED_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + WORKSPACE_ARCHIVED_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + WORKSPACE_ARCHIVED_ERROR -> Value.WORKSPACE_ARCHIVED_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + WORKSPACE_ARCHIVED_ERROR -> Known.WORKSPACE_ARCHIVED_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError{type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentArchiveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentArchiveParams.kt new file mode 100644 index 000000000..2edb1870a --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentArchiveParams.kt @@ -0,0 +1,275 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.JsonValue +import com.anthropic.core.Params +import com.anthropic.core.http.Headers +import com.anthropic.core.http.QueryParams +import com.anthropic.core.toImmutable +import com.anthropic.models.beta.AnthropicBeta +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Archive Deployment */ +class DeploymentArchiveParams +private constructor( + private val deploymentId: String?, + private val betas: List?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun deploymentId(): Optional = Optional.ofNullable(deploymentId) + + /** Optional header to specify the beta version(s) you want to use. */ + fun betas(): Optional> = Optional.ofNullable(betas) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): DeploymentArchiveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [DeploymentArchiveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DeploymentArchiveParams]. */ + class Builder internal constructor() { + + private var deploymentId: String? = null + private var betas: MutableList? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(deploymentArchiveParams: DeploymentArchiveParams) = apply { + deploymentId = deploymentArchiveParams.deploymentId + betas = deploymentArchiveParams.betas?.toMutableList() + additionalHeaders = deploymentArchiveParams.additionalHeaders.toBuilder() + additionalQueryParams = deploymentArchiveParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + deploymentArchiveParams.additionalBodyProperties.toMutableMap() + } + + fun deploymentId(deploymentId: String?) = apply { this.deploymentId = deploymentId } + + /** Alias for calling [Builder.deploymentId] with `deploymentId.orElse(null)`. */ + fun deploymentId(deploymentId: Optional) = deploymentId(deploymentId.getOrNull()) + + /** Optional header to specify the beta version(s) you want to use. */ + fun betas(betas: List?) = apply { this.betas = betas?.toMutableList() } + + /** Alias for calling [Builder.betas] with `betas.orElse(null)`. */ + fun betas(betas: Optional>) = betas(betas.getOrNull()) + + /** + * Adds a single [AnthropicBeta] to [betas]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBeta(beta: AnthropicBeta) = apply { + betas = (betas ?: mutableListOf()).apply { add(beta) } + } + + /** + * Sets [addBeta] to an arbitrary [String]. + * + * You should usually call [addBeta] with a well-typed [AnthropicBeta] constant instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun addBeta(value: String) = addBeta(AnthropicBeta.of(value)) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [DeploymentArchiveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DeploymentArchiveParams = + DeploymentArchiveParams( + deploymentId, + betas?.toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> deploymentId ?: "" + else -> "" + } + + override fun _headers(): Headers = + Headers.builder() + .apply { + betas?.forEach { put("anthropic-beta", it.toString()) } + putAll(additionalHeaders) + } + .build() + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DeploymentArchiveParams && + deploymentId == other.deploymentId && + betas == other.betas && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + deploymentId, + betas, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "DeploymentArchiveParams{deploymentId=$deploymentId, betas=$betas, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentCreateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentCreateParams.kt new file mode 100644 index 000000000..dc10db76a --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentCreateParams.kt @@ -0,0 +1,2055 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.BaseDeserializer +import com.anthropic.core.BaseSerializer +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.Params +import com.anthropic.core.allMaxBy +import com.anthropic.core.checkKnown +import com.anthropic.core.checkRequired +import com.anthropic.core.getOrThrow +import com.anthropic.core.http.Headers +import com.anthropic.core.http.QueryParams +import com.anthropic.core.toImmutable +import com.anthropic.errors.AnthropicInvalidDataException +import com.anthropic.models.beta.AnthropicBeta +import com.anthropic.models.beta.sessions.BetaManagedAgentsAgentParams +import com.anthropic.models.beta.sessions.BetaManagedAgentsFileResourceParams +import com.anthropic.models.beta.sessions.BetaManagedAgentsGitHubRepositoryResourceParams +import com.anthropic.models.beta.sessions.BetaManagedAgentsMemoryStoreResourceParam +import com.anthropic.models.beta.sessions.BetaManagedAgentsSystemContentBlock +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsSystemMessageEventParams +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsUserDefineOutcomeEventParams +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsUserMessageEventParams +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create Deployment */ +class DeploymentCreateParams +private constructor( + private val betas: List?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Optional header to specify the beta version(s) you want to use. */ + fun betas(): Optional> = Optional.ofNullable(betas) + + /** + * Agent to deploy. Accepts the `agent` ID string, which pins the latest version, or an `agent` + * object with both id and version specified. The agent must exist and not be archived. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun agent(): Agent = body.agent() + + /** + * ID of the `environment` defining the container configuration for sessions created from this + * deployment. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun environmentId(): String = body.environmentId() + + /** + * Events to send to each session immediately after creation. At least 1, maximum 50. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun initialEvents(): List = body.initialEvents() + + /** + * Human-readable name for the deployment. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = body.name() + + /** + * Description of what the deployment does. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun description(): Optional = body.description() + + /** + * Arbitrary key-value metadata. Maximum 16 pairs, keys up to 64 chars, values up to 512 chars. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = body.metadata() + + /** + * Resources (e.g. repositories, files) to mount into each session's container. Maximum 500. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun resources(): Optional> = body.resources() + + /** + * 5-field POSIX cron schedule. Literal wall-clock matching in the configured timezone. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun schedule(): Optional = body.schedule() + + /** + * Vault IDs for stored credentials the agent can use during sessions created from this + * deployment. Maximum 50. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun vaultIds(): Optional> = body.vaultIds() + + /** + * Returns the raw JSON value of [agent]. + * + * Unlike [agent], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _agent(): JsonField = body._agent() + + /** + * Returns the raw JSON value of [environmentId]. + * + * Unlike [environmentId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _environmentId(): JsonField = body._environmentId() + + /** + * Returns the raw JSON value of [initialEvents]. + * + * Unlike [initialEvents], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _initialEvents(): JsonField> = + body._initialEvents() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField = body._name() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField = body._description() + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _metadata(): JsonField = body._metadata() + + /** + * Returns the raw JSON value of [resources]. + * + * Unlike [resources], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _resources(): JsonField> = body._resources() + + /** + * Returns the raw JSON value of [schedule]. + * + * Unlike [schedule], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _schedule(): JsonField = body._schedule() + + /** + * Returns the raw JSON value of [vaultIds]. + * + * Unlike [vaultIds], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _vaultIds(): JsonField> = body._vaultIds() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DeploymentCreateParams]. + * + * The following fields are required: + * ```java + * .agent() + * .environmentId() + * .initialEvents() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DeploymentCreateParams]. */ + class Builder internal constructor() { + + private var betas: MutableList? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(deploymentCreateParams: DeploymentCreateParams) = apply { + betas = deploymentCreateParams.betas?.toMutableList() + body = deploymentCreateParams.body.toBuilder() + additionalHeaders = deploymentCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = deploymentCreateParams.additionalQueryParams.toBuilder() + } + + /** Optional header to specify the beta version(s) you want to use. */ + fun betas(betas: List?) = apply { this.betas = betas?.toMutableList() } + + /** Alias for calling [Builder.betas] with `betas.orElse(null)`. */ + fun betas(betas: Optional>) = betas(betas.getOrNull()) + + /** + * Adds a single [AnthropicBeta] to [betas]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBeta(beta: AnthropicBeta) = apply { + betas = (betas ?: mutableListOf()).apply { add(beta) } + } + + /** + * Sets [addBeta] to an arbitrary [String]. + * + * You should usually call [addBeta] with a well-typed [AnthropicBeta] constant instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun addBeta(value: String) = addBeta(AnthropicBeta.of(value)) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [agent] + * - [environmentId] + * - [initialEvents] + * - [name] + * - [description] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * Agent to deploy. Accepts the `agent` ID string, which pins the latest version, or an + * `agent` object with both id and version specified. The agent must exist and not be + * archived. + */ + fun agent(agent: Agent) = apply { body.agent(agent) } + + /** + * Sets [Builder.agent] to an arbitrary JSON value. + * + * You should usually call [Builder.agent] with a well-typed [Agent] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun agent(agent: JsonField) = apply { body.agent(agent) } + + /** Alias for calling [agent] with `Agent.ofString(string)`. */ + fun agent(string: String) = apply { body.agent(string) } + + /** + * Alias for calling [agent] with + * `Agent.ofBetaManagedAgentsAgentParams(betaManagedAgentsAgentParams)`. + */ + fun agent(betaManagedAgentsAgentParams: BetaManagedAgentsAgentParams) = apply { + body.agent(betaManagedAgentsAgentParams) + } + + /** + * ID of the `environment` defining the container configuration for sessions created from + * this deployment. + */ + fun environmentId(environmentId: String) = apply { body.environmentId(environmentId) } + + /** + * Sets [Builder.environmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.environmentId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun environmentId(environmentId: JsonField) = apply { + body.environmentId(environmentId) + } + + /** Events to send to each session immediately after creation. At least 1, maximum 50. */ + fun initialEvents(initialEvents: List) = + apply { + body.initialEvents(initialEvents) + } + + /** + * Sets [Builder.initialEvents] to an arbitrary JSON value. + * + * You should usually call [Builder.initialEvents] with a well-typed + * `List` value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun initialEvents( + initialEvents: JsonField> + ) = apply { body.initialEvents(initialEvents) } + + /** + * Adds a single [BetaManagedAgentsDeploymentInitialEventParams] to [initialEvents]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addInitialEvent(initialEvent: BetaManagedAgentsDeploymentInitialEventParams) = apply { + body.addInitialEvent(initialEvent) + } + + /** + * Alias for calling [addInitialEvent] with + * `BetaManagedAgentsDeploymentInitialEventParams.ofUserMessage(userMessage)`. + */ + fun addInitialEvent(userMessage: BetaManagedAgentsUserMessageEventParams) = apply { + body.addInitialEvent(userMessage) + } + + /** + * Alias for calling [addInitialEvent] with the following: + * ```java + * BetaManagedAgentsUserMessageEventParams.builder() + * .type(BetaManagedAgentsUserMessageEventParams.Type.USER_MESSAGE) + * .content(content) + * .build() + * ``` + */ + fun addUserMessageInitialEvent( + content: List + ) = apply { body.addUserMessageInitialEvent(content) } + + /** + * Alias for calling [addInitialEvent] with + * `BetaManagedAgentsDeploymentInitialEventParams.ofUserDefineOutcome(userDefineOutcome)`. + */ + fun addInitialEvent(userDefineOutcome: BetaManagedAgentsUserDefineOutcomeEventParams) = + apply { + body.addInitialEvent(userDefineOutcome) + } + + /** + * Alias for calling [addInitialEvent] with + * `BetaManagedAgentsDeploymentInitialEventParams.ofSystemMessage(systemMessage)`. + */ + fun addInitialEvent(systemMessage: BetaManagedAgentsSystemMessageEventParams) = apply { + body.addInitialEvent(systemMessage) + } + + /** + * Alias for calling [addInitialEvent] with the following: + * ```java + * BetaManagedAgentsSystemMessageEventParams.builder() + * .type(BetaManagedAgentsSystemMessageEventParams.Type.SYSTEM_MESSAGE) + * .content(content) + * .build() + * ``` + */ + fun addSystemMessageInitialEvent(content: List) = + apply { + body.addSystemMessageInitialEvent(content) + } + + /** Human-readable name for the deployment. */ + fun name(name: String) = apply { body.name(name) } + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { body.name(name) } + + /** Description of what the deployment does. */ + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { body.description(description) } + + /** + * Arbitrary key-value metadata. Maximum 16 pairs, keys up to 64 chars, values up to 512 + * chars. + */ + fun metadata(metadata: Metadata) = apply { body.metadata(metadata) } + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + + /** + * Resources (e.g. repositories, files) to mount into each session's container. Maximum 500. + */ + fun resources(resources: List) = apply { body.resources(resources) } + + /** + * Sets [Builder.resources] to an arbitrary JSON value. + * + * You should usually call [Builder.resources] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun resources(resources: JsonField>) = apply { body.resources(resources) } + + /** + * Adds a single [Resource] to [resources]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResource(resource: Resource) = apply { body.addResource(resource) } + + /** Alias for calling [addResource] with `Resource.ofGitHubRepository(githubRepository)`. */ + fun addResource(githubRepository: BetaManagedAgentsGitHubRepositoryResourceParams) = apply { + body.addResource(githubRepository) + } + + /** Alias for calling [addResource] with `Resource.ofFile(file)`. */ + fun addResource(file: BetaManagedAgentsFileResourceParams) = apply { + body.addResource(file) + } + + /** + * Alias for calling [addResource] with the following: + * ```java + * BetaManagedAgentsFileResourceParams.builder() + * .type(BetaManagedAgentsFileResourceParams.Type.FILE) + * .fileId(fileId) + * .build() + * ``` + */ + fun addFileResource(fileId: String) = apply { body.addFileResource(fileId) } + + /** Alias for calling [addResource] with `Resource.ofMemoryStore(memoryStore)`. */ + fun addResource(memoryStore: BetaManagedAgentsMemoryStoreResourceParam) = apply { + body.addResource(memoryStore) + } + + /** + * Alias for calling [addResource] with the following: + * ```java + * BetaManagedAgentsMemoryStoreResourceParam.builder() + * .type(BetaManagedAgentsMemoryStoreResourceParam.Type.MEMORY_STORE) + * .memoryStoreId(memoryStoreId) + * .build() + * ``` + */ + fun addMemoryStoreResource(memoryStoreId: String) = apply { + body.addMemoryStoreResource(memoryStoreId) + } + + /** 5-field POSIX cron schedule. Literal wall-clock matching in the configured timezone. */ + fun schedule(schedule: BetaManagedAgentsScheduleParams?) = apply { body.schedule(schedule) } + + /** Alias for calling [Builder.schedule] with `schedule.orElse(null)`. */ + fun schedule(schedule: Optional) = + schedule(schedule.getOrNull()) + + /** + * Sets [Builder.schedule] to an arbitrary JSON value. + * + * You should usually call [Builder.schedule] with a well-typed + * [BetaManagedAgentsScheduleParams] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun schedule(schedule: JsonField) = apply { + body.schedule(schedule) + } + + /** + * Vault IDs for stored credentials the agent can use during sessions created from this + * deployment. Maximum 50. + */ + fun vaultIds(vaultIds: List) = apply { body.vaultIds(vaultIds) } + + /** + * Sets [Builder.vaultIds] to an arbitrary JSON value. + * + * You should usually call [Builder.vaultIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun vaultIds(vaultIds: JsonField>) = apply { body.vaultIds(vaultIds) } + + /** + * Adds a single [String] to [vaultIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVaultId(vaultId: String) = apply { body.addVaultId(vaultId) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DeploymentCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .agent() + * .environmentId() + * .initialEvents() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DeploymentCreateParams = + DeploymentCreateParams( + betas?.toImmutable(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = + Headers.builder() + .apply { + betas?.forEach { put("anthropic-beta", it.toString()) } + putAll(additionalHeaders) + } + .build() + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Request parameters for creating a `deployment`. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val agent: JsonField, + private val environmentId: JsonField, + private val initialEvents: JsonField>, + private val name: JsonField, + private val description: JsonField, + private val metadata: JsonField, + private val resources: JsonField>, + private val schedule: JsonField, + private val vaultIds: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("agent") @ExcludeMissing agent: JsonField = JsonMissing.of(), + @JsonProperty("environment_id") + @ExcludeMissing + environmentId: JsonField = JsonMissing.of(), + @JsonProperty("initial_events") + @ExcludeMissing + initialEvents: JsonField> = + JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("resources") + @ExcludeMissing + resources: JsonField> = JsonMissing.of(), + @JsonProperty("schedule") + @ExcludeMissing + schedule: JsonField = JsonMissing.of(), + @JsonProperty("vault_ids") + @ExcludeMissing + vaultIds: JsonField> = JsonMissing.of(), + ) : this( + agent, + environmentId, + initialEvents, + name, + description, + metadata, + resources, + schedule, + vaultIds, + mutableMapOf(), + ) + + /** + * Agent to deploy. Accepts the `agent` ID string, which pins the latest version, or an + * `agent` object with both id and version specified. The agent must exist and not be + * archived. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun agent(): Agent = agent.getRequired("agent") + + /** + * ID of the `environment` defining the container configuration for sessions created from + * this deployment. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun environmentId(): String = environmentId.getRequired("environment_id") + + /** + * Events to send to each session immediately after creation. At least 1, maximum 50. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun initialEvents(): List = + initialEvents.getRequired("initial_events") + + /** + * Human-readable name for the deployment. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Description of what the deployment does. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * Arbitrary key-value metadata. Maximum 16 pairs, keys up to 64 chars, values up to 512 + * chars. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * Resources (e.g. repositories, files) to mount into each session's container. Maximum 500. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun resources(): Optional> = resources.getOptional("resources") + + /** + * 5-field POSIX cron schedule. Literal wall-clock matching in the configured timezone. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun schedule(): Optional = schedule.getOptional("schedule") + + /** + * Vault IDs for stored credentials the agent can use during sessions created from this + * deployment. Maximum 50. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun vaultIds(): Optional> = vaultIds.getOptional("vault_ids") + + /** + * Returns the raw JSON value of [agent]. + * + * Unlike [agent], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("agent") @ExcludeMissing fun _agent(): JsonField = agent + + /** + * Returns the raw JSON value of [environmentId]. + * + * Unlike [environmentId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("environment_id") + @ExcludeMissing + fun _environmentId(): JsonField = environmentId + + /** + * Returns the raw JSON value of [initialEvents]. + * + * Unlike [initialEvents], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("initial_events") + @ExcludeMissing + fun _initialEvents(): JsonField> = + initialEvents + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [resources]. + * + * Unlike [resources], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("resources") + @ExcludeMissing + fun _resources(): JsonField> = resources + + /** + * Returns the raw JSON value of [schedule]. + * + * Unlike [schedule], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("schedule") + @ExcludeMissing + fun _schedule(): JsonField = schedule + + /** + * Returns the raw JSON value of [vaultIds]. + * + * Unlike [vaultIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("vault_ids") + @ExcludeMissing + fun _vaultIds(): JsonField> = vaultIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .agent() + * .environmentId() + * .initialEvents() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var agent: JsonField? = null + private var environmentId: JsonField? = null + private var initialEvents: + JsonField>? = + null + private var name: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var resources: JsonField>? = null + private var schedule: JsonField = JsonMissing.of() + private var vaultIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + agent = body.agent + environmentId = body.environmentId + initialEvents = + body.initialEvents.map { it.toMutableList() }.takeUnless { it.isMissing() } + name = body.name + description = body.description + metadata = body.metadata + resources = body.resources.map { it.toMutableList() }.takeUnless { it.isMissing() } + schedule = body.schedule + vaultIds = body.vaultIds.map { it.toMutableList() }.takeUnless { it.isMissing() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * Agent to deploy. Accepts the `agent` ID string, which pins the latest version, or an + * `agent` object with both id and version specified. The agent must exist and not be + * archived. + */ + fun agent(agent: Agent) = agent(JsonField.of(agent)) + + /** + * Sets [Builder.agent] to an arbitrary JSON value. + * + * You should usually call [Builder.agent] with a well-typed [Agent] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun agent(agent: JsonField) = apply { this.agent = agent } + + /** Alias for calling [agent] with `Agent.ofString(string)`. */ + fun agent(string: String) = agent(Agent.ofString(string)) + + /** + * Alias for calling [agent] with + * `Agent.ofBetaManagedAgentsAgentParams(betaManagedAgentsAgentParams)`. + */ + fun agent(betaManagedAgentsAgentParams: BetaManagedAgentsAgentParams) = + agent(Agent.ofBetaManagedAgentsAgentParams(betaManagedAgentsAgentParams)) + + /** + * ID of the `environment` defining the container configuration for sessions created + * from this deployment. + */ + fun environmentId(environmentId: String) = environmentId(JsonField.of(environmentId)) + + /** + * Sets [Builder.environmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.environmentId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun environmentId(environmentId: JsonField) = apply { + this.environmentId = environmentId + } + + /** + * Events to send to each session immediately after creation. At least 1, maximum 50. + */ + fun initialEvents(initialEvents: List) = + initialEvents(JsonField.of(initialEvents)) + + /** + * Sets [Builder.initialEvents] to an arbitrary JSON value. + * + * You should usually call [Builder.initialEvents] with a well-typed + * `List` value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun initialEvents( + initialEvents: JsonField> + ) = apply { this.initialEvents = initialEvents.map { it.toMutableList() } } + + /** + * Adds a single [BetaManagedAgentsDeploymentInitialEventParams] to [initialEvents]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addInitialEvent(initialEvent: BetaManagedAgentsDeploymentInitialEventParams) = + apply { + initialEvents = + (initialEvents ?: JsonField.of(mutableListOf())).also { + checkKnown("initialEvents", it).add(initialEvent) + } + } + + /** + * Alias for calling [addInitialEvent] with + * `BetaManagedAgentsDeploymentInitialEventParams.ofUserMessage(userMessage)`. + */ + fun addInitialEvent(userMessage: BetaManagedAgentsUserMessageEventParams) = + addInitialEvent( + BetaManagedAgentsDeploymentInitialEventParams.ofUserMessage(userMessage) + ) + + /** + * Alias for calling [addInitialEvent] with the following: + * ```java + * BetaManagedAgentsUserMessageEventParams.builder() + * .type(BetaManagedAgentsUserMessageEventParams.Type.USER_MESSAGE) + * .content(content) + * .build() + * ``` + */ + fun addUserMessageInitialEvent( + content: List + ) = + addInitialEvent( + BetaManagedAgentsUserMessageEventParams.builder() + .type(BetaManagedAgentsUserMessageEventParams.Type.USER_MESSAGE) + .content(content) + .build() + ) + + /** + * Alias for calling [addInitialEvent] with + * `BetaManagedAgentsDeploymentInitialEventParams.ofUserDefineOutcome(userDefineOutcome)`. + */ + fun addInitialEvent(userDefineOutcome: BetaManagedAgentsUserDefineOutcomeEventParams) = + addInitialEvent( + BetaManagedAgentsDeploymentInitialEventParams.ofUserDefineOutcome( + userDefineOutcome + ) + ) + + /** + * Alias for calling [addInitialEvent] with + * `BetaManagedAgentsDeploymentInitialEventParams.ofSystemMessage(systemMessage)`. + */ + fun addInitialEvent(systemMessage: BetaManagedAgentsSystemMessageEventParams) = + addInitialEvent( + BetaManagedAgentsDeploymentInitialEventParams.ofSystemMessage(systemMessage) + ) + + /** + * Alias for calling [addInitialEvent] with the following: + * ```java + * BetaManagedAgentsSystemMessageEventParams.builder() + * .type(BetaManagedAgentsSystemMessageEventParams.Type.SYSTEM_MESSAGE) + * .content(content) + * .build() + * ``` + */ + fun addSystemMessageInitialEvent(content: List) = + addInitialEvent( + BetaManagedAgentsSystemMessageEventParams.builder() + .type(BetaManagedAgentsSystemMessageEventParams.Type.SYSTEM_MESSAGE) + .content(content) + .build() + ) + + /** Human-readable name for the deployment. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Description of what the deployment does. */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** + * Arbitrary key-value metadata. Maximum 16 pairs, keys up to 64 chars, values up to 512 + * chars. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * Resources (e.g. repositories, files) to mount into each session's container. + * Maximum 500. + */ + fun resources(resources: List) = resources(JsonField.of(resources)) + + /** + * Sets [Builder.resources] to an arbitrary JSON value. + * + * You should usually call [Builder.resources] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun resources(resources: JsonField>) = apply { + this.resources = resources.map { it.toMutableList() } + } + + /** + * Adds a single [Resource] to [resources]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResource(resource: Resource) = apply { + resources = + (resources ?: JsonField.of(mutableListOf())).also { + checkKnown("resources", it).add(resource) + } + } + + /** + * Alias for calling [addResource] with `Resource.ofGitHubRepository(githubRepository)`. + */ + fun addResource(githubRepository: BetaManagedAgentsGitHubRepositoryResourceParams) = + addResource(Resource.ofGitHubRepository(githubRepository)) + + /** Alias for calling [addResource] with `Resource.ofFile(file)`. */ + fun addResource(file: BetaManagedAgentsFileResourceParams) = + addResource(Resource.ofFile(file)) + + /** + * Alias for calling [addResource] with the following: + * ```java + * BetaManagedAgentsFileResourceParams.builder() + * .type(BetaManagedAgentsFileResourceParams.Type.FILE) + * .fileId(fileId) + * .build() + * ``` + */ + fun addFileResource(fileId: String) = + addResource( + BetaManagedAgentsFileResourceParams.builder() + .type(BetaManagedAgentsFileResourceParams.Type.FILE) + .fileId(fileId) + .build() + ) + + /** Alias for calling [addResource] with `Resource.ofMemoryStore(memoryStore)`. */ + fun addResource(memoryStore: BetaManagedAgentsMemoryStoreResourceParam) = + addResource(Resource.ofMemoryStore(memoryStore)) + + /** + * Alias for calling [addResource] with the following: + * ```java + * BetaManagedAgentsMemoryStoreResourceParam.builder() + * .type(BetaManagedAgentsMemoryStoreResourceParam.Type.MEMORY_STORE) + * .memoryStoreId(memoryStoreId) + * .build() + * ``` + */ + fun addMemoryStoreResource(memoryStoreId: String) = + addResource( + BetaManagedAgentsMemoryStoreResourceParam.builder() + .type(BetaManagedAgentsMemoryStoreResourceParam.Type.MEMORY_STORE) + .memoryStoreId(memoryStoreId) + .build() + ) + + /** + * 5-field POSIX cron schedule. Literal wall-clock matching in the configured timezone. + */ + fun schedule(schedule: BetaManagedAgentsScheduleParams?) = + schedule(JsonField.ofNullable(schedule)) + + /** Alias for calling [Builder.schedule] with `schedule.orElse(null)`. */ + fun schedule(schedule: Optional) = + schedule(schedule.getOrNull()) + + /** + * Sets [Builder.schedule] to an arbitrary JSON value. + * + * You should usually call [Builder.schedule] with a well-typed + * [BetaManagedAgentsScheduleParams] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun schedule(schedule: JsonField) = apply { + this.schedule = schedule + } + + /** + * Vault IDs for stored credentials the agent can use during sessions created from this + * deployment. Maximum 50. + */ + fun vaultIds(vaultIds: List) = vaultIds(JsonField.of(vaultIds)) + + /** + * Sets [Builder.vaultIds] to an arbitrary JSON value. + * + * You should usually call [Builder.vaultIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun vaultIds(vaultIds: JsonField>) = apply { + this.vaultIds = vaultIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [vaultIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVaultId(vaultId: String) = apply { + vaultIds = + (vaultIds ?: JsonField.of(mutableListOf())).also { + checkKnown("vaultIds", it).add(vaultId) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .agent() + * .environmentId() + * .initialEvents() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("agent", agent), + checkRequired("environmentId", environmentId), + checkRequired("initialEvents", initialEvents).map { it.toImmutable() }, + checkRequired("name", name), + description, + metadata, + (resources ?: JsonMissing.of()).map { it.toImmutable() }, + schedule, + (vaultIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + agent().validate() + environmentId() + initialEvents().forEach { it.validate() } + name() + description() + metadata().ifPresent { it.validate() } + resources().ifPresent { it.forEach { it.validate() } } + schedule().ifPresent { it.validate() } + vaultIds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (agent.asKnown().getOrNull()?.validity() ?: 0) + + (if (environmentId.asKnown().isPresent) 1 else 0) + + (initialEvents.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (resources.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (schedule.asKnown().getOrNull()?.validity() ?: 0) + + (vaultIds.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + agent == other.agent && + environmentId == other.environmentId && + initialEvents == other.initialEvents && + name == other.name && + description == other.description && + metadata == other.metadata && + resources == other.resources && + schedule == other.schedule && + vaultIds == other.vaultIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + agent, + environmentId, + initialEvents, + name, + description, + metadata, + resources, + schedule, + vaultIds, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{agent=$agent, environmentId=$environmentId, initialEvents=$initialEvents, name=$name, description=$description, metadata=$metadata, resources=$resources, schedule=$schedule, vaultIds=$vaultIds, additionalProperties=$additionalProperties}" + } + + /** + * Agent to deploy. Accepts the `agent` ID string, which pins the latest version, or an `agent` + * object with both id and version specified. The agent must exist and not be archived. + */ + @JsonDeserialize(using = Agent.Deserializer::class) + @JsonSerialize(using = Agent.Serializer::class) + class Agent + private constructor( + private val string: String? = null, + private val betaManagedAgentsAgentParams: BetaManagedAgentsAgentParams? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + /** + * Specification for an Agent. Provide a specific `version` or use the short-form + * `agent="agent_id"` for the most recent version + */ + fun betaManagedAgentsAgentParams(): Optional = + Optional.ofNullable(betaManagedAgentsAgentParams) + + fun isString(): Boolean = string != null + + fun isBetaManagedAgentsAgentParams(): Boolean = betaManagedAgentsAgentParams != null + + fun asString(): String = string.getOrThrow("string") + + /** + * Specification for an Agent. Provide a specific `version` or use the short-form + * `agent="agent_id"` for the most recent version + */ + fun asBetaManagedAgentsAgentParams(): BetaManagedAgentsAgentParams = + betaManagedAgentsAgentParams.getOrThrow("betaManagedAgentsAgentParams") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.anthropic.core.JsonValue; + * import java.util.Optional; + * + * Optional result = agent.accept(new Agent.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws AnthropicInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + betaManagedAgentsAgentParams != null -> + visitor.visitBetaManagedAgentsAgentParams(betaManagedAgentsAgentParams) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Agent = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitBetaManagedAgentsAgentParams( + betaManagedAgentsAgentParams: BetaManagedAgentsAgentParams + ) { + betaManagedAgentsAgentParams.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitBetaManagedAgentsAgentParams( + betaManagedAgentsAgentParams: BetaManagedAgentsAgentParams + ) = betaManagedAgentsAgentParams.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Agent && + string == other.string && + betaManagedAgentsAgentParams == other.betaManagedAgentsAgentParams + } + + override fun hashCode(): Int = Objects.hash(string, betaManagedAgentsAgentParams) + + override fun toString(): String = + when { + string != null -> "Agent{string=$string}" + betaManagedAgentsAgentParams != null -> + "Agent{betaManagedAgentsAgentParams=$betaManagedAgentsAgentParams}" + _json != null -> "Agent{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Agent") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Agent(string = string) + + /** + * Specification for an Agent. Provide a specific `version` or use the short-form + * `agent="agent_id"` for the most recent version + */ + @JvmStatic + fun ofBetaManagedAgentsAgentParams( + betaManagedAgentsAgentParams: BetaManagedAgentsAgentParams + ) = Agent(betaManagedAgentsAgentParams = betaManagedAgentsAgentParams) + } + + /** An interface that defines how to map each variant of [Agent] to a value of type [T]. */ + interface Visitor { + + fun visitString(string: String): T + + /** + * Specification for an Agent. Provide a specific `version` or use the short-form + * `agent="agent_id"` for the most recent version + */ + fun visitBetaManagedAgentsAgentParams( + betaManagedAgentsAgentParams: BetaManagedAgentsAgentParams + ): T + + /** + * Maps an unknown variant of [Agent] to a value of type [T]. + * + * An instance of [Agent] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws AnthropicInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw AnthropicInvalidDataException("Unknown Agent: $json") + } + } + + internal class Deserializer : BaseDeserializer(Agent::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Agent { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { Agent(betaManagedAgentsAgentParams = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Agent(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Agent(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Agent::class) { + + override fun serialize( + value: Agent, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.betaManagedAgentsAgentParams != null -> + generator.writeObject(value.betaManagedAgentsAgentParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Agent") + } + } + } + } + + /** + * Arbitrary key-value metadata. Maximum 16 pairs, keys up to 64 chars, values up to 512 chars. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + /** Union of resources that can be mounted into a session. */ + @JsonDeserialize(using = Resource.Deserializer::class) + @JsonSerialize(using = Resource.Serializer::class) + class Resource + private constructor( + private val githubRepository: BetaManagedAgentsGitHubRepositoryResourceParams? = null, + private val file: BetaManagedAgentsFileResourceParams? = null, + private val memoryStore: BetaManagedAgentsMemoryStoreResourceParam? = null, + private val _json: JsonValue? = null, + ) { + + /** Mount a GitHub repository into the session's container. */ + fun githubRepository(): Optional = + Optional.ofNullable(githubRepository) + + /** Mount a file uploaded via the Files API into the session. */ + fun file(): Optional = Optional.ofNullable(file) + + /** Parameters for attaching a memory store to an agent session. */ + fun memoryStore(): Optional = + Optional.ofNullable(memoryStore) + + fun isGitHubRepository(): Boolean = githubRepository != null + + fun isFile(): Boolean = file != null + + fun isMemoryStore(): Boolean = memoryStore != null + + /** Mount a GitHub repository into the session's container. */ + fun asGitHubRepository(): BetaManagedAgentsGitHubRepositoryResourceParams = + githubRepository.getOrThrow("githubRepository") + + /** Mount a file uploaded via the Files API into the session. */ + fun asFile(): BetaManagedAgentsFileResourceParams = file.getOrThrow("file") + + /** Parameters for attaching a memory store to an agent session. */ + fun asMemoryStore(): BetaManagedAgentsMemoryStoreResourceParam = + memoryStore.getOrThrow("memoryStore") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.anthropic.core.JsonValue; + * import java.util.Optional; + * + * Optional result = resource.accept(new Resource.Visitor>() { + * @Override + * public Optional visitGitHubRepository(BetaManagedAgentsGitHubRepositoryResourceParams githubRepository) { + * return Optional.of(githubRepository.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws AnthropicInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + githubRepository != null -> visitor.visitGitHubRepository(githubRepository) + file != null -> visitor.visitFile(file) + memoryStore != null -> visitor.visitMemoryStore(memoryStore) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Resource = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitGitHubRepository( + githubRepository: BetaManagedAgentsGitHubRepositoryResourceParams + ) { + githubRepository.validate() + } + + override fun visitFile(file: BetaManagedAgentsFileResourceParams) { + file.validate() + } + + override fun visitMemoryStore( + memoryStore: BetaManagedAgentsMemoryStoreResourceParam + ) { + memoryStore.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitGitHubRepository( + githubRepository: BetaManagedAgentsGitHubRepositoryResourceParams + ) = githubRepository.validity() + + override fun visitFile(file: BetaManagedAgentsFileResourceParams) = + file.validity() + + override fun visitMemoryStore( + memoryStore: BetaManagedAgentsMemoryStoreResourceParam + ) = memoryStore.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Resource && + githubRepository == other.githubRepository && + file == other.file && + memoryStore == other.memoryStore + } + + override fun hashCode(): Int = Objects.hash(githubRepository, file, memoryStore) + + override fun toString(): String = + when { + githubRepository != null -> "Resource{githubRepository=$githubRepository}" + file != null -> "Resource{file=$file}" + memoryStore != null -> "Resource{memoryStore=$memoryStore}" + _json != null -> "Resource{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Resource") + } + + companion object { + + /** Mount a GitHub repository into the session's container. */ + @JvmStatic + fun ofGitHubRepository( + githubRepository: BetaManagedAgentsGitHubRepositoryResourceParams + ) = Resource(githubRepository = githubRepository) + + /** Mount a file uploaded via the Files API into the session. */ + @JvmStatic fun ofFile(file: BetaManagedAgentsFileResourceParams) = Resource(file = file) + + /** Parameters for attaching a memory store to an agent session. */ + @JvmStatic + fun ofMemoryStore(memoryStore: BetaManagedAgentsMemoryStoreResourceParam) = + Resource(memoryStore = memoryStore) + } + + /** + * An interface that defines how to map each variant of [Resource] to a value of type [T]. + */ + interface Visitor { + + /** Mount a GitHub repository into the session's container. */ + fun visitGitHubRepository( + githubRepository: BetaManagedAgentsGitHubRepositoryResourceParams + ): T + + /** Mount a file uploaded via the Files API into the session. */ + fun visitFile(file: BetaManagedAgentsFileResourceParams): T + + /** Parameters for attaching a memory store to an agent session. */ + fun visitMemoryStore(memoryStore: BetaManagedAgentsMemoryStoreResourceParam): T + + /** + * Maps an unknown variant of [Resource] to a value of type [T]. + * + * An instance of [Resource] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws AnthropicInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw AnthropicInvalidDataException("Unknown Resource: $json") + } + } + + internal class Deserializer : BaseDeserializer(Resource::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Resource { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "github_repository" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Resource(githubRepository = it, _json = json) } + ?: Resource(_json = json) + } + "file" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Resource(file = it, _json = json) } ?: Resource(_json = json) + } + "memory_store" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Resource(memoryStore = it, _json = json) } + ?: Resource(_json = json) + } + } + + return Resource(_json = json) + } + } + + internal class Serializer : BaseSerializer(Resource::class) { + + override fun serialize( + value: Resource, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.githubRepository != null -> generator.writeObject(value.githubRepository) + value.file != null -> generator.writeObject(value.file) + value.memoryStore != null -> generator.writeObject(value.memoryStore) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Resource") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DeploymentCreateParams && + betas == other.betas && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(betas, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "DeploymentCreateParams{betas=$betas, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentListPage.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentListPage.kt new file mode 100644 index 000000000..55e34b742 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentListPage.kt @@ -0,0 +1,133 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.AutoPager +import com.anthropic.core.Page +import com.anthropic.core.checkRequired +import com.anthropic.services.blocking.beta.DeploymentService +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** @see DeploymentService.list */ +class DeploymentListPage +private constructor( + private val service: DeploymentService, + private val params: DeploymentListParams, + private val response: DeploymentListPageResponse, +) : Page { + + /** + * Delegates to [DeploymentListPageResponse], but gracefully handles missing data. + * + * @see DeploymentListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [DeploymentListPageResponse], but gracefully handles missing data. + * + * @see DeploymentListPageResponse.nextPage + */ + fun nextPageRaw(): Optional = response._nextPage().getOptional("next_page") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextPageRaw().isPresent + + fun nextPageParams(): DeploymentListParams { + val nextCursor = + nextPageRaw().getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().page(nextCursor).build() + } + + override fun nextPage(): DeploymentListPage = service.list(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): DeploymentListParams = params + + /** The response that this page was parsed from. */ + fun response(): DeploymentListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DeploymentListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DeploymentListPage]. */ + class Builder internal constructor() { + + private var service: DeploymentService? = null + private var params: DeploymentListParams? = null + private var response: DeploymentListPageResponse? = null + + @JvmSynthetic + internal fun from(deploymentListPage: DeploymentListPage) = apply { + service = deploymentListPage.service + params = deploymentListPage.params + response = deploymentListPage.response + } + + fun service(service: DeploymentService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: DeploymentListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: DeploymentListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [DeploymentListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DeploymentListPage = + DeploymentListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DeploymentListPage && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = + "DeploymentListPage{service=$service, params=$params, response=$response}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentListPageAsync.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentListPageAsync.kt new file mode 100644 index 000000000..7f1fdb7a2 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentListPageAsync.kt @@ -0,0 +1,148 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.AutoPagerAsync +import com.anthropic.core.PageAsync +import com.anthropic.core.checkRequired +import com.anthropic.services.async.beta.DeploymentServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import kotlin.jvm.optionals.getOrNull + +/** @see DeploymentServiceAsync.list */ +class DeploymentListPageAsync +private constructor( + private val service: DeploymentServiceAsync, + private val streamHandlerExecutor: Executor, + private val params: DeploymentListParams, + private val response: DeploymentListPageResponse, +) : PageAsync { + + /** + * Delegates to [DeploymentListPageResponse], but gracefully handles missing data. + * + * @see DeploymentListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [DeploymentListPageResponse], but gracefully handles missing data. + * + * @see DeploymentListPageResponse.nextPage + */ + fun nextPageRaw(): Optional = response._nextPage().getOptional("next_page") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextPageRaw().isPresent + + fun nextPageParams(): DeploymentListParams { + val nextCursor = + nextPageRaw().getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().page(nextCursor).build() + } + + override fun nextPage(): CompletableFuture = + service.list(nextPageParams()) + + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) + + /** The parameters that were used to request this page. */ + fun params(): DeploymentListParams = params + + /** The response that this page was parsed from. */ + fun response(): DeploymentListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DeploymentListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DeploymentListPageAsync]. */ + class Builder internal constructor() { + + private var service: DeploymentServiceAsync? = null + private var streamHandlerExecutor: Executor? = null + private var params: DeploymentListParams? = null + private var response: DeploymentListPageResponse? = null + + @JvmSynthetic + internal fun from(deploymentListPageAsync: DeploymentListPageAsync) = apply { + service = deploymentListPageAsync.service + streamHandlerExecutor = deploymentListPageAsync.streamHandlerExecutor + params = deploymentListPageAsync.params + response = deploymentListPageAsync.response + } + + fun service(service: DeploymentServiceAsync) = apply { this.service = service } + + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + + /** The parameters that were used to request this page. */ + fun params(params: DeploymentListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: DeploymentListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [DeploymentListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DeploymentListPageAsync = + DeploymentListPageAsync( + checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DeploymentListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) + + override fun toString() = + "DeploymentListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentListPageResponse.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentListPageResponse.kt new file mode 100644 index 000000000..63e497ad6 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentListPageResponse.kt @@ -0,0 +1,247 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkKnown +import com.anthropic.core.checkRequired +import com.anthropic.core.toImmutable +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Paginated list of deployments. */ +class DeploymentListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField>, + private val nextPage: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + data: JsonField> = JsonMissing.of(), + @JsonProperty("next_page") @ExcludeMissing nextPage: JsonField = JsonMissing.of(), + ) : this(data, nextPage, mutableMapOf()) + + /** + * List of deployments. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): List = data.getRequired("data") + + /** + * Opaque cursor for the next page. Null when no more results. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun nextPage(): Optional = nextPage.getOptional("next_page") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") + @ExcludeMissing + fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [nextPage]. + * + * Unlike [nextPage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_page") @ExcludeMissing fun _nextPage(): JsonField = nextPage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DeploymentListPageResponse]. + * + * The following fields are required: + * ```java + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DeploymentListPageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var nextPage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(deploymentListPageResponse: DeploymentListPageResponse) = apply { + data = + deploymentListPageResponse.data + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + nextPage = deploymentListPageResponse.nextPage + additionalProperties = deploymentListPageResponse.additionalProperties.toMutableMap() + } + + /** List of deployments. */ + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [BetaManagedAgentsDeployment] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: BetaManagedAgentsDeployment) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + /** Opaque cursor for the next page. Null when no more results. */ + fun nextPage(nextPage: String?) = nextPage(JsonField.ofNullable(nextPage)) + + /** Alias for calling [Builder.nextPage] with `nextPage.orElse(null)`. */ + fun nextPage(nextPage: Optional) = nextPage(nextPage.getOrNull()) + + /** + * Sets [Builder.nextPage] to an arbitrary JSON value. + * + * You should usually call [Builder.nextPage] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun nextPage(nextPage: JsonField) = apply { this.nextPage = nextPage } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DeploymentListPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DeploymentListPageResponse = + DeploymentListPageResponse( + checkRequired("data", data).map { it.toImmutable() }, + nextPage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): DeploymentListPageResponse = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + nextPage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (nextPage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DeploymentListPageResponse && + data == other.data && + nextPage == other.nextPage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, nextPage, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DeploymentListPageResponse{data=$data, nextPage=$nextPage, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentListParams.kt new file mode 100644 index 000000000..337d140ca --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentListParams.kt @@ -0,0 +1,368 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.Params +import com.anthropic.core.http.Headers +import com.anthropic.core.http.QueryParams +import com.anthropic.core.toImmutable +import com.anthropic.models.beta.AnthropicBeta +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** List Deployments */ +class DeploymentListParams +private constructor( + private val agentId: String?, + private val createdAtGte: OffsetDateTime?, + private val createdAtLte: OffsetDateTime?, + private val includeArchived: Boolean?, + private val limit: Int?, + private val page: String?, + private val status: BetaManagedAgentsDeploymentStatus?, + private val betas: List?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Filter by agent ID. */ + fun agentId(): Optional = Optional.ofNullable(agentId) + + /** Return deployments created at or after this time (inclusive). */ + fun createdAtGte(): Optional = Optional.ofNullable(createdAtGte) + + /** Return deployments created at or before this time (inclusive). */ + fun createdAtLte(): Optional = Optional.ofNullable(createdAtLte) + + /** When true, includes archived deployments. Default: false (exclude archived). */ + fun includeArchived(): Optional = Optional.ofNullable(includeArchived) + + /** Maximum results per page. Default 20, maximum 100. */ + fun limit(): Optional = Optional.ofNullable(limit) + + /** Opaque pagination cursor. */ + fun page(): Optional = Optional.ofNullable(page) + + /** + * Filter by status: active or paused. Omit for both. To include archived deployments, use + * include_archived instead; the two cannot be combined. + */ + fun status(): Optional = Optional.ofNullable(status) + + /** Optional header to specify the beta version(s) you want to use. */ + fun betas(): Optional> = Optional.ofNullable(betas) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): DeploymentListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [DeploymentListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DeploymentListParams]. */ + class Builder internal constructor() { + + private var agentId: String? = null + private var createdAtGte: OffsetDateTime? = null + private var createdAtLte: OffsetDateTime? = null + private var includeArchived: Boolean? = null + private var limit: Int? = null + private var page: String? = null + private var status: BetaManagedAgentsDeploymentStatus? = null + private var betas: MutableList? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(deploymentListParams: DeploymentListParams) = apply { + agentId = deploymentListParams.agentId + createdAtGte = deploymentListParams.createdAtGte + createdAtLte = deploymentListParams.createdAtLte + includeArchived = deploymentListParams.includeArchived + limit = deploymentListParams.limit + page = deploymentListParams.page + status = deploymentListParams.status + betas = deploymentListParams.betas?.toMutableList() + additionalHeaders = deploymentListParams.additionalHeaders.toBuilder() + additionalQueryParams = deploymentListParams.additionalQueryParams.toBuilder() + } + + /** Filter by agent ID. */ + fun agentId(agentId: String?) = apply { this.agentId = agentId } + + /** Alias for calling [Builder.agentId] with `agentId.orElse(null)`. */ + fun agentId(agentId: Optional) = agentId(agentId.getOrNull()) + + /** Return deployments created at or after this time (inclusive). */ + fun createdAtGte(createdAtGte: OffsetDateTime?) = apply { this.createdAtGte = createdAtGte } + + /** Alias for calling [Builder.createdAtGte] with `createdAtGte.orElse(null)`. */ + fun createdAtGte(createdAtGte: Optional) = + createdAtGte(createdAtGte.getOrNull()) + + /** Return deployments created at or before this time (inclusive). */ + fun createdAtLte(createdAtLte: OffsetDateTime?) = apply { this.createdAtLte = createdAtLte } + + /** Alias for calling [Builder.createdAtLte] with `createdAtLte.orElse(null)`. */ + fun createdAtLte(createdAtLte: Optional) = + createdAtLte(createdAtLte.getOrNull()) + + /** When true, includes archived deployments. Default: false (exclude archived). */ + fun includeArchived(includeArchived: Boolean?) = apply { + this.includeArchived = includeArchived + } + + /** + * Alias for [Builder.includeArchived]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeArchived(includeArchived: Boolean) = includeArchived(includeArchived as Boolean?) + + /** Alias for calling [Builder.includeArchived] with `includeArchived.orElse(null)`. */ + fun includeArchived(includeArchived: Optional) = + includeArchived(includeArchived.getOrNull()) + + /** Maximum results per page. Default 20, maximum 100. */ + fun limit(limit: Int?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Int) = limit(limit as Int?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + /** Opaque pagination cursor. */ + fun page(page: String?) = apply { this.page = page } + + /** Alias for calling [Builder.page] with `page.orElse(null)`. */ + fun page(page: Optional) = page(page.getOrNull()) + + /** + * Filter by status: active or paused. Omit for both. To include archived deployments, use + * include_archived instead; the two cannot be combined. + */ + fun status(status: BetaManagedAgentsDeploymentStatus?) = apply { this.status = status } + + /** Alias for calling [Builder.status] with `status.orElse(null)`. */ + fun status(status: Optional) = status(status.getOrNull()) + + /** Optional header to specify the beta version(s) you want to use. */ + fun betas(betas: List?) = apply { this.betas = betas?.toMutableList() } + + /** Alias for calling [Builder.betas] with `betas.orElse(null)`. */ + fun betas(betas: Optional>) = betas(betas.getOrNull()) + + /** + * Adds a single [AnthropicBeta] to [betas]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBeta(beta: AnthropicBeta) = apply { + betas = (betas ?: mutableListOf()).apply { add(beta) } + } + + /** + * Sets [addBeta] to an arbitrary [String]. + * + * You should usually call [addBeta] with a well-typed [AnthropicBeta] constant instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun addBeta(value: String) = addBeta(AnthropicBeta.of(value)) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DeploymentListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DeploymentListParams = + DeploymentListParams( + agentId, + createdAtGte, + createdAtLte, + includeArchived, + limit, + page, + status, + betas?.toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = + Headers.builder() + .apply { + betas?.forEach { put("anthropic-beta", it.toString()) } + putAll(additionalHeaders) + } + .build() + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + agentId?.let { put("agent_id", it) } + createdAtGte?.let { + put("created_at[gte]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + createdAtLte?.let { + put("created_at[lte]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + includeArchived?.let { put("include_archived", it.toString()) } + limit?.let { put("limit", it.toString()) } + page?.let { put("page", it) } + status?.let { put("status", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DeploymentListParams && + agentId == other.agentId && + createdAtGte == other.createdAtGte && + createdAtLte == other.createdAtLte && + includeArchived == other.includeArchived && + limit == other.limit && + page == other.page && + status == other.status && + betas == other.betas && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + agentId, + createdAtGte, + createdAtLte, + includeArchived, + limit, + page, + status, + betas, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "DeploymentListParams{agentId=$agentId, createdAtGte=$createdAtGte, createdAtLte=$createdAtLte, includeArchived=$includeArchived, limit=$limit, page=$page, status=$status, betas=$betas, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentPauseParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentPauseParams.kt new file mode 100644 index 000000000..34ed1bc1f --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentPauseParams.kt @@ -0,0 +1,274 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.JsonValue +import com.anthropic.core.Params +import com.anthropic.core.http.Headers +import com.anthropic.core.http.QueryParams +import com.anthropic.core.toImmutable +import com.anthropic.models.beta.AnthropicBeta +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Pause Deployment */ +class DeploymentPauseParams +private constructor( + private val deploymentId: String?, + private val betas: List?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun deploymentId(): Optional = Optional.ofNullable(deploymentId) + + /** Optional header to specify the beta version(s) you want to use. */ + fun betas(): Optional> = Optional.ofNullable(betas) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): DeploymentPauseParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [DeploymentPauseParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DeploymentPauseParams]. */ + class Builder internal constructor() { + + private var deploymentId: String? = null + private var betas: MutableList? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(deploymentPauseParams: DeploymentPauseParams) = apply { + deploymentId = deploymentPauseParams.deploymentId + betas = deploymentPauseParams.betas?.toMutableList() + additionalHeaders = deploymentPauseParams.additionalHeaders.toBuilder() + additionalQueryParams = deploymentPauseParams.additionalQueryParams.toBuilder() + additionalBodyProperties = deploymentPauseParams.additionalBodyProperties.toMutableMap() + } + + fun deploymentId(deploymentId: String?) = apply { this.deploymentId = deploymentId } + + /** Alias for calling [Builder.deploymentId] with `deploymentId.orElse(null)`. */ + fun deploymentId(deploymentId: Optional) = deploymentId(deploymentId.getOrNull()) + + /** Optional header to specify the beta version(s) you want to use. */ + fun betas(betas: List?) = apply { this.betas = betas?.toMutableList() } + + /** Alias for calling [Builder.betas] with `betas.orElse(null)`. */ + fun betas(betas: Optional>) = betas(betas.getOrNull()) + + /** + * Adds a single [AnthropicBeta] to [betas]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBeta(beta: AnthropicBeta) = apply { + betas = (betas ?: mutableListOf()).apply { add(beta) } + } + + /** + * Sets [addBeta] to an arbitrary [String]. + * + * You should usually call [addBeta] with a well-typed [AnthropicBeta] constant instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun addBeta(value: String) = addBeta(AnthropicBeta.of(value)) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [DeploymentPauseParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DeploymentPauseParams = + DeploymentPauseParams( + deploymentId, + betas?.toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> deploymentId ?: "" + else -> "" + } + + override fun _headers(): Headers = + Headers.builder() + .apply { + betas?.forEach { put("anthropic-beta", it.toString()) } + putAll(additionalHeaders) + } + .build() + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DeploymentPauseParams && + deploymentId == other.deploymentId && + betas == other.betas && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + deploymentId, + betas, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "DeploymentPauseParams{deploymentId=$deploymentId, betas=$betas, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentRetrieveParams.kt new file mode 100644 index 000000000..2dec54722 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentRetrieveParams.kt @@ -0,0 +1,234 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.Params +import com.anthropic.core.http.Headers +import com.anthropic.core.http.QueryParams +import com.anthropic.core.toImmutable +import com.anthropic.models.beta.AnthropicBeta +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get Deployment */ +class DeploymentRetrieveParams +private constructor( + private val deploymentId: String?, + private val betas: List?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun deploymentId(): Optional = Optional.ofNullable(deploymentId) + + /** Optional header to specify the beta version(s) you want to use. */ + fun betas(): Optional> = Optional.ofNullable(betas) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): DeploymentRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [DeploymentRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DeploymentRetrieveParams]. */ + class Builder internal constructor() { + + private var deploymentId: String? = null + private var betas: MutableList? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(deploymentRetrieveParams: DeploymentRetrieveParams) = apply { + deploymentId = deploymentRetrieveParams.deploymentId + betas = deploymentRetrieveParams.betas?.toMutableList() + additionalHeaders = deploymentRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = deploymentRetrieveParams.additionalQueryParams.toBuilder() + } + + fun deploymentId(deploymentId: String?) = apply { this.deploymentId = deploymentId } + + /** Alias for calling [Builder.deploymentId] with `deploymentId.orElse(null)`. */ + fun deploymentId(deploymentId: Optional) = deploymentId(deploymentId.getOrNull()) + + /** Optional header to specify the beta version(s) you want to use. */ + fun betas(betas: List?) = apply { this.betas = betas?.toMutableList() } + + /** Alias for calling [Builder.betas] with `betas.orElse(null)`. */ + fun betas(betas: Optional>) = betas(betas.getOrNull()) + + /** + * Adds a single [AnthropicBeta] to [betas]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBeta(beta: AnthropicBeta) = apply { + betas = (betas ?: mutableListOf()).apply { add(beta) } + } + + /** + * Sets [addBeta] to an arbitrary [String]. + * + * You should usually call [addBeta] with a well-typed [AnthropicBeta] constant instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun addBeta(value: String) = addBeta(AnthropicBeta.of(value)) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DeploymentRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DeploymentRetrieveParams = + DeploymentRetrieveParams( + deploymentId, + betas?.toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> deploymentId ?: "" + else -> "" + } + + override fun _headers(): Headers = + Headers.builder() + .apply { + betas?.forEach { put("anthropic-beta", it.toString()) } + putAll(additionalHeaders) + } + .build() + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DeploymentRetrieveParams && + deploymentId == other.deploymentId && + betas == other.betas && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(deploymentId, betas, additionalHeaders, additionalQueryParams) + + override fun toString() = + "DeploymentRetrieveParams{deploymentId=$deploymentId, betas=$betas, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentRunParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentRunParams.kt new file mode 100644 index 000000000..3c847a59f --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentRunParams.kt @@ -0,0 +1,274 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.JsonValue +import com.anthropic.core.Params +import com.anthropic.core.http.Headers +import com.anthropic.core.http.QueryParams +import com.anthropic.core.toImmutable +import com.anthropic.models.beta.AnthropicBeta +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Run Deployment Now */ +class DeploymentRunParams +private constructor( + private val deploymentId: String?, + private val betas: List?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun deploymentId(): Optional = Optional.ofNullable(deploymentId) + + /** Optional header to specify the beta version(s) you want to use. */ + fun betas(): Optional> = Optional.ofNullable(betas) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): DeploymentRunParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [DeploymentRunParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DeploymentRunParams]. */ + class Builder internal constructor() { + + private var deploymentId: String? = null + private var betas: MutableList? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(deploymentRunParams: DeploymentRunParams) = apply { + deploymentId = deploymentRunParams.deploymentId + betas = deploymentRunParams.betas?.toMutableList() + additionalHeaders = deploymentRunParams.additionalHeaders.toBuilder() + additionalQueryParams = deploymentRunParams.additionalQueryParams.toBuilder() + additionalBodyProperties = deploymentRunParams.additionalBodyProperties.toMutableMap() + } + + fun deploymentId(deploymentId: String?) = apply { this.deploymentId = deploymentId } + + /** Alias for calling [Builder.deploymentId] with `deploymentId.orElse(null)`. */ + fun deploymentId(deploymentId: Optional) = deploymentId(deploymentId.getOrNull()) + + /** Optional header to specify the beta version(s) you want to use. */ + fun betas(betas: List?) = apply { this.betas = betas?.toMutableList() } + + /** Alias for calling [Builder.betas] with `betas.orElse(null)`. */ + fun betas(betas: Optional>) = betas(betas.getOrNull()) + + /** + * Adds a single [AnthropicBeta] to [betas]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBeta(beta: AnthropicBeta) = apply { + betas = (betas ?: mutableListOf()).apply { add(beta) } + } + + /** + * Sets [addBeta] to an arbitrary [String]. + * + * You should usually call [addBeta] with a well-typed [AnthropicBeta] constant instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun addBeta(value: String) = addBeta(AnthropicBeta.of(value)) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [DeploymentRunParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DeploymentRunParams = + DeploymentRunParams( + deploymentId, + betas?.toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> deploymentId ?: "" + else -> "" + } + + override fun _headers(): Headers = + Headers.builder() + .apply { + betas?.forEach { put("anthropic-beta", it.toString()) } + putAll(additionalHeaders) + } + .build() + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DeploymentRunParams && + deploymentId == other.deploymentId && + betas == other.betas && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + deploymentId, + betas, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "DeploymentRunParams{deploymentId=$deploymentId, betas=$betas, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentUnpauseParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentUnpauseParams.kt new file mode 100644 index 000000000..14504f93c --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentUnpauseParams.kt @@ -0,0 +1,275 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.JsonValue +import com.anthropic.core.Params +import com.anthropic.core.http.Headers +import com.anthropic.core.http.QueryParams +import com.anthropic.core.toImmutable +import com.anthropic.models.beta.AnthropicBeta +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Unpause Deployment */ +class DeploymentUnpauseParams +private constructor( + private val deploymentId: String?, + private val betas: List?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun deploymentId(): Optional = Optional.ofNullable(deploymentId) + + /** Optional header to specify the beta version(s) you want to use. */ + fun betas(): Optional> = Optional.ofNullable(betas) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): DeploymentUnpauseParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [DeploymentUnpauseParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DeploymentUnpauseParams]. */ + class Builder internal constructor() { + + private var deploymentId: String? = null + private var betas: MutableList? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(deploymentUnpauseParams: DeploymentUnpauseParams) = apply { + deploymentId = deploymentUnpauseParams.deploymentId + betas = deploymentUnpauseParams.betas?.toMutableList() + additionalHeaders = deploymentUnpauseParams.additionalHeaders.toBuilder() + additionalQueryParams = deploymentUnpauseParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + deploymentUnpauseParams.additionalBodyProperties.toMutableMap() + } + + fun deploymentId(deploymentId: String?) = apply { this.deploymentId = deploymentId } + + /** Alias for calling [Builder.deploymentId] with `deploymentId.orElse(null)`. */ + fun deploymentId(deploymentId: Optional) = deploymentId(deploymentId.getOrNull()) + + /** Optional header to specify the beta version(s) you want to use. */ + fun betas(betas: List?) = apply { this.betas = betas?.toMutableList() } + + /** Alias for calling [Builder.betas] with `betas.orElse(null)`. */ + fun betas(betas: Optional>) = betas(betas.getOrNull()) + + /** + * Adds a single [AnthropicBeta] to [betas]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBeta(beta: AnthropicBeta) = apply { + betas = (betas ?: mutableListOf()).apply { add(beta) } + } + + /** + * Sets [addBeta] to an arbitrary [String]. + * + * You should usually call [addBeta] with a well-typed [AnthropicBeta] constant instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun addBeta(value: String) = addBeta(AnthropicBeta.of(value)) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [DeploymentUnpauseParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DeploymentUnpauseParams = + DeploymentUnpauseParams( + deploymentId, + betas?.toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> deploymentId ?: "" + else -> "" + } + + override fun _headers(): Headers = + Headers.builder() + .apply { + betas?.forEach { put("anthropic-beta", it.toString()) } + putAll(additionalHeaders) + } + .build() + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DeploymentUnpauseParams && + deploymentId == other.deploymentId && + betas == other.betas && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + deploymentId, + betas, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "DeploymentUnpauseParams{deploymentId=$deploymentId, betas=$betas, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentUpdateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentUpdateParams.kt new file mode 100644 index 000000000..797b46995 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentUpdateParams.kt @@ -0,0 +1,2062 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.BaseDeserializer +import com.anthropic.core.BaseSerializer +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.Params +import com.anthropic.core.allMaxBy +import com.anthropic.core.checkKnown +import com.anthropic.core.getOrThrow +import com.anthropic.core.http.Headers +import com.anthropic.core.http.QueryParams +import com.anthropic.core.toImmutable +import com.anthropic.errors.AnthropicInvalidDataException +import com.anthropic.models.beta.AnthropicBeta +import com.anthropic.models.beta.sessions.BetaManagedAgentsAgentParams +import com.anthropic.models.beta.sessions.BetaManagedAgentsFileResourceParams +import com.anthropic.models.beta.sessions.BetaManagedAgentsGitHubRepositoryResourceParams +import com.anthropic.models.beta.sessions.BetaManagedAgentsMemoryStoreResourceParam +import com.anthropic.models.beta.sessions.BetaManagedAgentsSystemContentBlock +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsSystemMessageEventParams +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsUserDefineOutcomeEventParams +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsUserMessageEventParams +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update Deployment */ +class DeploymentUpdateParams +private constructor( + private val deploymentId: String?, + private val betas: List?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun deploymentId(): Optional = Optional.ofNullable(deploymentId) + + /** Optional header to specify the beta version(s) you want to use. */ + fun betas(): Optional> = Optional.ofNullable(betas) + + /** + * Agent to deploy. Accepts the `agent` ID string, which re-pins to the latest version, or an + * `agent` object with both id and version specified. Omit to preserve. Cannot be cleared. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun agent(): Optional = body.agent() + + /** + * Description. Omit to preserve; send empty string or null to clear. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun description(): Optional = body.description() + + /** + * ID of the `environment` where sessions run. Omit to preserve. Cannot be cleared. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun environmentId(): Optional = body.environmentId() + + /** + * Initial events. Full replacement. Omit to preserve. Cannot be cleared. At least 1, + * maximum 50. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun initialEvents(): Optional> = + body.initialEvents() + + /** + * Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omit the field + * to preserve. The stored bag is limited to 16 keys (up to 64 chars each) with values up to 512 + * chars. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = body.metadata() + + /** + * Human-readable name. Must be non-empty. Omit to preserve. Cannot be cleared. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): Optional = body.name() + + /** + * Session resources. Full replacement. Omit to preserve; send empty array or null to clear. + * Maximum 500. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun resources(): Optional> = body.resources() + + /** + * 5-field POSIX cron schedule. Literal wall-clock matching in the configured timezone. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun schedule(): Optional = body.schedule() + + /** + * Vault IDs. Full replacement. Omit to preserve; send empty array or null to clear. Maximum 50. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun vaultIds(): Optional> = body.vaultIds() + + /** + * Returns the raw JSON value of [agent]. + * + * Unlike [agent], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _agent(): JsonField = body._agent() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField = body._description() + + /** + * Returns the raw JSON value of [environmentId]. + * + * Unlike [environmentId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _environmentId(): JsonField = body._environmentId() + + /** + * Returns the raw JSON value of [initialEvents]. + * + * Unlike [initialEvents], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _initialEvents(): JsonField> = + body._initialEvents() + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _metadata(): JsonField = body._metadata() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField = body._name() + + /** + * Returns the raw JSON value of [resources]. + * + * Unlike [resources], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _resources(): JsonField> = body._resources() + + /** + * Returns the raw JSON value of [schedule]. + * + * Unlike [schedule], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _schedule(): JsonField = body._schedule() + + /** + * Returns the raw JSON value of [vaultIds]. + * + * Unlike [vaultIds], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _vaultIds(): JsonField> = body._vaultIds() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): DeploymentUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [DeploymentUpdateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DeploymentUpdateParams]. */ + class Builder internal constructor() { + + private var deploymentId: String? = null + private var betas: MutableList? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(deploymentUpdateParams: DeploymentUpdateParams) = apply { + deploymentId = deploymentUpdateParams.deploymentId + betas = deploymentUpdateParams.betas?.toMutableList() + body = deploymentUpdateParams.body.toBuilder() + additionalHeaders = deploymentUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = deploymentUpdateParams.additionalQueryParams.toBuilder() + } + + fun deploymentId(deploymentId: String?) = apply { this.deploymentId = deploymentId } + + /** Alias for calling [Builder.deploymentId] with `deploymentId.orElse(null)`. */ + fun deploymentId(deploymentId: Optional) = deploymentId(deploymentId.getOrNull()) + + /** Optional header to specify the beta version(s) you want to use. */ + fun betas(betas: List?) = apply { this.betas = betas?.toMutableList() } + + /** Alias for calling [Builder.betas] with `betas.orElse(null)`. */ + fun betas(betas: Optional>) = betas(betas.getOrNull()) + + /** + * Adds a single [AnthropicBeta] to [betas]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBeta(beta: AnthropicBeta) = apply { + betas = (betas ?: mutableListOf()).apply { add(beta) } + } + + /** + * Sets [addBeta] to an arbitrary [String]. + * + * You should usually call [addBeta] with a well-typed [AnthropicBeta] constant instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun addBeta(value: String) = addBeta(AnthropicBeta.of(value)) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [agent] + * - [description] + * - [environmentId] + * - [initialEvents] + * - [metadata] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * Agent to deploy. Accepts the `agent` ID string, which re-pins to the latest version, or + * an `agent` object with both id and version specified. Omit to preserve. Cannot be + * cleared. + */ + fun agent(agent: Agent) = apply { body.agent(agent) } + + /** + * Sets [Builder.agent] to an arbitrary JSON value. + * + * You should usually call [Builder.agent] with a well-typed [Agent] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun agent(agent: JsonField) = apply { body.agent(agent) } + + /** Alias for calling [agent] with `Agent.ofString(string)`. */ + fun agent(string: String) = apply { body.agent(string) } + + /** + * Alias for calling [agent] with + * `Agent.ofBetaManagedAgentsAgentParams(betaManagedAgentsAgentParams)`. + */ + fun agent(betaManagedAgentsAgentParams: BetaManagedAgentsAgentParams) = apply { + body.agent(betaManagedAgentsAgentParams) + } + + /** Description. Omit to preserve; send empty string or null to clear. */ + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { body.description(description) } + + /** ID of the `environment` where sessions run. Omit to preserve. Cannot be cleared. */ + fun environmentId(environmentId: String) = apply { body.environmentId(environmentId) } + + /** + * Sets [Builder.environmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.environmentId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun environmentId(environmentId: JsonField) = apply { + body.environmentId(environmentId) + } + + /** + * Initial events. Full replacement. Omit to preserve. Cannot be cleared. At least 1, + * maximum 50. + */ + fun initialEvents(initialEvents: List) = + apply { + body.initialEvents(initialEvents) + } + + /** + * Sets [Builder.initialEvents] to an arbitrary JSON value. + * + * You should usually call [Builder.initialEvents] with a well-typed + * `List` value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun initialEvents( + initialEvents: JsonField> + ) = apply { body.initialEvents(initialEvents) } + + /** + * Adds a single [BetaManagedAgentsDeploymentInitialEventParams] to [initialEvents]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addInitialEvent(initialEvent: BetaManagedAgentsDeploymentInitialEventParams) = apply { + body.addInitialEvent(initialEvent) + } + + /** + * Alias for calling [addInitialEvent] with + * `BetaManagedAgentsDeploymentInitialEventParams.ofUserMessage(userMessage)`. + */ + fun addInitialEvent(userMessage: BetaManagedAgentsUserMessageEventParams) = apply { + body.addInitialEvent(userMessage) + } + + /** + * Alias for calling [addInitialEvent] with the following: + * ```java + * BetaManagedAgentsUserMessageEventParams.builder() + * .type(BetaManagedAgentsUserMessageEventParams.Type.USER_MESSAGE) + * .content(content) + * .build() + * ``` + */ + fun addUserMessageInitialEvent( + content: List + ) = apply { body.addUserMessageInitialEvent(content) } + + /** + * Alias for calling [addInitialEvent] with + * `BetaManagedAgentsDeploymentInitialEventParams.ofUserDefineOutcome(userDefineOutcome)`. + */ + fun addInitialEvent(userDefineOutcome: BetaManagedAgentsUserDefineOutcomeEventParams) = + apply { + body.addInitialEvent(userDefineOutcome) + } + + /** + * Alias for calling [addInitialEvent] with + * `BetaManagedAgentsDeploymentInitialEventParams.ofSystemMessage(systemMessage)`. + */ + fun addInitialEvent(systemMessage: BetaManagedAgentsSystemMessageEventParams) = apply { + body.addInitialEvent(systemMessage) + } + + /** + * Alias for calling [addInitialEvent] with the following: + * ```java + * BetaManagedAgentsSystemMessageEventParams.builder() + * .type(BetaManagedAgentsSystemMessageEventParams.Type.SYSTEM_MESSAGE) + * .content(content) + * .build() + * ``` + */ + fun addSystemMessageInitialEvent(content: List) = + apply { + body.addSystemMessageInitialEvent(content) + } + + /** + * Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omit the + * field to preserve. The stored bag is limited to 16 keys (up to 64 chars each) with values + * up to 512 chars. + */ + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + + /** Human-readable name. Must be non-empty. Omit to preserve. Cannot be cleared. */ + fun name(name: String) = apply { body.name(name) } + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { body.name(name) } + + /** + * Session resources. Full replacement. Omit to preserve; send empty array or null to clear. + * Maximum 500. + */ + fun resources(resources: List?) = apply { body.resources(resources) } + + /** Alias for calling [Builder.resources] with `resources.orElse(null)`. */ + fun resources(resources: Optional>) = resources(resources.getOrNull()) + + /** + * Sets [Builder.resources] to an arbitrary JSON value. + * + * You should usually call [Builder.resources] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun resources(resources: JsonField>) = apply { body.resources(resources) } + + /** + * Adds a single [Resource] to [resources]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResource(resource: Resource) = apply { body.addResource(resource) } + + /** Alias for calling [addResource] with `Resource.ofGitHubRepository(githubRepository)`. */ + fun addResource(githubRepository: BetaManagedAgentsGitHubRepositoryResourceParams) = apply { + body.addResource(githubRepository) + } + + /** Alias for calling [addResource] with `Resource.ofFile(file)`. */ + fun addResource(file: BetaManagedAgentsFileResourceParams) = apply { + body.addResource(file) + } + + /** + * Alias for calling [addResource] with the following: + * ```java + * BetaManagedAgentsFileResourceParams.builder() + * .type(BetaManagedAgentsFileResourceParams.Type.FILE) + * .fileId(fileId) + * .build() + * ``` + */ + fun addFileResource(fileId: String) = apply { body.addFileResource(fileId) } + + /** Alias for calling [addResource] with `Resource.ofMemoryStore(memoryStore)`. */ + fun addResource(memoryStore: BetaManagedAgentsMemoryStoreResourceParam) = apply { + body.addResource(memoryStore) + } + + /** + * Alias for calling [addResource] with the following: + * ```java + * BetaManagedAgentsMemoryStoreResourceParam.builder() + * .type(BetaManagedAgentsMemoryStoreResourceParam.Type.MEMORY_STORE) + * .memoryStoreId(memoryStoreId) + * .build() + * ``` + */ + fun addMemoryStoreResource(memoryStoreId: String) = apply { + body.addMemoryStoreResource(memoryStoreId) + } + + /** 5-field POSIX cron schedule. Literal wall-clock matching in the configured timezone. */ + fun schedule(schedule: BetaManagedAgentsScheduleParams?) = apply { body.schedule(schedule) } + + /** Alias for calling [Builder.schedule] with `schedule.orElse(null)`. */ + fun schedule(schedule: Optional) = + schedule(schedule.getOrNull()) + + /** + * Sets [Builder.schedule] to an arbitrary JSON value. + * + * You should usually call [Builder.schedule] with a well-typed + * [BetaManagedAgentsScheduleParams] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun schedule(schedule: JsonField) = apply { + body.schedule(schedule) + } + + /** + * Vault IDs. Full replacement. Omit to preserve; send empty array or null to clear. + * Maximum 50. + */ + fun vaultIds(vaultIds: List?) = apply { body.vaultIds(vaultIds) } + + /** Alias for calling [Builder.vaultIds] with `vaultIds.orElse(null)`. */ + fun vaultIds(vaultIds: Optional>) = vaultIds(vaultIds.getOrNull()) + + /** + * Sets [Builder.vaultIds] to an arbitrary JSON value. + * + * You should usually call [Builder.vaultIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun vaultIds(vaultIds: JsonField>) = apply { body.vaultIds(vaultIds) } + + /** + * Adds a single [String] to [vaultIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVaultId(vaultId: String) = apply { body.addVaultId(vaultId) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DeploymentUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DeploymentUpdateParams = + DeploymentUpdateParams( + deploymentId, + betas?.toImmutable(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> deploymentId ?: "" + else -> "" + } + + override fun _headers(): Headers = + Headers.builder() + .apply { + betas?.forEach { put("anthropic-beta", it.toString()) } + putAll(additionalHeaders) + } + .build() + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** + * Request parameters for updating a `deployment`. Omit a field to preserve its current value. + */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val agent: JsonField, + private val description: JsonField, + private val environmentId: JsonField, + private val initialEvents: JsonField>, + private val metadata: JsonField, + private val name: JsonField, + private val resources: JsonField>, + private val schedule: JsonField, + private val vaultIds: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("agent") @ExcludeMissing agent: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("environment_id") + @ExcludeMissing + environmentId: JsonField = JsonMissing.of(), + @JsonProperty("initial_events") + @ExcludeMissing + initialEvents: JsonField> = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("resources") + @ExcludeMissing + resources: JsonField> = JsonMissing.of(), + @JsonProperty("schedule") + @ExcludeMissing + schedule: JsonField = JsonMissing.of(), + @JsonProperty("vault_ids") + @ExcludeMissing + vaultIds: JsonField> = JsonMissing.of(), + ) : this( + agent, + description, + environmentId, + initialEvents, + metadata, + name, + resources, + schedule, + vaultIds, + mutableMapOf(), + ) + + /** + * Agent to deploy. Accepts the `agent` ID string, which re-pins to the latest version, or + * an `agent` object with both id and version specified. Omit to preserve. Cannot be + * cleared. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun agent(): Optional = agent.getOptional("agent") + + /** + * Description. Omit to preserve; send empty string or null to clear. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * ID of the `environment` where sessions run. Omit to preserve. Cannot be cleared. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun environmentId(): Optional = environmentId.getOptional("environment_id") + + /** + * Initial events. Full replacement. Omit to preserve. Cannot be cleared. At least 1, + * maximum 50. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun initialEvents(): Optional> = + initialEvents.getOptional("initial_events") + + /** + * Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omit the + * field to preserve. The stored bag is limited to 16 keys (up to 64 chars each) with values + * up to 512 chars. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * Human-readable name. Must be non-empty. Omit to preserve. Cannot be cleared. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Session resources. Full replacement. Omit to preserve; send empty array or null to clear. + * Maximum 500. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun resources(): Optional> = resources.getOptional("resources") + + /** + * 5-field POSIX cron schedule. Literal wall-clock matching in the configured timezone. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun schedule(): Optional = schedule.getOptional("schedule") + + /** + * Vault IDs. Full replacement. Omit to preserve; send empty array or null to clear. + * Maximum 50. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun vaultIds(): Optional> = vaultIds.getOptional("vault_ids") + + /** + * Returns the raw JSON value of [agent]. + * + * Unlike [agent], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("agent") @ExcludeMissing fun _agent(): JsonField = agent + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [environmentId]. + * + * Unlike [environmentId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("environment_id") + @ExcludeMissing + fun _environmentId(): JsonField = environmentId + + /** + * Returns the raw JSON value of [initialEvents]. + * + * Unlike [initialEvents], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("initial_events") + @ExcludeMissing + fun _initialEvents(): JsonField> = + initialEvents + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [resources]. + * + * Unlike [resources], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("resources") + @ExcludeMissing + fun _resources(): JsonField> = resources + + /** + * Returns the raw JSON value of [schedule]. + * + * Unlike [schedule], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("schedule") + @ExcludeMissing + fun _schedule(): JsonField = schedule + + /** + * Returns the raw JSON value of [vaultIds]. + * + * Unlike [vaultIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("vault_ids") + @ExcludeMissing + fun _vaultIds(): JsonField> = vaultIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var agent: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var environmentId: JsonField = JsonMissing.of() + private var initialEvents: + JsonField>? = + null + private var metadata: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var resources: JsonField>? = null + private var schedule: JsonField = JsonMissing.of() + private var vaultIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + agent = body.agent + description = body.description + environmentId = body.environmentId + initialEvents = + body.initialEvents.map { it.toMutableList() }.takeUnless { it.isMissing() } + metadata = body.metadata + name = body.name + resources = body.resources.map { it.toMutableList() }.takeUnless { it.isMissing() } + schedule = body.schedule + vaultIds = body.vaultIds.map { it.toMutableList() }.takeUnless { it.isMissing() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * Agent to deploy. Accepts the `agent` ID string, which re-pins to the latest version, + * or an `agent` object with both id and version specified. Omit to preserve. Cannot be + * cleared. + */ + fun agent(agent: Agent) = agent(JsonField.of(agent)) + + /** + * Sets [Builder.agent] to an arbitrary JSON value. + * + * You should usually call [Builder.agent] with a well-typed [Agent] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun agent(agent: JsonField) = apply { this.agent = agent } + + /** Alias for calling [agent] with `Agent.ofString(string)`. */ + fun agent(string: String) = agent(Agent.ofString(string)) + + /** + * Alias for calling [agent] with + * `Agent.ofBetaManagedAgentsAgentParams(betaManagedAgentsAgentParams)`. + */ + fun agent(betaManagedAgentsAgentParams: BetaManagedAgentsAgentParams) = + agent(Agent.ofBetaManagedAgentsAgentParams(betaManagedAgentsAgentParams)) + + /** Description. Omit to preserve; send empty string or null to clear. */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** ID of the `environment` where sessions run. Omit to preserve. Cannot be cleared. */ + fun environmentId(environmentId: String) = environmentId(JsonField.of(environmentId)) + + /** + * Sets [Builder.environmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.environmentId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun environmentId(environmentId: JsonField) = apply { + this.environmentId = environmentId + } + + /** + * Initial events. Full replacement. Omit to preserve. Cannot be cleared. At least 1, + * maximum 50. + */ + fun initialEvents(initialEvents: List) = + initialEvents(JsonField.of(initialEvents)) + + /** + * Sets [Builder.initialEvents] to an arbitrary JSON value. + * + * You should usually call [Builder.initialEvents] with a well-typed + * `List` value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun initialEvents( + initialEvents: JsonField> + ) = apply { this.initialEvents = initialEvents.map { it.toMutableList() } } + + /** + * Adds a single [BetaManagedAgentsDeploymentInitialEventParams] to [initialEvents]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addInitialEvent(initialEvent: BetaManagedAgentsDeploymentInitialEventParams) = + apply { + initialEvents = + (initialEvents ?: JsonField.of(mutableListOf())).also { + checkKnown("initialEvents", it).add(initialEvent) + } + } + + /** + * Alias for calling [addInitialEvent] with + * `BetaManagedAgentsDeploymentInitialEventParams.ofUserMessage(userMessage)`. + */ + fun addInitialEvent(userMessage: BetaManagedAgentsUserMessageEventParams) = + addInitialEvent( + BetaManagedAgentsDeploymentInitialEventParams.ofUserMessage(userMessage) + ) + + /** + * Alias for calling [addInitialEvent] with the following: + * ```java + * BetaManagedAgentsUserMessageEventParams.builder() + * .type(BetaManagedAgentsUserMessageEventParams.Type.USER_MESSAGE) + * .content(content) + * .build() + * ``` + */ + fun addUserMessageInitialEvent( + content: List + ) = + addInitialEvent( + BetaManagedAgentsUserMessageEventParams.builder() + .type(BetaManagedAgentsUserMessageEventParams.Type.USER_MESSAGE) + .content(content) + .build() + ) + + /** + * Alias for calling [addInitialEvent] with + * `BetaManagedAgentsDeploymentInitialEventParams.ofUserDefineOutcome(userDefineOutcome)`. + */ + fun addInitialEvent(userDefineOutcome: BetaManagedAgentsUserDefineOutcomeEventParams) = + addInitialEvent( + BetaManagedAgentsDeploymentInitialEventParams.ofUserDefineOutcome( + userDefineOutcome + ) + ) + + /** + * Alias for calling [addInitialEvent] with + * `BetaManagedAgentsDeploymentInitialEventParams.ofSystemMessage(systemMessage)`. + */ + fun addInitialEvent(systemMessage: BetaManagedAgentsSystemMessageEventParams) = + addInitialEvent( + BetaManagedAgentsDeploymentInitialEventParams.ofSystemMessage(systemMessage) + ) + + /** + * Alias for calling [addInitialEvent] with the following: + * ```java + * BetaManagedAgentsSystemMessageEventParams.builder() + * .type(BetaManagedAgentsSystemMessageEventParams.Type.SYSTEM_MESSAGE) + * .content(content) + * .build() + * ``` + */ + fun addSystemMessageInitialEvent(content: List) = + addInitialEvent( + BetaManagedAgentsSystemMessageEventParams.builder() + .type(BetaManagedAgentsSystemMessageEventParams.Type.SYSTEM_MESSAGE) + .content(content) + .build() + ) + + /** + * Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omit the + * field to preserve. The stored bag is limited to 16 keys (up to 64 chars each) with + * values up to 512 chars. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** Human-readable name. Must be non-empty. Omit to preserve. Cannot be cleared. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * Session resources. Full replacement. Omit to preserve; send empty array or null to + * clear. Maximum 500. + */ + fun resources(resources: List?) = resources(JsonField.ofNullable(resources)) + + /** Alias for calling [Builder.resources] with `resources.orElse(null)`. */ + fun resources(resources: Optional>) = resources(resources.getOrNull()) + + /** + * Sets [Builder.resources] to an arbitrary JSON value. + * + * You should usually call [Builder.resources] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun resources(resources: JsonField>) = apply { + this.resources = resources.map { it.toMutableList() } + } + + /** + * Adds a single [Resource] to [resources]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResource(resource: Resource) = apply { + resources = + (resources ?: JsonField.of(mutableListOf())).also { + checkKnown("resources", it).add(resource) + } + } + + /** + * Alias for calling [addResource] with `Resource.ofGitHubRepository(githubRepository)`. + */ + fun addResource(githubRepository: BetaManagedAgentsGitHubRepositoryResourceParams) = + addResource(Resource.ofGitHubRepository(githubRepository)) + + /** Alias for calling [addResource] with `Resource.ofFile(file)`. */ + fun addResource(file: BetaManagedAgentsFileResourceParams) = + addResource(Resource.ofFile(file)) + + /** + * Alias for calling [addResource] with the following: + * ```java + * BetaManagedAgentsFileResourceParams.builder() + * .type(BetaManagedAgentsFileResourceParams.Type.FILE) + * .fileId(fileId) + * .build() + * ``` + */ + fun addFileResource(fileId: String) = + addResource( + BetaManagedAgentsFileResourceParams.builder() + .type(BetaManagedAgentsFileResourceParams.Type.FILE) + .fileId(fileId) + .build() + ) + + /** Alias for calling [addResource] with `Resource.ofMemoryStore(memoryStore)`. */ + fun addResource(memoryStore: BetaManagedAgentsMemoryStoreResourceParam) = + addResource(Resource.ofMemoryStore(memoryStore)) + + /** + * Alias for calling [addResource] with the following: + * ```java + * BetaManagedAgentsMemoryStoreResourceParam.builder() + * .type(BetaManagedAgentsMemoryStoreResourceParam.Type.MEMORY_STORE) + * .memoryStoreId(memoryStoreId) + * .build() + * ``` + */ + fun addMemoryStoreResource(memoryStoreId: String) = + addResource( + BetaManagedAgentsMemoryStoreResourceParam.builder() + .type(BetaManagedAgentsMemoryStoreResourceParam.Type.MEMORY_STORE) + .memoryStoreId(memoryStoreId) + .build() + ) + + /** + * 5-field POSIX cron schedule. Literal wall-clock matching in the configured timezone. + */ + fun schedule(schedule: BetaManagedAgentsScheduleParams?) = + schedule(JsonField.ofNullable(schedule)) + + /** Alias for calling [Builder.schedule] with `schedule.orElse(null)`. */ + fun schedule(schedule: Optional) = + schedule(schedule.getOrNull()) + + /** + * Sets [Builder.schedule] to an arbitrary JSON value. + * + * You should usually call [Builder.schedule] with a well-typed + * [BetaManagedAgentsScheduleParams] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun schedule(schedule: JsonField) = apply { + this.schedule = schedule + } + + /** + * Vault IDs. Full replacement. Omit to preserve; send empty array or null to clear. + * Maximum 50. + */ + fun vaultIds(vaultIds: List?) = vaultIds(JsonField.ofNullable(vaultIds)) + + /** Alias for calling [Builder.vaultIds] with `vaultIds.orElse(null)`. */ + fun vaultIds(vaultIds: Optional>) = vaultIds(vaultIds.getOrNull()) + + /** + * Sets [Builder.vaultIds] to an arbitrary JSON value. + * + * You should usually call [Builder.vaultIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun vaultIds(vaultIds: JsonField>) = apply { + this.vaultIds = vaultIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [vaultIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVaultId(vaultId: String) = apply { + vaultIds = + (vaultIds ?: JsonField.of(mutableListOf())).also { + checkKnown("vaultIds", it).add(vaultId) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + agent, + description, + environmentId, + (initialEvents ?: JsonMissing.of()).map { it.toImmutable() }, + metadata, + name, + (resources ?: JsonMissing.of()).map { it.toImmutable() }, + schedule, + (vaultIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + agent().ifPresent { it.validate() } + description() + environmentId() + initialEvents().ifPresent { it.forEach { it.validate() } } + metadata().ifPresent { it.validate() } + name() + resources().ifPresent { it.forEach { it.validate() } } + schedule().ifPresent { it.validate() } + vaultIds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (agent.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (environmentId.asKnown().isPresent) 1 else 0) + + (initialEvents.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (resources.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (schedule.asKnown().getOrNull()?.validity() ?: 0) + + (vaultIds.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + agent == other.agent && + description == other.description && + environmentId == other.environmentId && + initialEvents == other.initialEvents && + metadata == other.metadata && + name == other.name && + resources == other.resources && + schedule == other.schedule && + vaultIds == other.vaultIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + agent, + description, + environmentId, + initialEvents, + metadata, + name, + resources, + schedule, + vaultIds, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{agent=$agent, description=$description, environmentId=$environmentId, initialEvents=$initialEvents, metadata=$metadata, name=$name, resources=$resources, schedule=$schedule, vaultIds=$vaultIds, additionalProperties=$additionalProperties}" + } + + /** + * Agent to deploy. Accepts the `agent` ID string, which re-pins to the latest version, or an + * `agent` object with both id and version specified. Omit to preserve. Cannot be cleared. + */ + @JsonDeserialize(using = Agent.Deserializer::class) + @JsonSerialize(using = Agent.Serializer::class) + class Agent + private constructor( + private val string: String? = null, + private val betaManagedAgentsAgentParams: BetaManagedAgentsAgentParams? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + /** + * Specification for an Agent. Provide a specific `version` or use the short-form + * `agent="agent_id"` for the most recent version + */ + fun betaManagedAgentsAgentParams(): Optional = + Optional.ofNullable(betaManagedAgentsAgentParams) + + fun isString(): Boolean = string != null + + fun isBetaManagedAgentsAgentParams(): Boolean = betaManagedAgentsAgentParams != null + + fun asString(): String = string.getOrThrow("string") + + /** + * Specification for an Agent. Provide a specific `version` or use the short-form + * `agent="agent_id"` for the most recent version + */ + fun asBetaManagedAgentsAgentParams(): BetaManagedAgentsAgentParams = + betaManagedAgentsAgentParams.getOrThrow("betaManagedAgentsAgentParams") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.anthropic.core.JsonValue; + * import java.util.Optional; + * + * Optional result = agent.accept(new Agent.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws AnthropicInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + betaManagedAgentsAgentParams != null -> + visitor.visitBetaManagedAgentsAgentParams(betaManagedAgentsAgentParams) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Agent = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitBetaManagedAgentsAgentParams( + betaManagedAgentsAgentParams: BetaManagedAgentsAgentParams + ) { + betaManagedAgentsAgentParams.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitBetaManagedAgentsAgentParams( + betaManagedAgentsAgentParams: BetaManagedAgentsAgentParams + ) = betaManagedAgentsAgentParams.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Agent && + string == other.string && + betaManagedAgentsAgentParams == other.betaManagedAgentsAgentParams + } + + override fun hashCode(): Int = Objects.hash(string, betaManagedAgentsAgentParams) + + override fun toString(): String = + when { + string != null -> "Agent{string=$string}" + betaManagedAgentsAgentParams != null -> + "Agent{betaManagedAgentsAgentParams=$betaManagedAgentsAgentParams}" + _json != null -> "Agent{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Agent") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Agent(string = string) + + /** + * Specification for an Agent. Provide a specific `version` or use the short-form + * `agent="agent_id"` for the most recent version + */ + @JvmStatic + fun ofBetaManagedAgentsAgentParams( + betaManagedAgentsAgentParams: BetaManagedAgentsAgentParams + ) = Agent(betaManagedAgentsAgentParams = betaManagedAgentsAgentParams) + } + + /** An interface that defines how to map each variant of [Agent] to a value of type [T]. */ + interface Visitor { + + fun visitString(string: String): T + + /** + * Specification for an Agent. Provide a specific `version` or use the short-form + * `agent="agent_id"` for the most recent version + */ + fun visitBetaManagedAgentsAgentParams( + betaManagedAgentsAgentParams: BetaManagedAgentsAgentParams + ): T + + /** + * Maps an unknown variant of [Agent] to a value of type [T]. + * + * An instance of [Agent] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws AnthropicInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw AnthropicInvalidDataException("Unknown Agent: $json") + } + } + + internal class Deserializer : BaseDeserializer(Agent::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Agent { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { Agent(betaManagedAgentsAgentParams = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Agent(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Agent(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Agent::class) { + + override fun serialize( + value: Agent, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.betaManagedAgentsAgentParams != null -> + generator.writeObject(value.betaManagedAgentsAgentParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Agent") + } + } + } + } + + /** + * Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omit the field + * to preserve. The stored bag is limited to 16 keys (up to 64 chars each) with values up to 512 + * chars. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + /** Union of resources that can be mounted into a session. */ + @JsonDeserialize(using = Resource.Deserializer::class) + @JsonSerialize(using = Resource.Serializer::class) + class Resource + private constructor( + private val githubRepository: BetaManagedAgentsGitHubRepositoryResourceParams? = null, + private val file: BetaManagedAgentsFileResourceParams? = null, + private val memoryStore: BetaManagedAgentsMemoryStoreResourceParam? = null, + private val _json: JsonValue? = null, + ) { + + /** Mount a GitHub repository into the session's container. */ + fun githubRepository(): Optional = + Optional.ofNullable(githubRepository) + + /** Mount a file uploaded via the Files API into the session. */ + fun file(): Optional = Optional.ofNullable(file) + + /** Parameters for attaching a memory store to an agent session. */ + fun memoryStore(): Optional = + Optional.ofNullable(memoryStore) + + fun isGitHubRepository(): Boolean = githubRepository != null + + fun isFile(): Boolean = file != null + + fun isMemoryStore(): Boolean = memoryStore != null + + /** Mount a GitHub repository into the session's container. */ + fun asGitHubRepository(): BetaManagedAgentsGitHubRepositoryResourceParams = + githubRepository.getOrThrow("githubRepository") + + /** Mount a file uploaded via the Files API into the session. */ + fun asFile(): BetaManagedAgentsFileResourceParams = file.getOrThrow("file") + + /** Parameters for attaching a memory store to an agent session. */ + fun asMemoryStore(): BetaManagedAgentsMemoryStoreResourceParam = + memoryStore.getOrThrow("memoryStore") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.anthropic.core.JsonValue; + * import java.util.Optional; + * + * Optional result = resource.accept(new Resource.Visitor>() { + * @Override + * public Optional visitGitHubRepository(BetaManagedAgentsGitHubRepositoryResourceParams githubRepository) { + * return Optional.of(githubRepository.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws AnthropicInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + githubRepository != null -> visitor.visitGitHubRepository(githubRepository) + file != null -> visitor.visitFile(file) + memoryStore != null -> visitor.visitMemoryStore(memoryStore) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Resource = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitGitHubRepository( + githubRepository: BetaManagedAgentsGitHubRepositoryResourceParams + ) { + githubRepository.validate() + } + + override fun visitFile(file: BetaManagedAgentsFileResourceParams) { + file.validate() + } + + override fun visitMemoryStore( + memoryStore: BetaManagedAgentsMemoryStoreResourceParam + ) { + memoryStore.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitGitHubRepository( + githubRepository: BetaManagedAgentsGitHubRepositoryResourceParams + ) = githubRepository.validity() + + override fun visitFile(file: BetaManagedAgentsFileResourceParams) = + file.validity() + + override fun visitMemoryStore( + memoryStore: BetaManagedAgentsMemoryStoreResourceParam + ) = memoryStore.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Resource && + githubRepository == other.githubRepository && + file == other.file && + memoryStore == other.memoryStore + } + + override fun hashCode(): Int = Objects.hash(githubRepository, file, memoryStore) + + override fun toString(): String = + when { + githubRepository != null -> "Resource{githubRepository=$githubRepository}" + file != null -> "Resource{file=$file}" + memoryStore != null -> "Resource{memoryStore=$memoryStore}" + _json != null -> "Resource{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Resource") + } + + companion object { + + /** Mount a GitHub repository into the session's container. */ + @JvmStatic + fun ofGitHubRepository( + githubRepository: BetaManagedAgentsGitHubRepositoryResourceParams + ) = Resource(githubRepository = githubRepository) + + /** Mount a file uploaded via the Files API into the session. */ + @JvmStatic fun ofFile(file: BetaManagedAgentsFileResourceParams) = Resource(file = file) + + /** Parameters for attaching a memory store to an agent session. */ + @JvmStatic + fun ofMemoryStore(memoryStore: BetaManagedAgentsMemoryStoreResourceParam) = + Resource(memoryStore = memoryStore) + } + + /** + * An interface that defines how to map each variant of [Resource] to a value of type [T]. + */ + interface Visitor { + + /** Mount a GitHub repository into the session's container. */ + fun visitGitHubRepository( + githubRepository: BetaManagedAgentsGitHubRepositoryResourceParams + ): T + + /** Mount a file uploaded via the Files API into the session. */ + fun visitFile(file: BetaManagedAgentsFileResourceParams): T + + /** Parameters for attaching a memory store to an agent session. */ + fun visitMemoryStore(memoryStore: BetaManagedAgentsMemoryStoreResourceParam): T + + /** + * Maps an unknown variant of [Resource] to a value of type [T]. + * + * An instance of [Resource] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws AnthropicInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw AnthropicInvalidDataException("Unknown Resource: $json") + } + } + + internal class Deserializer : BaseDeserializer(Resource::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Resource { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "github_repository" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Resource(githubRepository = it, _json = json) } + ?: Resource(_json = json) + } + "file" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Resource(file = it, _json = json) } ?: Resource(_json = json) + } + "memory_store" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Resource(memoryStore = it, _json = json) } + ?: Resource(_json = json) + } + } + + return Resource(_json = json) + } + } + + internal class Serializer : BaseSerializer(Resource::class) { + + override fun serialize( + value: Resource, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.githubRepository != null -> generator.writeObject(value.githubRepository) + value.file != null -> generator.writeObject(value.file) + value.memoryStore != null -> generator.writeObject(value.memoryStore) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Resource") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DeploymentUpdateParams && + deploymentId == other.deploymentId && + betas == other.betas && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(deploymentId, betas, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "DeploymentUpdateParams{deploymentId=$deploymentId, betas=$betas, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSession.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSession.kt index bd0f6dd6b..e95d21fca 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSession.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSession.kt @@ -44,6 +44,7 @@ private constructor( private val updatedAt: JsonField, private val usage: JsonField, private val vaultIds: JsonField>, + private val deploymentId: JsonField, private val additionalProperties: MutableMap, ) { @@ -85,6 +86,9 @@ private constructor( @JsonProperty("vault_ids") @ExcludeMissing vaultIds: JsonField> = JsonMissing.of(), + @JsonProperty("deployment_id") + @ExcludeMissing + deploymentId: JsonField = JsonMissing.of(), ) : this( id, agent, @@ -101,6 +105,7 @@ private constructor( updatedAt, usage, vaultIds, + deploymentId, mutableMapOf(), ) @@ -214,6 +219,14 @@ private constructor( */ fun vaultIds(): List = vaultIds.getRequired("vault_ids") + /** + * Deployment ID when the session was created from a deployment reference. Null otherwise. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun deploymentId(): Optional = deploymentId.getOptional("deployment_id") + /** * Returns the raw JSON value of [id]. * @@ -339,6 +352,15 @@ private constructor( */ @JsonProperty("vault_ids") @ExcludeMissing fun _vaultIds(): JsonField> = vaultIds + /** + * Returns the raw JSON value of [deploymentId]. + * + * Unlike [deploymentId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("deployment_id") + @ExcludeMissing + fun _deploymentId(): JsonField = deploymentId + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -398,6 +420,7 @@ private constructor( private var updatedAt: JsonField? = null private var usage: JsonField? = null private var vaultIds: JsonField>? = null + private var deploymentId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -426,6 +449,7 @@ private constructor( betaManagedAgentsSession.vaultIds .map { it.toMutableList() } .takeUnless { it.isMissing() } + deploymentId = betaManagedAgentsSession.deploymentId additionalProperties = betaManagedAgentsSession.additionalProperties.toMutableMap() } @@ -693,6 +717,25 @@ private constructor( } } + /** + * Deployment ID when the session was created from a deployment reference. Null otherwise. + */ + fun deploymentId(deploymentId: String?) = deploymentId(JsonField.ofNullable(deploymentId)) + + /** Alias for calling [Builder.deploymentId] with `deploymentId.orElse(null)`. */ + fun deploymentId(deploymentId: Optional) = deploymentId(deploymentId.getOrNull()) + + /** + * Sets [Builder.deploymentId] to an arbitrary JSON value. + * + * You should usually call [Builder.deploymentId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun deploymentId(deploymentId: JsonField) = apply { + this.deploymentId = deploymentId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -755,6 +798,7 @@ private constructor( checkRequired("updatedAt", updatedAt), checkRequired("usage", usage), checkRequired("vaultIds", vaultIds).map { it.toImmutable() }, + deploymentId, additionalProperties.toMutableMap(), ) } @@ -789,6 +833,7 @@ private constructor( updatedAt() usage().validate() vaultIds() + deploymentId() validated = true } @@ -821,7 +866,8 @@ private constructor( (type.asKnown().getOrNull()?.validity() ?: 0) + (if (updatedAt.asKnown().isPresent) 1 else 0) + (usage.asKnown().getOrNull()?.validity() ?: 0) + - (vaultIds.asKnown().getOrNull()?.size ?: 0) + (vaultIds.asKnown().getOrNull()?.size ?: 0) + + (if (deploymentId.asKnown().isPresent) 1 else 0) class Metadata @JsonCreator @@ -1231,6 +1277,7 @@ private constructor( updatedAt == other.updatedAt && usage == other.usage && vaultIds == other.vaultIds && + deploymentId == other.deploymentId && additionalProperties == other.additionalProperties } @@ -1251,6 +1298,7 @@ private constructor( updatedAt, usage, vaultIds, + deploymentId, additionalProperties, ) } @@ -1258,5 +1306,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BetaManagedAgentsSession{id=$id, agent=$agent, archivedAt=$archivedAt, createdAt=$createdAt, environmentId=$environmentId, metadata=$metadata, outcomeEvaluations=$outcomeEvaluations, resources=$resources, stats=$stats, status=$status, title=$title, type=$type, updatedAt=$updatedAt, usage=$usage, vaultIds=$vaultIds, additionalProperties=$additionalProperties}" + "BetaManagedAgentsSession{id=$id, agent=$agent, archivedAt=$archivedAt, createdAt=$createdAt, environmentId=$environmentId, metadata=$metadata, outcomeEvaluations=$outcomeEvaluations, resources=$resources, stats=$stats, status=$status, title=$title, type=$type, updatedAt=$updatedAt, usage=$usage, vaultIds=$vaultIds, deploymentId=$deploymentId, additionalProperties=$additionalProperties}" } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSystemContentBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSystemContentBlock.kt new file mode 100644 index 000000000..0c293e455 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSystemContentBlock.kt @@ -0,0 +1,352 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.sessions + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** Regular text content. */ +class BetaManagedAgentsSystemContentBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val text: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(text, type, mutableMapOf()) + + /** + * The text content. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsSystemContentBlock]. + * + * The following fields are required: + * ```java + * .text() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsSystemContentBlock]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsSystemContentBlock: BetaManagedAgentsSystemContentBlock + ) = apply { + text = betaManagedAgentsSystemContentBlock.text + type = betaManagedAgentsSystemContentBlock.type + additionalProperties = + betaManagedAgentsSystemContentBlock.additionalProperties.toMutableMap() + } + + /** The text content. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsSystemContentBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .text() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsSystemContentBlock = + BetaManagedAgentsSystemContentBlock( + checkRequired("text", text), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsSystemContentBlock = apply { + if (validated) { + return@apply + } + + text() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (text.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TEXT = of("text") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + TEXT + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TEXT, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TEXT -> Value.TEXT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TEXT -> Known.TEXT + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsSystemContentBlock && + text == other.text && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(text, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsSystemContentBlock{text=$text, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSystemMessageEvent.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSystemMessageEvent.kt new file mode 100644 index 000000000..ba7a69b4e --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSystemMessageEvent.kt @@ -0,0 +1,484 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.sessions + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkKnown +import com.anthropic.core.checkRequired +import com.anthropic.core.toImmutable +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * A mid-conversation system message event. Carries system-role content that is appended to the + * session as a `role: "system"` turn. + */ +class BetaManagedAgentsSystemMessageEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val content: JsonField>, + private val type: JsonField, + private val processedAt: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + content: JsonField> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("processed_at") + @ExcludeMissing + processedAt: JsonField = JsonMissing.of(), + ) : this(id, content, type, processedAt, mutableMapOf()) + + /** + * Unique identifier for this event. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * System content blocks. Text-only. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun content(): List = content.getRequired("content") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * A timestamp in RFC 3339 format + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun processedAt(): Optional = processedAt.getOptional("processed_at") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") + @ExcludeMissing + fun _content(): JsonField> = content + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [processedAt]. + * + * Unlike [processedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("processed_at") + @ExcludeMissing + fun _processedAt(): JsonField = processedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsSystemMessageEvent]. + * + * The following fields are required: + * ```java + * .id() + * .content() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsSystemMessageEvent]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var content: JsonField>? = null + private var type: JsonField? = null + private var processedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsSystemMessageEvent: BetaManagedAgentsSystemMessageEvent + ) = apply { + id = betaManagedAgentsSystemMessageEvent.id + content = + betaManagedAgentsSystemMessageEvent.content + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + type = betaManagedAgentsSystemMessageEvent.type + processedAt = betaManagedAgentsSystemMessageEvent.processedAt + additionalProperties = + betaManagedAgentsSystemMessageEvent.additionalProperties.toMutableMap() + } + + /** Unique identifier for this event. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** System content blocks. Text-only. */ + fun content(content: List) = + content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun content(content: JsonField>) = apply { + this.content = content.map { it.toMutableList() } + } + + /** + * Adds a single [BetaManagedAgentsSystemContentBlock] to [Builder.content]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addContent(content: BetaManagedAgentsSystemContentBlock) = apply { + this.content = + (this.content ?: JsonField.of(mutableListOf())).also { + checkKnown("content", it).add(content) + } + } + + /** + * Alias for calling [addContent] with the following: + * ```java + * BetaManagedAgentsSystemContentBlock.builder() + * .type(BetaManagedAgentsSystemContentBlock.Type.TEXT) + * .text(text) + * .build() + * ``` + */ + fun addTextContent(text: String) = + addContent( + BetaManagedAgentsSystemContentBlock.builder() + .type(BetaManagedAgentsSystemContentBlock.Type.TEXT) + .text(text) + .build() + ) + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** A timestamp in RFC 3339 format */ + fun processedAt(processedAt: OffsetDateTime?) = + processedAt(JsonField.ofNullable(processedAt)) + + /** Alias for calling [Builder.processedAt] with `processedAt.orElse(null)`. */ + fun processedAt(processedAt: Optional) = + processedAt(processedAt.getOrNull()) + + /** + * Sets [Builder.processedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.processedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun processedAt(processedAt: JsonField) = apply { + this.processedAt = processedAt + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsSystemMessageEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .content() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsSystemMessageEvent = + BetaManagedAgentsSystemMessageEvent( + checkRequired("id", id), + checkRequired("content", content).map { it.toImmutable() }, + checkRequired("type", type), + processedAt, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsSystemMessageEvent = apply { + if (validated) { + return@apply + } + + id() + content().forEach { it.validate() } + type().validate() + processedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (content.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (processedAt.asKnown().isPresent) 1 else 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SYSTEM_MESSAGE = of("system.message") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + SYSTEM_MESSAGE + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SYSTEM_MESSAGE, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SYSTEM_MESSAGE -> Value.SYSTEM_MESSAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SYSTEM_MESSAGE -> Known.SYSTEM_MESSAGE + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsSystemMessageEvent && + id == other.id && + content == other.content && + type == other.type && + processedAt == other.processedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, content, type, processedAt, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsSystemMessageEvent{id=$id, content=$content, type=$type, processedAt=$processedAt, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionListParams.kt index 7a1ef9d21..0894ecd0a 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionListParams.kt @@ -26,6 +26,7 @@ private constructor( private val createdAtGte: OffsetDateTime?, private val createdAtLt: OffsetDateTime?, private val createdAtLte: OffsetDateTime?, + private val deploymentId: String?, private val includeArchived: Boolean?, private val limit: Int?, private val memoryStoreId: String?, @@ -55,6 +56,9 @@ private constructor( /** Return sessions created at or before this time (inclusive). */ fun createdAtLte(): Optional = Optional.ofNullable(createdAtLte) + /** Filter sessions created by this deployment ID. */ + fun deploymentId(): Optional = Optional.ofNullable(deploymentId) + /** When true, includes archived sessions. Default: false (exclude archived). */ fun includeArchived(): Optional = Optional.ofNullable(includeArchived) @@ -101,6 +105,7 @@ private constructor( private var createdAtGte: OffsetDateTime? = null private var createdAtLt: OffsetDateTime? = null private var createdAtLte: OffsetDateTime? = null + private var deploymentId: String? = null private var includeArchived: Boolean? = null private var limit: Int? = null private var memoryStoreId: String? = null @@ -119,6 +124,7 @@ private constructor( createdAtGte = sessionListParams.createdAtGte createdAtLt = sessionListParams.createdAtLt createdAtLte = sessionListParams.createdAtLte + deploymentId = sessionListParams.deploymentId includeArchived = sessionListParams.includeArchived limit = sessionListParams.limit memoryStoreId = sessionListParams.memoryStoreId @@ -177,6 +183,12 @@ private constructor( fun createdAtLte(createdAtLte: Optional) = createdAtLte(createdAtLte.getOrNull()) + /** Filter sessions created by this deployment ID. */ + fun deploymentId(deploymentId: String?) = apply { this.deploymentId = deploymentId } + + /** Alias for calling [Builder.deploymentId] with `deploymentId.orElse(null)`. */ + fun deploymentId(deploymentId: Optional) = deploymentId(deploymentId.getOrNull()) + /** When true, includes archived sessions. Default: false (exclude archived). */ fun includeArchived(includeArchived: Boolean?) = apply { this.includeArchived = includeArchived @@ -375,6 +387,7 @@ private constructor( createdAtGte, createdAtLt, createdAtLte, + deploymentId, includeArchived, limit, memoryStoreId, @@ -412,6 +425,7 @@ private constructor( createdAtLte?.let { put("created_at[lte]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) } + deploymentId?.let { put("deployment_id", it) } includeArchived?.let { put("include_archived", it.toString()) } limit?.let { put("limit", it.toString()) } memoryStoreId?.let { put("memory_store_id", it) } @@ -720,6 +734,7 @@ private constructor( createdAtGte == other.createdAtGte && createdAtLt == other.createdAtLt && createdAtLte == other.createdAtLte && + deploymentId == other.deploymentId && includeArchived == other.includeArchived && limit == other.limit && memoryStoreId == other.memoryStoreId && @@ -739,6 +754,7 @@ private constructor( createdAtGte, createdAtLt, createdAtLte, + deploymentId, includeArchived, limit, memoryStoreId, @@ -751,5 +767,5 @@ private constructor( ) override fun toString() = - "SessionListParams{agentId=$agentId, agentVersion=$agentVersion, createdAtGt=$createdAtGt, createdAtGte=$createdAtGte, createdAtLt=$createdAtLt, createdAtLte=$createdAtLte, includeArchived=$includeArchived, limit=$limit, memoryStoreId=$memoryStoreId, order=$order, page=$page, statuses=$statuses, betas=$betas, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "SessionListParams{agentId=$agentId, agentVersion=$agentVersion, createdAtGt=$createdAtGt, createdAtGte=$createdAtGte, createdAtLt=$createdAtLt, createdAtLte=$createdAtLte, deploymentId=$deploymentId, includeArchived=$includeArchived, limit=$limit, memoryStoreId=$memoryStoreId, order=$order, page=$page, statuses=$statuses, betas=$betas, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsCredentialHostUnreachableError.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsCredentialHostUnreachableError.kt new file mode 100644 index 000000000..04bac3864 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsCredentialHostUnreachableError.kt @@ -0,0 +1,800 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.sessions.events + +import com.anthropic.core.BaseDeserializer +import com.anthropic.core.BaseSerializer +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.core.getOrThrow +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * An `environment_variable` credential's `auth.networking.allowed_hosts` includes a host the + * environment's network policy does not permit. + */ +class BetaManagedAgentsCredentialHostUnreachableError +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val credentialId: JsonField, + private val message: JsonField, + private val retryStatus: JsonField, + private val type: JsonField, + private val vaultId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("credential_id") + @ExcludeMissing + credentialId: JsonField = JsonMissing.of(), + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("retry_status") + @ExcludeMissing + retryStatus: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("vault_id") @ExcludeMissing vaultId: JsonField = JsonMissing.of(), + ) : this(credentialId, message, retryStatus, type, vaultId, mutableMapOf()) + + /** + * ID of the affected credential. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun credentialId(): String = credentialId.getRequired("credential_id") + + /** + * Human-readable error description. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): String = message.getRequired("message") + + /** + * What the client should do next in response to this error. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun retryStatus(): RetryStatus = retryStatus.getRequired("retry_status") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * ID of the vault containing the affected credential. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun vaultId(): String = vaultId.getRequired("vault_id") + + /** + * Returns the raw JSON value of [credentialId]. + * + * Unlike [credentialId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credential_id") + @ExcludeMissing + fun _credentialId(): JsonField = credentialId + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + /** + * Returns the raw JSON value of [retryStatus]. + * + * Unlike [retryStatus], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("retry_status") + @ExcludeMissing + fun _retryStatus(): JsonField = retryStatus + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [vaultId]. + * + * Unlike [vaultId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("vault_id") @ExcludeMissing fun _vaultId(): JsonField = vaultId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsCredentialHostUnreachableError]. + * + * The following fields are required: + * ```java + * .credentialId() + * .message() + * .retryStatus() + * .type() + * .vaultId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsCredentialHostUnreachableError]. */ + class Builder internal constructor() { + + private var credentialId: JsonField? = null + private var message: JsonField? = null + private var retryStatus: JsonField? = null + private var type: JsonField? = null + private var vaultId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsCredentialHostUnreachableError: + BetaManagedAgentsCredentialHostUnreachableError + ) = apply { + credentialId = betaManagedAgentsCredentialHostUnreachableError.credentialId + message = betaManagedAgentsCredentialHostUnreachableError.message + retryStatus = betaManagedAgentsCredentialHostUnreachableError.retryStatus + type = betaManagedAgentsCredentialHostUnreachableError.type + vaultId = betaManagedAgentsCredentialHostUnreachableError.vaultId + additionalProperties = + betaManagedAgentsCredentialHostUnreachableError.additionalProperties.toMutableMap() + } + + /** ID of the affected credential. */ + fun credentialId(credentialId: String) = credentialId(JsonField.of(credentialId)) + + /** + * Sets [Builder.credentialId] to an arbitrary JSON value. + * + * You should usually call [Builder.credentialId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun credentialId(credentialId: JsonField) = apply { + this.credentialId = credentialId + } + + /** Human-readable error description. */ + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + /** What the client should do next in response to this error. */ + fun retryStatus(retryStatus: RetryStatus) = retryStatus(JsonField.of(retryStatus)) + + /** + * Sets [Builder.retryStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.retryStatus] with a well-typed [RetryStatus] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun retryStatus(retryStatus: JsonField) = apply { + this.retryStatus = retryStatus + } + + /** Alias for calling [retryStatus] with `RetryStatus.ofRetrying(retrying)`. */ + fun retryStatus(retrying: BetaManagedAgentsRetryStatusRetrying) = + retryStatus(RetryStatus.ofRetrying(retrying)) + + /** Alias for calling [retryStatus] with `RetryStatus.ofExhausted(exhausted)`. */ + fun retryStatus(exhausted: BetaManagedAgentsRetryStatusExhausted) = + retryStatus(RetryStatus.ofExhausted(exhausted)) + + /** Alias for calling [retryStatus] with `RetryStatus.ofTerminal(terminal)`. */ + fun retryStatus(terminal: BetaManagedAgentsRetryStatusTerminal) = + retryStatus(RetryStatus.ofTerminal(terminal)) + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** ID of the vault containing the affected credential. */ + fun vaultId(vaultId: String) = vaultId(JsonField.of(vaultId)) + + /** + * Sets [Builder.vaultId] to an arbitrary JSON value. + * + * You should usually call [Builder.vaultId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun vaultId(vaultId: JsonField) = apply { this.vaultId = vaultId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsCredentialHostUnreachableError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .credentialId() + * .message() + * .retryStatus() + * .type() + * .vaultId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsCredentialHostUnreachableError = + BetaManagedAgentsCredentialHostUnreachableError( + checkRequired("credentialId", credentialId), + checkRequired("message", message), + checkRequired("retryStatus", retryStatus), + checkRequired("type", type), + checkRequired("vaultId", vaultId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsCredentialHostUnreachableError = apply { + if (validated) { + return@apply + } + + credentialId() + message() + retryStatus().validate() + type().validate() + vaultId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (credentialId.asKnown().isPresent) 1 else 0) + + (if (message.asKnown().isPresent) 1 else 0) + + (retryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (vaultId.asKnown().isPresent) 1 else 0) + + /** What the client should do next in response to this error. */ + @JsonDeserialize(using = RetryStatus.Deserializer::class) + @JsonSerialize(using = RetryStatus.Serializer::class) + class RetryStatus + private constructor( + private val retrying: BetaManagedAgentsRetryStatusRetrying? = null, + private val exhausted: BetaManagedAgentsRetryStatusExhausted? = null, + private val terminal: BetaManagedAgentsRetryStatusTerminal? = null, + private val _json: JsonValue? = null, + ) { + + /** + * The server is retrying automatically. Client should wait; the same error type may fire + * again as retrying, then once as exhausted when the retry budget runs out. + */ + fun retrying(): Optional = + Optional.ofNullable(retrying) + + /** + * This turn is dead; queued inputs are flushed and the session returns to idle. Client may + * send a new prompt. + */ + fun exhausted(): Optional = + Optional.ofNullable(exhausted) + + /** The session encountered a terminal error and will transition to `terminated` state. */ + fun terminal(): Optional = + Optional.ofNullable(terminal) + + fun isRetrying(): Boolean = retrying != null + + fun isExhausted(): Boolean = exhausted != null + + fun isTerminal(): Boolean = terminal != null + + /** + * The server is retrying automatically. Client should wait; the same error type may fire + * again as retrying, then once as exhausted when the retry budget runs out. + */ + fun asRetrying(): BetaManagedAgentsRetryStatusRetrying = retrying.getOrThrow("retrying") + + /** + * This turn is dead; queued inputs are flushed and the session returns to idle. Client may + * send a new prompt. + */ + fun asExhausted(): BetaManagedAgentsRetryStatusExhausted = exhausted.getOrThrow("exhausted") + + /** The session encountered a terminal error and will transition to `terminated` state. */ + fun asTerminal(): BetaManagedAgentsRetryStatusTerminal = terminal.getOrThrow("terminal") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.anthropic.core.JsonValue; + * import java.util.Optional; + * + * Optional result = retryStatus.accept(new RetryStatus.Visitor>() { + * @Override + * public Optional visitRetrying(BetaManagedAgentsRetryStatusRetrying retrying) { + * return Optional.of(retrying.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws AnthropicInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + retrying != null -> visitor.visitRetrying(retrying) + exhausted != null -> visitor.visitExhausted(exhausted) + terminal != null -> visitor.visitTerminal(terminal) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): RetryStatus = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitRetrying(retrying: BetaManagedAgentsRetryStatusRetrying) { + retrying.validate() + } + + override fun visitExhausted(exhausted: BetaManagedAgentsRetryStatusExhausted) { + exhausted.validate() + } + + override fun visitTerminal(terminal: BetaManagedAgentsRetryStatusTerminal) { + terminal.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitRetrying(retrying: BetaManagedAgentsRetryStatusRetrying) = + retrying.validity() + + override fun visitExhausted(exhausted: BetaManagedAgentsRetryStatusExhausted) = + exhausted.validity() + + override fun visitTerminal(terminal: BetaManagedAgentsRetryStatusTerminal) = + terminal.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RetryStatus && + retrying == other.retrying && + exhausted == other.exhausted && + terminal == other.terminal + } + + override fun hashCode(): Int = Objects.hash(retrying, exhausted, terminal) + + override fun toString(): String = + when { + retrying != null -> "RetryStatus{retrying=$retrying}" + exhausted != null -> "RetryStatus{exhausted=$exhausted}" + terminal != null -> "RetryStatus{terminal=$terminal}" + _json != null -> "RetryStatus{_unknown=$_json}" + else -> throw IllegalStateException("Invalid RetryStatus") + } + + companion object { + + /** + * The server is retrying automatically. Client should wait; the same error type may + * fire again as retrying, then once as exhausted when the retry budget runs out. + */ + @JvmStatic + fun ofRetrying(retrying: BetaManagedAgentsRetryStatusRetrying) = + RetryStatus(retrying = retrying) + + /** + * This turn is dead; queued inputs are flushed and the session returns to idle. Client + * may send a new prompt. + */ + @JvmStatic + fun ofExhausted(exhausted: BetaManagedAgentsRetryStatusExhausted) = + RetryStatus(exhausted = exhausted) + + /** + * The session encountered a terminal error and will transition to `terminated` state. + */ + @JvmStatic + fun ofTerminal(terminal: BetaManagedAgentsRetryStatusTerminal) = + RetryStatus(terminal = terminal) + } + + /** + * An interface that defines how to map each variant of [RetryStatus] to a value of type + * [T]. + */ + interface Visitor { + + /** + * The server is retrying automatically. Client should wait; the same error type may + * fire again as retrying, then once as exhausted when the retry budget runs out. + */ + fun visitRetrying(retrying: BetaManagedAgentsRetryStatusRetrying): T + + /** + * This turn is dead; queued inputs are flushed and the session returns to idle. Client + * may send a new prompt. + */ + fun visitExhausted(exhausted: BetaManagedAgentsRetryStatusExhausted): T + + /** + * The session encountered a terminal error and will transition to `terminated` state. + */ + fun visitTerminal(terminal: BetaManagedAgentsRetryStatusTerminal): T + + /** + * Maps an unknown variant of [RetryStatus] to a value of type [T]. + * + * An instance of [RetryStatus] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws AnthropicInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw AnthropicInvalidDataException("Unknown RetryStatus: $json") + } + } + + internal class Deserializer : BaseDeserializer(RetryStatus::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): RetryStatus { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "retrying" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { RetryStatus(retrying = it, _json = json) } + ?: RetryStatus(_json = json) + } + "exhausted" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { RetryStatus(exhausted = it, _json = json) } + ?: RetryStatus(_json = json) + } + "terminal" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { RetryStatus(terminal = it, _json = json) } + ?: RetryStatus(_json = json) + } + } + + return RetryStatus(_json = json) + } + } + + internal class Serializer : BaseSerializer(RetryStatus::class) { + + override fun serialize( + value: RetryStatus, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.retrying != null -> generator.writeObject(value.retrying) + value.exhausted != null -> generator.writeObject(value.exhausted) + value.terminal != null -> generator.writeObject(value.terminal) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid RetryStatus") + } + } + } + } + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField + val CREDENTIAL_HOST_UNREACHABLE_ERROR = of("credential_host_unreachable_error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CREDENTIAL_HOST_UNREACHABLE_ERROR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CREDENTIAL_HOST_UNREACHABLE_ERROR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CREDENTIAL_HOST_UNREACHABLE_ERROR -> Value.CREDENTIAL_HOST_UNREACHABLE_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CREDENTIAL_HOST_UNREACHABLE_ERROR -> Known.CREDENTIAL_HOST_UNREACHABLE_ERROR + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsCredentialHostUnreachableError && + credentialId == other.credentialId && + message == other.message && + retryStatus == other.retryStatus && + type == other.type && + vaultId == other.vaultId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(credentialId, message, retryStatus, type, vaultId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsCredentialHostUnreachableError{credentialId=$credentialId, message=$message, retryStatus=$retryStatus, type=$type, vaultId=$vaultId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsEventParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsEventParams.kt index 81ad655f4..bc87db778 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsEventParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsEventParams.kt @@ -29,6 +29,7 @@ private constructor( private val userCustomToolResult: BetaManagedAgentsUserCustomToolResultEventParams? = null, private val userDefineOutcome: BetaManagedAgentsUserDefineOutcomeEventParams? = null, private val userToolResult: BetaManagedAgentsUserToolResultEventParams? = null, + private val systemMessage: BetaManagedAgentsSystemMessageEventParams? = null, private val _json: JsonValue? = null, ) { @@ -63,6 +64,16 @@ private constructor( fun userToolResult(): Optional = Optional.ofNullable(userToolResult) + /** + * Privileged context for the accompanying turn and all subsequent turns, appended to the + * session's system context as a `role: "system"` turn rather than replacing the top-level + * system prompt. At most one per request: it must be the final event and immediately follow the + * `user.message`, `user.tool_result`, or `user.custom_tool_result` it accompanies. Only + * supported on models that accept mid-conversation system messages. + */ + fun systemMessage(): Optional = + Optional.ofNullable(systemMessage) + fun isUserMessage(): Boolean = userMessage != null fun isUserInterrupt(): Boolean = userInterrupt != null @@ -75,6 +86,8 @@ private constructor( fun isUserToolResult(): Boolean = userToolResult != null + fun isSystemMessage(): Boolean = systemMessage != null + /** Parameters for sending a user message to the session. */ fun asUserMessage(): BetaManagedAgentsUserMessageEventParams = userMessage.getOrThrow("userMessage") @@ -106,6 +119,16 @@ private constructor( fun asUserToolResult(): BetaManagedAgentsUserToolResultEventParams = userToolResult.getOrThrow("userToolResult") + /** + * Privileged context for the accompanying turn and all subsequent turns, appended to the + * session's system context as a `role: "system"` turn rather than replacing the top-level + * system prompt. At most one per request: it must be the final event and immediately follow the + * `user.message`, `user.tool_result`, or `user.custom_tool_result` it accompanies. Only + * supported on models that accept mid-conversation system messages. + */ + fun asSystemMessage(): BetaManagedAgentsSystemMessageEventParams = + systemMessage.getOrThrow("systemMessage") + fun _json(): Optional = Optional.ofNullable(_json) /** @@ -145,6 +168,7 @@ private constructor( userCustomToolResult != null -> visitor.visitUserCustomToolResult(userCustomToolResult) userDefineOutcome != null -> visitor.visitUserDefineOutcome(userDefineOutcome) userToolResult != null -> visitor.visitUserToolResult(userToolResult) + systemMessage != null -> visitor.visitSystemMessage(systemMessage) else -> visitor.unknown(_json) } @@ -200,6 +224,12 @@ private constructor( ) { userToolResult.validate() } + + override fun visitSystemMessage( + systemMessage: BetaManagedAgentsSystemMessageEventParams + ) { + systemMessage.validate() + } } ) validated = true @@ -246,6 +276,10 @@ private constructor( userToolResult: BetaManagedAgentsUserToolResultEventParams ) = userToolResult.validity() + override fun visitSystemMessage( + systemMessage: BetaManagedAgentsSystemMessageEventParams + ) = systemMessage.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -261,7 +295,8 @@ private constructor( userToolConfirmation == other.userToolConfirmation && userCustomToolResult == other.userCustomToolResult && userDefineOutcome == other.userDefineOutcome && - userToolResult == other.userToolResult + userToolResult == other.userToolResult && + systemMessage == other.systemMessage } override fun hashCode(): Int = @@ -272,6 +307,7 @@ private constructor( userCustomToolResult, userDefineOutcome, userToolResult, + systemMessage, ) override fun toString(): String = @@ -285,6 +321,7 @@ private constructor( userDefineOutcome != null -> "BetaManagedAgentsEventParams{userDefineOutcome=$userDefineOutcome}" userToolResult != null -> "BetaManagedAgentsEventParams{userToolResult=$userToolResult}" + systemMessage != null -> "BetaManagedAgentsEventParams{systemMessage=$systemMessage}" _json != null -> "BetaManagedAgentsEventParams{_unknown=$_json}" else -> throw IllegalStateException("Invalid BetaManagedAgentsEventParams") } @@ -329,6 +366,17 @@ private constructor( @JvmStatic fun ofUserToolResult(userToolResult: BetaManagedAgentsUserToolResultEventParams) = BetaManagedAgentsEventParams(userToolResult = userToolResult) + + /** + * Privileged context for the accompanying turn and all subsequent turns, appended to the + * session's system context as a `role: "system"` turn rather than replacing the top-level + * system prompt. At most one per request: it must be the final event and immediately follow + * the `user.message`, `user.tool_result`, or `user.custom_tool_result` it accompanies. Only + * supported on models that accept mid-conversation system messages. + */ + @JvmStatic + fun ofSystemMessage(systemMessage: BetaManagedAgentsSystemMessageEventParams) = + BetaManagedAgentsEventParams(systemMessage = systemMessage) } /** @@ -368,6 +416,15 @@ private constructor( */ fun visitUserToolResult(userToolResult: BetaManagedAgentsUserToolResultEventParams): T + /** + * Privileged context for the accompanying turn and all subsequent turns, appended to the + * session's system context as a `role: "system"` turn rather than replacing the top-level + * system prompt. At most one per request: it must be the final event and immediately follow + * the `user.message`, `user.tool_result`, or `user.custom_tool_result` it accompanies. Only + * supported on models that accept mid-conversation system messages. + */ + fun visitSystemMessage(systemMessage: BetaManagedAgentsSystemMessageEventParams): T + /** * Maps an unknown variant of [BetaManagedAgentsEventParams] to a value of type [T]. * @@ -441,6 +498,14 @@ private constructor( ?.let { BetaManagedAgentsEventParams(userToolResult = it, _json = json) } ?: BetaManagedAgentsEventParams(_json = json) } + "system.message" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { BetaManagedAgentsEventParams(systemMessage = it, _json = json) } + ?: BetaManagedAgentsEventParams(_json = json) + } } return BetaManagedAgentsEventParams(_json = json) @@ -464,6 +529,7 @@ private constructor( generator.writeObject(value.userCustomToolResult) value.userDefineOutcome != null -> generator.writeObject(value.userDefineOutcome) value.userToolResult != null -> generator.writeObject(value.userToolResult) + value.systemMessage != null -> generator.writeObject(value.systemMessage) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid BetaManagedAgentsEventParams") } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSendSessionEvents.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSendSessionEvents.kt index dd2e0221c..cf0acb0dc 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSendSessionEvents.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSendSessionEvents.kt @@ -12,6 +12,7 @@ import com.anthropic.core.checkKnown import com.anthropic.core.getOrThrow import com.anthropic.core.toImmutable import com.anthropic.errors.AnthropicInvalidDataException +import com.anthropic.models.beta.sessions.BetaManagedAgentsSystemMessageEvent import com.anthropic.models.beta.sessions.BetaManagedAgentsUserToolResultEvent import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -161,6 +162,10 @@ private constructor( fun addData(userToolResult: BetaManagedAgentsUserToolResultEvent) = addData(Data.ofUserToolResult(userToolResult)) + /** Alias for calling [addData] with `Data.ofSystemMessage(systemMessage)`. */ + fun addData(systemMessage: BetaManagedAgentsSystemMessageEvent) = + addData(Data.ofSystemMessage(systemMessage)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -239,6 +244,7 @@ private constructor( private val userCustomToolResult: BetaManagedAgentsUserCustomToolResultEvent? = null, private val userDefineOutcome: BetaManagedAgentsUserDefineOutcomeEvent? = null, private val userToolResult: BetaManagedAgentsUserToolResultEvent? = null, + private val systemMessage: BetaManagedAgentsSystemMessageEvent? = null, private val _json: JsonValue? = null, ) { @@ -273,6 +279,13 @@ private constructor( fun userToolResult(): Optional = Optional.ofNullable(userToolResult) + /** + * A mid-conversation system message event. Carries system-role content that is appended to + * the session as a `role: "system"` turn. + */ + fun systemMessage(): Optional = + Optional.ofNullable(systemMessage) + fun isUserMessage(): Boolean = userMessage != null fun isUserInterrupt(): Boolean = userInterrupt != null @@ -285,6 +298,8 @@ private constructor( fun isUserToolResult(): Boolean = userToolResult != null + fun isSystemMessage(): Boolean = systemMessage != null + /** A user message event in the session conversation. */ fun asUserMessage(): BetaManagedAgentsUserMessageEvent = userMessage.getOrThrow("userMessage") @@ -316,6 +331,13 @@ private constructor( fun asUserToolResult(): BetaManagedAgentsUserToolResultEvent = userToolResult.getOrThrow("userToolResult") + /** + * A mid-conversation system message event. Carries system-role content that is appended to + * the session as a `role: "system"` turn. + */ + fun asSystemMessage(): BetaManagedAgentsSystemMessageEvent = + systemMessage.getOrThrow("systemMessage") + fun _json(): Optional = Optional.ofNullable(_json) /** @@ -357,6 +379,7 @@ private constructor( visitor.visitUserCustomToolResult(userCustomToolResult) userDefineOutcome != null -> visitor.visitUserDefineOutcome(userDefineOutcome) userToolResult != null -> visitor.visitUserToolResult(userToolResult) + systemMessage != null -> visitor.visitSystemMessage(systemMessage) else -> visitor.unknown(_json) } @@ -411,6 +434,12 @@ private constructor( ) { userToolResult.validate() } + + override fun visitSystemMessage( + systemMessage: BetaManagedAgentsSystemMessageEvent + ) { + systemMessage.validate() + } } ) validated = true @@ -457,6 +486,10 @@ private constructor( userToolResult: BetaManagedAgentsUserToolResultEvent ) = userToolResult.validity() + override fun visitSystemMessage( + systemMessage: BetaManagedAgentsSystemMessageEvent + ) = systemMessage.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -472,7 +505,8 @@ private constructor( userToolConfirmation == other.userToolConfirmation && userCustomToolResult == other.userCustomToolResult && userDefineOutcome == other.userDefineOutcome && - userToolResult == other.userToolResult + userToolResult == other.userToolResult && + systemMessage == other.systemMessage } override fun hashCode(): Int = @@ -483,6 +517,7 @@ private constructor( userCustomToolResult, userDefineOutcome, userToolResult, + systemMessage, ) override fun toString(): String = @@ -493,6 +528,7 @@ private constructor( userCustomToolResult != null -> "Data{userCustomToolResult=$userCustomToolResult}" userDefineOutcome != null -> "Data{userDefineOutcome=$userDefineOutcome}" userToolResult != null -> "Data{userToolResult=$userToolResult}" + systemMessage != null -> "Data{systemMessage=$systemMessage}" _json != null -> "Data{_unknown=$_json}" else -> throw IllegalStateException("Invalid Data") } @@ -537,6 +573,14 @@ private constructor( @JvmStatic fun ofUserToolResult(userToolResult: BetaManagedAgentsUserToolResultEvent) = Data(userToolResult = userToolResult) + + /** + * A mid-conversation system message event. Carries system-role content that is appended + * to the session as a `role: "system"` turn. + */ + @JvmStatic + fun ofSystemMessage(systemMessage: BetaManagedAgentsSystemMessageEvent) = + Data(systemMessage = systemMessage) } /** An interface that defines how to map each variant of [Data] to a value of type [T]. */ @@ -573,6 +617,12 @@ private constructor( */ fun visitUserToolResult(userToolResult: BetaManagedAgentsUserToolResultEvent): T + /** + * A mid-conversation system message event. Carries system-role content that is appended + * to the session as a `role: "system"` turn. + */ + fun visitSystemMessage(systemMessage: BetaManagedAgentsSystemMessageEvent): T + /** * Maps an unknown variant of [Data] to a value of type [T]. * @@ -639,6 +689,13 @@ private constructor( ) ?.let { Data(userToolResult = it, _json = json) } ?: Data(_json = json) } + "system.message" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Data(systemMessage = it, _json = json) } ?: Data(_json = json) + } } return Data(_json = json) @@ -662,6 +719,7 @@ private constructor( value.userDefineOutcome != null -> generator.writeObject(value.userDefineOutcome) value.userToolResult != null -> generator.writeObject(value.userToolResult) + value.systemMessage != null -> generator.writeObject(value.systemMessage) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Data") } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionErrorEvent.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionErrorEvent.kt index 4e6a311ef..8d009ba80 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionErrorEvent.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionErrorEvent.kt @@ -215,6 +215,13 @@ private constructor( /** Alias for calling [error] with `Error.ofBilling(billing)`. */ fun error(billing: BetaManagedAgentsBillingError) = error(Error.ofBilling(billing)) + /** + * Alias for calling [error] with + * `Error.ofCredentialHostUnreachable(credentialHostUnreachable)`. + */ + fun error(credentialHostUnreachable: BetaManagedAgentsCredentialHostUnreachableError) = + error(Error.ofCredentialHostUnreachable(credentialHostUnreachable)) + /** A timestamp in RFC 3339 format */ fun processedAt(processedAt: OffsetDateTime) = processedAt(JsonField.of(processedAt)) @@ -340,6 +347,8 @@ private constructor( private val mcpConnectionFailed: BetaManagedAgentsMcpConnectionFailedError? = null, private val mcpAuthenticationFailed: BetaManagedAgentsMcpAuthenticationFailedError? = null, private val billing: BetaManagedAgentsBillingError? = null, + private val credentialHostUnreachable: BetaManagedAgentsCredentialHostUnreachableError? = + null, private val _json: JsonValue? = null, ) { @@ -377,6 +386,13 @@ private constructor( */ fun billing(): Optional = Optional.ofNullable(billing) + /** + * An `environment_variable` credential's `auth.networking.allowed_hosts` includes a host + * the environment's network policy does not permit. + */ + fun credentialHostUnreachable(): Optional = + Optional.ofNullable(credentialHostUnreachable) + fun isUnknown(): Boolean = unknown != null fun isModelOverloaded(): Boolean = modelOverloaded != null @@ -391,6 +407,8 @@ private constructor( fun isBilling(): Boolean = billing != null + fun isCredentialHostUnreachable(): Boolean = credentialHostUnreachable != null + /** * An unknown or unexpected error occurred during session execution. A fallback variant; * clients that don't recognize a new error code can match on `retry_status` and `message` @@ -425,6 +443,13 @@ private constructor( */ fun asBilling(): BetaManagedAgentsBillingError = billing.getOrThrow("billing") + /** + * An `environment_variable` credential's `auth.networking.allowed_hosts` includes a host + * the environment's network policy does not permit. + */ + fun asCredentialHostUnreachable(): BetaManagedAgentsCredentialHostUnreachableError = + credentialHostUnreachable.getOrThrow("credentialHostUnreachable") + fun _json(): Optional = Optional.ofNullable(_json) /** @@ -466,6 +491,8 @@ private constructor( mcpAuthenticationFailed != null -> visitor.visitMcpAuthenticationFailed(mcpAuthenticationFailed) billing != null -> visitor.visitBilling(billing) + credentialHostUnreachable != null -> + visitor.visitCredentialHostUnreachable(credentialHostUnreachable) else -> visitor.unknown(_json) } @@ -524,6 +551,12 @@ private constructor( override fun visitBilling(billing: BetaManagedAgentsBillingError) { billing.validate() } + + override fun visitCredentialHostUnreachable( + credentialHostUnreachable: BetaManagedAgentsCredentialHostUnreachableError + ) { + credentialHostUnreachable.validate() + } } ) validated = true @@ -573,6 +606,10 @@ private constructor( override fun visitBilling(billing: BetaManagedAgentsBillingError) = billing.validity() + override fun visitCredentialHostUnreachable( + credentialHostUnreachable: BetaManagedAgentsCredentialHostUnreachableError + ) = credentialHostUnreachable.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -589,7 +626,8 @@ private constructor( modelRequestFailed == other.modelRequestFailed && mcpConnectionFailed == other.mcpConnectionFailed && mcpAuthenticationFailed == other.mcpAuthenticationFailed && - billing == other.billing + billing == other.billing && + credentialHostUnreachable == other.credentialHostUnreachable } override fun hashCode(): Int = @@ -601,6 +639,7 @@ private constructor( mcpConnectionFailed, mcpAuthenticationFailed, billing, + credentialHostUnreachable, ) override fun toString(): String = @@ -613,6 +652,8 @@ private constructor( mcpAuthenticationFailed != null -> "Error{mcpAuthenticationFailed=$mcpAuthenticationFailed}" billing != null -> "Error{billing=$billing}" + credentialHostUnreachable != null -> + "Error{credentialHostUnreachable=$credentialHostUnreachable}" _json != null -> "Error{_unknown=$_json}" else -> throw IllegalStateException("Invalid Error") } @@ -661,6 +702,15 @@ private constructor( */ @JvmStatic fun ofBilling(billing: BetaManagedAgentsBillingError) = Error(billing = billing) + + /** + * An `environment_variable` credential's `auth.networking.allowed_hosts` includes a + * host the environment's network policy does not permit. + */ + @JvmStatic + fun ofCredentialHostUnreachable( + credentialHostUnreachable: BetaManagedAgentsCredentialHostUnreachableError + ) = Error(credentialHostUnreachable = credentialHostUnreachable) } /** An interface that defines how to map each variant of [Error] to a value of type [T]. */ @@ -701,6 +751,14 @@ private constructor( */ fun visitBilling(billing: BetaManagedAgentsBillingError): T + /** + * An `environment_variable` credential's `auth.networking.allowed_hosts` includes a + * host the environment's network policy does not permit. + */ + fun visitCredentialHostUnreachable( + credentialHostUnreachable: BetaManagedAgentsCredentialHostUnreachableError + ): T + /** * Maps an unknown variant of [Error] to a value of type [T]. * @@ -771,6 +829,14 @@ private constructor( return tryDeserialize(node, jacksonTypeRef()) ?.let { Error(billing = it, _json = json) } ?: Error(_json = json) } + "credential_host_unreachable_error" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Error(credentialHostUnreachable = it, _json = json) } + ?: Error(_json = json) + } } return Error(_json = json) @@ -795,6 +861,8 @@ private constructor( value.mcpAuthenticationFailed != null -> generator.writeObject(value.mcpAuthenticationFailed) value.billing != null -> generator.writeObject(value.billing) + value.credentialHostUnreachable != null -> + generator.writeObject(value.credentialHostUnreachable) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Error") } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionEvent.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionEvent.kt index 8ca950e00..10db8de4c 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionEvent.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionEvent.kt @@ -8,6 +8,7 @@ import com.anthropic.core.JsonValue import com.anthropic.core.getOrThrow import com.anthropic.errors.AnthropicInvalidDataException import com.anthropic.models.beta.sessions.BetaManagedAgentsSessionUpdatedEvent +import com.anthropic.models.beta.sessions.BetaManagedAgentsSystemMessageEvent import com.anthropic.models.beta.sessions.BetaManagedAgentsUserToolResultEvent import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec @@ -67,6 +68,7 @@ private constructor( BetaManagedAgentsSessionThreadStatusRescheduledEvent? = null, private val sessionUpdated: BetaManagedAgentsSessionUpdatedEvent? = null, + private val systemMessage: BetaManagedAgentsSystemMessageEvent? = null, private val _json: JsonValue? = null, ) { @@ -255,6 +257,13 @@ private constructor( fun sessionUpdated(): Optional = Optional.ofNullable(sessionUpdated) + /** + * A mid-conversation system message event. Carries system-role content that is appended to the + * session as a `role: "system"` turn. + */ + fun systemMessage(): Optional = + Optional.ofNullable(systemMessage) + fun isUserMessage(): Boolean = userMessage != null fun isUserInterrupt(): Boolean = userInterrupt != null @@ -321,6 +330,8 @@ private constructor( fun isSessionUpdated(): Boolean = sessionUpdated != null + fun isSystemMessage(): Boolean = systemMessage != null + /** A user message event in the session conversation. */ fun asUserMessage(): BetaManagedAgentsUserMessageEvent = userMessage.getOrThrow("userMessage") @@ -502,6 +513,13 @@ private constructor( fun asSessionUpdated(): BetaManagedAgentsSessionUpdatedEvent = sessionUpdated.getOrThrow("sessionUpdated") + /** + * A mid-conversation system message event. Carries system-role content that is appended to the + * session as a `role: "system"` turn. + */ + fun asSystemMessage(): BetaManagedAgentsSystemMessageEvent = + systemMessage.getOrThrow("systemMessage") + fun _json(): Optional = Optional.ofNullable(_json) /** @@ -581,6 +599,7 @@ private constructor( sessionThreadStatusRescheduled != null -> visitor.visitSessionThreadStatusRescheduled(sessionThreadStatusRescheduled) sessionUpdated != null -> visitor.visitSessionUpdated(sessionUpdated) + systemMessage != null -> visitor.visitSystemMessage(systemMessage) else -> visitor.unknown(_json) } @@ -792,6 +811,12 @@ private constructor( ) { sessionUpdated.validate() } + + override fun visitSystemMessage( + systemMessage: BetaManagedAgentsSystemMessageEvent + ) { + systemMessage.validate() + } } ) validated = true @@ -944,6 +969,10 @@ private constructor( sessionUpdated: BetaManagedAgentsSessionUpdatedEvent ) = sessionUpdated.validity() + override fun visitSystemMessage( + systemMessage: BetaManagedAgentsSystemMessageEvent + ) = systemMessage.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -986,7 +1015,8 @@ private constructor( sessionThreadStatusTerminated == other.sessionThreadStatusTerminated && userToolResult == other.userToolResult && sessionThreadStatusRescheduled == other.sessionThreadStatusRescheduled && - sessionUpdated == other.sessionUpdated + sessionUpdated == other.sessionUpdated && + systemMessage == other.systemMessage } override fun hashCode(): Int = @@ -1024,6 +1054,7 @@ private constructor( userToolResult, sessionThreadStatusRescheduled, sessionUpdated, + systemMessage, ) override fun toString(): String = @@ -1088,6 +1119,7 @@ private constructor( "BetaManagedAgentsSessionEvent{sessionThreadStatusRescheduled=$sessionThreadStatusRescheduled}" sessionUpdated != null -> "BetaManagedAgentsSessionEvent{sessionUpdated=$sessionUpdated}" + systemMessage != null -> "BetaManagedAgentsSessionEvent{systemMessage=$systemMessage}" _json != null -> "BetaManagedAgentsSessionEvent{_unknown=$_json}" else -> throw IllegalStateException("Invalid BetaManagedAgentsSessionEvent") } @@ -1336,6 +1368,14 @@ private constructor( @JvmStatic fun ofSessionUpdated(sessionUpdated: BetaManagedAgentsSessionUpdatedEvent) = BetaManagedAgentsSessionEvent(sessionUpdated = sessionUpdated) + + /** + * A mid-conversation system message event. Carries system-role content that is appended to + * the session as a `role: "system"` turn. + */ + @JvmStatic + fun ofSystemMessage(systemMessage: BetaManagedAgentsSystemMessageEvent) = + BetaManagedAgentsSessionEvent(systemMessage = systemMessage) } /** @@ -1531,6 +1571,12 @@ private constructor( */ fun visitSessionUpdated(sessionUpdated: BetaManagedAgentsSessionUpdatedEvent): T + /** + * A mid-conversation system message event. Carries system-role content that is appended to + * the session as a `role: "system"` turn. + */ + fun visitSystemMessage(systemMessage: BetaManagedAgentsSystemMessageEvent): T + /** * Maps an unknown variant of [BetaManagedAgentsSessionEvent] to a value of type [T]. * @@ -1870,6 +1916,14 @@ private constructor( ?.let { BetaManagedAgentsSessionEvent(sessionUpdated = it, _json = json) } ?: BetaManagedAgentsSessionEvent(_json = json) } + "system.message" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { BetaManagedAgentsSessionEvent(systemMessage = it, _json = json) } + ?: BetaManagedAgentsSessionEvent(_json = json) + } } return BetaManagedAgentsSessionEvent(_json = json) @@ -1936,6 +1990,7 @@ private constructor( value.sessionThreadStatusRescheduled != null -> generator.writeObject(value.sessionThreadStatusRescheduled) value.sessionUpdated != null -> generator.writeObject(value.sessionUpdated) + value.systemMessage != null -> generator.writeObject(value.systemMessage) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid BetaManagedAgentsSessionEvent") } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsStreamSessionEvents.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsStreamSessionEvents.kt index c47580646..3c5ef298a 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsStreamSessionEvents.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsStreamSessionEvents.kt @@ -8,6 +8,7 @@ import com.anthropic.core.JsonValue import com.anthropic.core.getOrThrow import com.anthropic.errors.AnthropicInvalidDataException import com.anthropic.models.beta.sessions.BetaManagedAgentsSessionUpdatedEvent +import com.anthropic.models.beta.sessions.BetaManagedAgentsSystemMessageEvent import com.anthropic.models.beta.sessions.BetaManagedAgentsUserToolResultEvent import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec @@ -67,6 +68,7 @@ private constructor( BetaManagedAgentsSessionThreadStatusRescheduledEvent? = null, private val sessionUpdated: BetaManagedAgentsSessionUpdatedEvent? = null, + private val systemMessage: BetaManagedAgentsSystemMessageEvent? = null, private val _json: JsonValue? = null, ) { @@ -255,6 +257,13 @@ private constructor( fun sessionUpdated(): Optional = Optional.ofNullable(sessionUpdated) + /** + * A mid-conversation system message event. Carries system-role content that is appended to the + * session as a `role: "system"` turn. + */ + fun systemMessage(): Optional = + Optional.ofNullable(systemMessage) + fun isUserMessage(): Boolean = userMessage != null fun isUserInterrupt(): Boolean = userInterrupt != null @@ -321,6 +330,8 @@ private constructor( fun isSessionUpdated(): Boolean = sessionUpdated != null + fun isSystemMessage(): Boolean = systemMessage != null + /** A user message event in the session conversation. */ fun asUserMessage(): BetaManagedAgentsUserMessageEvent = userMessage.getOrThrow("userMessage") @@ -502,6 +513,13 @@ private constructor( fun asSessionUpdated(): BetaManagedAgentsSessionUpdatedEvent = sessionUpdated.getOrThrow("sessionUpdated") + /** + * A mid-conversation system message event. Carries system-role content that is appended to the + * session as a `role: "system"` turn. + */ + fun asSystemMessage(): BetaManagedAgentsSystemMessageEvent = + systemMessage.getOrThrow("systemMessage") + fun _json(): Optional = Optional.ofNullable(_json) /** @@ -581,6 +599,7 @@ private constructor( sessionThreadStatusRescheduled != null -> visitor.visitSessionThreadStatusRescheduled(sessionThreadStatusRescheduled) sessionUpdated != null -> visitor.visitSessionUpdated(sessionUpdated) + systemMessage != null -> visitor.visitSystemMessage(systemMessage) else -> visitor.unknown(_json) } @@ -792,6 +811,12 @@ private constructor( ) { sessionUpdated.validate() } + + override fun visitSystemMessage( + systemMessage: BetaManagedAgentsSystemMessageEvent + ) { + systemMessage.validate() + } } ) validated = true @@ -944,6 +969,10 @@ private constructor( sessionUpdated: BetaManagedAgentsSessionUpdatedEvent ) = sessionUpdated.validity() + override fun visitSystemMessage( + systemMessage: BetaManagedAgentsSystemMessageEvent + ) = systemMessage.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -986,7 +1015,8 @@ private constructor( sessionThreadStatusTerminated == other.sessionThreadStatusTerminated && userToolResult == other.userToolResult && sessionThreadStatusRescheduled == other.sessionThreadStatusRescheduled && - sessionUpdated == other.sessionUpdated + sessionUpdated == other.sessionUpdated && + systemMessage == other.systemMessage } override fun hashCode(): Int = @@ -1024,6 +1054,7 @@ private constructor( userToolResult, sessionThreadStatusRescheduled, sessionUpdated, + systemMessage, ) override fun toString(): String = @@ -1093,6 +1124,8 @@ private constructor( "BetaManagedAgentsStreamSessionEvents{sessionThreadStatusRescheduled=$sessionThreadStatusRescheduled}" sessionUpdated != null -> "BetaManagedAgentsStreamSessionEvents{sessionUpdated=$sessionUpdated}" + systemMessage != null -> + "BetaManagedAgentsStreamSessionEvents{systemMessage=$systemMessage}" _json != null -> "BetaManagedAgentsStreamSessionEvents{_unknown=$_json}" else -> throw IllegalStateException("Invalid BetaManagedAgentsStreamSessionEvents") } @@ -1359,6 +1392,14 @@ private constructor( @JvmStatic fun ofSessionUpdated(sessionUpdated: BetaManagedAgentsSessionUpdatedEvent) = BetaManagedAgentsStreamSessionEvents(sessionUpdated = sessionUpdated) + + /** + * A mid-conversation system message event. Carries system-role content that is appended to + * the session as a `role: "system"` turn. + */ + @JvmStatic + fun ofSystemMessage(systemMessage: BetaManagedAgentsSystemMessageEvent) = + BetaManagedAgentsStreamSessionEvents(systemMessage = systemMessage) } /** @@ -1554,6 +1595,12 @@ private constructor( */ fun visitSessionUpdated(sessionUpdated: BetaManagedAgentsSessionUpdatedEvent): T + /** + * A mid-conversation system message event. Carries system-role content that is appended to + * the session as a `role: "system"` turn. + */ + fun visitSystemMessage(systemMessage: BetaManagedAgentsSystemMessageEvent): T + /** * Maps an unknown variant of [BetaManagedAgentsStreamSessionEvents] to a value of type [T]. * @@ -1941,6 +1988,15 @@ private constructor( BetaManagedAgentsStreamSessionEvents(sessionUpdated = it, _json = json) } ?: BetaManagedAgentsStreamSessionEvents(_json = json) } + "system.message" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + BetaManagedAgentsStreamSessionEvents(systemMessage = it, _json = json) + } ?: BetaManagedAgentsStreamSessionEvents(_json = json) + } } return BetaManagedAgentsStreamSessionEvents(_json = json) @@ -2009,6 +2065,7 @@ private constructor( value.sessionThreadStatusRescheduled != null -> generator.writeObject(value.sessionThreadStatusRescheduled) value.sessionUpdated != null -> generator.writeObject(value.sessionUpdated) + value.systemMessage != null -> generator.writeObject(value.systemMessage) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid BetaManagedAgentsStreamSessionEvents") } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSystemMessageEventParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSystemMessageEventParams.kt new file mode 100644 index 000000000..5fa6044b8 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSystemMessageEventParams.kt @@ -0,0 +1,402 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.sessions.events + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkKnown +import com.anthropic.core.checkRequired +import com.anthropic.core.toImmutable +import com.anthropic.errors.AnthropicInvalidDataException +import com.anthropic.models.beta.sessions.BetaManagedAgentsSystemContentBlock +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** + * Privileged context for the accompanying turn and all subsequent turns, appended to the session's + * system context as a `role: "system"` turn rather than replacing the top-level system prompt. At + * most one per request: it must be the final event and immediately follow the `user.message`, + * `user.tool_result`, or `user.custom_tool_result` it accompanies. Only supported on models that + * accept mid-conversation system messages. + */ +class BetaManagedAgentsSystemMessageEventParams +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val content: JsonField>, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("content") + @ExcludeMissing + content: JsonField> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(content, type, mutableMapOf()) + + /** + * System content blocks to append. Text-only. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun content(): List = content.getRequired("content") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") + @ExcludeMissing + fun _content(): JsonField> = content + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsSystemMessageEventParams]. + * + * The following fields are required: + * ```java + * .content() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsSystemMessageEventParams]. */ + class Builder internal constructor() { + + private var content: JsonField>? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsSystemMessageEventParams: BetaManagedAgentsSystemMessageEventParams + ) = apply { + content = + betaManagedAgentsSystemMessageEventParams.content + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + type = betaManagedAgentsSystemMessageEventParams.type + additionalProperties = + betaManagedAgentsSystemMessageEventParams.additionalProperties.toMutableMap() + } + + /** System content blocks to append. Text-only. */ + fun content(content: List) = + content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun content(content: JsonField>) = apply { + this.content = content.map { it.toMutableList() } + } + + /** + * Adds a single [BetaManagedAgentsSystemContentBlock] to [Builder.content]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addContent(content: BetaManagedAgentsSystemContentBlock) = apply { + this.content = + (this.content ?: JsonField.of(mutableListOf())).also { + checkKnown("content", it).add(content) + } + } + + /** + * Alias for calling [addContent] with the following: + * ```java + * BetaManagedAgentsSystemContentBlock.builder() + * .type(BetaManagedAgentsSystemContentBlock.Type.TEXT) + * .text(text) + * .build() + * ``` + */ + fun addTextContent(text: String) = + addContent( + BetaManagedAgentsSystemContentBlock.builder() + .type(BetaManagedAgentsSystemContentBlock.Type.TEXT) + .text(text) + .build() + ) + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsSystemMessageEventParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsSystemMessageEventParams = + BetaManagedAgentsSystemMessageEventParams( + checkRequired("content", content).map { it.toImmutable() }, + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsSystemMessageEventParams = apply { + if (validated) { + return@apply + } + + content().forEach { it.validate() } + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (content.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SYSTEM_MESSAGE = of("system.message") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + SYSTEM_MESSAGE + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SYSTEM_MESSAGE, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SYSTEM_MESSAGE -> Value.SYSTEM_MESSAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SYSTEM_MESSAGE -> Known.SYSTEM_MESSAGE + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsSystemMessageEventParams && + content == other.content && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(content, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsSystemMessageEventParams{content=$content, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/EventListPageResponse.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/EventListPageResponse.kt index b0952924c..d972371c2 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/EventListPageResponse.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/EventListPageResponse.kt @@ -10,6 +10,7 @@ import com.anthropic.core.checkKnown import com.anthropic.core.toImmutable import com.anthropic.errors.AnthropicInvalidDataException import com.anthropic.models.beta.sessions.BetaManagedAgentsSessionUpdatedEvent +import com.anthropic.models.beta.sessions.BetaManagedAgentsSystemMessageEvent import com.anthropic.models.beta.sessions.BetaManagedAgentsUserToolResultEvent import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -420,6 +421,13 @@ private constructor( fun addData(sessionUpdated: BetaManagedAgentsSessionUpdatedEvent) = addData(BetaManagedAgentsSessionEvent.ofSessionUpdated(sessionUpdated)) + /** + * Alias for calling [addData] with + * `BetaManagedAgentsSessionEvent.ofSystemMessage(systemMessage)`. + */ + fun addData(systemMessage: BetaManagedAgentsSystemMessageEvent) = + addData(BetaManagedAgentsSessionEvent.ofSystemMessage(systemMessage)) + /** Opaque cursor for the next page. Null when no more results. */ fun nextPage(nextPage: String?) = nextPage(JsonField.ofNullable(nextPage)) diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/EventSendParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/EventSendParams.kt index 7adfddc4e..e66e50f2b 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/EventSendParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/EventSendParams.kt @@ -14,6 +14,7 @@ import com.anthropic.core.http.QueryParams import com.anthropic.core.toImmutable import com.anthropic.errors.AnthropicInvalidDataException import com.anthropic.models.beta.AnthropicBeta +import com.anthropic.models.beta.sessions.BetaManagedAgentsSystemContentBlock import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -243,6 +244,27 @@ private constructor( body.addUserToolResultEvent(toolUseId) } + /** + * Alias for calling [addEvent] with + * `BetaManagedAgentsEventParams.ofSystemMessage(systemMessage)`. + */ + fun addEvent(systemMessage: BetaManagedAgentsSystemMessageEventParams) = apply { + body.addEvent(systemMessage) + } + + /** + * Alias for calling [addEvent] with the following: + * ```java + * BetaManagedAgentsSystemMessageEventParams.builder() + * .type(BetaManagedAgentsSystemMessageEventParams.Type.SYSTEM_MESSAGE) + * .content(content) + * .build() + * ``` + */ + fun addSystemMessageEvent(content: List) = apply { + body.addSystemMessageEvent(content) + } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) } @@ -593,6 +615,30 @@ private constructor( .build() ) + /** + * Alias for calling [addEvent] with + * `BetaManagedAgentsEventParams.ofSystemMessage(systemMessage)`. + */ + fun addEvent(systemMessage: BetaManagedAgentsSystemMessageEventParams) = + addEvent(BetaManagedAgentsEventParams.ofSystemMessage(systemMessage)) + + /** + * Alias for calling [addEvent] with the following: + * ```java + * BetaManagedAgentsSystemMessageEventParams.builder() + * .type(BetaManagedAgentsSystemMessageEventParams.Type.SYSTEM_MESSAGE) + * .content(content) + * .build() + * ``` + */ + fun addSystemMessageEvent(content: List) = + addEvent( + BetaManagedAgentsSystemMessageEventParams.builder() + .type(BetaManagedAgentsSystemMessageEventParams.Type.SYSTEM_MESSAGE) + .content(content) + .build() + ) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/BetaManagedAgentsStreamSessionThreadEvents.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/BetaManagedAgentsStreamSessionThreadEvents.kt index d1a264eca..4103b8be2 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/BetaManagedAgentsStreamSessionThreadEvents.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/BetaManagedAgentsStreamSessionThreadEvents.kt @@ -8,6 +8,7 @@ import com.anthropic.core.JsonValue import com.anthropic.core.getOrThrow import com.anthropic.errors.AnthropicInvalidDataException import com.anthropic.models.beta.sessions.BetaManagedAgentsSessionUpdatedEvent +import com.anthropic.models.beta.sessions.BetaManagedAgentsSystemMessageEvent import com.anthropic.models.beta.sessions.BetaManagedAgentsUserToolResultEvent import com.anthropic.models.beta.sessions.events.BetaManagedAgentsAgentCustomToolUseEvent import com.anthropic.models.beta.sessions.events.BetaManagedAgentsAgentMcpToolResultEvent @@ -98,6 +99,7 @@ private constructor( BetaManagedAgentsSessionThreadStatusRescheduledEvent? = null, private val sessionUpdated: BetaManagedAgentsSessionUpdatedEvent? = null, + private val systemMessage: BetaManagedAgentsSystemMessageEvent? = null, private val _json: JsonValue? = null, ) { @@ -286,6 +288,13 @@ private constructor( fun sessionUpdated(): Optional = Optional.ofNullable(sessionUpdated) + /** + * A mid-conversation system message event. Carries system-role content that is appended to the + * session as a `role: "system"` turn. + */ + fun systemMessage(): Optional = + Optional.ofNullable(systemMessage) + fun isUserMessage(): Boolean = userMessage != null fun isUserInterrupt(): Boolean = userInterrupt != null @@ -352,6 +361,8 @@ private constructor( fun isSessionUpdated(): Boolean = sessionUpdated != null + fun isSystemMessage(): Boolean = systemMessage != null + /** A user message event in the session conversation. */ fun asUserMessage(): BetaManagedAgentsUserMessageEvent = userMessage.getOrThrow("userMessage") @@ -533,6 +544,13 @@ private constructor( fun asSessionUpdated(): BetaManagedAgentsSessionUpdatedEvent = sessionUpdated.getOrThrow("sessionUpdated") + /** + * A mid-conversation system message event. Carries system-role content that is appended to the + * session as a `role: "system"` turn. + */ + fun asSystemMessage(): BetaManagedAgentsSystemMessageEvent = + systemMessage.getOrThrow("systemMessage") + fun _json(): Optional = Optional.ofNullable(_json) /** @@ -612,6 +630,7 @@ private constructor( sessionThreadStatusRescheduled != null -> visitor.visitSessionThreadStatusRescheduled(sessionThreadStatusRescheduled) sessionUpdated != null -> visitor.visitSessionUpdated(sessionUpdated) + systemMessage != null -> visitor.visitSystemMessage(systemMessage) else -> visitor.unknown(_json) } @@ -823,6 +842,12 @@ private constructor( ) { sessionUpdated.validate() } + + override fun visitSystemMessage( + systemMessage: BetaManagedAgentsSystemMessageEvent + ) { + systemMessage.validate() + } } ) validated = true @@ -975,6 +1000,10 @@ private constructor( sessionUpdated: BetaManagedAgentsSessionUpdatedEvent ) = sessionUpdated.validity() + override fun visitSystemMessage( + systemMessage: BetaManagedAgentsSystemMessageEvent + ) = systemMessage.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -1017,7 +1046,8 @@ private constructor( sessionThreadStatusTerminated == other.sessionThreadStatusTerminated && userToolResult == other.userToolResult && sessionThreadStatusRescheduled == other.sessionThreadStatusRescheduled && - sessionUpdated == other.sessionUpdated + sessionUpdated == other.sessionUpdated && + systemMessage == other.systemMessage } override fun hashCode(): Int = @@ -1055,6 +1085,7 @@ private constructor( userToolResult, sessionThreadStatusRescheduled, sessionUpdated, + systemMessage, ) override fun toString(): String = @@ -1125,6 +1156,8 @@ private constructor( "BetaManagedAgentsStreamSessionThreadEvents{sessionThreadStatusRescheduled=$sessionThreadStatusRescheduled}" sessionUpdated != null -> "BetaManagedAgentsStreamSessionThreadEvents{sessionUpdated=$sessionUpdated}" + systemMessage != null -> + "BetaManagedAgentsStreamSessionThreadEvents{systemMessage=$systemMessage}" _json != null -> "BetaManagedAgentsStreamSessionThreadEvents{_unknown=$_json}" else -> throw IllegalStateException("Invalid BetaManagedAgentsStreamSessionThreadEvents") @@ -1404,6 +1437,14 @@ private constructor( @JvmStatic fun ofSessionUpdated(sessionUpdated: BetaManagedAgentsSessionUpdatedEvent) = BetaManagedAgentsStreamSessionThreadEvents(sessionUpdated = sessionUpdated) + + /** + * A mid-conversation system message event. Carries system-role content that is appended to + * the session as a `role: "system"` turn. + */ + @JvmStatic + fun ofSystemMessage(systemMessage: BetaManagedAgentsSystemMessageEvent) = + BetaManagedAgentsStreamSessionThreadEvents(systemMessage = systemMessage) } /** @@ -1599,6 +1640,12 @@ private constructor( */ fun visitSessionUpdated(sessionUpdated: BetaManagedAgentsSessionUpdatedEvent): T + /** + * A mid-conversation system message event. Carries system-role content that is appended to + * the session as a `role: "system"` turn. + */ + fun visitSystemMessage(systemMessage: BetaManagedAgentsSystemMessageEvent): T + /** * Maps an unknown variant of [BetaManagedAgentsStreamSessionThreadEvents] to a value of * type [T]. @@ -2022,6 +2069,18 @@ private constructor( ) } ?: BetaManagedAgentsStreamSessionThreadEvents(_json = json) } + "system.message" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + BetaManagedAgentsStreamSessionThreadEvents( + systemMessage = it, + _json = json, + ) + } ?: BetaManagedAgentsStreamSessionThreadEvents(_json = json) + } } return BetaManagedAgentsStreamSessionThreadEvents(_json = json) @@ -2090,6 +2149,7 @@ private constructor( value.sessionThreadStatusRescheduled != null -> generator.writeObject(value.sessionThreadStatusRescheduled) value.sessionUpdated != null -> generator.writeObject(value.sessionUpdated) + value.systemMessage != null -> generator.writeObject(value.systemMessage) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException( diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/events/EventListPageResponse.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/events/EventListPageResponse.kt index 238a09d8e..7b54406be 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/events/EventListPageResponse.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/events/EventListPageResponse.kt @@ -10,6 +10,7 @@ import com.anthropic.core.checkKnown import com.anthropic.core.toImmutable import com.anthropic.errors.AnthropicInvalidDataException import com.anthropic.models.beta.sessions.BetaManagedAgentsSessionUpdatedEvent +import com.anthropic.models.beta.sessions.BetaManagedAgentsSystemMessageEvent import com.anthropic.models.beta.sessions.BetaManagedAgentsUserToolResultEvent import com.anthropic.models.beta.sessions.events.BetaManagedAgentsAgentCustomToolUseEvent import com.anthropic.models.beta.sessions.events.BetaManagedAgentsAgentMcpToolResultEvent @@ -452,6 +453,13 @@ private constructor( fun addData(sessionUpdated: BetaManagedAgentsSessionUpdatedEvent) = addData(BetaManagedAgentsSessionEvent.ofSessionUpdated(sessionUpdated)) + /** + * Alias for calling [addData] with + * `BetaManagedAgentsSessionEvent.ofSystemMessage(systemMessage)`. + */ + fun addData(systemMessage: BetaManagedAgentsSystemMessageEvent) = + addData(BetaManagedAgentsSessionEvent.ofSystemMessage(systemMessage)) + /** Opaque cursor for the next page. Null when no more results. */ fun nextPage(nextPage: String?) = nextPage(JsonField.ofNullable(nextPage)) diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsCredential.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsCredential.kt index d2ae3d9c9..1af393e0f 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsCredential.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsCredential.kt @@ -359,6 +359,10 @@ private constructor( .build() ) + /** Alias for calling [auth] with `Auth.ofEnvironmentVariable(environmentVariable)`. */ + fun auth(environmentVariable: BetaManagedAgentsEnvironmentVariableAuthResponse) = + auth(Auth.ofEnvironmentVariable(environmentVariable)) + /** A timestamp in RFC 3339 format */ fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) @@ -543,6 +547,7 @@ private constructor( private constructor( private val mcpOAuth: BetaManagedAgentsMcpOAuthAuthResponse? = null, private val staticBearer: BetaManagedAgentsStaticBearerAuthResponse? = null, + private val environmentVariable: BetaManagedAgentsEnvironmentVariableAuthResponse? = null, private val _json: JsonValue? = null, ) { @@ -554,10 +559,16 @@ private constructor( fun staticBearer(): Optional = Optional.ofNullable(staticBearer) + /** Environment variable credential details. The secret value is never returned. */ + fun environmentVariable(): Optional = + Optional.ofNullable(environmentVariable) + fun isMcpOAuth(): Boolean = mcpOAuth != null fun isStaticBearer(): Boolean = staticBearer != null + fun isEnvironmentVariable(): Boolean = environmentVariable != null + /** OAuth credential details for an MCP server. */ fun asMcpOAuth(): BetaManagedAgentsMcpOAuthAuthResponse = mcpOAuth.getOrThrow("mcpOAuth") @@ -565,6 +576,10 @@ private constructor( fun asStaticBearer(): BetaManagedAgentsStaticBearerAuthResponse = staticBearer.getOrThrow("staticBearer") + /** Environment variable credential details. The secret value is never returned. */ + fun asEnvironmentVariable(): BetaManagedAgentsEnvironmentVariableAuthResponse = + environmentVariable.getOrThrow("environmentVariable") + fun _json(): Optional = Optional.ofNullable(_json) /** @@ -600,6 +615,7 @@ private constructor( when { mcpOAuth != null -> visitor.visitMcpOAuth(mcpOAuth) staticBearer != null -> visitor.visitStaticBearer(staticBearer) + environmentVariable != null -> visitor.visitEnvironmentVariable(environmentVariable) else -> visitor.unknown(_json) } @@ -630,6 +646,12 @@ private constructor( ) { staticBearer.validate() } + + override fun visitEnvironmentVariable( + environmentVariable: BetaManagedAgentsEnvironmentVariableAuthResponse + ) { + environmentVariable.validate() + } } ) validated = true @@ -660,6 +682,10 @@ private constructor( staticBearer: BetaManagedAgentsStaticBearerAuthResponse ) = staticBearer.validity() + override fun visitEnvironmentVariable( + environmentVariable: BetaManagedAgentsEnvironmentVariableAuthResponse + ) = environmentVariable.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -669,15 +695,19 @@ private constructor( return true } - return other is Auth && mcpOAuth == other.mcpOAuth && staticBearer == other.staticBearer + return other is Auth && + mcpOAuth == other.mcpOAuth && + staticBearer == other.staticBearer && + environmentVariable == other.environmentVariable } - override fun hashCode(): Int = Objects.hash(mcpOAuth, staticBearer) + override fun hashCode(): Int = Objects.hash(mcpOAuth, staticBearer, environmentVariable) override fun toString(): String = when { mcpOAuth != null -> "Auth{mcpOAuth=$mcpOAuth}" staticBearer != null -> "Auth{staticBearer=$staticBearer}" + environmentVariable != null -> "Auth{environmentVariable=$environmentVariable}" _json != null -> "Auth{_unknown=$_json}" else -> throw IllegalStateException("Invalid Auth") } @@ -693,6 +723,12 @@ private constructor( @JvmStatic fun ofStaticBearer(staticBearer: BetaManagedAgentsStaticBearerAuthResponse) = Auth(staticBearer = staticBearer) + + /** Environment variable credential details. The secret value is never returned. */ + @JvmStatic + fun ofEnvironmentVariable( + environmentVariable: BetaManagedAgentsEnvironmentVariableAuthResponse + ) = Auth(environmentVariable = environmentVariable) } /** An interface that defines how to map each variant of [Auth] to a value of type [T]. */ @@ -704,6 +740,11 @@ private constructor( /** Static bearer token credential details for an MCP server. */ fun visitStaticBearer(staticBearer: BetaManagedAgentsStaticBearerAuthResponse): T + /** Environment variable credential details. The secret value is never returned. */ + fun visitEnvironmentVariable( + environmentVariable: BetaManagedAgentsEnvironmentVariableAuthResponse + ): T + /** * Maps an unknown variant of [Auth] to a value of type [T]. * @@ -739,6 +780,14 @@ private constructor( ) ?.let { Auth(staticBearer = it, _json = json) } ?: Auth(_json = json) } + "environment_variable" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Auth(environmentVariable = it, _json = json) } + ?: Auth(_json = json) + } } return Auth(_json = json) @@ -755,6 +804,8 @@ private constructor( when { value.mcpOAuth != null -> generator.writeObject(value.mcpOAuth) value.staticBearer != null -> generator.writeObject(value.staticBearer) + value.environmentVariable != null -> + generator.writeObject(value.environmentVariable) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Auth") } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsCredentialNetworkingParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsCredentialNetworkingParams.kt new file mode 100644 index 000000000..910a817d5 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsCredentialNetworkingParams.kt @@ -0,0 +1,295 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.vaults.credentials + +import com.anthropic.core.BaseDeserializer +import com.anthropic.core.BaseSerializer +import com.anthropic.core.JsonValue +import com.anthropic.core.getOrThrow +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Substitute the secret on any host the session's Environment network policy permits egress to. The + * Environment's network policy is the only boundary on where the secret can reach. + */ +@JsonDeserialize(using = BetaManagedAgentsCredentialNetworkingParams.Deserializer::class) +@JsonSerialize(using = BetaManagedAgentsCredentialNetworkingParams.Serializer::class) +class BetaManagedAgentsCredentialNetworkingParams +private constructor( + private val unrestricted: BetaManagedAgentsUnrestrictedCredentialNetworkingParams? = null, + private val limited: BetaManagedAgentsLimitedCredentialNetworkingParams? = null, + private val _json: JsonValue? = null, +) { + + /** + * Substitute the secret on any host the session's Environment network policy permits egress to. + * The Environment's network policy is the only boundary on where the secret can reach. + */ + fun unrestricted(): Optional = + Optional.ofNullable(unrestricted) + + /** Substitute the secret only on requests to the listed hosts. */ + fun limited(): Optional = + Optional.ofNullable(limited) + + fun isUnrestricted(): Boolean = unrestricted != null + + fun isLimited(): Boolean = limited != null + + /** + * Substitute the secret on any host the session's Environment network policy permits egress to. + * The Environment's network policy is the only boundary on where the secret can reach. + */ + fun asUnrestricted(): BetaManagedAgentsUnrestrictedCredentialNetworkingParams = + unrestricted.getOrThrow("unrestricted") + + /** Substitute the secret only on requests to the listed hosts. */ + fun asLimited(): BetaManagedAgentsLimitedCredentialNetworkingParams = + limited.getOrThrow("limited") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.anthropic.core.JsonValue; + * import java.util.Optional; + * + * Optional result = betaManagedAgentsCredentialNetworkingParams.accept(new BetaManagedAgentsCredentialNetworkingParams.Visitor>() { + * @Override + * public Optional visitUnrestricted(BetaManagedAgentsUnrestrictedCredentialNetworkingParams unrestricted) { + * return Optional.of(unrestricted.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws AnthropicInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + unrestricted != null -> visitor.visitUnrestricted(unrestricted) + limited != null -> visitor.visitLimited(limited) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsCredentialNetworkingParams = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnrestricted( + unrestricted: BetaManagedAgentsUnrestrictedCredentialNetworkingParams + ) { + unrestricted.validate() + } + + override fun visitLimited( + limited: BetaManagedAgentsLimitedCredentialNetworkingParams + ) { + limited.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnrestricted( + unrestricted: BetaManagedAgentsUnrestrictedCredentialNetworkingParams + ) = unrestricted.validity() + + override fun visitLimited( + limited: BetaManagedAgentsLimitedCredentialNetworkingParams + ) = limited.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsCredentialNetworkingParams && + unrestricted == other.unrestricted && + limited == other.limited + } + + override fun hashCode(): Int = Objects.hash(unrestricted, limited) + + override fun toString(): String = + when { + unrestricted != null -> + "BetaManagedAgentsCredentialNetworkingParams{unrestricted=$unrestricted}" + limited != null -> "BetaManagedAgentsCredentialNetworkingParams{limited=$limited}" + _json != null -> "BetaManagedAgentsCredentialNetworkingParams{_unknown=$_json}" + else -> + throw IllegalStateException("Invalid BetaManagedAgentsCredentialNetworkingParams") + } + + companion object { + + /** + * Substitute the secret on any host the session's Environment network policy permits egress + * to. The Environment's network policy is the only boundary on where the secret can reach. + */ + @JvmStatic + fun ofUnrestricted(unrestricted: BetaManagedAgentsUnrestrictedCredentialNetworkingParams) = + BetaManagedAgentsCredentialNetworkingParams(unrestricted = unrestricted) + + /** Substitute the secret only on requests to the listed hosts. */ + @JvmStatic + fun ofLimited(limited: BetaManagedAgentsLimitedCredentialNetworkingParams) = + BetaManagedAgentsCredentialNetworkingParams(limited = limited) + } + + /** + * An interface that defines how to map each variant of + * [BetaManagedAgentsCredentialNetworkingParams] to a value of type [T]. + */ + interface Visitor { + + /** + * Substitute the secret on any host the session's Environment network policy permits egress + * to. The Environment's network policy is the only boundary on where the secret can reach. + */ + fun visitUnrestricted( + unrestricted: BetaManagedAgentsUnrestrictedCredentialNetworkingParams + ): T + + /** Substitute the secret only on requests to the listed hosts. */ + fun visitLimited(limited: BetaManagedAgentsLimitedCredentialNetworkingParams): T + + /** + * Maps an unknown variant of [BetaManagedAgentsCredentialNetworkingParams] to a value of + * type [T]. + * + * An instance of [BetaManagedAgentsCredentialNetworkingParams] can contain an unknown + * variant if it was deserialized from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws AnthropicInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw AnthropicInvalidDataException( + "Unknown BetaManagedAgentsCredentialNetworkingParams: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + BetaManagedAgentsCredentialNetworkingParams::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): BetaManagedAgentsCredentialNetworkingParams { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "unrestricted" -> { + return tryDeserialize( + node, + jacksonTypeRef< + BetaManagedAgentsUnrestrictedCredentialNetworkingParams + >(), + ) + ?.let { + BetaManagedAgentsCredentialNetworkingParams( + unrestricted = it, + _json = json, + ) + } ?: BetaManagedAgentsCredentialNetworkingParams(_json = json) + } + "limited" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + BetaManagedAgentsCredentialNetworkingParams(limited = it, _json = json) + } ?: BetaManagedAgentsCredentialNetworkingParams(_json = json) + } + } + + return BetaManagedAgentsCredentialNetworkingParams(_json = json) + } + } + + internal class Serializer : + BaseSerializer( + BetaManagedAgentsCredentialNetworkingParams::class + ) { + + override fun serialize( + value: BetaManagedAgentsCredentialNetworkingParams, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unrestricted != null -> generator.writeObject(value.unrestricted) + value.limited != null -> generator.writeObject(value.limited) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid BetaManagedAgentsCredentialNetworkingParams" + ) + } + } + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsEnvironmentVariableAuthResponse.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsEnvironmentVariableAuthResponse.kt new file mode 100644 index 000000000..6db90b2d7 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsEnvironmentVariableAuthResponse.kt @@ -0,0 +1,692 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.vaults.credentials + +import com.anthropic.core.BaseDeserializer +import com.anthropic.core.BaseSerializer +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.core.getOrThrow +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Environment variable credential details. The secret value is never returned. */ +class BetaManagedAgentsEnvironmentVariableAuthResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val networking: JsonField, + private val secretName: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("networking") + @ExcludeMissing + networking: JsonField = JsonMissing.of(), + @JsonProperty("secret_name") + @ExcludeMissing + secretName: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(networking, secretName, type, mutableMapOf()) + + /** + * Outbound hosts the secret value is substituted on. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun networking(): Networking = networking.getRequired("networking") + + /** + * Name of the environment variable. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun secretName(): String = secretName.getRequired("secret_name") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [networking]. + * + * Unlike [networking], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("networking") + @ExcludeMissing + fun _networking(): JsonField = networking + + /** + * Returns the raw JSON value of [secretName]. + * + * Unlike [secretName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("secret_name") @ExcludeMissing fun _secretName(): JsonField = secretName + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsEnvironmentVariableAuthResponse]. + * + * The following fields are required: + * ```java + * .networking() + * .secretName() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsEnvironmentVariableAuthResponse]. */ + class Builder internal constructor() { + + private var networking: JsonField? = null + private var secretName: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsEnvironmentVariableAuthResponse: + BetaManagedAgentsEnvironmentVariableAuthResponse + ) = apply { + networking = betaManagedAgentsEnvironmentVariableAuthResponse.networking + secretName = betaManagedAgentsEnvironmentVariableAuthResponse.secretName + type = betaManagedAgentsEnvironmentVariableAuthResponse.type + additionalProperties = + betaManagedAgentsEnvironmentVariableAuthResponse.additionalProperties.toMutableMap() + } + + /** Outbound hosts the secret value is substituted on. */ + fun networking(networking: Networking) = networking(JsonField.of(networking)) + + /** + * Sets [Builder.networking] to an arbitrary JSON value. + * + * You should usually call [Builder.networking] with a well-typed [Networking] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun networking(networking: JsonField) = apply { this.networking = networking } + + /** Alias for calling [networking] with `Networking.ofUnrestricted(unrestricted)`. */ + fun networking(unrestricted: BetaManagedAgentsUnrestrictedCredentialNetworkingResponse) = + networking(Networking.ofUnrestricted(unrestricted)) + + /** Alias for calling [networking] with `Networking.ofLimited(limited)`. */ + fun networking(limited: BetaManagedAgentsLimitedCredentialNetworkingResponse) = + networking(Networking.ofLimited(limited)) + + /** + * Alias for calling [networking] with the following: + * ```java + * BetaManagedAgentsLimitedCredentialNetworkingResponse.builder() + * .type(BetaManagedAgentsLimitedCredentialNetworkingResponse.Type.LIMITED) + * .allowedHosts(allowedHosts) + * .build() + * ``` + */ + fun limitedNetworking(allowedHosts: List) = + networking( + BetaManagedAgentsLimitedCredentialNetworkingResponse.builder() + .type(BetaManagedAgentsLimitedCredentialNetworkingResponse.Type.LIMITED) + .allowedHosts(allowedHosts) + .build() + ) + + /** Name of the environment variable. */ + fun secretName(secretName: String) = secretName(JsonField.of(secretName)) + + /** + * Sets [Builder.secretName] to an arbitrary JSON value. + * + * You should usually call [Builder.secretName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun secretName(secretName: JsonField) = apply { this.secretName = secretName } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsEnvironmentVariableAuthResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .networking() + * .secretName() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsEnvironmentVariableAuthResponse = + BetaManagedAgentsEnvironmentVariableAuthResponse( + checkRequired("networking", networking), + checkRequired("secretName", secretName), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsEnvironmentVariableAuthResponse = apply { + if (validated) { + return@apply + } + + networking().validate() + secretName() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (networking.asKnown().getOrNull()?.validity() ?: 0) + + (if (secretName.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + /** Outbound hosts the secret value is substituted on. */ + @JsonDeserialize(using = Networking.Deserializer::class) + @JsonSerialize(using = Networking.Serializer::class) + class Networking + private constructor( + private val unrestricted: BetaManagedAgentsUnrestrictedCredentialNetworkingResponse? = null, + private val limited: BetaManagedAgentsLimitedCredentialNetworkingResponse? = null, + private val _json: JsonValue? = null, + ) { + + /** + * The secret is substituted on any host the session's Environment network policy permits + * egress to. + */ + fun unrestricted(): Optional = + Optional.ofNullable(unrestricted) + + /** The secret is substituted only on requests to the listed hosts. */ + fun limited(): Optional = + Optional.ofNullable(limited) + + fun isUnrestricted(): Boolean = unrestricted != null + + fun isLimited(): Boolean = limited != null + + /** + * The secret is substituted on any host the session's Environment network policy permits + * egress to. + */ + fun asUnrestricted(): BetaManagedAgentsUnrestrictedCredentialNetworkingResponse = + unrestricted.getOrThrow("unrestricted") + + /** The secret is substituted only on requests to the listed hosts. */ + fun asLimited(): BetaManagedAgentsLimitedCredentialNetworkingResponse = + limited.getOrThrow("limited") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.anthropic.core.JsonValue; + * import java.util.Optional; + * + * Optional result = networking.accept(new Networking.Visitor>() { + * @Override + * public Optional visitUnrestricted(BetaManagedAgentsUnrestrictedCredentialNetworkingResponse unrestricted) { + * return Optional.of(unrestricted.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws AnthropicInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + unrestricted != null -> visitor.visitUnrestricted(unrestricted) + limited != null -> visitor.visitLimited(limited) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Networking = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnrestricted( + unrestricted: BetaManagedAgentsUnrestrictedCredentialNetworkingResponse + ) { + unrestricted.validate() + } + + override fun visitLimited( + limited: BetaManagedAgentsLimitedCredentialNetworkingResponse + ) { + limited.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnrestricted( + unrestricted: BetaManagedAgentsUnrestrictedCredentialNetworkingResponse + ) = unrestricted.validity() + + override fun visitLimited( + limited: BetaManagedAgentsLimitedCredentialNetworkingResponse + ) = limited.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Networking && + unrestricted == other.unrestricted && + limited == other.limited + } + + override fun hashCode(): Int = Objects.hash(unrestricted, limited) + + override fun toString(): String = + when { + unrestricted != null -> "Networking{unrestricted=$unrestricted}" + limited != null -> "Networking{limited=$limited}" + _json != null -> "Networking{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Networking") + } + + companion object { + + /** + * The secret is substituted on any host the session's Environment network policy + * permits egress to. + */ + @JvmStatic + fun ofUnrestricted( + unrestricted: BetaManagedAgentsUnrestrictedCredentialNetworkingResponse + ) = Networking(unrestricted = unrestricted) + + /** The secret is substituted only on requests to the listed hosts. */ + @JvmStatic + fun ofLimited(limited: BetaManagedAgentsLimitedCredentialNetworkingResponse) = + Networking(limited = limited) + } + + /** + * An interface that defines how to map each variant of [Networking] to a value of type [T]. + */ + interface Visitor { + + /** + * The secret is substituted on any host the session's Environment network policy + * permits egress to. + */ + fun visitUnrestricted( + unrestricted: BetaManagedAgentsUnrestrictedCredentialNetworkingResponse + ): T + + /** The secret is substituted only on requests to the listed hosts. */ + fun visitLimited(limited: BetaManagedAgentsLimitedCredentialNetworkingResponse): T + + /** + * Maps an unknown variant of [Networking] to a value of type [T]. + * + * An instance of [Networking] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws AnthropicInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw AnthropicInvalidDataException("Unknown Networking: $json") + } + } + + internal class Deserializer : BaseDeserializer(Networking::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Networking { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "unrestricted" -> { + return tryDeserialize( + node, + jacksonTypeRef< + BetaManagedAgentsUnrestrictedCredentialNetworkingResponse + >(), + ) + ?.let { Networking(unrestricted = it, _json = json) } + ?: Networking(_json = json) + } + "limited" -> { + return tryDeserialize( + node, + jacksonTypeRef< + BetaManagedAgentsLimitedCredentialNetworkingResponse + >(), + ) + ?.let { Networking(limited = it, _json = json) } + ?: Networking(_json = json) + } + } + + return Networking(_json = json) + } + } + + internal class Serializer : BaseSerializer(Networking::class) { + + override fun serialize( + value: Networking, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unrestricted != null -> generator.writeObject(value.unrestricted) + value.limited != null -> generator.writeObject(value.limited) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Networking") + } + } + } + } + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ENVIRONMENT_VARIABLE = of("environment_variable") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ENVIRONMENT_VARIABLE + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ENVIRONMENT_VARIABLE, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ENVIRONMENT_VARIABLE -> Value.ENVIRONMENT_VARIABLE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ENVIRONMENT_VARIABLE -> Known.ENVIRONMENT_VARIABLE + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsEnvironmentVariableAuthResponse && + networking == other.networking && + secretName == other.secretName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(networking, secretName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsEnvironmentVariableAuthResponse{networking=$networking, secretName=$secretName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsEnvironmentVariableCreateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsEnvironmentVariableCreateParams.kt new file mode 100644 index 000000000..2e1fdfc58 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsEnvironmentVariableCreateParams.kt @@ -0,0 +1,476 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.vaults.credentials + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** Parameters for creating an environment variable credential. */ +class BetaManagedAgentsEnvironmentVariableCreateParams +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val networking: JsonField, + private val secretName: JsonField, + private val secretValue: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("networking") + @ExcludeMissing + networking: JsonField = JsonMissing.of(), + @JsonProperty("secret_name") + @ExcludeMissing + secretName: JsonField = JsonMissing.of(), + @JsonProperty("secret_value") + @ExcludeMissing + secretValue: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(networking, secretName, secretValue, type, mutableMapOf()) + + /** + * Outbound hosts the secret value is substituted on. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun networking(): BetaManagedAgentsCredentialNetworkingParams = + networking.getRequired("networking") + + /** + * Name of the environment variable. Immutable after create. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun secretName(): String = secretName.getRequired("secret_name") + + /** + * Secret value. Write-only; never returned in responses. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun secretValue(): String = secretValue.getRequired("secret_value") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [networking]. + * + * Unlike [networking], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("networking") + @ExcludeMissing + fun _networking(): JsonField = networking + + /** + * Returns the raw JSON value of [secretName]. + * + * Unlike [secretName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("secret_name") @ExcludeMissing fun _secretName(): JsonField = secretName + + /** + * Returns the raw JSON value of [secretValue]. + * + * Unlike [secretValue], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("secret_value") + @ExcludeMissing + fun _secretValue(): JsonField = secretValue + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsEnvironmentVariableCreateParams]. + * + * The following fields are required: + * ```java + * .networking() + * .secretName() + * .secretValue() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsEnvironmentVariableCreateParams]. */ + class Builder internal constructor() { + + private var networking: JsonField? = null + private var secretName: JsonField? = null + private var secretValue: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsEnvironmentVariableCreateParams: + BetaManagedAgentsEnvironmentVariableCreateParams + ) = apply { + networking = betaManagedAgentsEnvironmentVariableCreateParams.networking + secretName = betaManagedAgentsEnvironmentVariableCreateParams.secretName + secretValue = betaManagedAgentsEnvironmentVariableCreateParams.secretValue + type = betaManagedAgentsEnvironmentVariableCreateParams.type + additionalProperties = + betaManagedAgentsEnvironmentVariableCreateParams.additionalProperties.toMutableMap() + } + + /** Outbound hosts the secret value is substituted on. */ + fun networking(networking: BetaManagedAgentsCredentialNetworkingParams) = + networking(JsonField.of(networking)) + + /** + * Sets [Builder.networking] to an arbitrary JSON value. + * + * You should usually call [Builder.networking] with a well-typed + * [BetaManagedAgentsCredentialNetworkingParams] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun networking(networking: JsonField) = apply { + this.networking = networking + } + + /** + * Alias for calling [networking] with + * `BetaManagedAgentsCredentialNetworkingParams.ofUnrestricted(unrestricted)`. + */ + fun networking(unrestricted: BetaManagedAgentsUnrestrictedCredentialNetworkingParams) = + networking(BetaManagedAgentsCredentialNetworkingParams.ofUnrestricted(unrestricted)) + + /** + * Alias for calling [networking] with + * `BetaManagedAgentsCredentialNetworkingParams.ofLimited(limited)`. + */ + fun networking(limited: BetaManagedAgentsLimitedCredentialNetworkingParams) = + networking(BetaManagedAgentsCredentialNetworkingParams.ofLimited(limited)) + + /** + * Alias for calling [networking] with the following: + * ```java + * BetaManagedAgentsLimitedCredentialNetworkingParams.builder() + * .type(BetaManagedAgentsLimitedCredentialNetworkingParams.Type.LIMITED) + * .allowedHosts(allowedHosts) + * .build() + * ``` + */ + fun limitedNetworking(allowedHosts: List) = + networking( + BetaManagedAgentsLimitedCredentialNetworkingParams.builder() + .type(BetaManagedAgentsLimitedCredentialNetworkingParams.Type.LIMITED) + .allowedHosts(allowedHosts) + .build() + ) + + /** Name of the environment variable. Immutable after create. */ + fun secretName(secretName: String) = secretName(JsonField.of(secretName)) + + /** + * Sets [Builder.secretName] to an arbitrary JSON value. + * + * You should usually call [Builder.secretName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun secretName(secretName: JsonField) = apply { this.secretName = secretName } + + /** Secret value. Write-only; never returned in responses. */ + fun secretValue(secretValue: String) = secretValue(JsonField.of(secretValue)) + + /** + * Sets [Builder.secretValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secretValue] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun secretValue(secretValue: JsonField) = apply { this.secretValue = secretValue } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsEnvironmentVariableCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .networking() + * .secretName() + * .secretValue() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsEnvironmentVariableCreateParams = + BetaManagedAgentsEnvironmentVariableCreateParams( + checkRequired("networking", networking), + checkRequired("secretName", secretName), + checkRequired("secretValue", secretValue), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsEnvironmentVariableCreateParams = apply { + if (validated) { + return@apply + } + + networking().validate() + secretName() + secretValue() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (networking.asKnown().getOrNull()?.validity() ?: 0) + + (if (secretName.asKnown().isPresent) 1 else 0) + + (if (secretValue.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ENVIRONMENT_VARIABLE = of("environment_variable") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ENVIRONMENT_VARIABLE + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ENVIRONMENT_VARIABLE, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ENVIRONMENT_VARIABLE -> Value.ENVIRONMENT_VARIABLE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ENVIRONMENT_VARIABLE -> Known.ENVIRONMENT_VARIABLE + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsEnvironmentVariableCreateParams && + networking == other.networking && + secretName == other.secretName && + secretValue == other.secretValue && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(networking, secretName, secretValue, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsEnvironmentVariableCreateParams{networking=$networking, secretName=$secretName, secretValue=$secretValue, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsEnvironmentVariableUpdateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsEnvironmentVariableUpdateParams.kt new file mode 100644 index 000000000..d7165b123 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsEnvironmentVariableUpdateParams.kt @@ -0,0 +1,442 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.vaults.credentials + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Parameters for updating an environment variable credential. `secret_name` is immutable. */ +class BetaManagedAgentsEnvironmentVariableUpdateParams +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val type: JsonField, + private val networking: JsonField, + private val secretValue: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("networking") + @ExcludeMissing + networking: JsonField = JsonMissing.of(), + @JsonProperty("secret_value") + @ExcludeMissing + secretValue: JsonField = JsonMissing.of(), + ) : this(type, networking, secretValue, mutableMapOf()) + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Updated networking scope. Full replacement. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun networking(): Optional = + networking.getOptional("networking") + + /** + * Updated secret value. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun secretValue(): Optional = secretValue.getOptional("secret_value") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [networking]. + * + * Unlike [networking], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("networking") + @ExcludeMissing + fun _networking(): JsonField = networking + + /** + * Returns the raw JSON value of [secretValue]. + * + * Unlike [secretValue], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("secret_value") + @ExcludeMissing + fun _secretValue(): JsonField = secretValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsEnvironmentVariableUpdateParams]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsEnvironmentVariableUpdateParams]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var networking: JsonField = + JsonMissing.of() + private var secretValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsEnvironmentVariableUpdateParams: + BetaManagedAgentsEnvironmentVariableUpdateParams + ) = apply { + type = betaManagedAgentsEnvironmentVariableUpdateParams.type + networking = betaManagedAgentsEnvironmentVariableUpdateParams.networking + secretValue = betaManagedAgentsEnvironmentVariableUpdateParams.secretValue + additionalProperties = + betaManagedAgentsEnvironmentVariableUpdateParams.additionalProperties.toMutableMap() + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** Updated networking scope. Full replacement. */ + fun networking(networking: BetaManagedAgentsCredentialNetworkingParams?) = + networking(JsonField.ofNullable(networking)) + + /** Alias for calling [Builder.networking] with `networking.orElse(null)`. */ + fun networking(networking: Optional) = + networking(networking.getOrNull()) + + /** + * Sets [Builder.networking] to an arbitrary JSON value. + * + * You should usually call [Builder.networking] with a well-typed + * [BetaManagedAgentsCredentialNetworkingParams] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun networking(networking: JsonField) = apply { + this.networking = networking + } + + /** + * Alias for calling [networking] with + * `BetaManagedAgentsCredentialNetworkingParams.ofUnrestricted(unrestricted)`. + */ + fun networking(unrestricted: BetaManagedAgentsUnrestrictedCredentialNetworkingParams) = + networking(BetaManagedAgentsCredentialNetworkingParams.ofUnrestricted(unrestricted)) + + /** + * Alias for calling [networking] with + * `BetaManagedAgentsCredentialNetworkingParams.ofLimited(limited)`. + */ + fun networking(limited: BetaManagedAgentsLimitedCredentialNetworkingParams) = + networking(BetaManagedAgentsCredentialNetworkingParams.ofLimited(limited)) + + /** + * Alias for calling [networking] with the following: + * ```java + * BetaManagedAgentsLimitedCredentialNetworkingParams.builder() + * .type(BetaManagedAgentsLimitedCredentialNetworkingParams.Type.LIMITED) + * .allowedHosts(allowedHosts) + * .build() + * ``` + */ + fun limitedNetworking(allowedHosts: List) = + networking( + BetaManagedAgentsLimitedCredentialNetworkingParams.builder() + .type(BetaManagedAgentsLimitedCredentialNetworkingParams.Type.LIMITED) + .allowedHosts(allowedHosts) + .build() + ) + + /** Updated secret value. */ + fun secretValue(secretValue: String?) = secretValue(JsonField.ofNullable(secretValue)) + + /** Alias for calling [Builder.secretValue] with `secretValue.orElse(null)`. */ + fun secretValue(secretValue: Optional) = secretValue(secretValue.getOrNull()) + + /** + * Sets [Builder.secretValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secretValue] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun secretValue(secretValue: JsonField) = apply { this.secretValue = secretValue } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsEnvironmentVariableUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsEnvironmentVariableUpdateParams = + BetaManagedAgentsEnvironmentVariableUpdateParams( + checkRequired("type", type), + networking, + secretValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsEnvironmentVariableUpdateParams = apply { + if (validated) { + return@apply + } + + type().validate() + networking().ifPresent { it.validate() } + secretValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (type.asKnown().getOrNull()?.validity() ?: 0) + + (networking.asKnown().getOrNull()?.validity() ?: 0) + + (if (secretValue.asKnown().isPresent) 1 else 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ENVIRONMENT_VARIABLE = of("environment_variable") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ENVIRONMENT_VARIABLE + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ENVIRONMENT_VARIABLE, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ENVIRONMENT_VARIABLE -> Value.ENVIRONMENT_VARIABLE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ENVIRONMENT_VARIABLE -> Known.ENVIRONMENT_VARIABLE + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsEnvironmentVariableUpdateParams && + type == other.type && + networking == other.networking && + secretValue == other.secretValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, networking, secretValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsEnvironmentVariableUpdateParams{type=$type, networking=$networking, secretValue=$secretValue, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsLimitedCredentialNetworkingParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsLimitedCredentialNetworkingParams.kt new file mode 100644 index 000000000..f4c81118a --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsLimitedCredentialNetworkingParams.kt @@ -0,0 +1,387 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.vaults.credentials + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkKnown +import com.anthropic.core.checkRequired +import com.anthropic.core.toImmutable +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** Substitute the secret only on requests to the listed hosts. */ +class BetaManagedAgentsLimitedCredentialNetworkingParams +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val allowedHosts: JsonField>, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("allowed_hosts") + @ExcludeMissing + allowedHosts: JsonField> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(allowedHosts, type, mutableMapOf()) + + /** + * Hostnames on which the secret will be substituted. Each entry is a bare hostname + * (`api.example.com`), an IPv4 address (`192.0.2.1`), or a `*.`-prefixed wildcard + * (`*.example.com`). URLs, ports, paths, and IPv6 addresses are not accepted. At most 16 + * entries. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun allowedHosts(): List = allowedHosts.getRequired("allowed_hosts") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [allowedHosts]. + * + * Unlike [allowedHosts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allowed_hosts") + @ExcludeMissing + fun _allowedHosts(): JsonField> = allowedHosts + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsLimitedCredentialNetworkingParams]. + * + * The following fields are required: + * ```java + * .allowedHosts() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsLimitedCredentialNetworkingParams]. */ + class Builder internal constructor() { + + private var allowedHosts: JsonField>? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsLimitedCredentialNetworkingParams: + BetaManagedAgentsLimitedCredentialNetworkingParams + ) = apply { + allowedHosts = + betaManagedAgentsLimitedCredentialNetworkingParams.allowedHosts + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + type = betaManagedAgentsLimitedCredentialNetworkingParams.type + additionalProperties = + betaManagedAgentsLimitedCredentialNetworkingParams.additionalProperties + .toMutableMap() + } + + /** + * Hostnames on which the secret will be substituted. Each entry is a bare hostname + * (`api.example.com`), an IPv4 address (`192.0.2.1`), or a `*.`-prefixed wildcard + * (`*.example.com`). URLs, ports, paths, and IPv6 addresses are not accepted. At most 16 + * entries. + */ + fun allowedHosts(allowedHosts: List) = allowedHosts(JsonField.of(allowedHosts)) + + /** + * Sets [Builder.allowedHosts] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedHosts] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allowedHosts(allowedHosts: JsonField>) = apply { + this.allowedHosts = allowedHosts.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [allowedHosts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedHost(allowedHost: String) = apply { + allowedHosts = + (allowedHosts ?: JsonField.of(mutableListOf())).also { + checkKnown("allowedHosts", it).add(allowedHost) + } + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsLimitedCredentialNetworkingParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allowedHosts() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsLimitedCredentialNetworkingParams = + BetaManagedAgentsLimitedCredentialNetworkingParams( + checkRequired("allowedHosts", allowedHosts).map { it.toImmutable() }, + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsLimitedCredentialNetworkingParams = apply { + if (validated) { + return@apply + } + + allowedHosts() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (allowedHosts.asKnown().getOrNull()?.size ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LIMITED = of("limited") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + LIMITED + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LIMITED, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LIMITED -> Value.LIMITED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LIMITED -> Known.LIMITED + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsLimitedCredentialNetworkingParams && + allowedHosts == other.allowedHosts && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(allowedHosts, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsLimitedCredentialNetworkingParams{allowedHosts=$allowedHosts, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsLimitedCredentialNetworkingResponse.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsLimitedCredentialNetworkingResponse.kt new file mode 100644 index 000000000..b70722f3d --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsLimitedCredentialNetworkingResponse.kt @@ -0,0 +1,384 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.vaults.credentials + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkKnown +import com.anthropic.core.checkRequired +import com.anthropic.core.toImmutable +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** The secret is substituted only on requests to the listed hosts. */ +class BetaManagedAgentsLimitedCredentialNetworkingResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val allowedHosts: JsonField>, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("allowed_hosts") + @ExcludeMissing + allowedHosts: JsonField> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(allowedHosts, type, mutableMapOf()) + + /** + * Hostnames on which the secret will be substituted. An entry matches the request host exactly; + * a `*.`-prefixed entry matches any subdomain of the named domain but not the domain itself. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun allowedHosts(): List = allowedHosts.getRequired("allowed_hosts") + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [allowedHosts]. + * + * Unlike [allowedHosts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allowed_hosts") + @ExcludeMissing + fun _allowedHosts(): JsonField> = allowedHosts + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsLimitedCredentialNetworkingResponse]. + * + * The following fields are required: + * ```java + * .allowedHosts() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsLimitedCredentialNetworkingResponse]. */ + class Builder internal constructor() { + + private var allowedHosts: JsonField>? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsLimitedCredentialNetworkingResponse: + BetaManagedAgentsLimitedCredentialNetworkingResponse + ) = apply { + allowedHosts = + betaManagedAgentsLimitedCredentialNetworkingResponse.allowedHosts + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + type = betaManagedAgentsLimitedCredentialNetworkingResponse.type + additionalProperties = + betaManagedAgentsLimitedCredentialNetworkingResponse.additionalProperties + .toMutableMap() + } + + /** + * Hostnames on which the secret will be substituted. An entry matches the request host + * exactly; a `*.`-prefixed entry matches any subdomain of the named domain but not the + * domain itself. + */ + fun allowedHosts(allowedHosts: List) = allowedHosts(JsonField.of(allowedHosts)) + + /** + * Sets [Builder.allowedHosts] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedHosts] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allowedHosts(allowedHosts: JsonField>) = apply { + this.allowedHosts = allowedHosts.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [allowedHosts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedHost(allowedHost: String) = apply { + allowedHosts = + (allowedHosts ?: JsonField.of(mutableListOf())).also { + checkKnown("allowedHosts", it).add(allowedHost) + } + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaManagedAgentsLimitedCredentialNetworkingResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allowedHosts() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsLimitedCredentialNetworkingResponse = + BetaManagedAgentsLimitedCredentialNetworkingResponse( + checkRequired("allowedHosts", allowedHosts).map { it.toImmutable() }, + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsLimitedCredentialNetworkingResponse = apply { + if (validated) { + return@apply + } + + allowedHosts() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (allowedHosts.asKnown().getOrNull()?.size ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LIMITED = of("limited") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + LIMITED + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LIMITED, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LIMITED -> Value.LIMITED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LIMITED -> Known.LIMITED + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsLimitedCredentialNetworkingResponse && + allowedHosts == other.allowedHosts && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(allowedHosts, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsLimitedCredentialNetworkingResponse{allowedHosts=$allowedHosts, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsUnrestrictedCredentialNetworkingParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsUnrestrictedCredentialNetworkingParams.kt new file mode 100644 index 000000000..28df68c29 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsUnrestrictedCredentialNetworkingParams.kt @@ -0,0 +1,321 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.vaults.credentials + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** + * Substitute the secret on any host the session's Environment network policy permits egress to. The + * Environment's network policy is the only boundary on where the secret can reach. + */ +class BetaManagedAgentsUnrestrictedCredentialNetworkingParams +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsUnrestrictedCredentialNetworkingParams]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsUnrestrictedCredentialNetworkingParams]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsUnrestrictedCredentialNetworkingParams: + BetaManagedAgentsUnrestrictedCredentialNetworkingParams + ) = apply { + type = betaManagedAgentsUnrestrictedCredentialNetworkingParams.type + additionalProperties = + betaManagedAgentsUnrestrictedCredentialNetworkingParams.additionalProperties + .toMutableMap() + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of + * [BetaManagedAgentsUnrestrictedCredentialNetworkingParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsUnrestrictedCredentialNetworkingParams = + BetaManagedAgentsUnrestrictedCredentialNetworkingParams( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsUnrestrictedCredentialNetworkingParams = apply { + if (validated) { + return@apply + } + + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val UNRESTRICTED = of("unrestricted") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + UNRESTRICTED + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + UNRESTRICTED, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + UNRESTRICTED -> Value.UNRESTRICTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + UNRESTRICTED -> Known.UNRESTRICTED + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsUnrestrictedCredentialNetworkingParams && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsUnrestrictedCredentialNetworkingParams{type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsUnrestrictedCredentialNetworkingResponse.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsUnrestrictedCredentialNetworkingResponse.kt new file mode 100644 index 000000000..0658656cd --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsUnrestrictedCredentialNetworkingResponse.kt @@ -0,0 +1,320 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.vaults.credentials + +import com.anthropic.core.Enum +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.checkRequired +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** + * The secret is substituted on any host the session's Environment network policy permits egress to. + */ +class BetaManagedAgentsUnrestrictedCredentialNetworkingResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BetaManagedAgentsUnrestrictedCredentialNetworkingResponse]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsUnrestrictedCredentialNetworkingResponse]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsUnrestrictedCredentialNetworkingResponse: + BetaManagedAgentsUnrestrictedCredentialNetworkingResponse + ) = apply { + type = betaManagedAgentsUnrestrictedCredentialNetworkingResponse.type + additionalProperties = + betaManagedAgentsUnrestrictedCredentialNetworkingResponse.additionalProperties + .toMutableMap() + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of + * [BetaManagedAgentsUnrestrictedCredentialNetworkingResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsUnrestrictedCredentialNetworkingResponse = + BetaManagedAgentsUnrestrictedCredentialNetworkingResponse( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaManagedAgentsUnrestrictedCredentialNetworkingResponse = apply { + if (validated) { + return@apply + } + + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val UNRESTRICTED = of("unrestricted") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + UNRESTRICTED + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + UNRESTRICTED, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + UNRESTRICTED -> Value.UNRESTRICTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws AnthropicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + UNRESTRICTED -> Known.UNRESTRICTED + else -> throw AnthropicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws AnthropicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + AnthropicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws AnthropicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: AnthropicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsUnrestrictedCredentialNetworkingResponse && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsUnrestrictedCredentialNetworkingResponse{type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialCreateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialCreateParams.kt index f9b5b1e37..23ecbbaf6 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialCreateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialCreateParams.kt @@ -193,6 +193,11 @@ private constructor( body.auth(staticBearer) } + /** Alias for calling [auth] with `Auth.ofEnvironmentVariable(environmentVariable)`. */ + fun auth(environmentVariable: BetaManagedAgentsEnvironmentVariableCreateParams) = apply { + body.auth(environmentVariable) + } + /** Human-readable name for the credential. Up to 255 characters. */ fun displayName(displayName: String?) = apply { body.displayName(displayName) } @@ -509,6 +514,10 @@ private constructor( fun auth(staticBearer: BetaManagedAgentsStaticBearerCreateParams) = auth(Auth.ofStaticBearer(staticBearer)) + /** Alias for calling [auth] with `Auth.ofEnvironmentVariable(environmentVariable)`. */ + fun auth(environmentVariable: BetaManagedAgentsEnvironmentVariableCreateParams) = + auth(Auth.ofEnvironmentVariable(environmentVariable)) + /** Human-readable name for the credential. Up to 255 characters. */ fun displayName(displayName: String?) = displayName(JsonField.ofNullable(displayName)) @@ -652,6 +661,7 @@ private constructor( private constructor( private val mcpOAuth: BetaManagedAgentsMcpOAuthCreateParams? = null, private val staticBearer: BetaManagedAgentsStaticBearerCreateParams? = null, + private val environmentVariable: BetaManagedAgentsEnvironmentVariableCreateParams? = null, private val _json: JsonValue? = null, ) { @@ -663,10 +673,16 @@ private constructor( fun staticBearer(): Optional = Optional.ofNullable(staticBearer) + /** Parameters for creating an environment variable credential. */ + fun environmentVariable(): Optional = + Optional.ofNullable(environmentVariable) + fun isMcpOAuth(): Boolean = mcpOAuth != null fun isStaticBearer(): Boolean = staticBearer != null + fun isEnvironmentVariable(): Boolean = environmentVariable != null + /** Parameters for creating an MCP OAuth credential. */ fun asMcpOAuth(): BetaManagedAgentsMcpOAuthCreateParams = mcpOAuth.getOrThrow("mcpOAuth") @@ -674,6 +690,10 @@ private constructor( fun asStaticBearer(): BetaManagedAgentsStaticBearerCreateParams = staticBearer.getOrThrow("staticBearer") + /** Parameters for creating an environment variable credential. */ + fun asEnvironmentVariable(): BetaManagedAgentsEnvironmentVariableCreateParams = + environmentVariable.getOrThrow("environmentVariable") + fun _json(): Optional = Optional.ofNullable(_json) /** @@ -709,6 +729,7 @@ private constructor( when { mcpOAuth != null -> visitor.visitMcpOAuth(mcpOAuth) staticBearer != null -> visitor.visitStaticBearer(staticBearer) + environmentVariable != null -> visitor.visitEnvironmentVariable(environmentVariable) else -> visitor.unknown(_json) } @@ -739,6 +760,12 @@ private constructor( ) { staticBearer.validate() } + + override fun visitEnvironmentVariable( + environmentVariable: BetaManagedAgentsEnvironmentVariableCreateParams + ) { + environmentVariable.validate() + } } ) validated = true @@ -769,6 +796,10 @@ private constructor( staticBearer: BetaManagedAgentsStaticBearerCreateParams ) = staticBearer.validity() + override fun visitEnvironmentVariable( + environmentVariable: BetaManagedAgentsEnvironmentVariableCreateParams + ) = environmentVariable.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -778,15 +809,19 @@ private constructor( return true } - return other is Auth && mcpOAuth == other.mcpOAuth && staticBearer == other.staticBearer + return other is Auth && + mcpOAuth == other.mcpOAuth && + staticBearer == other.staticBearer && + environmentVariable == other.environmentVariable } - override fun hashCode(): Int = Objects.hash(mcpOAuth, staticBearer) + override fun hashCode(): Int = Objects.hash(mcpOAuth, staticBearer, environmentVariable) override fun toString(): String = when { mcpOAuth != null -> "Auth{mcpOAuth=$mcpOAuth}" staticBearer != null -> "Auth{staticBearer=$staticBearer}" + environmentVariable != null -> "Auth{environmentVariable=$environmentVariable}" _json != null -> "Auth{_unknown=$_json}" else -> throw IllegalStateException("Invalid Auth") } @@ -802,6 +837,12 @@ private constructor( @JvmStatic fun ofStaticBearer(staticBearer: BetaManagedAgentsStaticBearerCreateParams) = Auth(staticBearer = staticBearer) + + /** Parameters for creating an environment variable credential. */ + @JvmStatic + fun ofEnvironmentVariable( + environmentVariable: BetaManagedAgentsEnvironmentVariableCreateParams + ) = Auth(environmentVariable = environmentVariable) } /** An interface that defines how to map each variant of [Auth] to a value of type [T]. */ @@ -813,6 +854,11 @@ private constructor( /** Parameters for creating a static bearer token credential. */ fun visitStaticBearer(staticBearer: BetaManagedAgentsStaticBearerCreateParams): T + /** Parameters for creating an environment variable credential. */ + fun visitEnvironmentVariable( + environmentVariable: BetaManagedAgentsEnvironmentVariableCreateParams + ): T + /** * Maps an unknown variant of [Auth] to a value of type [T]. * @@ -848,6 +894,14 @@ private constructor( ) ?.let { Auth(staticBearer = it, _json = json) } ?: Auth(_json = json) } + "environment_variable" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Auth(environmentVariable = it, _json = json) } + ?: Auth(_json = json) + } } return Auth(_json = json) @@ -864,6 +918,8 @@ private constructor( when { value.mcpOAuth != null -> generator.writeObject(value.mcpOAuth) value.staticBearer != null -> generator.writeObject(value.staticBearer) + value.environmentVariable != null -> + generator.writeObject(value.environmentVariable) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Auth") } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialUpdateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialUpdateParams.kt index 977fa631b..54ef93743 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialUpdateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialUpdateParams.kt @@ -200,6 +200,11 @@ private constructor( body.auth(staticBearer) } + /** Alias for calling [auth] with `Auth.ofEnvironmentVariable(environmentVariable)`. */ + fun auth(environmentVariable: BetaManagedAgentsEnvironmentVariableUpdateParams) = apply { + body.auth(environmentVariable) + } + /** Updated human-readable name for the credential. 1-255 characters. */ fun displayName(displayName: String?) = apply { body.displayName(displayName) } @@ -514,6 +519,10 @@ private constructor( fun auth(staticBearer: BetaManagedAgentsStaticBearerUpdateParams) = auth(Auth.ofStaticBearer(staticBearer)) + /** Alias for calling [auth] with `Auth.ofEnvironmentVariable(environmentVariable)`. */ + fun auth(environmentVariable: BetaManagedAgentsEnvironmentVariableUpdateParams) = + auth(Auth.ofEnvironmentVariable(environmentVariable)) + /** Updated human-readable name for the credential. 1-255 characters. */ fun displayName(displayName: String?) = displayName(JsonField.ofNullable(displayName)) @@ -648,6 +657,7 @@ private constructor( private constructor( private val mcpOAuth: BetaManagedAgentsMcpOAuthUpdateParams? = null, private val staticBearer: BetaManagedAgentsStaticBearerUpdateParams? = null, + private val environmentVariable: BetaManagedAgentsEnvironmentVariableUpdateParams? = null, private val _json: JsonValue? = null, ) { @@ -662,10 +672,18 @@ private constructor( fun staticBearer(): Optional = Optional.ofNullable(staticBearer) + /** + * Parameters for updating an environment variable credential. `secret_name` is immutable. + */ + fun environmentVariable(): Optional = + Optional.ofNullable(environmentVariable) + fun isMcpOAuth(): Boolean = mcpOAuth != null fun isStaticBearer(): Boolean = staticBearer != null + fun isEnvironmentVariable(): Boolean = environmentVariable != null + /** Parameters for updating an MCP OAuth credential. The `mcp_server_url` is immutable. */ fun asMcpOAuth(): BetaManagedAgentsMcpOAuthUpdateParams = mcpOAuth.getOrThrow("mcpOAuth") @@ -676,6 +694,12 @@ private constructor( fun asStaticBearer(): BetaManagedAgentsStaticBearerUpdateParams = staticBearer.getOrThrow("staticBearer") + /** + * Parameters for updating an environment variable credential. `secret_name` is immutable. + */ + fun asEnvironmentVariable(): BetaManagedAgentsEnvironmentVariableUpdateParams = + environmentVariable.getOrThrow("environmentVariable") + fun _json(): Optional = Optional.ofNullable(_json) /** @@ -711,6 +735,7 @@ private constructor( when { mcpOAuth != null -> visitor.visitMcpOAuth(mcpOAuth) staticBearer != null -> visitor.visitStaticBearer(staticBearer) + environmentVariable != null -> visitor.visitEnvironmentVariable(environmentVariable) else -> visitor.unknown(_json) } @@ -741,6 +766,12 @@ private constructor( ) { staticBearer.validate() } + + override fun visitEnvironmentVariable( + environmentVariable: BetaManagedAgentsEnvironmentVariableUpdateParams + ) { + environmentVariable.validate() + } } ) validated = true @@ -771,6 +802,10 @@ private constructor( staticBearer: BetaManagedAgentsStaticBearerUpdateParams ) = staticBearer.validity() + override fun visitEnvironmentVariable( + environmentVariable: BetaManagedAgentsEnvironmentVariableUpdateParams + ) = environmentVariable.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -780,15 +815,19 @@ private constructor( return true } - return other is Auth && mcpOAuth == other.mcpOAuth && staticBearer == other.staticBearer + return other is Auth && + mcpOAuth == other.mcpOAuth && + staticBearer == other.staticBearer && + environmentVariable == other.environmentVariable } - override fun hashCode(): Int = Objects.hash(mcpOAuth, staticBearer) + override fun hashCode(): Int = Objects.hash(mcpOAuth, staticBearer, environmentVariable) override fun toString(): String = when { mcpOAuth != null -> "Auth{mcpOAuth=$mcpOAuth}" staticBearer != null -> "Auth{staticBearer=$staticBearer}" + environmentVariable != null -> "Auth{environmentVariable=$environmentVariable}" _json != null -> "Auth{_unknown=$_json}" else -> throw IllegalStateException("Invalid Auth") } @@ -809,6 +848,15 @@ private constructor( @JvmStatic fun ofStaticBearer(staticBearer: BetaManagedAgentsStaticBearerUpdateParams) = Auth(staticBearer = staticBearer) + + /** + * Parameters for updating an environment variable credential. `secret_name` is + * immutable. + */ + @JvmStatic + fun ofEnvironmentVariable( + environmentVariable: BetaManagedAgentsEnvironmentVariableUpdateParams + ) = Auth(environmentVariable = environmentVariable) } /** An interface that defines how to map each variant of [Auth] to a value of type [T]. */ @@ -825,6 +873,14 @@ private constructor( */ fun visitStaticBearer(staticBearer: BetaManagedAgentsStaticBearerUpdateParams): T + /** + * Parameters for updating an environment variable credential. `secret_name` is + * immutable. + */ + fun visitEnvironmentVariable( + environmentVariable: BetaManagedAgentsEnvironmentVariableUpdateParams + ): T + /** * Maps an unknown variant of [Auth] to a value of type [T]. * @@ -860,6 +916,14 @@ private constructor( ) ?.let { Auth(staticBearer = it, _json = json) } ?: Auth(_json = json) } + "environment_variable" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Auth(environmentVariable = it, _json = json) } + ?: Auth(_json = json) + } } return Auth(_json = json) @@ -876,6 +940,8 @@ private constructor( when { value.mcpOAuth != null -> generator.writeObject(value.mcpOAuth) value.staticBearer != null -> generator.writeObject(value.staticBearer) + value.environmentVariable != null -> + generator.writeObject(value.environmentVariable) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Auth") } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/webhooks/BetaWebhookSessionThreadCreatedEventData.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/webhooks/BetaWebhookSessionThreadCreatedEventData.kt index 57c3857c5..08b80784f 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/webhooks/BetaWebhookSessionThreadCreatedEventData.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/webhooks/BetaWebhookSessionThreadCreatedEventData.kt @@ -20,6 +20,7 @@ class BetaWebhookSessionThreadCreatedEventData private constructor( private val id: JsonField, private val organizationId: JsonField, + private val sessionThreadId: JsonField, private val type: JsonValue, private val workspaceId: JsonField, private val additionalProperties: MutableMap, @@ -31,11 +32,14 @@ private constructor( @JsonProperty("organization_id") @ExcludeMissing organizationId: JsonField = JsonMissing.of(), + @JsonProperty("session_thread_id") + @ExcludeMissing + sessionThreadId: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("workspace_id") @ExcludeMissing workspaceId: JsonField = JsonMissing.of(), - ) : this(id, organizationId, type, workspaceId, mutableMapOf()) + ) : this(id, organizationId, sessionThreadId, type, workspaceId, mutableMapOf()) /** * ID of the session that triggered the event. @@ -51,6 +55,14 @@ private constructor( */ fun organizationId(): String = organizationId.getRequired("organization_id") + /** + * ID of the session thread this event refers to. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sessionThreadId(): String = sessionThreadId.getRequired("session_thread_id") + /** * Expected to always return the following: * ```java @@ -84,6 +96,15 @@ private constructor( @ExcludeMissing fun _organizationId(): JsonField = organizationId + /** + * Returns the raw JSON value of [sessionThreadId]. + * + * Unlike [sessionThreadId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_thread_id") + @ExcludeMissing + fun _sessionThreadId(): JsonField = sessionThreadId + /** * Returns the raw JSON value of [workspaceId]. * @@ -115,6 +136,7 @@ private constructor( * ```java * .id() * .organizationId() + * .sessionThreadId() * .workspaceId() * ``` */ @@ -126,6 +148,7 @@ private constructor( private var id: JsonField? = null private var organizationId: JsonField? = null + private var sessionThreadId: JsonField? = null private var type: JsonValue = JsonValue.from("session.thread_created") private var workspaceId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -136,6 +159,7 @@ private constructor( ) = apply { id = betaWebhookSessionThreadCreatedEventData.id organizationId = betaWebhookSessionThreadCreatedEventData.organizationId + sessionThreadId = betaWebhookSessionThreadCreatedEventData.sessionThreadId type = betaWebhookSessionThreadCreatedEventData.type workspaceId = betaWebhookSessionThreadCreatedEventData.workspaceId additionalProperties = @@ -166,6 +190,21 @@ private constructor( this.organizationId = organizationId } + /** ID of the session thread this event refers to. */ + fun sessionThreadId(sessionThreadId: String) = + sessionThreadId(JsonField.of(sessionThreadId)) + + /** + * Sets [Builder.sessionThreadId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionThreadId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sessionThreadId(sessionThreadId: JsonField) = apply { + this.sessionThreadId = sessionThreadId + } + /** * Sets the field to an arbitrary JSON value. * @@ -219,6 +258,7 @@ private constructor( * ```java * .id() * .organizationId() + * .sessionThreadId() * .workspaceId() * ``` * @@ -228,6 +268,7 @@ private constructor( BetaWebhookSessionThreadCreatedEventData( checkRequired("id", id), checkRequired("organizationId", organizationId), + checkRequired("sessionThreadId", sessionThreadId), type, checkRequired("workspaceId", workspaceId), additionalProperties.toMutableMap(), @@ -251,6 +292,7 @@ private constructor( id() organizationId() + sessionThreadId() _type().let { if (it != JsonValue.from("session.thread_created")) { throw AnthropicInvalidDataException("'type' is invalid, received $it") @@ -277,6 +319,7 @@ private constructor( internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (sessionThreadId.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("session.thread_created")) 1 else 0 } + (if (workspaceId.asKnown().isPresent) 1 else 0) @@ -288,17 +331,18 @@ private constructor( return other is BetaWebhookSessionThreadCreatedEventData && id == other.id && organizationId == other.organizationId && + sessionThreadId == other.sessionThreadId && type == other.type && workspaceId == other.workspaceId && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, organizationId, type, workspaceId, additionalProperties) + Objects.hash(id, organizationId, sessionThreadId, type, workspaceId, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "BetaWebhookSessionThreadCreatedEventData{id=$id, organizationId=$organizationId, type=$type, workspaceId=$workspaceId, additionalProperties=$additionalProperties}" + "BetaWebhookSessionThreadCreatedEventData{id=$id, organizationId=$organizationId, sessionThreadId=$sessionThreadId, type=$type, workspaceId=$workspaceId, additionalProperties=$additionalProperties}" } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/webhooks/BetaWebhookSessionThreadIdledEventData.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/webhooks/BetaWebhookSessionThreadIdledEventData.kt index 8516401e9..32b420127 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/webhooks/BetaWebhookSessionThreadIdledEventData.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/webhooks/BetaWebhookSessionThreadIdledEventData.kt @@ -20,6 +20,7 @@ class BetaWebhookSessionThreadIdledEventData private constructor( private val id: JsonField, private val organizationId: JsonField, + private val sessionThreadId: JsonField, private val type: JsonValue, private val workspaceId: JsonField, private val additionalProperties: MutableMap, @@ -31,11 +32,14 @@ private constructor( @JsonProperty("organization_id") @ExcludeMissing organizationId: JsonField = JsonMissing.of(), + @JsonProperty("session_thread_id") + @ExcludeMissing + sessionThreadId: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("workspace_id") @ExcludeMissing workspaceId: JsonField = JsonMissing.of(), - ) : this(id, organizationId, type, workspaceId, mutableMapOf()) + ) : this(id, organizationId, sessionThreadId, type, workspaceId, mutableMapOf()) /** * ID of the session that triggered the event. @@ -51,6 +55,14 @@ private constructor( */ fun organizationId(): String = organizationId.getRequired("organization_id") + /** + * ID of the session thread this event refers to. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sessionThreadId(): String = sessionThreadId.getRequired("session_thread_id") + /** * Expected to always return the following: * ```java @@ -84,6 +96,15 @@ private constructor( @ExcludeMissing fun _organizationId(): JsonField = organizationId + /** + * Returns the raw JSON value of [sessionThreadId]. + * + * Unlike [sessionThreadId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_thread_id") + @ExcludeMissing + fun _sessionThreadId(): JsonField = sessionThreadId + /** * Returns the raw JSON value of [workspaceId]. * @@ -115,6 +136,7 @@ private constructor( * ```java * .id() * .organizationId() + * .sessionThreadId() * .workspaceId() * ``` */ @@ -126,6 +148,7 @@ private constructor( private var id: JsonField? = null private var organizationId: JsonField? = null + private var sessionThreadId: JsonField? = null private var type: JsonValue = JsonValue.from("session.thread_idled") private var workspaceId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -136,6 +159,7 @@ private constructor( ) = apply { id = betaWebhookSessionThreadIdledEventData.id organizationId = betaWebhookSessionThreadIdledEventData.organizationId + sessionThreadId = betaWebhookSessionThreadIdledEventData.sessionThreadId type = betaWebhookSessionThreadIdledEventData.type workspaceId = betaWebhookSessionThreadIdledEventData.workspaceId additionalProperties = @@ -166,6 +190,21 @@ private constructor( this.organizationId = organizationId } + /** ID of the session thread this event refers to. */ + fun sessionThreadId(sessionThreadId: String) = + sessionThreadId(JsonField.of(sessionThreadId)) + + /** + * Sets [Builder.sessionThreadId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionThreadId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sessionThreadId(sessionThreadId: JsonField) = apply { + this.sessionThreadId = sessionThreadId + } + /** * Sets the field to an arbitrary JSON value. * @@ -219,6 +258,7 @@ private constructor( * ```java * .id() * .organizationId() + * .sessionThreadId() * .workspaceId() * ``` * @@ -228,6 +268,7 @@ private constructor( BetaWebhookSessionThreadIdledEventData( checkRequired("id", id), checkRequired("organizationId", organizationId), + checkRequired("sessionThreadId", sessionThreadId), type, checkRequired("workspaceId", workspaceId), additionalProperties.toMutableMap(), @@ -251,6 +292,7 @@ private constructor( id() organizationId() + sessionThreadId() _type().let { if (it != JsonValue.from("session.thread_idled")) { throw AnthropicInvalidDataException("'type' is invalid, received $it") @@ -277,6 +319,7 @@ private constructor( internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (sessionThreadId.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("session.thread_idled")) 1 else 0 } + (if (workspaceId.asKnown().isPresent) 1 else 0) @@ -288,17 +331,18 @@ private constructor( return other is BetaWebhookSessionThreadIdledEventData && id == other.id && organizationId == other.organizationId && + sessionThreadId == other.sessionThreadId && type == other.type && workspaceId == other.workspaceId && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, organizationId, type, workspaceId, additionalProperties) + Objects.hash(id, organizationId, sessionThreadId, type, workspaceId, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "BetaWebhookSessionThreadIdledEventData{id=$id, organizationId=$organizationId, type=$type, workspaceId=$workspaceId, additionalProperties=$additionalProperties}" + "BetaWebhookSessionThreadIdledEventData{id=$id, organizationId=$organizationId, sessionThreadId=$sessionThreadId, type=$type, workspaceId=$workspaceId, additionalProperties=$additionalProperties}" } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/webhooks/BetaWebhookSessionThreadTerminatedEventData.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/webhooks/BetaWebhookSessionThreadTerminatedEventData.kt index cc982d46b..2a2d316b3 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/webhooks/BetaWebhookSessionThreadTerminatedEventData.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/webhooks/BetaWebhookSessionThreadTerminatedEventData.kt @@ -20,6 +20,7 @@ class BetaWebhookSessionThreadTerminatedEventData private constructor( private val id: JsonField, private val organizationId: JsonField, + private val sessionThreadId: JsonField, private val type: JsonValue, private val workspaceId: JsonField, private val additionalProperties: MutableMap, @@ -31,11 +32,14 @@ private constructor( @JsonProperty("organization_id") @ExcludeMissing organizationId: JsonField = JsonMissing.of(), + @JsonProperty("session_thread_id") + @ExcludeMissing + sessionThreadId: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("workspace_id") @ExcludeMissing workspaceId: JsonField = JsonMissing.of(), - ) : this(id, organizationId, type, workspaceId, mutableMapOf()) + ) : this(id, organizationId, sessionThreadId, type, workspaceId, mutableMapOf()) /** * ID of the session that triggered the event. @@ -51,6 +55,14 @@ private constructor( */ fun organizationId(): String = organizationId.getRequired("organization_id") + /** + * ID of the session thread this event refers to. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sessionThreadId(): String = sessionThreadId.getRequired("session_thread_id") + /** * Expected to always return the following: * ```java @@ -84,6 +96,15 @@ private constructor( @ExcludeMissing fun _organizationId(): JsonField = organizationId + /** + * Returns the raw JSON value of [sessionThreadId]. + * + * Unlike [sessionThreadId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_thread_id") + @ExcludeMissing + fun _sessionThreadId(): JsonField = sessionThreadId + /** * Returns the raw JSON value of [workspaceId]. * @@ -115,6 +136,7 @@ private constructor( * ```java * .id() * .organizationId() + * .sessionThreadId() * .workspaceId() * ``` */ @@ -126,6 +148,7 @@ private constructor( private var id: JsonField? = null private var organizationId: JsonField? = null + private var sessionThreadId: JsonField? = null private var type: JsonValue = JsonValue.from("session.thread_terminated") private var workspaceId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -136,6 +159,7 @@ private constructor( ) = apply { id = betaWebhookSessionThreadTerminatedEventData.id organizationId = betaWebhookSessionThreadTerminatedEventData.organizationId + sessionThreadId = betaWebhookSessionThreadTerminatedEventData.sessionThreadId type = betaWebhookSessionThreadTerminatedEventData.type workspaceId = betaWebhookSessionThreadTerminatedEventData.workspaceId additionalProperties = @@ -166,6 +190,21 @@ private constructor( this.organizationId = organizationId } + /** ID of the session thread this event refers to. */ + fun sessionThreadId(sessionThreadId: String) = + sessionThreadId(JsonField.of(sessionThreadId)) + + /** + * Sets [Builder.sessionThreadId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionThreadId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sessionThreadId(sessionThreadId: JsonField) = apply { + this.sessionThreadId = sessionThreadId + } + /** * Sets the field to an arbitrary JSON value. * @@ -219,6 +258,7 @@ private constructor( * ```java * .id() * .organizationId() + * .sessionThreadId() * .workspaceId() * ``` * @@ -228,6 +268,7 @@ private constructor( BetaWebhookSessionThreadTerminatedEventData( checkRequired("id", id), checkRequired("organizationId", organizationId), + checkRequired("sessionThreadId", sessionThreadId), type, checkRequired("workspaceId", workspaceId), additionalProperties.toMutableMap(), @@ -251,6 +292,7 @@ private constructor( id() organizationId() + sessionThreadId() _type().let { if (it != JsonValue.from("session.thread_terminated")) { throw AnthropicInvalidDataException("'type' is invalid, received $it") @@ -277,6 +319,7 @@ private constructor( internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (sessionThreadId.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("session.thread_terminated")) 1 else 0 } + (if (workspaceId.asKnown().isPresent) 1 else 0) @@ -288,17 +331,18 @@ private constructor( return other is BetaWebhookSessionThreadTerminatedEventData && id == other.id && organizationId == other.organizationId && + sessionThreadId == other.sessionThreadId && type == other.type && workspaceId == other.workspaceId && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, organizationId, type, workspaceId, additionalProperties) + Objects.hash(id, organizationId, sessionThreadId, type, workspaceId, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "BetaWebhookSessionThreadTerminatedEventData{id=$id, organizationId=$organizationId, type=$type, workspaceId=$workspaceId, additionalProperties=$additionalProperties}" + "BetaWebhookSessionThreadTerminatedEventData{id=$id, organizationId=$organizationId, sessionThreadId=$sessionThreadId, type=$type, workspaceId=$workspaceId, additionalProperties=$additionalProperties}" } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/BetaServiceAsync.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/BetaServiceAsync.kt index eedf78031..d1eb4cb9a 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/BetaServiceAsync.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/BetaServiceAsync.kt @@ -4,6 +4,8 @@ package com.anthropic.services.async import com.anthropic.core.ClientOptions import com.anthropic.services.async.beta.AgentServiceAsync +import com.anthropic.services.async.beta.DeploymentRunServiceAsync +import com.anthropic.services.async.beta.DeploymentServiceAsync import com.anthropic.services.async.beta.EnvironmentServiceAsync import com.anthropic.services.async.beta.FileServiceAsync import com.anthropic.services.async.beta.MemoryStoreServiceAsync @@ -40,6 +42,10 @@ interface BetaServiceAsync { fun sessions(): SessionServiceAsync + fun deployments(): DeploymentServiceAsync + + fun deploymentRuns(): DeploymentRunServiceAsync + fun vaults(): VaultServiceAsync fun memoryStores(): MemoryStoreServiceAsync @@ -72,6 +78,10 @@ interface BetaServiceAsync { fun sessions(): SessionServiceAsync.WithRawResponse + fun deployments(): DeploymentServiceAsync.WithRawResponse + + fun deploymentRuns(): DeploymentRunServiceAsync.WithRawResponse + fun vaults(): VaultServiceAsync.WithRawResponse fun memoryStores(): MemoryStoreServiceAsync.WithRawResponse diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/BetaServiceAsyncImpl.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/BetaServiceAsyncImpl.kt index 077107560..d3acb9865 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/BetaServiceAsyncImpl.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/BetaServiceAsyncImpl.kt @@ -5,6 +5,10 @@ package com.anthropic.services.async import com.anthropic.core.ClientOptions import com.anthropic.services.async.beta.AgentServiceAsync import com.anthropic.services.async.beta.AgentServiceAsyncImpl +import com.anthropic.services.async.beta.DeploymentRunServiceAsync +import com.anthropic.services.async.beta.DeploymentRunServiceAsyncImpl +import com.anthropic.services.async.beta.DeploymentServiceAsync +import com.anthropic.services.async.beta.DeploymentServiceAsyncImpl import com.anthropic.services.async.beta.EnvironmentServiceAsync import com.anthropic.services.async.beta.EnvironmentServiceAsyncImpl import com.anthropic.services.async.beta.FileServiceAsync @@ -46,6 +50,14 @@ class BetaServiceAsyncImpl internal constructor(private val clientOptions: Clien private val sessions: SessionServiceAsync by lazy { SessionServiceAsyncImpl(clientOptions) } + private val deployments: DeploymentServiceAsync by lazy { + DeploymentServiceAsyncImpl(clientOptions) + } + + private val deploymentRuns: DeploymentRunServiceAsync by lazy { + DeploymentRunServiceAsyncImpl(clientOptions) + } + private val vaults: VaultServiceAsync by lazy { VaultServiceAsyncImpl(clientOptions) } private val memoryStores: MemoryStoreServiceAsync by lazy { @@ -77,6 +89,10 @@ class BetaServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun sessions(): SessionServiceAsync = sessions + override fun deployments(): DeploymentServiceAsync = deployments + + override fun deploymentRuns(): DeploymentRunServiceAsync = deploymentRuns + override fun vaults(): VaultServiceAsync = vaults override fun memoryStores(): MemoryStoreServiceAsync = memoryStores @@ -112,6 +128,14 @@ class BetaServiceAsyncImpl internal constructor(private val clientOptions: Clien SessionServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val deployments: DeploymentServiceAsync.WithRawResponse by lazy { + DeploymentServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val deploymentRuns: DeploymentRunServiceAsync.WithRawResponse by lazy { + DeploymentRunServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + private val vaults: VaultServiceAsync.WithRawResponse by lazy { VaultServiceAsyncImpl.WithRawResponseImpl(clientOptions) } @@ -153,6 +177,10 @@ class BetaServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun sessions(): SessionServiceAsync.WithRawResponse = sessions + override fun deployments(): DeploymentServiceAsync.WithRawResponse = deployments + + override fun deploymentRuns(): DeploymentRunServiceAsync.WithRawResponse = deploymentRuns + override fun vaults(): VaultServiceAsync.WithRawResponse = vaults override fun memoryStores(): MemoryStoreServiceAsync.WithRawResponse = memoryStores diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/beta/DeploymentRunServiceAsync.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/beta/DeploymentRunServiceAsync.kt new file mode 100644 index 000000000..f0ac8d88d --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/beta/DeploymentRunServiceAsync.kt @@ -0,0 +1,167 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.services.async.beta + +import com.anthropic.core.ClientOptions +import com.anthropic.core.RequestOptions +import com.anthropic.core.http.HttpResponseFor +import com.anthropic.models.beta.deploymentruns.BetaManagedAgentsDeploymentRun +import com.anthropic.models.beta.deploymentruns.DeploymentRunListPageAsync +import com.anthropic.models.beta.deploymentruns.DeploymentRunListParams +import com.anthropic.models.beta.deploymentruns.DeploymentRunRetrieveParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface DeploymentRunServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DeploymentRunServiceAsync + + /** Get Deployment Run */ + fun retrieve(deploymentRunId: String): CompletableFuture = + retrieve(deploymentRunId, DeploymentRunRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + deploymentRunId: String, + params: DeploymentRunRetrieveParams = DeploymentRunRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().deploymentRunId(deploymentRunId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + deploymentRunId: String, + params: DeploymentRunRetrieveParams = DeploymentRunRetrieveParams.none(), + ): CompletableFuture = + retrieve(deploymentRunId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: DeploymentRunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve( + params: DeploymentRunRetrieveParams + ): CompletableFuture = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + deploymentRunId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(deploymentRunId, DeploymentRunRetrieveParams.none(), requestOptions) + + /** List Deployment Runs */ + fun list(): CompletableFuture = list(DeploymentRunListParams.none()) + + /** @see list */ + fun list( + params: DeploymentRunListParams = DeploymentRunListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list( + params: DeploymentRunListParams = DeploymentRunListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(DeploymentRunListParams.none(), requestOptions) + + /** + * A view of [DeploymentRunServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): DeploymentRunServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /v1/deployment_runs/{deployment_run_id}?beta=true`, + * but is otherwise the same as [DeploymentRunServiceAsync.retrieve]. + */ + fun retrieve( + deploymentRunId: String + ): CompletableFuture> = + retrieve(deploymentRunId, DeploymentRunRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + deploymentRunId: String, + params: DeploymentRunRetrieveParams = DeploymentRunRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().deploymentRunId(deploymentRunId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + deploymentRunId: String, + params: DeploymentRunRetrieveParams = DeploymentRunRetrieveParams.none(), + ): CompletableFuture> = + retrieve(deploymentRunId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: DeploymentRunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: DeploymentRunRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + deploymentRunId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(deploymentRunId, DeploymentRunRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v1/deployment_runs?beta=true`, but is otherwise the + * same as [DeploymentRunServiceAsync.list]. + */ + fun list(): CompletableFuture> = + list(DeploymentRunListParams.none()) + + /** @see list */ + fun list( + params: DeploymentRunListParams = DeploymentRunListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: DeploymentRunListParams = DeploymentRunListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(DeploymentRunListParams.none(), requestOptions) + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/beta/DeploymentRunServiceAsyncImpl.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/beta/DeploymentRunServiceAsyncImpl.kt new file mode 100644 index 000000000..6612c0971 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/beta/DeploymentRunServiceAsyncImpl.kt @@ -0,0 +1,148 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.services.async.beta + +import com.anthropic.core.ClientOptions +import com.anthropic.core.RequestOptions +import com.anthropic.core.checkRequired +import com.anthropic.core.handlers.errorBodyHandler +import com.anthropic.core.handlers.errorHandler +import com.anthropic.core.handlers.jsonHandler +import com.anthropic.core.http.Headers +import com.anthropic.core.http.HttpMethod +import com.anthropic.core.http.HttpRequest +import com.anthropic.core.http.HttpResponse +import com.anthropic.core.http.HttpResponse.Handler +import com.anthropic.core.http.HttpResponseFor +import com.anthropic.core.http.parseable +import com.anthropic.core.prepareAsync +import com.anthropic.models.beta.deploymentruns.BetaManagedAgentsDeploymentRun +import com.anthropic.models.beta.deploymentruns.DeploymentRunListPageAsync +import com.anthropic.models.beta.deploymentruns.DeploymentRunListPageResponse +import com.anthropic.models.beta.deploymentruns.DeploymentRunListParams +import com.anthropic.models.beta.deploymentruns.DeploymentRunRetrieveParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class DeploymentRunServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + DeploymentRunServiceAsync { + + companion object { + + private val DEFAULT_HEADERS = + Headers.builder().put("anthropic-beta", "managed-agents-2026-04-01").build() + } + + private val withRawResponse: DeploymentRunServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): DeploymentRunServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): DeploymentRunServiceAsync = + DeploymentRunServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: DeploymentRunRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/deployment_runs/{deployment_run_id}?beta=true + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: DeploymentRunListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/deployment_runs?beta=true + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + DeploymentRunServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): DeploymentRunServiceAsync.WithRawResponse = + DeploymentRunServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: DeploymentRunRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("deploymentRunId", params.deploymentRunId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "deployment_runs", params._pathParam(0)) + .putQueryParam("beta", "true") + .putAllHeaders(DEFAULT_HEADERS) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: DeploymentRunListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "deployment_runs") + .putQueryParam("beta", "true") + .putAllHeaders(DEFAULT_HEADERS) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + DeploymentRunListPageAsync.builder() + .service(DeploymentRunServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) + .params(params) + .response(it) + .build() + } + } + } + } + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/beta/DeploymentServiceAsync.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/beta/DeploymentServiceAsync.kt new file mode 100644 index 000000000..2a036e79d --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/beta/DeploymentServiceAsync.kt @@ -0,0 +1,593 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.services.async.beta + +import com.anthropic.core.ClientOptions +import com.anthropic.core.RequestOptions +import com.anthropic.core.http.HttpResponseFor +import com.anthropic.models.beta.deploymentruns.BetaManagedAgentsDeploymentRun +import com.anthropic.models.beta.deployments.BetaManagedAgentsDeployment +import com.anthropic.models.beta.deployments.DeploymentArchiveParams +import com.anthropic.models.beta.deployments.DeploymentCreateParams +import com.anthropic.models.beta.deployments.DeploymentListPageAsync +import com.anthropic.models.beta.deployments.DeploymentListParams +import com.anthropic.models.beta.deployments.DeploymentPauseParams +import com.anthropic.models.beta.deployments.DeploymentRetrieveParams +import com.anthropic.models.beta.deployments.DeploymentRunParams +import com.anthropic.models.beta.deployments.DeploymentUnpauseParams +import com.anthropic.models.beta.deployments.DeploymentUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface DeploymentServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DeploymentServiceAsync + + /** Create Deployment */ + fun create(params: DeploymentCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: DeploymentCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Get Deployment */ + fun retrieve(deploymentId: String): CompletableFuture = + retrieve(deploymentId, DeploymentRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + deploymentId: String, + params: DeploymentRetrieveParams = DeploymentRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().deploymentId(deploymentId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + deploymentId: String, + params: DeploymentRetrieveParams = DeploymentRetrieveParams.none(), + ): CompletableFuture = + retrieve(deploymentId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: DeploymentRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve(params: DeploymentRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + deploymentId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(deploymentId, DeploymentRetrieveParams.none(), requestOptions) + + /** Update Deployment */ + fun update(deploymentId: String): CompletableFuture = + update(deploymentId, DeploymentUpdateParams.none()) + + /** @see update */ + fun update( + deploymentId: String, + params: DeploymentUpdateParams = DeploymentUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().deploymentId(deploymentId).build(), requestOptions) + + /** @see update */ + fun update( + deploymentId: String, + params: DeploymentUpdateParams = DeploymentUpdateParams.none(), + ): CompletableFuture = + update(deploymentId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: DeploymentUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see update */ + fun update(params: DeploymentUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + deploymentId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + update(deploymentId, DeploymentUpdateParams.none(), requestOptions) + + /** List Deployments */ + fun list(): CompletableFuture = list(DeploymentListParams.none()) + + /** @see list */ + fun list( + params: DeploymentListParams = DeploymentListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list( + params: DeploymentListParams = DeploymentListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(DeploymentListParams.none(), requestOptions) + + /** Archive Deployment */ + fun archive(deploymentId: String): CompletableFuture = + archive(deploymentId, DeploymentArchiveParams.none()) + + /** @see archive */ + fun archive( + deploymentId: String, + params: DeploymentArchiveParams = DeploymentArchiveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + archive(params.toBuilder().deploymentId(deploymentId).build(), requestOptions) + + /** @see archive */ + fun archive( + deploymentId: String, + params: DeploymentArchiveParams = DeploymentArchiveParams.none(), + ): CompletableFuture = + archive(deploymentId, params, RequestOptions.none()) + + /** @see archive */ + fun archive( + params: DeploymentArchiveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see archive */ + fun archive(params: DeploymentArchiveParams): CompletableFuture = + archive(params, RequestOptions.none()) + + /** @see archive */ + fun archive( + deploymentId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + archive(deploymentId, DeploymentArchiveParams.none(), requestOptions) + + /** Pause Deployment */ + fun pause(deploymentId: String): CompletableFuture = + pause(deploymentId, DeploymentPauseParams.none()) + + /** @see pause */ + fun pause( + deploymentId: String, + params: DeploymentPauseParams = DeploymentPauseParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + pause(params.toBuilder().deploymentId(deploymentId).build(), requestOptions) + + /** @see pause */ + fun pause( + deploymentId: String, + params: DeploymentPauseParams = DeploymentPauseParams.none(), + ): CompletableFuture = + pause(deploymentId, params, RequestOptions.none()) + + /** @see pause */ + fun pause( + params: DeploymentPauseParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see pause */ + fun pause(params: DeploymentPauseParams): CompletableFuture = + pause(params, RequestOptions.none()) + + /** @see pause */ + fun pause( + deploymentId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + pause(deploymentId, DeploymentPauseParams.none(), requestOptions) + + /** Run Deployment Now */ + fun run(deploymentId: String): CompletableFuture = + run(deploymentId, DeploymentRunParams.none()) + + /** @see run */ + fun run( + deploymentId: String, + params: DeploymentRunParams = DeploymentRunParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + run(params.toBuilder().deploymentId(deploymentId).build(), requestOptions) + + /** @see run */ + fun run( + deploymentId: String, + params: DeploymentRunParams = DeploymentRunParams.none(), + ): CompletableFuture = + run(deploymentId, params, RequestOptions.none()) + + /** @see run */ + fun run( + params: DeploymentRunParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see run */ + fun run(params: DeploymentRunParams): CompletableFuture = + run(params, RequestOptions.none()) + + /** @see run */ + fun run( + deploymentId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + run(deploymentId, DeploymentRunParams.none(), requestOptions) + + /** Unpause Deployment */ + fun unpause(deploymentId: String): CompletableFuture = + unpause(deploymentId, DeploymentUnpauseParams.none()) + + /** @see unpause */ + fun unpause( + deploymentId: String, + params: DeploymentUnpauseParams = DeploymentUnpauseParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + unpause(params.toBuilder().deploymentId(deploymentId).build(), requestOptions) + + /** @see unpause */ + fun unpause( + deploymentId: String, + params: DeploymentUnpauseParams = DeploymentUnpauseParams.none(), + ): CompletableFuture = + unpause(deploymentId, params, RequestOptions.none()) + + /** @see unpause */ + fun unpause( + params: DeploymentUnpauseParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see unpause */ + fun unpause(params: DeploymentUnpauseParams): CompletableFuture = + unpause(params, RequestOptions.none()) + + /** @see unpause */ + fun unpause( + deploymentId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + unpause(deploymentId, DeploymentUnpauseParams.none(), requestOptions) + + /** + * A view of [DeploymentServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): DeploymentServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/deployments?beta=true`, but is otherwise the + * same as [DeploymentServiceAsync.create]. + */ + fun create( + params: DeploymentCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: DeploymentCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/deployments/{deployment_id}?beta=true`, but is + * otherwise the same as [DeploymentServiceAsync.retrieve]. + */ + fun retrieve( + deploymentId: String + ): CompletableFuture> = + retrieve(deploymentId, DeploymentRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + deploymentId: String, + params: DeploymentRetrieveParams = DeploymentRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().deploymentId(deploymentId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + deploymentId: String, + params: DeploymentRetrieveParams = DeploymentRetrieveParams.none(), + ): CompletableFuture> = + retrieve(deploymentId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: DeploymentRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: DeploymentRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + deploymentId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(deploymentId, DeploymentRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /v1/deployments/{deployment_id}?beta=true`, but is + * otherwise the same as [DeploymentServiceAsync.update]. + */ + fun update( + deploymentId: String + ): CompletableFuture> = + update(deploymentId, DeploymentUpdateParams.none()) + + /** @see update */ + fun update( + deploymentId: String, + params: DeploymentUpdateParams = DeploymentUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().deploymentId(deploymentId).build(), requestOptions) + + /** @see update */ + fun update( + deploymentId: String, + params: DeploymentUpdateParams = DeploymentUpdateParams.none(), + ): CompletableFuture> = + update(deploymentId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: DeploymentUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see update */ + fun update( + params: DeploymentUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + deploymentId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(deploymentId, DeploymentUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v1/deployments?beta=true`, but is otherwise the + * same as [DeploymentServiceAsync.list]. + */ + fun list(): CompletableFuture> = + list(DeploymentListParams.none()) + + /** @see list */ + fun list( + params: DeploymentListParams = DeploymentListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: DeploymentListParams = DeploymentListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(DeploymentListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /v1/deployments/{deployment_id}/archive?beta=true`, + * but is otherwise the same as [DeploymentServiceAsync.archive]. + */ + fun archive( + deploymentId: String + ): CompletableFuture> = + archive(deploymentId, DeploymentArchiveParams.none()) + + /** @see archive */ + fun archive( + deploymentId: String, + params: DeploymentArchiveParams = DeploymentArchiveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + archive(params.toBuilder().deploymentId(deploymentId).build(), requestOptions) + + /** @see archive */ + fun archive( + deploymentId: String, + params: DeploymentArchiveParams = DeploymentArchiveParams.none(), + ): CompletableFuture> = + archive(deploymentId, params, RequestOptions.none()) + + /** @see archive */ + fun archive( + params: DeploymentArchiveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see archive */ + fun archive( + params: DeploymentArchiveParams + ): CompletableFuture> = + archive(params, RequestOptions.none()) + + /** @see archive */ + fun archive( + deploymentId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + archive(deploymentId, DeploymentArchiveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /v1/deployments/{deployment_id}/pause?beta=true`, + * but is otherwise the same as [DeploymentServiceAsync.pause]. + */ + fun pause( + deploymentId: String + ): CompletableFuture> = + pause(deploymentId, DeploymentPauseParams.none()) + + /** @see pause */ + fun pause( + deploymentId: String, + params: DeploymentPauseParams = DeploymentPauseParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + pause(params.toBuilder().deploymentId(deploymentId).build(), requestOptions) + + /** @see pause */ + fun pause( + deploymentId: String, + params: DeploymentPauseParams = DeploymentPauseParams.none(), + ): CompletableFuture> = + pause(deploymentId, params, RequestOptions.none()) + + /** @see pause */ + fun pause( + params: DeploymentPauseParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see pause */ + fun pause( + params: DeploymentPauseParams + ): CompletableFuture> = + pause(params, RequestOptions.none()) + + /** @see pause */ + fun pause( + deploymentId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + pause(deploymentId, DeploymentPauseParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /v1/deployments/{deployment_id}/run?beta=true`, but + * is otherwise the same as [DeploymentServiceAsync.run]. + */ + fun run( + deploymentId: String + ): CompletableFuture> = + run(deploymentId, DeploymentRunParams.none()) + + /** @see run */ + fun run( + deploymentId: String, + params: DeploymentRunParams = DeploymentRunParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + run(params.toBuilder().deploymentId(deploymentId).build(), requestOptions) + + /** @see run */ + fun run( + deploymentId: String, + params: DeploymentRunParams = DeploymentRunParams.none(), + ): CompletableFuture> = + run(deploymentId, params, RequestOptions.none()) + + /** @see run */ + fun run( + params: DeploymentRunParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see run */ + fun run( + params: DeploymentRunParams + ): CompletableFuture> = + run(params, RequestOptions.none()) + + /** @see run */ + fun run( + deploymentId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + run(deploymentId, DeploymentRunParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /v1/deployments/{deployment_id}/unpause?beta=true`, + * but is otherwise the same as [DeploymentServiceAsync.unpause]. + */ + fun unpause( + deploymentId: String + ): CompletableFuture> = + unpause(deploymentId, DeploymentUnpauseParams.none()) + + /** @see unpause */ + fun unpause( + deploymentId: String, + params: DeploymentUnpauseParams = DeploymentUnpauseParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + unpause(params.toBuilder().deploymentId(deploymentId).build(), requestOptions) + + /** @see unpause */ + fun unpause( + deploymentId: String, + params: DeploymentUnpauseParams = DeploymentUnpauseParams.none(), + ): CompletableFuture> = + unpause(deploymentId, params, RequestOptions.none()) + + /** @see unpause */ + fun unpause( + params: DeploymentUnpauseParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see unpause */ + fun unpause( + params: DeploymentUnpauseParams + ): CompletableFuture> = + unpause(params, RequestOptions.none()) + + /** @see unpause */ + fun unpause( + deploymentId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + unpause(deploymentId, DeploymentUnpauseParams.none(), requestOptions) + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/beta/DeploymentServiceAsyncImpl.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/beta/DeploymentServiceAsyncImpl.kt new file mode 100644 index 000000000..afc367c3f --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/beta/DeploymentServiceAsyncImpl.kt @@ -0,0 +1,411 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.services.async.beta + +import com.anthropic.core.ClientOptions +import com.anthropic.core.RequestOptions +import com.anthropic.core.checkRequired +import com.anthropic.core.handlers.errorBodyHandler +import com.anthropic.core.handlers.errorHandler +import com.anthropic.core.handlers.jsonHandler +import com.anthropic.core.http.Headers +import com.anthropic.core.http.HttpMethod +import com.anthropic.core.http.HttpRequest +import com.anthropic.core.http.HttpResponse +import com.anthropic.core.http.HttpResponse.Handler +import com.anthropic.core.http.HttpResponseFor +import com.anthropic.core.http.json +import com.anthropic.core.http.parseable +import com.anthropic.core.prepareAsync +import com.anthropic.models.beta.deploymentruns.BetaManagedAgentsDeploymentRun +import com.anthropic.models.beta.deployments.BetaManagedAgentsDeployment +import com.anthropic.models.beta.deployments.DeploymentArchiveParams +import com.anthropic.models.beta.deployments.DeploymentCreateParams +import com.anthropic.models.beta.deployments.DeploymentListPageAsync +import com.anthropic.models.beta.deployments.DeploymentListPageResponse +import com.anthropic.models.beta.deployments.DeploymentListParams +import com.anthropic.models.beta.deployments.DeploymentPauseParams +import com.anthropic.models.beta.deployments.DeploymentRetrieveParams +import com.anthropic.models.beta.deployments.DeploymentRunParams +import com.anthropic.models.beta.deployments.DeploymentUnpauseParams +import com.anthropic.models.beta.deployments.DeploymentUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class DeploymentServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + DeploymentServiceAsync { + + companion object { + + private val DEFAULT_HEADERS = + Headers.builder().put("anthropic-beta", "managed-agents-2026-04-01").build() + } + + private val withRawResponse: DeploymentServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): DeploymentServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): DeploymentServiceAsync = + DeploymentServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: DeploymentCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/deployments?beta=true + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: DeploymentRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/deployments/{deployment_id}?beta=true + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: DeploymentUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/deployments/{deployment_id}?beta=true + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: DeploymentListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/deployments?beta=true + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun archive( + params: DeploymentArchiveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/deployments/{deployment_id}/archive?beta=true + withRawResponse().archive(params, requestOptions).thenApply { it.parse() } + + override fun pause( + params: DeploymentPauseParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/deployments/{deployment_id}/pause?beta=true + withRawResponse().pause(params, requestOptions).thenApply { it.parse() } + + override fun run( + params: DeploymentRunParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/deployments/{deployment_id}/run?beta=true + withRawResponse().run(params, requestOptions).thenApply { it.parse() } + + override fun unpause( + params: DeploymentUnpauseParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/deployments/{deployment_id}/unpause?beta=true + withRawResponse().unpause(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + DeploymentServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): DeploymentServiceAsync.WithRawResponse = + DeploymentServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: DeploymentCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "deployments") + .putQueryParam("beta", "true") + .putAllHeaders(DEFAULT_HEADERS) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: DeploymentRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("deploymentId", params.deploymentId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "deployments", params._pathParam(0)) + .putQueryParam("beta", "true") + .putAllHeaders(DEFAULT_HEADERS) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: DeploymentUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("deploymentId", params.deploymentId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "deployments", params._pathParam(0)) + .putQueryParam("beta", "true") + .putAllHeaders(DEFAULT_HEADERS) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: DeploymentListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "deployments") + .putQueryParam("beta", "true") + .putAllHeaders(DEFAULT_HEADERS) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + DeploymentListPageAsync.builder() + .service(DeploymentServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) + .params(params) + .response(it) + .build() + } + } + } + } + + private val archiveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun archive( + params: DeploymentArchiveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("deploymentId", params.deploymentId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "deployments", params._pathParam(0), "archive") + .putQueryParam("beta", "true") + .putAllHeaders(DEFAULT_HEADERS) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { archiveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val pauseHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun pause( + params: DeploymentPauseParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("deploymentId", params.deploymentId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "deployments", params._pathParam(0), "pause") + .putQueryParam("beta", "true") + .putAllHeaders(DEFAULT_HEADERS) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { pauseHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val runHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun run( + params: DeploymentRunParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("deploymentId", params.deploymentId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "deployments", params._pathParam(0), "run") + .putQueryParam("beta", "true") + .putAllHeaders(DEFAULT_HEADERS) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { runHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val unpauseHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun unpause( + params: DeploymentUnpauseParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("deploymentId", params.deploymentId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "deployments", params._pathParam(0), "unpause") + .putQueryParam("beta", "true") + .putAllHeaders(DEFAULT_HEADERS) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { unpauseHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/BetaService.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/BetaService.kt index 3a24d28f4..541270cf4 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/BetaService.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/BetaService.kt @@ -4,6 +4,8 @@ package com.anthropic.services.blocking import com.anthropic.core.ClientOptions import com.anthropic.services.blocking.beta.AgentService +import com.anthropic.services.blocking.beta.DeploymentRunService +import com.anthropic.services.blocking.beta.DeploymentService import com.anthropic.services.blocking.beta.EnvironmentService import com.anthropic.services.blocking.beta.FileService import com.anthropic.services.blocking.beta.MemoryStoreService @@ -40,6 +42,10 @@ interface BetaService { fun sessions(): SessionService + fun deployments(): DeploymentService + + fun deploymentRuns(): DeploymentRunService + fun vaults(): VaultService fun memoryStores(): MemoryStoreService @@ -72,6 +78,10 @@ interface BetaService { fun sessions(): SessionService.WithRawResponse + fun deployments(): DeploymentService.WithRawResponse + + fun deploymentRuns(): DeploymentRunService.WithRawResponse + fun vaults(): VaultService.WithRawResponse fun memoryStores(): MemoryStoreService.WithRawResponse diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/BetaServiceImpl.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/BetaServiceImpl.kt index 9e94f7d02..e9def80c8 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/BetaServiceImpl.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/BetaServiceImpl.kt @@ -5,6 +5,10 @@ package com.anthropic.services.blocking import com.anthropic.core.ClientOptions import com.anthropic.services.blocking.beta.AgentService import com.anthropic.services.blocking.beta.AgentServiceImpl +import com.anthropic.services.blocking.beta.DeploymentRunService +import com.anthropic.services.blocking.beta.DeploymentRunServiceImpl +import com.anthropic.services.blocking.beta.DeploymentService +import com.anthropic.services.blocking.beta.DeploymentServiceImpl import com.anthropic.services.blocking.beta.EnvironmentService import com.anthropic.services.blocking.beta.EnvironmentServiceImpl import com.anthropic.services.blocking.beta.FileService @@ -43,6 +47,12 @@ class BetaServiceImpl internal constructor(private val clientOptions: ClientOpti private val sessions: SessionService by lazy { SessionServiceImpl(clientOptions) } + private val deployments: DeploymentService by lazy { DeploymentServiceImpl(clientOptions) } + + private val deploymentRuns: DeploymentRunService by lazy { + DeploymentRunServiceImpl(clientOptions) + } + private val vaults: VaultService by lazy { VaultServiceImpl(clientOptions) } private val memoryStores: MemoryStoreService by lazy { MemoryStoreServiceImpl(clientOptions) } @@ -70,6 +80,10 @@ class BetaServiceImpl internal constructor(private val clientOptions: ClientOpti override fun sessions(): SessionService = sessions + override fun deployments(): DeploymentService = deployments + + override fun deploymentRuns(): DeploymentRunService = deploymentRuns + override fun vaults(): VaultService = vaults override fun memoryStores(): MemoryStoreService = memoryStores @@ -105,6 +119,14 @@ class BetaServiceImpl internal constructor(private val clientOptions: ClientOpti SessionServiceImpl.WithRawResponseImpl(clientOptions) } + private val deployments: DeploymentService.WithRawResponse by lazy { + DeploymentServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val deploymentRuns: DeploymentRunService.WithRawResponse by lazy { + DeploymentRunServiceImpl.WithRawResponseImpl(clientOptions) + } + private val vaults: VaultService.WithRawResponse by lazy { VaultServiceImpl.WithRawResponseImpl(clientOptions) } @@ -146,6 +168,10 @@ class BetaServiceImpl internal constructor(private val clientOptions: ClientOpti override fun sessions(): SessionService.WithRawResponse = sessions + override fun deployments(): DeploymentService.WithRawResponse = deployments + + override fun deploymentRuns(): DeploymentRunService.WithRawResponse = deploymentRuns + override fun vaults(): VaultService.WithRawResponse = vaults override fun memoryStores(): MemoryStoreService.WithRawResponse = memoryStores diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/beta/DeploymentRunService.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/beta/DeploymentRunService.kt new file mode 100644 index 000000000..39ea36113 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/beta/DeploymentRunService.kt @@ -0,0 +1,167 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.services.blocking.beta + +import com.anthropic.core.ClientOptions +import com.anthropic.core.RequestOptions +import com.anthropic.core.http.HttpResponseFor +import com.anthropic.models.beta.deploymentruns.BetaManagedAgentsDeploymentRun +import com.anthropic.models.beta.deploymentruns.DeploymentRunListPage +import com.anthropic.models.beta.deploymentruns.DeploymentRunListParams +import com.anthropic.models.beta.deploymentruns.DeploymentRunRetrieveParams +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface DeploymentRunService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DeploymentRunService + + /** Get Deployment Run */ + fun retrieve(deploymentRunId: String): BetaManagedAgentsDeploymentRun = + retrieve(deploymentRunId, DeploymentRunRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + deploymentRunId: String, + params: DeploymentRunRetrieveParams = DeploymentRunRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BetaManagedAgentsDeploymentRun = + retrieve(params.toBuilder().deploymentRunId(deploymentRunId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + deploymentRunId: String, + params: DeploymentRunRetrieveParams = DeploymentRunRetrieveParams.none(), + ): BetaManagedAgentsDeploymentRun = retrieve(deploymentRunId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: DeploymentRunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BetaManagedAgentsDeploymentRun + + /** @see retrieve */ + fun retrieve(params: DeploymentRunRetrieveParams): BetaManagedAgentsDeploymentRun = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + deploymentRunId: String, + requestOptions: RequestOptions, + ): BetaManagedAgentsDeploymentRun = + retrieve(deploymentRunId, DeploymentRunRetrieveParams.none(), requestOptions) + + /** List Deployment Runs */ + fun list(): DeploymentRunListPage = list(DeploymentRunListParams.none()) + + /** @see list */ + fun list( + params: DeploymentRunListParams = DeploymentRunListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): DeploymentRunListPage + + /** @see list */ + fun list( + params: DeploymentRunListParams = DeploymentRunListParams.none() + ): DeploymentRunListPage = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): DeploymentRunListPage = + list(DeploymentRunListParams.none(), requestOptions) + + /** + * A view of [DeploymentRunService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): DeploymentRunService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /v1/deployment_runs/{deployment_run_id}?beta=true`, + * but is otherwise the same as [DeploymentRunService.retrieve]. + */ + @MustBeClosed + fun retrieve(deploymentRunId: String): HttpResponseFor = + retrieve(deploymentRunId, DeploymentRunRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + deploymentRunId: String, + params: DeploymentRunRetrieveParams = DeploymentRunRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().deploymentRunId(deploymentRunId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + deploymentRunId: String, + params: DeploymentRunRetrieveParams = DeploymentRunRetrieveParams.none(), + ): HttpResponseFor = + retrieve(deploymentRunId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: DeploymentRunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: DeploymentRunRetrieveParams + ): HttpResponseFor = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + deploymentRunId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(deploymentRunId, DeploymentRunRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v1/deployment_runs?beta=true`, but is otherwise the + * same as [DeploymentRunService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor = list(DeploymentRunListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: DeploymentRunListParams = DeploymentRunListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list( + params: DeploymentRunListParams = DeploymentRunListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(DeploymentRunListParams.none(), requestOptions) + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/beta/DeploymentRunServiceImpl.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/beta/DeploymentRunServiceImpl.kt new file mode 100644 index 000000000..68e6f8915 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/beta/DeploymentRunServiceImpl.kt @@ -0,0 +1,140 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.services.blocking.beta + +import com.anthropic.core.ClientOptions +import com.anthropic.core.RequestOptions +import com.anthropic.core.checkRequired +import com.anthropic.core.handlers.errorBodyHandler +import com.anthropic.core.handlers.errorHandler +import com.anthropic.core.handlers.jsonHandler +import com.anthropic.core.http.Headers +import com.anthropic.core.http.HttpMethod +import com.anthropic.core.http.HttpRequest +import com.anthropic.core.http.HttpResponse +import com.anthropic.core.http.HttpResponse.Handler +import com.anthropic.core.http.HttpResponseFor +import com.anthropic.core.http.parseable +import com.anthropic.core.prepare +import com.anthropic.models.beta.deploymentruns.BetaManagedAgentsDeploymentRun +import com.anthropic.models.beta.deploymentruns.DeploymentRunListPage +import com.anthropic.models.beta.deploymentruns.DeploymentRunListPageResponse +import com.anthropic.models.beta.deploymentruns.DeploymentRunListParams +import com.anthropic.models.beta.deploymentruns.DeploymentRunRetrieveParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class DeploymentRunServiceImpl internal constructor(private val clientOptions: ClientOptions) : + DeploymentRunService { + + companion object { + + private val DEFAULT_HEADERS = + Headers.builder().put("anthropic-beta", "managed-agents-2026-04-01").build() + } + + private val withRawResponse: DeploymentRunService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): DeploymentRunService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): DeploymentRunService = + DeploymentRunServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: DeploymentRunRetrieveParams, + requestOptions: RequestOptions, + ): BetaManagedAgentsDeploymentRun = + // get /v1/deployment_runs/{deployment_run_id}?beta=true + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list( + params: DeploymentRunListParams, + requestOptions: RequestOptions, + ): DeploymentRunListPage = + // get /v1/deployment_runs?beta=true + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + DeploymentRunService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): DeploymentRunService.WithRawResponse = + DeploymentRunServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: DeploymentRunRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("deploymentRunId", params.deploymentRunId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "deployment_runs", params._pathParam(0)) + .putQueryParam("beta", "true") + .putAllHeaders(DEFAULT_HEADERS) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: DeploymentRunListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "deployment_runs") + .putQueryParam("beta", "true") + .putAllHeaders(DEFAULT_HEADERS) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + DeploymentRunListPage.builder() + .service(DeploymentRunServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } + } + } + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/beta/DeploymentService.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/beta/DeploymentService.kt new file mode 100644 index 000000000..d12b574d4 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/beta/DeploymentService.kt @@ -0,0 +1,581 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.services.blocking.beta + +import com.anthropic.core.ClientOptions +import com.anthropic.core.RequestOptions +import com.anthropic.core.http.HttpResponseFor +import com.anthropic.models.beta.deploymentruns.BetaManagedAgentsDeploymentRun +import com.anthropic.models.beta.deployments.BetaManagedAgentsDeployment +import com.anthropic.models.beta.deployments.DeploymentArchiveParams +import com.anthropic.models.beta.deployments.DeploymentCreateParams +import com.anthropic.models.beta.deployments.DeploymentListPage +import com.anthropic.models.beta.deployments.DeploymentListParams +import com.anthropic.models.beta.deployments.DeploymentPauseParams +import com.anthropic.models.beta.deployments.DeploymentRetrieveParams +import com.anthropic.models.beta.deployments.DeploymentRunParams +import com.anthropic.models.beta.deployments.DeploymentUnpauseParams +import com.anthropic.models.beta.deployments.DeploymentUpdateParams +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface DeploymentService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DeploymentService + + /** Create Deployment */ + fun create(params: DeploymentCreateParams): BetaManagedAgentsDeployment = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: DeploymentCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BetaManagedAgentsDeployment + + /** Get Deployment */ + fun retrieve(deploymentId: String): BetaManagedAgentsDeployment = + retrieve(deploymentId, DeploymentRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + deploymentId: String, + params: DeploymentRetrieveParams = DeploymentRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BetaManagedAgentsDeployment = + retrieve(params.toBuilder().deploymentId(deploymentId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + deploymentId: String, + params: DeploymentRetrieveParams = DeploymentRetrieveParams.none(), + ): BetaManagedAgentsDeployment = retrieve(deploymentId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: DeploymentRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BetaManagedAgentsDeployment + + /** @see retrieve */ + fun retrieve(params: DeploymentRetrieveParams): BetaManagedAgentsDeployment = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + deploymentId: String, + requestOptions: RequestOptions, + ): BetaManagedAgentsDeployment = + retrieve(deploymentId, DeploymentRetrieveParams.none(), requestOptions) + + /** Update Deployment */ + fun update(deploymentId: String): BetaManagedAgentsDeployment = + update(deploymentId, DeploymentUpdateParams.none()) + + /** @see update */ + fun update( + deploymentId: String, + params: DeploymentUpdateParams = DeploymentUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BetaManagedAgentsDeployment = + update(params.toBuilder().deploymentId(deploymentId).build(), requestOptions) + + /** @see update */ + fun update( + deploymentId: String, + params: DeploymentUpdateParams = DeploymentUpdateParams.none(), + ): BetaManagedAgentsDeployment = update(deploymentId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: DeploymentUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BetaManagedAgentsDeployment + + /** @see update */ + fun update(params: DeploymentUpdateParams): BetaManagedAgentsDeployment = + update(params, RequestOptions.none()) + + /** @see update */ + fun update(deploymentId: String, requestOptions: RequestOptions): BetaManagedAgentsDeployment = + update(deploymentId, DeploymentUpdateParams.none(), requestOptions) + + /** List Deployments */ + fun list(): DeploymentListPage = list(DeploymentListParams.none()) + + /** @see list */ + fun list( + params: DeploymentListParams = DeploymentListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): DeploymentListPage + + /** @see list */ + fun list(params: DeploymentListParams = DeploymentListParams.none()): DeploymentListPage = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): DeploymentListPage = + list(DeploymentListParams.none(), requestOptions) + + /** Archive Deployment */ + fun archive(deploymentId: String): BetaManagedAgentsDeployment = + archive(deploymentId, DeploymentArchiveParams.none()) + + /** @see archive */ + fun archive( + deploymentId: String, + params: DeploymentArchiveParams = DeploymentArchiveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BetaManagedAgentsDeployment = + archive(params.toBuilder().deploymentId(deploymentId).build(), requestOptions) + + /** @see archive */ + fun archive( + deploymentId: String, + params: DeploymentArchiveParams = DeploymentArchiveParams.none(), + ): BetaManagedAgentsDeployment = archive(deploymentId, params, RequestOptions.none()) + + /** @see archive */ + fun archive( + params: DeploymentArchiveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BetaManagedAgentsDeployment + + /** @see archive */ + fun archive(params: DeploymentArchiveParams): BetaManagedAgentsDeployment = + archive(params, RequestOptions.none()) + + /** @see archive */ + fun archive(deploymentId: String, requestOptions: RequestOptions): BetaManagedAgentsDeployment = + archive(deploymentId, DeploymentArchiveParams.none(), requestOptions) + + /** Pause Deployment */ + fun pause(deploymentId: String): BetaManagedAgentsDeployment = + pause(deploymentId, DeploymentPauseParams.none()) + + /** @see pause */ + fun pause( + deploymentId: String, + params: DeploymentPauseParams = DeploymentPauseParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BetaManagedAgentsDeployment = + pause(params.toBuilder().deploymentId(deploymentId).build(), requestOptions) + + /** @see pause */ + fun pause( + deploymentId: String, + params: DeploymentPauseParams = DeploymentPauseParams.none(), + ): BetaManagedAgentsDeployment = pause(deploymentId, params, RequestOptions.none()) + + /** @see pause */ + fun pause( + params: DeploymentPauseParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BetaManagedAgentsDeployment + + /** @see pause */ + fun pause(params: DeploymentPauseParams): BetaManagedAgentsDeployment = + pause(params, RequestOptions.none()) + + /** @see pause */ + fun pause(deploymentId: String, requestOptions: RequestOptions): BetaManagedAgentsDeployment = + pause(deploymentId, DeploymentPauseParams.none(), requestOptions) + + /** Run Deployment Now */ + fun run(deploymentId: String): BetaManagedAgentsDeploymentRun = + run(deploymentId, DeploymentRunParams.none()) + + /** @see run */ + fun run( + deploymentId: String, + params: DeploymentRunParams = DeploymentRunParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BetaManagedAgentsDeploymentRun = + run(params.toBuilder().deploymentId(deploymentId).build(), requestOptions) + + /** @see run */ + fun run( + deploymentId: String, + params: DeploymentRunParams = DeploymentRunParams.none(), + ): BetaManagedAgentsDeploymentRun = run(deploymentId, params, RequestOptions.none()) + + /** @see run */ + fun run( + params: DeploymentRunParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BetaManagedAgentsDeploymentRun + + /** @see run */ + fun run(params: DeploymentRunParams): BetaManagedAgentsDeploymentRun = + run(params, RequestOptions.none()) + + /** @see run */ + fun run(deploymentId: String, requestOptions: RequestOptions): BetaManagedAgentsDeploymentRun = + run(deploymentId, DeploymentRunParams.none(), requestOptions) + + /** Unpause Deployment */ + fun unpause(deploymentId: String): BetaManagedAgentsDeployment = + unpause(deploymentId, DeploymentUnpauseParams.none()) + + /** @see unpause */ + fun unpause( + deploymentId: String, + params: DeploymentUnpauseParams = DeploymentUnpauseParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BetaManagedAgentsDeployment = + unpause(params.toBuilder().deploymentId(deploymentId).build(), requestOptions) + + /** @see unpause */ + fun unpause( + deploymentId: String, + params: DeploymentUnpauseParams = DeploymentUnpauseParams.none(), + ): BetaManagedAgentsDeployment = unpause(deploymentId, params, RequestOptions.none()) + + /** @see unpause */ + fun unpause( + params: DeploymentUnpauseParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BetaManagedAgentsDeployment + + /** @see unpause */ + fun unpause(params: DeploymentUnpauseParams): BetaManagedAgentsDeployment = + unpause(params, RequestOptions.none()) + + /** @see unpause */ + fun unpause(deploymentId: String, requestOptions: RequestOptions): BetaManagedAgentsDeployment = + unpause(deploymentId, DeploymentUnpauseParams.none(), requestOptions) + + /** A view of [DeploymentService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): DeploymentService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/deployments?beta=true`, but is otherwise the + * same as [DeploymentService.create]. + */ + @MustBeClosed + fun create(params: DeploymentCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: DeploymentCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/deployments/{deployment_id}?beta=true`, but is + * otherwise the same as [DeploymentService.retrieve]. + */ + @MustBeClosed + fun retrieve(deploymentId: String): HttpResponseFor = + retrieve(deploymentId, DeploymentRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + deploymentId: String, + params: DeploymentRetrieveParams = DeploymentRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().deploymentId(deploymentId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + deploymentId: String, + params: DeploymentRetrieveParams = DeploymentRetrieveParams.none(), + ): HttpResponseFor = + retrieve(deploymentId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: DeploymentRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: DeploymentRetrieveParams + ): HttpResponseFor = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + deploymentId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(deploymentId, DeploymentRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /v1/deployments/{deployment_id}?beta=true`, but is + * otherwise the same as [DeploymentService.update]. + */ + @MustBeClosed + fun update(deploymentId: String): HttpResponseFor = + update(deploymentId, DeploymentUpdateParams.none()) + + /** @see update */ + @MustBeClosed + fun update( + deploymentId: String, + params: DeploymentUpdateParams = DeploymentUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().deploymentId(deploymentId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update( + deploymentId: String, + params: DeploymentUpdateParams = DeploymentUpdateParams.none(), + ): HttpResponseFor = + update(deploymentId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: DeploymentUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see update */ + @MustBeClosed + fun update(params: DeploymentUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + deploymentId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + update(deploymentId, DeploymentUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v1/deployments?beta=true`, but is otherwise the + * same as [DeploymentService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor = list(DeploymentListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: DeploymentListParams = DeploymentListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list( + params: DeploymentListParams = DeploymentListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(DeploymentListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /v1/deployments/{deployment_id}/archive?beta=true`, + * but is otherwise the same as [DeploymentService.archive]. + */ + @MustBeClosed + fun archive(deploymentId: String): HttpResponseFor = + archive(deploymentId, DeploymentArchiveParams.none()) + + /** @see archive */ + @MustBeClosed + fun archive( + deploymentId: String, + params: DeploymentArchiveParams = DeploymentArchiveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + archive(params.toBuilder().deploymentId(deploymentId).build(), requestOptions) + + /** @see archive */ + @MustBeClosed + fun archive( + deploymentId: String, + params: DeploymentArchiveParams = DeploymentArchiveParams.none(), + ): HttpResponseFor = + archive(deploymentId, params, RequestOptions.none()) + + /** @see archive */ + @MustBeClosed + fun archive( + params: DeploymentArchiveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see archive */ + @MustBeClosed + fun archive(params: DeploymentArchiveParams): HttpResponseFor = + archive(params, RequestOptions.none()) + + /** @see archive */ + @MustBeClosed + fun archive( + deploymentId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + archive(deploymentId, DeploymentArchiveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /v1/deployments/{deployment_id}/pause?beta=true`, + * but is otherwise the same as [DeploymentService.pause]. + */ + @MustBeClosed + fun pause(deploymentId: String): HttpResponseFor = + pause(deploymentId, DeploymentPauseParams.none()) + + /** @see pause */ + @MustBeClosed + fun pause( + deploymentId: String, + params: DeploymentPauseParams = DeploymentPauseParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + pause(params.toBuilder().deploymentId(deploymentId).build(), requestOptions) + + /** @see pause */ + @MustBeClosed + fun pause( + deploymentId: String, + params: DeploymentPauseParams = DeploymentPauseParams.none(), + ): HttpResponseFor = + pause(deploymentId, params, RequestOptions.none()) + + /** @see pause */ + @MustBeClosed + fun pause( + params: DeploymentPauseParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see pause */ + @MustBeClosed + fun pause(params: DeploymentPauseParams): HttpResponseFor = + pause(params, RequestOptions.none()) + + /** @see pause */ + @MustBeClosed + fun pause( + deploymentId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + pause(deploymentId, DeploymentPauseParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /v1/deployments/{deployment_id}/run?beta=true`, but + * is otherwise the same as [DeploymentService.run]. + */ + @MustBeClosed + fun run(deploymentId: String): HttpResponseFor = + run(deploymentId, DeploymentRunParams.none()) + + /** @see run */ + @MustBeClosed + fun run( + deploymentId: String, + params: DeploymentRunParams = DeploymentRunParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + run(params.toBuilder().deploymentId(deploymentId).build(), requestOptions) + + /** @see run */ + @MustBeClosed + fun run( + deploymentId: String, + params: DeploymentRunParams = DeploymentRunParams.none(), + ): HttpResponseFor = + run(deploymentId, params, RequestOptions.none()) + + /** @see run */ + @MustBeClosed + fun run( + params: DeploymentRunParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see run */ + @MustBeClosed + fun run(params: DeploymentRunParams): HttpResponseFor = + run(params, RequestOptions.none()) + + /** @see run */ + @MustBeClosed + fun run( + deploymentId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + run(deploymentId, DeploymentRunParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /v1/deployments/{deployment_id}/unpause?beta=true`, + * but is otherwise the same as [DeploymentService.unpause]. + */ + @MustBeClosed + fun unpause(deploymentId: String): HttpResponseFor = + unpause(deploymentId, DeploymentUnpauseParams.none()) + + /** @see unpause */ + @MustBeClosed + fun unpause( + deploymentId: String, + params: DeploymentUnpauseParams = DeploymentUnpauseParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + unpause(params.toBuilder().deploymentId(deploymentId).build(), requestOptions) + + /** @see unpause */ + @MustBeClosed + fun unpause( + deploymentId: String, + params: DeploymentUnpauseParams = DeploymentUnpauseParams.none(), + ): HttpResponseFor = + unpause(deploymentId, params, RequestOptions.none()) + + /** @see unpause */ + @MustBeClosed + fun unpause( + params: DeploymentUnpauseParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see unpause */ + @MustBeClosed + fun unpause(params: DeploymentUnpauseParams): HttpResponseFor = + unpause(params, RequestOptions.none()) + + /** @see unpause */ + @MustBeClosed + fun unpause( + deploymentId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + unpause(deploymentId, DeploymentUnpauseParams.none(), requestOptions) + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/beta/DeploymentServiceImpl.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/beta/DeploymentServiceImpl.kt new file mode 100644 index 000000000..7367e66fb --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/beta/DeploymentServiceImpl.kt @@ -0,0 +1,385 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.services.blocking.beta + +import com.anthropic.core.ClientOptions +import com.anthropic.core.RequestOptions +import com.anthropic.core.checkRequired +import com.anthropic.core.handlers.errorBodyHandler +import com.anthropic.core.handlers.errorHandler +import com.anthropic.core.handlers.jsonHandler +import com.anthropic.core.http.Headers +import com.anthropic.core.http.HttpMethod +import com.anthropic.core.http.HttpRequest +import com.anthropic.core.http.HttpResponse +import com.anthropic.core.http.HttpResponse.Handler +import com.anthropic.core.http.HttpResponseFor +import com.anthropic.core.http.json +import com.anthropic.core.http.parseable +import com.anthropic.core.prepare +import com.anthropic.models.beta.deploymentruns.BetaManagedAgentsDeploymentRun +import com.anthropic.models.beta.deployments.BetaManagedAgentsDeployment +import com.anthropic.models.beta.deployments.DeploymentArchiveParams +import com.anthropic.models.beta.deployments.DeploymentCreateParams +import com.anthropic.models.beta.deployments.DeploymentListPage +import com.anthropic.models.beta.deployments.DeploymentListPageResponse +import com.anthropic.models.beta.deployments.DeploymentListParams +import com.anthropic.models.beta.deployments.DeploymentPauseParams +import com.anthropic.models.beta.deployments.DeploymentRetrieveParams +import com.anthropic.models.beta.deployments.DeploymentRunParams +import com.anthropic.models.beta.deployments.DeploymentUnpauseParams +import com.anthropic.models.beta.deployments.DeploymentUpdateParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class DeploymentServiceImpl internal constructor(private val clientOptions: ClientOptions) : + DeploymentService { + + companion object { + + private val DEFAULT_HEADERS = + Headers.builder().put("anthropic-beta", "managed-agents-2026-04-01").build() + } + + private val withRawResponse: DeploymentService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): DeploymentService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): DeploymentService = + DeploymentServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: DeploymentCreateParams, + requestOptions: RequestOptions, + ): BetaManagedAgentsDeployment = + // post /v1/deployments?beta=true + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: DeploymentRetrieveParams, + requestOptions: RequestOptions, + ): BetaManagedAgentsDeployment = + // get /v1/deployments/{deployment_id}?beta=true + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update( + params: DeploymentUpdateParams, + requestOptions: RequestOptions, + ): BetaManagedAgentsDeployment = + // post /v1/deployments/{deployment_id}?beta=true + withRawResponse().update(params, requestOptions).parse() + + override fun list( + params: DeploymentListParams, + requestOptions: RequestOptions, + ): DeploymentListPage = + // get /v1/deployments?beta=true + withRawResponse().list(params, requestOptions).parse() + + override fun archive( + params: DeploymentArchiveParams, + requestOptions: RequestOptions, + ): BetaManagedAgentsDeployment = + // post /v1/deployments/{deployment_id}/archive?beta=true + withRawResponse().archive(params, requestOptions).parse() + + override fun pause( + params: DeploymentPauseParams, + requestOptions: RequestOptions, + ): BetaManagedAgentsDeployment = + // post /v1/deployments/{deployment_id}/pause?beta=true + withRawResponse().pause(params, requestOptions).parse() + + override fun run( + params: DeploymentRunParams, + requestOptions: RequestOptions, + ): BetaManagedAgentsDeploymentRun = + // post /v1/deployments/{deployment_id}/run?beta=true + withRawResponse().run(params, requestOptions).parse() + + override fun unpause( + params: DeploymentUnpauseParams, + requestOptions: RequestOptions, + ): BetaManagedAgentsDeployment = + // post /v1/deployments/{deployment_id}/unpause?beta=true + withRawResponse().unpause(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + DeploymentService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): DeploymentService.WithRawResponse = + DeploymentServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: DeploymentCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "deployments") + .putQueryParam("beta", "true") + .putAllHeaders(DEFAULT_HEADERS) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: DeploymentRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("deploymentId", params.deploymentId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "deployments", params._pathParam(0)) + .putQueryParam("beta", "true") + .putAllHeaders(DEFAULT_HEADERS) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: DeploymentUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("deploymentId", params.deploymentId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "deployments", params._pathParam(0)) + .putQueryParam("beta", "true") + .putAllHeaders(DEFAULT_HEADERS) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: DeploymentListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "deployments") + .putQueryParam("beta", "true") + .putAllHeaders(DEFAULT_HEADERS) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + DeploymentListPage.builder() + .service(DeploymentServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } + } + } + + private val archiveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun archive( + params: DeploymentArchiveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("deploymentId", params.deploymentId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "deployments", params._pathParam(0), "archive") + .putQueryParam("beta", "true") + .putAllHeaders(DEFAULT_HEADERS) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { archiveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val pauseHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun pause( + params: DeploymentPauseParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("deploymentId", params.deploymentId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "deployments", params._pathParam(0), "pause") + .putQueryParam("beta", "true") + .putAllHeaders(DEFAULT_HEADERS) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { pauseHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val runHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun run( + params: DeploymentRunParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("deploymentId", params.deploymentId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "deployments", params._pathParam(0), "run") + .putQueryParam("beta", "true") + .putAllHeaders(DEFAULT_HEADERS) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { runHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val unpauseHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun unpause( + params: DeploymentUnpauseParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("deploymentId", params.deploymentId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "deployments", params._pathParam(0), "unpause") + .putQueryParam("beta", "true") + .putAllHeaders(DEFAULT_HEADERS) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { unpauseHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsAgentArchivedRunErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsAgentArchivedRunErrorTest.kt new file mode 100644 index 000000000..29dae1978 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsAgentArchivedRunErrorTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsAgentArchivedRunErrorTest { + + @Test + fun create() { + val betaManagedAgentsAgentArchivedRunError = + BetaManagedAgentsAgentArchivedRunError.builder() + .message("message") + .type(BetaManagedAgentsAgentArchivedRunError.Type.AGENT_ARCHIVED_ERROR) + .build() + + assertThat(betaManagedAgentsAgentArchivedRunError.message()).isEqualTo("message") + assertThat(betaManagedAgentsAgentArchivedRunError.type()) + .isEqualTo(BetaManagedAgentsAgentArchivedRunError.Type.AGENT_ARCHIVED_ERROR) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsAgentArchivedRunError = + BetaManagedAgentsAgentArchivedRunError.builder() + .message("message") + .type(BetaManagedAgentsAgentArchivedRunError.Type.AGENT_ARCHIVED_ERROR) + .build() + + val roundtrippedBetaManagedAgentsAgentArchivedRunError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsAgentArchivedRunError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsAgentArchivedRunError) + .isEqualTo(betaManagedAgentsAgentArchivedRunError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsDeploymentRunTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsDeploymentRunTest.kt new file mode 100644 index 000000000..f41fbd6fb --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsDeploymentRunTest.kt @@ -0,0 +1,102 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.jsonMapper +import com.anthropic.models.beta.agents.BetaManagedAgentsAgentReference +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsDeploymentRunTest { + + @Test + fun create() { + val betaManagedAgentsDeploymentRun = + BetaManagedAgentsDeploymentRun.builder() + .id("id") + .agent( + BetaManagedAgentsAgentReference.builder() + .id("agent_011CZkYqphY8vELVzwCUpqiQ") + .type(BetaManagedAgentsAgentReference.Type.AGENT) + .version(1) + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deploymentId("deployment_id") + .environmentArchivedError("message") + .sessionId("session_id") + .scheduleTriggerContext(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type(BetaManagedAgentsDeploymentRun.Type.DEPLOYMENT_RUN) + .build() + + assertThat(betaManagedAgentsDeploymentRun.id()).isEqualTo("id") + assertThat(betaManagedAgentsDeploymentRun.agent()) + .isEqualTo( + BetaManagedAgentsAgentReference.builder() + .id("agent_011CZkYqphY8vELVzwCUpqiQ") + .type(BetaManagedAgentsAgentReference.Type.AGENT) + .version(1) + .build() + ) + assertThat(betaManagedAgentsDeploymentRun.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(betaManagedAgentsDeploymentRun.deploymentId()).isEqualTo("deployment_id") + assertThat(betaManagedAgentsDeploymentRun.error()) + .contains( + BetaManagedAgentsDeploymentRun.Error.ofEnvironmentArchived( + BetaManagedAgentsEnvironmentArchivedRunError.builder() + .message("message") + .type( + BetaManagedAgentsEnvironmentArchivedRunError.Type + .ENVIRONMENT_ARCHIVED_ERROR + ) + .build() + ) + ) + assertThat(betaManagedAgentsDeploymentRun.sessionId()).contains("session_id") + assertThat(betaManagedAgentsDeploymentRun.triggerContext()) + .isEqualTo( + BetaManagedAgentsTriggerContext.ofSchedule( + BetaManagedAgentsScheduleTriggerContext.builder() + .scheduledAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type(BetaManagedAgentsScheduleTriggerContext.Type.SCHEDULE) + .build() + ) + ) + assertThat(betaManagedAgentsDeploymentRun.type()) + .isEqualTo(BetaManagedAgentsDeploymentRun.Type.DEPLOYMENT_RUN) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsDeploymentRun = + BetaManagedAgentsDeploymentRun.builder() + .id("id") + .agent( + BetaManagedAgentsAgentReference.builder() + .id("agent_011CZkYqphY8vELVzwCUpqiQ") + .type(BetaManagedAgentsAgentReference.Type.AGENT) + .version(1) + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deploymentId("deployment_id") + .environmentArchivedError("message") + .sessionId("session_id") + .scheduleTriggerContext(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type(BetaManagedAgentsDeploymentRun.Type.DEPLOYMENT_RUN) + .build() + + val roundtrippedBetaManagedAgentsDeploymentRun = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsDeploymentRun), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsDeploymentRun) + .isEqualTo(betaManagedAgentsDeploymentRun) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsEnvironmentArchivedRunErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsEnvironmentArchivedRunErrorTest.kt new file mode 100644 index 000000000..ee58cecc2 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsEnvironmentArchivedRunErrorTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsEnvironmentArchivedRunErrorTest { + + @Test + fun create() { + val betaManagedAgentsEnvironmentArchivedRunError = + BetaManagedAgentsEnvironmentArchivedRunError.builder() + .message("message") + .type(BetaManagedAgentsEnvironmentArchivedRunError.Type.ENVIRONMENT_ARCHIVED_ERROR) + .build() + + assertThat(betaManagedAgentsEnvironmentArchivedRunError.message()).isEqualTo("message") + assertThat(betaManagedAgentsEnvironmentArchivedRunError.type()) + .isEqualTo(BetaManagedAgentsEnvironmentArchivedRunError.Type.ENVIRONMENT_ARCHIVED_ERROR) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsEnvironmentArchivedRunError = + BetaManagedAgentsEnvironmentArchivedRunError.builder() + .message("message") + .type(BetaManagedAgentsEnvironmentArchivedRunError.Type.ENVIRONMENT_ARCHIVED_ERROR) + .build() + + val roundtrippedBetaManagedAgentsEnvironmentArchivedRunError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsEnvironmentArchivedRunError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsEnvironmentArchivedRunError) + .isEqualTo(betaManagedAgentsEnvironmentArchivedRunError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsEnvironmentNotFoundRunErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsEnvironmentNotFoundRunErrorTest.kt new file mode 100644 index 000000000..4746a6d2d --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsEnvironmentNotFoundRunErrorTest.kt @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsEnvironmentNotFoundRunErrorTest { + + @Test + fun create() { + val betaManagedAgentsEnvironmentNotFoundRunError = + BetaManagedAgentsEnvironmentNotFoundRunError.builder() + .message("message") + .type(BetaManagedAgentsEnvironmentNotFoundRunError.Type.ENVIRONMENT_NOT_FOUND_ERROR) + .build() + + assertThat(betaManagedAgentsEnvironmentNotFoundRunError.message()).isEqualTo("message") + assertThat(betaManagedAgentsEnvironmentNotFoundRunError.type()) + .isEqualTo( + BetaManagedAgentsEnvironmentNotFoundRunError.Type.ENVIRONMENT_NOT_FOUND_ERROR + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsEnvironmentNotFoundRunError = + BetaManagedAgentsEnvironmentNotFoundRunError.builder() + .message("message") + .type(BetaManagedAgentsEnvironmentNotFoundRunError.Type.ENVIRONMENT_NOT_FOUND_ERROR) + .build() + + val roundtrippedBetaManagedAgentsEnvironmentNotFoundRunError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsEnvironmentNotFoundRunError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsEnvironmentNotFoundRunError) + .isEqualTo(betaManagedAgentsEnvironmentNotFoundRunError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsFileNotFoundRunErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsFileNotFoundRunErrorTest.kt new file mode 100644 index 000000000..2417713df --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsFileNotFoundRunErrorTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsFileNotFoundRunErrorTest { + + @Test + fun create() { + val betaManagedAgentsFileNotFoundRunError = + BetaManagedAgentsFileNotFoundRunError.builder() + .message("message") + .type(BetaManagedAgentsFileNotFoundRunError.Type.FILE_NOT_FOUND_ERROR) + .build() + + assertThat(betaManagedAgentsFileNotFoundRunError.message()).isEqualTo("message") + assertThat(betaManagedAgentsFileNotFoundRunError.type()) + .isEqualTo(BetaManagedAgentsFileNotFoundRunError.Type.FILE_NOT_FOUND_ERROR) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsFileNotFoundRunError = + BetaManagedAgentsFileNotFoundRunError.builder() + .message("message") + .type(BetaManagedAgentsFileNotFoundRunError.Type.FILE_NOT_FOUND_ERROR) + .build() + + val roundtrippedBetaManagedAgentsFileNotFoundRunError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsFileNotFoundRunError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsFileNotFoundRunError) + .isEqualTo(betaManagedAgentsFileNotFoundRunError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsManualTriggerContextTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsManualTriggerContextTest.kt new file mode 100644 index 000000000..d20d3ca6b --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsManualTriggerContextTest.kt @@ -0,0 +1,40 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsManualTriggerContextTest { + + @Test + fun create() { + val betaManagedAgentsManualTriggerContext = + BetaManagedAgentsManualTriggerContext.builder() + .type(BetaManagedAgentsManualTriggerContext.Type.MANUAL) + .build() + + assertThat(betaManagedAgentsManualTriggerContext.type()) + .isEqualTo(BetaManagedAgentsManualTriggerContext.Type.MANUAL) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsManualTriggerContext = + BetaManagedAgentsManualTriggerContext.builder() + .type(BetaManagedAgentsManualTriggerContext.Type.MANUAL) + .build() + + val roundtrippedBetaManagedAgentsManualTriggerContext = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsManualTriggerContext), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsManualTriggerContext) + .isEqualTo(betaManagedAgentsManualTriggerContext) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsMcpEgressBlockedRunErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsMcpEgressBlockedRunErrorTest.kt new file mode 100644 index 000000000..f18ff0b12 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsMcpEgressBlockedRunErrorTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsMcpEgressBlockedRunErrorTest { + + @Test + fun create() { + val betaManagedAgentsMcpEgressBlockedRunError = + BetaManagedAgentsMcpEgressBlockedRunError.builder() + .message("message") + .type(BetaManagedAgentsMcpEgressBlockedRunError.Type.MCP_EGRESS_BLOCKED_ERROR) + .build() + + assertThat(betaManagedAgentsMcpEgressBlockedRunError.message()).isEqualTo("message") + assertThat(betaManagedAgentsMcpEgressBlockedRunError.type()) + .isEqualTo(BetaManagedAgentsMcpEgressBlockedRunError.Type.MCP_EGRESS_BLOCKED_ERROR) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsMcpEgressBlockedRunError = + BetaManagedAgentsMcpEgressBlockedRunError.builder() + .message("message") + .type(BetaManagedAgentsMcpEgressBlockedRunError.Type.MCP_EGRESS_BLOCKED_ERROR) + .build() + + val roundtrippedBetaManagedAgentsMcpEgressBlockedRunError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsMcpEgressBlockedRunError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsMcpEgressBlockedRunError) + .isEqualTo(betaManagedAgentsMcpEgressBlockedRunError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsMemoryStoreArchivedRunErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsMemoryStoreArchivedRunErrorTest.kt new file mode 100644 index 000000000..8963988cb --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsMemoryStoreArchivedRunErrorTest.kt @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsMemoryStoreArchivedRunErrorTest { + + @Test + fun create() { + val betaManagedAgentsMemoryStoreArchivedRunError = + BetaManagedAgentsMemoryStoreArchivedRunError.builder() + .message("message") + .type(BetaManagedAgentsMemoryStoreArchivedRunError.Type.MEMORY_STORE_ARCHIVED_ERROR) + .build() + + assertThat(betaManagedAgentsMemoryStoreArchivedRunError.message()).isEqualTo("message") + assertThat(betaManagedAgentsMemoryStoreArchivedRunError.type()) + .isEqualTo( + BetaManagedAgentsMemoryStoreArchivedRunError.Type.MEMORY_STORE_ARCHIVED_ERROR + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsMemoryStoreArchivedRunError = + BetaManagedAgentsMemoryStoreArchivedRunError.builder() + .message("message") + .type(BetaManagedAgentsMemoryStoreArchivedRunError.Type.MEMORY_STORE_ARCHIVED_ERROR) + .build() + + val roundtrippedBetaManagedAgentsMemoryStoreArchivedRunError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsMemoryStoreArchivedRunError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsMemoryStoreArchivedRunError) + .isEqualTo(betaManagedAgentsMemoryStoreArchivedRunError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsOrganizationDisabledRunErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsOrganizationDisabledRunErrorTest.kt new file mode 100644 index 000000000..aacd08c9e --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsOrganizationDisabledRunErrorTest.kt @@ -0,0 +1,49 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsOrganizationDisabledRunErrorTest { + + @Test + fun create() { + val betaManagedAgentsOrganizationDisabledRunError = + BetaManagedAgentsOrganizationDisabledRunError.builder() + .message("message") + .type( + BetaManagedAgentsOrganizationDisabledRunError.Type.ORGANIZATION_DISABLED_ERROR + ) + .build() + + assertThat(betaManagedAgentsOrganizationDisabledRunError.message()).isEqualTo("message") + assertThat(betaManagedAgentsOrganizationDisabledRunError.type()) + .isEqualTo( + BetaManagedAgentsOrganizationDisabledRunError.Type.ORGANIZATION_DISABLED_ERROR + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsOrganizationDisabledRunError = + BetaManagedAgentsOrganizationDisabledRunError.builder() + .message("message") + .type( + BetaManagedAgentsOrganizationDisabledRunError.Type.ORGANIZATION_DISABLED_ERROR + ) + .build() + + val roundtrippedBetaManagedAgentsOrganizationDisabledRunError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsOrganizationDisabledRunError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsOrganizationDisabledRunError) + .isEqualTo(betaManagedAgentsOrganizationDisabledRunError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsScheduleTriggerContextTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsScheduleTriggerContextTest.kt new file mode 100644 index 000000000..b7c6ded4f --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsScheduleTriggerContextTest.kt @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsScheduleTriggerContextTest { + + @Test + fun create() { + val betaManagedAgentsScheduleTriggerContext = + BetaManagedAgentsScheduleTriggerContext.builder() + .scheduledAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type(BetaManagedAgentsScheduleTriggerContext.Type.SCHEDULE) + .build() + + assertThat(betaManagedAgentsScheduleTriggerContext.scheduledAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(betaManagedAgentsScheduleTriggerContext.type()) + .isEqualTo(BetaManagedAgentsScheduleTriggerContext.Type.SCHEDULE) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsScheduleTriggerContext = + BetaManagedAgentsScheduleTriggerContext.builder() + .scheduledAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type(BetaManagedAgentsScheduleTriggerContext.Type.SCHEDULE) + .build() + + val roundtrippedBetaManagedAgentsScheduleTriggerContext = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsScheduleTriggerContext), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsScheduleTriggerContext) + .isEqualTo(betaManagedAgentsScheduleTriggerContext) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSelfHostedResourcesUnsupportedRunErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSelfHostedResourcesUnsupportedRunErrorTest.kt new file mode 100644 index 000000000..05b3c55e8 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSelfHostedResourcesUnsupportedRunErrorTest.kt @@ -0,0 +1,55 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsSelfHostedResourcesUnsupportedRunErrorTest { + + @Test + fun create() { + val betaManagedAgentsSelfHostedResourcesUnsupportedRunError = + BetaManagedAgentsSelfHostedResourcesUnsupportedRunError.builder() + .message("message") + .type( + BetaManagedAgentsSelfHostedResourcesUnsupportedRunError.Type + .SELF_HOSTED_RESOURCES_UNSUPPORTED_ERROR + ) + .build() + + assertThat(betaManagedAgentsSelfHostedResourcesUnsupportedRunError.message()) + .isEqualTo("message") + assertThat(betaManagedAgentsSelfHostedResourcesUnsupportedRunError.type()) + .isEqualTo( + BetaManagedAgentsSelfHostedResourcesUnsupportedRunError.Type + .SELF_HOSTED_RESOURCES_UNSUPPORTED_ERROR + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsSelfHostedResourcesUnsupportedRunError = + BetaManagedAgentsSelfHostedResourcesUnsupportedRunError.builder() + .message("message") + .type( + BetaManagedAgentsSelfHostedResourcesUnsupportedRunError.Type + .SELF_HOSTED_RESOURCES_UNSUPPORTED_ERROR + ) + .build() + + val roundtrippedBetaManagedAgentsSelfHostedResourcesUnsupportedRunError = + jsonMapper.readValue( + jsonMapper.writeValueAsString( + betaManagedAgentsSelfHostedResourcesUnsupportedRunError + ), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsSelfHostedResourcesUnsupportedRunError) + .isEqualTo(betaManagedAgentsSelfHostedResourcesUnsupportedRunError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSessionCreationRejectedRunErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSessionCreationRejectedRunErrorTest.kt new file mode 100644 index 000000000..be0ce8fa8 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSessionCreationRejectedRunErrorTest.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsSessionCreationRejectedRunErrorTest { + + @Test + fun create() { + val betaManagedAgentsSessionCreationRejectedRunError = + BetaManagedAgentsSessionCreationRejectedRunError.builder() + .message("message") + .type( + BetaManagedAgentsSessionCreationRejectedRunError.Type + .SESSION_CREATION_REJECTED_ERROR + ) + .build() + + assertThat(betaManagedAgentsSessionCreationRejectedRunError.message()).isEqualTo("message") + assertThat(betaManagedAgentsSessionCreationRejectedRunError.type()) + .isEqualTo( + BetaManagedAgentsSessionCreationRejectedRunError.Type + .SESSION_CREATION_REJECTED_ERROR + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsSessionCreationRejectedRunError = + BetaManagedAgentsSessionCreationRejectedRunError.builder() + .message("message") + .type( + BetaManagedAgentsSessionCreationRejectedRunError.Type + .SESSION_CREATION_REJECTED_ERROR + ) + .build() + + val roundtrippedBetaManagedAgentsSessionCreationRejectedRunError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsSessionCreationRejectedRunError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsSessionCreationRejectedRunError) + .isEqualTo(betaManagedAgentsSessionCreationRejectedRunError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSessionRateLimitedRunErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSessionRateLimitedRunErrorTest.kt new file mode 100644 index 000000000..b01ec81a5 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSessionRateLimitedRunErrorTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsSessionRateLimitedRunErrorTest { + + @Test + fun create() { + val betaManagedAgentsSessionRateLimitedRunError = + BetaManagedAgentsSessionRateLimitedRunError.builder() + .message("message") + .type(BetaManagedAgentsSessionRateLimitedRunError.Type.SESSION_RATE_LIMITED_ERROR) + .build() + + assertThat(betaManagedAgentsSessionRateLimitedRunError.message()).isEqualTo("message") + assertThat(betaManagedAgentsSessionRateLimitedRunError.type()) + .isEqualTo(BetaManagedAgentsSessionRateLimitedRunError.Type.SESSION_RATE_LIMITED_ERROR) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsSessionRateLimitedRunError = + BetaManagedAgentsSessionRateLimitedRunError.builder() + .message("message") + .type(BetaManagedAgentsSessionRateLimitedRunError.Type.SESSION_RATE_LIMITED_ERROR) + .build() + + val roundtrippedBetaManagedAgentsSessionRateLimitedRunError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsSessionRateLimitedRunError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsSessionRateLimitedRunError) + .isEqualTo(betaManagedAgentsSessionRateLimitedRunError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSessionResourceNotFoundRunErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSessionResourceNotFoundRunErrorTest.kt new file mode 100644 index 000000000..6355ff7d1 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSessionResourceNotFoundRunErrorTest.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsSessionResourceNotFoundRunErrorTest { + + @Test + fun create() { + val betaManagedAgentsSessionResourceNotFoundRunError = + BetaManagedAgentsSessionResourceNotFoundRunError.builder() + .message("message") + .type( + BetaManagedAgentsSessionResourceNotFoundRunError.Type + .SESSION_RESOURCE_NOT_FOUND_ERROR + ) + .build() + + assertThat(betaManagedAgentsSessionResourceNotFoundRunError.message()).isEqualTo("message") + assertThat(betaManagedAgentsSessionResourceNotFoundRunError.type()) + .isEqualTo( + BetaManagedAgentsSessionResourceNotFoundRunError.Type + .SESSION_RESOURCE_NOT_FOUND_ERROR + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsSessionResourceNotFoundRunError = + BetaManagedAgentsSessionResourceNotFoundRunError.builder() + .message("message") + .type( + BetaManagedAgentsSessionResourceNotFoundRunError.Type + .SESSION_RESOURCE_NOT_FOUND_ERROR + ) + .build() + + val roundtrippedBetaManagedAgentsSessionResourceNotFoundRunError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsSessionResourceNotFoundRunError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsSessionResourceNotFoundRunError) + .isEqualTo(betaManagedAgentsSessionResourceNotFoundRunError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSkillNotFoundRunErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSkillNotFoundRunErrorTest.kt new file mode 100644 index 000000000..e200b38e5 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsSkillNotFoundRunErrorTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsSkillNotFoundRunErrorTest { + + @Test + fun create() { + val betaManagedAgentsSkillNotFoundRunError = + BetaManagedAgentsSkillNotFoundRunError.builder() + .message("message") + .type(BetaManagedAgentsSkillNotFoundRunError.Type.SKILL_NOT_FOUND_ERROR) + .build() + + assertThat(betaManagedAgentsSkillNotFoundRunError.message()).isEqualTo("message") + assertThat(betaManagedAgentsSkillNotFoundRunError.type()) + .isEqualTo(BetaManagedAgentsSkillNotFoundRunError.Type.SKILL_NOT_FOUND_ERROR) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsSkillNotFoundRunError = + BetaManagedAgentsSkillNotFoundRunError.builder() + .message("message") + .type(BetaManagedAgentsSkillNotFoundRunError.Type.SKILL_NOT_FOUND_ERROR) + .build() + + val roundtrippedBetaManagedAgentsSkillNotFoundRunError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsSkillNotFoundRunError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsSkillNotFoundRunError) + .isEqualTo(betaManagedAgentsSkillNotFoundRunError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsTriggerContextTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsTriggerContextTest.kt new file mode 100644 index 000000000..b269a47e4 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsTriggerContextTest.kt @@ -0,0 +1,107 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.JsonValue +import com.anthropic.core.jsonMapper +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class BetaManagedAgentsTriggerContextTest { + + @Test + fun ofSchedule() { + val schedule = + BetaManagedAgentsScheduleTriggerContext.builder() + .scheduledAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type(BetaManagedAgentsScheduleTriggerContext.Type.SCHEDULE) + .build() + + val betaManagedAgentsTriggerContext = BetaManagedAgentsTriggerContext.ofSchedule(schedule) + + assertThat(betaManagedAgentsTriggerContext.schedule()).contains(schedule) + assertThat(betaManagedAgentsTriggerContext.manual()).isEmpty + } + + @Test + fun ofScheduleRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsTriggerContext = + BetaManagedAgentsTriggerContext.ofSchedule( + BetaManagedAgentsScheduleTriggerContext.builder() + .scheduledAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type(BetaManagedAgentsScheduleTriggerContext.Type.SCHEDULE) + .build() + ) + + val roundtrippedBetaManagedAgentsTriggerContext = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsTriggerContext), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsTriggerContext) + .isEqualTo(betaManagedAgentsTriggerContext) + } + + @Test + fun ofManual() { + val manual = + BetaManagedAgentsManualTriggerContext.builder() + .type(BetaManagedAgentsManualTriggerContext.Type.MANUAL) + .build() + + val betaManagedAgentsTriggerContext = BetaManagedAgentsTriggerContext.ofManual(manual) + + assertThat(betaManagedAgentsTriggerContext.schedule()).isEmpty + assertThat(betaManagedAgentsTriggerContext.manual()).contains(manual) + } + + @Test + fun ofManualRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsTriggerContext = + BetaManagedAgentsTriggerContext.ofManual( + BetaManagedAgentsManualTriggerContext.builder() + .type(BetaManagedAgentsManualTriggerContext.Type.MANUAL) + .build() + ) + + val roundtrippedBetaManagedAgentsTriggerContext = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsTriggerContext), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsTriggerContext) + .isEqualTo(betaManagedAgentsTriggerContext) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val betaManagedAgentsTriggerContext = + jsonMapper() + .convertValue(testCase.value, jacksonTypeRef()) + + val e = + assertThrows { + betaManagedAgentsTriggerContext.validate() + } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsUnknownRunErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsUnknownRunErrorTest.kt new file mode 100644 index 000000000..a74368888 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsUnknownRunErrorTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsUnknownRunErrorTest { + + @Test + fun create() { + val betaManagedAgentsUnknownRunError = + BetaManagedAgentsUnknownRunError.builder() + .message("message") + .type(BetaManagedAgentsUnknownRunError.Type.UNKNOWN_ERROR) + .build() + + assertThat(betaManagedAgentsUnknownRunError.message()).isEqualTo("message") + assertThat(betaManagedAgentsUnknownRunError.type()) + .isEqualTo(BetaManagedAgentsUnknownRunError.Type.UNKNOWN_ERROR) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsUnknownRunError = + BetaManagedAgentsUnknownRunError.builder() + .message("message") + .type(BetaManagedAgentsUnknownRunError.Type.UNKNOWN_ERROR) + .build() + + val roundtrippedBetaManagedAgentsUnknownRunError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsUnknownRunError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsUnknownRunError) + .isEqualTo(betaManagedAgentsUnknownRunError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsVaultArchivedRunErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsVaultArchivedRunErrorTest.kt new file mode 100644 index 000000000..714e04fb5 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsVaultArchivedRunErrorTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsVaultArchivedRunErrorTest { + + @Test + fun create() { + val betaManagedAgentsVaultArchivedRunError = + BetaManagedAgentsVaultArchivedRunError.builder() + .message("message") + .type(BetaManagedAgentsVaultArchivedRunError.Type.VAULT_ARCHIVED_ERROR) + .build() + + assertThat(betaManagedAgentsVaultArchivedRunError.message()).isEqualTo("message") + assertThat(betaManagedAgentsVaultArchivedRunError.type()) + .isEqualTo(BetaManagedAgentsVaultArchivedRunError.Type.VAULT_ARCHIVED_ERROR) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsVaultArchivedRunError = + BetaManagedAgentsVaultArchivedRunError.builder() + .message("message") + .type(BetaManagedAgentsVaultArchivedRunError.Type.VAULT_ARCHIVED_ERROR) + .build() + + val roundtrippedBetaManagedAgentsVaultArchivedRunError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsVaultArchivedRunError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsVaultArchivedRunError) + .isEqualTo(betaManagedAgentsVaultArchivedRunError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsVaultNotFoundRunErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsVaultNotFoundRunErrorTest.kt new file mode 100644 index 000000000..79368c422 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsVaultNotFoundRunErrorTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsVaultNotFoundRunErrorTest { + + @Test + fun create() { + val betaManagedAgentsVaultNotFoundRunError = + BetaManagedAgentsVaultNotFoundRunError.builder() + .message("message") + .type(BetaManagedAgentsVaultNotFoundRunError.Type.VAULT_NOT_FOUND_ERROR) + .build() + + assertThat(betaManagedAgentsVaultNotFoundRunError.message()).isEqualTo("message") + assertThat(betaManagedAgentsVaultNotFoundRunError.type()) + .isEqualTo(BetaManagedAgentsVaultNotFoundRunError.Type.VAULT_NOT_FOUND_ERROR) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsVaultNotFoundRunError = + BetaManagedAgentsVaultNotFoundRunError.builder() + .message("message") + .type(BetaManagedAgentsVaultNotFoundRunError.Type.VAULT_NOT_FOUND_ERROR) + .build() + + val roundtrippedBetaManagedAgentsVaultNotFoundRunError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsVaultNotFoundRunError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsVaultNotFoundRunError) + .isEqualTo(betaManagedAgentsVaultNotFoundRunError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsWorkspaceArchivedRunErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsWorkspaceArchivedRunErrorTest.kt new file mode 100644 index 000000000..0e11d5d24 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/BetaManagedAgentsWorkspaceArchivedRunErrorTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsWorkspaceArchivedRunErrorTest { + + @Test + fun create() { + val betaManagedAgentsWorkspaceArchivedRunError = + BetaManagedAgentsWorkspaceArchivedRunError.builder() + .message("message") + .type(BetaManagedAgentsWorkspaceArchivedRunError.Type.WORKSPACE_ARCHIVED_ERROR) + .build() + + assertThat(betaManagedAgentsWorkspaceArchivedRunError.message()).isEqualTo("message") + assertThat(betaManagedAgentsWorkspaceArchivedRunError.type()) + .isEqualTo(BetaManagedAgentsWorkspaceArchivedRunError.Type.WORKSPACE_ARCHIVED_ERROR) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsWorkspaceArchivedRunError = + BetaManagedAgentsWorkspaceArchivedRunError.builder() + .message("message") + .type(BetaManagedAgentsWorkspaceArchivedRunError.Type.WORKSPACE_ARCHIVED_ERROR) + .build() + + val roundtrippedBetaManagedAgentsWorkspaceArchivedRunError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsWorkspaceArchivedRunError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsWorkspaceArchivedRunError) + .isEqualTo(betaManagedAgentsWorkspaceArchivedRunError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunListPageResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunListPageResponseTest.kt new file mode 100644 index 000000000..0062413f6 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunListPageResponseTest.kt @@ -0,0 +1,96 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.jsonMapper +import com.anthropic.models.beta.agents.BetaManagedAgentsAgentReference +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DeploymentRunListPageResponseTest { + + @Test + fun create() { + val deploymentRunListPageResponse = + DeploymentRunListPageResponse.builder() + .addData( + BetaManagedAgentsDeploymentRun.builder() + .id("id") + .agent( + BetaManagedAgentsAgentReference.builder() + .id("agent_011CZkYqphY8vELVzwCUpqiQ") + .type(BetaManagedAgentsAgentReference.Type.AGENT) + .version(1) + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deploymentId("deployment_id") + .environmentArchivedError("message") + .sessionId("session_id") + .scheduleTriggerContext(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type(BetaManagedAgentsDeploymentRun.Type.DEPLOYMENT_RUN) + .build() + ) + .nextPage("next_page") + .build() + + assertThat(deploymentRunListPageResponse.data()) + .containsExactly( + BetaManagedAgentsDeploymentRun.builder() + .id("id") + .agent( + BetaManagedAgentsAgentReference.builder() + .id("agent_011CZkYqphY8vELVzwCUpqiQ") + .type(BetaManagedAgentsAgentReference.Type.AGENT) + .version(1) + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deploymentId("deployment_id") + .environmentArchivedError("message") + .sessionId("session_id") + .scheduleTriggerContext(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type(BetaManagedAgentsDeploymentRun.Type.DEPLOYMENT_RUN) + .build() + ) + assertThat(deploymentRunListPageResponse.nextPage()).contains("next_page") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val deploymentRunListPageResponse = + DeploymentRunListPageResponse.builder() + .addData( + BetaManagedAgentsDeploymentRun.builder() + .id("id") + .agent( + BetaManagedAgentsAgentReference.builder() + .id("agent_011CZkYqphY8vELVzwCUpqiQ") + .type(BetaManagedAgentsAgentReference.Type.AGENT) + .version(1) + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deploymentId("deployment_id") + .environmentArchivedError("message") + .sessionId("session_id") + .scheduleTriggerContext(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type(BetaManagedAgentsDeploymentRun.Type.DEPLOYMENT_RUN) + .build() + ) + .nextPage("next_page") + .build() + + val roundtrippedDeploymentRunListPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(deploymentRunListPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDeploymentRunListPageResponse) + .isEqualTo(deploymentRunListPageResponse) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunListParamsTest.kt new file mode 100644 index 000000000..aaaf1bee8 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunListParamsTest.kt @@ -0,0 +1,105 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.http.Headers +import com.anthropic.core.http.QueryParams +import com.anthropic.models.beta.AnthropicBeta +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DeploymentRunListParamsTest { + + @Test + fun create() { + DeploymentRunListParams.builder() + .createdAtGt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAtGte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAtLt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAtLte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deploymentId("deployment_id") + .hasError(true) + .limit(0) + .page("page") + .triggerType(BetaManagedAgentsTriggerType.SCHEDULE) + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + } + + @Test + fun headers() { + val params = + DeploymentRunListParams.builder() + .createdAtGt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAtGte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAtLt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAtLte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deploymentId("deployment_id") + .hasError(true) + .limit(0) + .page("page") + .triggerType(BetaManagedAgentsTriggerType.SCHEDULE) + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + + val headers = params._headers() + + assertThat(headers) + .isEqualTo( + Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + ) + } + + @Test + fun headersWithoutOptionalFields() { + val params = DeploymentRunListParams.builder().build() + + val headers = params._headers() + + assertThat(headers).isEqualTo(Headers.builder().build()) + } + + @Test + fun queryParams() { + val params = + DeploymentRunListParams.builder() + .createdAtGt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAtGte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAtLt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAtLte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deploymentId("deployment_id") + .hasError(true) + .limit(0) + .page("page") + .triggerType(BetaManagedAgentsTriggerType.SCHEDULE) + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("created_at[gt]", "2019-12-27T18:11:19.117Z") + .put("created_at[gte]", "2019-12-27T18:11:19.117Z") + .put("created_at[lt]", "2019-12-27T18:11:19.117Z") + .put("created_at[lte]", "2019-12-27T18:11:19.117Z") + .put("deployment_id", "deployment_id") + .put("has_error", "true") + .put("limit", "0") + .put("page", "page") + .put("trigger_type", "schedule") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = DeploymentRunListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunRetrieveParamsTest.kt new file mode 100644 index 000000000..61f7a052f --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunRetrieveParamsTest.kt @@ -0,0 +1,55 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deploymentruns + +import com.anthropic.core.http.Headers +import com.anthropic.models.beta.AnthropicBeta +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DeploymentRunRetrieveParamsTest { + + @Test + fun create() { + DeploymentRunRetrieveParams.builder() + .deploymentRunId("deployment_run_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + } + + @Test + fun pathParams() { + val params = + DeploymentRunRetrieveParams.builder().deploymentRunId("deployment_run_id").build() + + assertThat(params._pathParam(0)).isEqualTo("deployment_run_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun headers() { + val params = + DeploymentRunRetrieveParams.builder() + .deploymentRunId("deployment_run_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + + val headers = params._headers() + + assertThat(headers) + .isEqualTo( + Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + ) + } + + @Test + fun headersWithoutOptionalFields() { + val params = + DeploymentRunRetrieveParams.builder().deploymentRunId("deployment_run_id").build() + + val headers = params._headers() + + assertThat(headers).isEqualTo(Headers.builder().build()) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsAgentArchivedDeploymentPausedReasonErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsAgentArchivedDeploymentPausedReasonErrorTest.kt new file mode 100644 index 000000000..7aced5d46 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsAgentArchivedDeploymentPausedReasonErrorTest.kt @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsAgentArchivedDeploymentPausedReasonErrorTest { + + @Test + fun create() { + val betaManagedAgentsAgentArchivedDeploymentPausedReasonError = + BetaManagedAgentsAgentArchivedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsAgentArchivedDeploymentPausedReasonError.Type + .AGENT_ARCHIVED_ERROR + ) + .build() + + assertThat(betaManagedAgentsAgentArchivedDeploymentPausedReasonError.type()) + .isEqualTo( + BetaManagedAgentsAgentArchivedDeploymentPausedReasonError.Type.AGENT_ARCHIVED_ERROR + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsAgentArchivedDeploymentPausedReasonError = + BetaManagedAgentsAgentArchivedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsAgentArchivedDeploymentPausedReasonError.Type + .AGENT_ARCHIVED_ERROR + ) + .build() + + val roundtrippedBetaManagedAgentsAgentArchivedDeploymentPausedReasonError = + jsonMapper.readValue( + jsonMapper.writeValueAsString( + betaManagedAgentsAgentArchivedDeploymentPausedReasonError + ), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsAgentArchivedDeploymentPausedReasonError) + .isEqualTo(betaManagedAgentsAgentArchivedDeploymentPausedReasonError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsCronScheduleParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsCronScheduleParamsTest.kt new file mode 100644 index 000000000..f6bcdf257 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsCronScheduleParamsTest.kt @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsCronScheduleParamsTest { + + @Test + fun create() { + val betaManagedAgentsCronScheduleParams = + BetaManagedAgentsCronScheduleParams.builder() + .expression("x") + .timezone("x") + .type(BetaManagedAgentsCronScheduleParams.Type.CRON) + .build() + + assertThat(betaManagedAgentsCronScheduleParams.expression()).isEqualTo("x") + assertThat(betaManagedAgentsCronScheduleParams.timezone()).isEqualTo("x") + assertThat(betaManagedAgentsCronScheduleParams.type()) + .isEqualTo(BetaManagedAgentsCronScheduleParams.Type.CRON) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsCronScheduleParams = + BetaManagedAgentsCronScheduleParams.builder() + .expression("x") + .timezone("x") + .type(BetaManagedAgentsCronScheduleParams.Type.CRON) + .build() + + val roundtrippedBetaManagedAgentsCronScheduleParams = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsCronScheduleParams), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsCronScheduleParams) + .isEqualTo(betaManagedAgentsCronScheduleParams) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsCronScheduleTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsCronScheduleTest.kt new file mode 100644 index 000000000..dc846f688 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsCronScheduleTest.kt @@ -0,0 +1,75 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsCronScheduleTest { + + @Test + fun create() { + val betaManagedAgentsCronSchedule = + BetaManagedAgentsCronSchedule.builder() + .expression("x") + .timezone("x") + .type(BetaManagedAgentsCronSchedule.Type.CRON) + .lastRunAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUpcomingRunsAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(betaManagedAgentsCronSchedule.expression()).isEqualTo("x") + assertThat(betaManagedAgentsCronSchedule.timezone()).isEqualTo("x") + assertThat(betaManagedAgentsCronSchedule.type()) + .isEqualTo(BetaManagedAgentsCronSchedule.Type.CRON) + assertThat(betaManagedAgentsCronSchedule.lastRunAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(betaManagedAgentsCronSchedule.upcomingRunsAt().getOrNull()) + .containsExactly(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun addToUnsetListsOnToBuilder() { + val baseBetaManagedAgentsCronSchedule = + BetaManagedAgentsCronSchedule.builder() + .expression("x") + .timezone("x") + .type(BetaManagedAgentsCronSchedule.Type.CRON) + .build() + + val betaManagedAgentsCronSchedule = + baseBetaManagedAgentsCronSchedule + .toBuilder() + .addUpcomingRunsAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(betaManagedAgentsCronSchedule.upcomingRunsAt().getOrNull()) + .containsExactly(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsCronSchedule = + BetaManagedAgentsCronSchedule.builder() + .expression("x") + .timezone("x") + .type(BetaManagedAgentsCronSchedule.Type.CRON) + .lastRunAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUpcomingRunsAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedBetaManagedAgentsCronSchedule = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsCronSchedule), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsCronSchedule) + .isEqualTo(betaManagedAgentsCronSchedule) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentInitialEventParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentInitialEventParamsTest.kt new file mode 100644 index 000000000..cf409daeb --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentInitialEventParamsTest.kt @@ -0,0 +1,162 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.JsonValue +import com.anthropic.core.jsonMapper +import com.anthropic.errors.AnthropicInvalidDataException +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsSystemMessageEventParams +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsUserDefineOutcomeEventParams +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsUserMessageEventParams +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class BetaManagedAgentsDeploymentInitialEventParamsTest { + + @Test + fun ofUserMessage() { + val userMessage = + BetaManagedAgentsUserMessageEventParams.builder() + .addTextContent("Where is my order #1234?") + .type(BetaManagedAgentsUserMessageEventParams.Type.USER_MESSAGE) + .build() + + val betaManagedAgentsDeploymentInitialEventParams = + BetaManagedAgentsDeploymentInitialEventParams.ofUserMessage(userMessage) + + assertThat(betaManagedAgentsDeploymentInitialEventParams.userMessage()) + .contains(userMessage) + assertThat(betaManagedAgentsDeploymentInitialEventParams.userDefineOutcome()).isEmpty + assertThat(betaManagedAgentsDeploymentInitialEventParams.systemMessage()).isEmpty + } + + @Test + fun ofUserMessageRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsDeploymentInitialEventParams = + BetaManagedAgentsDeploymentInitialEventParams.ofUserMessage( + BetaManagedAgentsUserMessageEventParams.builder() + .addTextContent("Where is my order #1234?") + .type(BetaManagedAgentsUserMessageEventParams.Type.USER_MESSAGE) + .build() + ) + + val roundtrippedBetaManagedAgentsDeploymentInitialEventParams = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsDeploymentInitialEventParams), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsDeploymentInitialEventParams) + .isEqualTo(betaManagedAgentsDeploymentInitialEventParams) + } + + @Test + fun ofUserDefineOutcome() { + val userDefineOutcome = + BetaManagedAgentsUserDefineOutcomeEventParams.builder() + .description("Produce a 2-page summary as summary.md") + .textRubric("Must cover all five sections; cite sources inline.") + .type(BetaManagedAgentsUserDefineOutcomeEventParams.Type.USER_DEFINE_OUTCOME) + .maxIterations(3) + .build() + + val betaManagedAgentsDeploymentInitialEventParams = + BetaManagedAgentsDeploymentInitialEventParams.ofUserDefineOutcome(userDefineOutcome) + + assertThat(betaManagedAgentsDeploymentInitialEventParams.userMessage()).isEmpty + assertThat(betaManagedAgentsDeploymentInitialEventParams.userDefineOutcome()) + .contains(userDefineOutcome) + assertThat(betaManagedAgentsDeploymentInitialEventParams.systemMessage()).isEmpty + } + + @Test + fun ofUserDefineOutcomeRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsDeploymentInitialEventParams = + BetaManagedAgentsDeploymentInitialEventParams.ofUserDefineOutcome( + BetaManagedAgentsUserDefineOutcomeEventParams.builder() + .description("Produce a 2-page summary as summary.md") + .textRubric("Must cover all five sections; cite sources inline.") + .type(BetaManagedAgentsUserDefineOutcomeEventParams.Type.USER_DEFINE_OUTCOME) + .maxIterations(3) + .build() + ) + + val roundtrippedBetaManagedAgentsDeploymentInitialEventParams = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsDeploymentInitialEventParams), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsDeploymentInitialEventParams) + .isEqualTo(betaManagedAgentsDeploymentInitialEventParams) + } + + @Test + fun ofSystemMessage() { + val systemMessage = + BetaManagedAgentsSystemMessageEventParams.builder() + .addTextContent("Where is my order #1234?") + .type(BetaManagedAgentsSystemMessageEventParams.Type.SYSTEM_MESSAGE) + .build() + + val betaManagedAgentsDeploymentInitialEventParams = + BetaManagedAgentsDeploymentInitialEventParams.ofSystemMessage(systemMessage) + + assertThat(betaManagedAgentsDeploymentInitialEventParams.userMessage()).isEmpty + assertThat(betaManagedAgentsDeploymentInitialEventParams.userDefineOutcome()).isEmpty + assertThat(betaManagedAgentsDeploymentInitialEventParams.systemMessage()) + .contains(systemMessage) + } + + @Test + fun ofSystemMessageRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsDeploymentInitialEventParams = + BetaManagedAgentsDeploymentInitialEventParams.ofSystemMessage( + BetaManagedAgentsSystemMessageEventParams.builder() + .addTextContent("Where is my order #1234?") + .type(BetaManagedAgentsSystemMessageEventParams.Type.SYSTEM_MESSAGE) + .build() + ) + + val roundtrippedBetaManagedAgentsDeploymentInitialEventParams = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsDeploymentInitialEventParams), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsDeploymentInitialEventParams) + .isEqualTo(betaManagedAgentsDeploymentInitialEventParams) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val betaManagedAgentsDeploymentInitialEventParams = + jsonMapper() + .convertValue( + testCase.value, + jacksonTypeRef(), + ) + + val e = + assertThrows { + betaManagedAgentsDeploymentInitialEventParams.validate() + } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentInitialEventTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentInitialEventTest.kt new file mode 100644 index 000000000..7b2b29c85 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentInitialEventTest.kt @@ -0,0 +1,159 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.JsonValue +import com.anthropic.core.jsonMapper +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class BetaManagedAgentsDeploymentInitialEventTest { + + @Test + fun ofUserMessage() { + val userMessage = + BetaManagedAgentsDeploymentUserMessageEvent.builder() + .addTextContent("Where is my order #1234?") + .type(BetaManagedAgentsDeploymentUserMessageEvent.Type.USER_MESSAGE) + .build() + + val betaManagedAgentsDeploymentInitialEvent = + BetaManagedAgentsDeploymentInitialEvent.ofUserMessage(userMessage) + + assertThat(betaManagedAgentsDeploymentInitialEvent.userMessage()).contains(userMessage) + assertThat(betaManagedAgentsDeploymentInitialEvent.userDefineOutcome()).isEmpty + assertThat(betaManagedAgentsDeploymentInitialEvent.systemMessage()).isEmpty + } + + @Test + fun ofUserMessageRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsDeploymentInitialEvent = + BetaManagedAgentsDeploymentInitialEvent.ofUserMessage( + BetaManagedAgentsDeploymentUserMessageEvent.builder() + .addTextContent("Where is my order #1234?") + .type(BetaManagedAgentsDeploymentUserMessageEvent.Type.USER_MESSAGE) + .build() + ) + + val roundtrippedBetaManagedAgentsDeploymentInitialEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsDeploymentInitialEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsDeploymentInitialEvent) + .isEqualTo(betaManagedAgentsDeploymentInitialEvent) + } + + @Test + fun ofUserDefineOutcome() { + val userDefineOutcome = + BetaManagedAgentsDeploymentUserDefineOutcomeEvent.builder() + .description("description") + .fileRubric("file_id") + .type(BetaManagedAgentsDeploymentUserDefineOutcomeEvent.Type.USER_DEFINE_OUTCOME) + .maxIterations(0) + .build() + + val betaManagedAgentsDeploymentInitialEvent = + BetaManagedAgentsDeploymentInitialEvent.ofUserDefineOutcome(userDefineOutcome) + + assertThat(betaManagedAgentsDeploymentInitialEvent.userMessage()).isEmpty + assertThat(betaManagedAgentsDeploymentInitialEvent.userDefineOutcome()) + .contains(userDefineOutcome) + assertThat(betaManagedAgentsDeploymentInitialEvent.systemMessage()).isEmpty + } + + @Test + fun ofUserDefineOutcomeRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsDeploymentInitialEvent = + BetaManagedAgentsDeploymentInitialEvent.ofUserDefineOutcome( + BetaManagedAgentsDeploymentUserDefineOutcomeEvent.builder() + .description("description") + .fileRubric("file_id") + .type( + BetaManagedAgentsDeploymentUserDefineOutcomeEvent.Type.USER_DEFINE_OUTCOME + ) + .maxIterations(0) + .build() + ) + + val roundtrippedBetaManagedAgentsDeploymentInitialEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsDeploymentInitialEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsDeploymentInitialEvent) + .isEqualTo(betaManagedAgentsDeploymentInitialEvent) + } + + @Test + fun ofSystemMessage() { + val systemMessage = + BetaManagedAgentsDeploymentSystemMessageEvent.builder() + .addTextContent("Where is my order #1234?") + .type(BetaManagedAgentsDeploymentSystemMessageEvent.Type.SYSTEM_MESSAGE) + .build() + + val betaManagedAgentsDeploymentInitialEvent = + BetaManagedAgentsDeploymentInitialEvent.ofSystemMessage(systemMessage) + + assertThat(betaManagedAgentsDeploymentInitialEvent.userMessage()).isEmpty + assertThat(betaManagedAgentsDeploymentInitialEvent.userDefineOutcome()).isEmpty + assertThat(betaManagedAgentsDeploymentInitialEvent.systemMessage()).contains(systemMessage) + } + + @Test + fun ofSystemMessageRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsDeploymentInitialEvent = + BetaManagedAgentsDeploymentInitialEvent.ofSystemMessage( + BetaManagedAgentsDeploymentSystemMessageEvent.builder() + .addTextContent("Where is my order #1234?") + .type(BetaManagedAgentsDeploymentSystemMessageEvent.Type.SYSTEM_MESSAGE) + .build() + ) + + val roundtrippedBetaManagedAgentsDeploymentInitialEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsDeploymentInitialEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsDeploymentInitialEvent) + .isEqualTo(betaManagedAgentsDeploymentInitialEvent) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val betaManagedAgentsDeploymentInitialEvent = + jsonMapper() + .convertValue( + testCase.value, + jacksonTypeRef(), + ) + + val e = + assertThrows { + betaManagedAgentsDeploymentInitialEvent.validate() + } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentPausedReasonErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentPausedReasonErrorTest.kt new file mode 100644 index 000000000..aca84200d --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentPausedReasonErrorTest.kt @@ -0,0 +1,796 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.JsonValue +import com.anthropic.core.jsonMapper +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class BetaManagedAgentsDeploymentPausedReasonErrorTest { + + @Test + fun ofEnvironmentArchived() { + val environmentArchived = + BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError.Type + .ENVIRONMENT_ARCHIVED_ERROR + ) + .build() + + val betaManagedAgentsDeploymentPausedReasonError = + BetaManagedAgentsDeploymentPausedReasonError.ofEnvironmentArchived(environmentArchived) + + assertThat(betaManagedAgentsDeploymentPausedReasonError.environmentArchived()) + .contains(environmentArchived) + assertThat(betaManagedAgentsDeploymentPausedReasonError.agentArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.environmentNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.vaultNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.fileNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.sessionResourceNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.workspaceArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.organizationDisabled()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.memoryStoreArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.skillNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.vaultArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.unknown()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.selfHostedResourcesUnsupported()) + .isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.mcpEgressBlocked()).isEmpty + } + + @Test + fun ofEnvironmentArchivedRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsDeploymentPausedReasonError = + BetaManagedAgentsDeploymentPausedReasonError.ofEnvironmentArchived( + BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError.Type + .ENVIRONMENT_ARCHIVED_ERROR + ) + .build() + ) + + val roundtrippedBetaManagedAgentsDeploymentPausedReasonError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsDeploymentPausedReasonError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsDeploymentPausedReasonError) + .isEqualTo(betaManagedAgentsDeploymentPausedReasonError) + } + + @Test + fun ofAgentArchived() { + val agentArchived = + BetaManagedAgentsAgentArchivedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsAgentArchivedDeploymentPausedReasonError.Type + .AGENT_ARCHIVED_ERROR + ) + .build() + + val betaManagedAgentsDeploymentPausedReasonError = + BetaManagedAgentsDeploymentPausedReasonError.ofAgentArchived(agentArchived) + + assertThat(betaManagedAgentsDeploymentPausedReasonError.environmentArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.agentArchived()) + .contains(agentArchived) + assertThat(betaManagedAgentsDeploymentPausedReasonError.environmentNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.vaultNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.fileNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.sessionResourceNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.workspaceArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.organizationDisabled()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.memoryStoreArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.skillNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.vaultArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.unknown()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.selfHostedResourcesUnsupported()) + .isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.mcpEgressBlocked()).isEmpty + } + + @Test + fun ofAgentArchivedRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsDeploymentPausedReasonError = + BetaManagedAgentsDeploymentPausedReasonError.ofAgentArchived( + BetaManagedAgentsAgentArchivedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsAgentArchivedDeploymentPausedReasonError.Type + .AGENT_ARCHIVED_ERROR + ) + .build() + ) + + val roundtrippedBetaManagedAgentsDeploymentPausedReasonError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsDeploymentPausedReasonError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsDeploymentPausedReasonError) + .isEqualTo(betaManagedAgentsDeploymentPausedReasonError) + } + + @Test + fun ofEnvironmentNotFound() { + val environmentNotFound = + BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError.Type + .ENVIRONMENT_NOT_FOUND_ERROR + ) + .build() + + val betaManagedAgentsDeploymentPausedReasonError = + BetaManagedAgentsDeploymentPausedReasonError.ofEnvironmentNotFound(environmentNotFound) + + assertThat(betaManagedAgentsDeploymentPausedReasonError.environmentArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.agentArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.environmentNotFound()) + .contains(environmentNotFound) + assertThat(betaManagedAgentsDeploymentPausedReasonError.vaultNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.fileNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.sessionResourceNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.workspaceArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.organizationDisabled()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.memoryStoreArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.skillNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.vaultArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.unknown()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.selfHostedResourcesUnsupported()) + .isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.mcpEgressBlocked()).isEmpty + } + + @Test + fun ofEnvironmentNotFoundRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsDeploymentPausedReasonError = + BetaManagedAgentsDeploymentPausedReasonError.ofEnvironmentNotFound( + BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError.Type + .ENVIRONMENT_NOT_FOUND_ERROR + ) + .build() + ) + + val roundtrippedBetaManagedAgentsDeploymentPausedReasonError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsDeploymentPausedReasonError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsDeploymentPausedReasonError) + .isEqualTo(betaManagedAgentsDeploymentPausedReasonError) + } + + @Test + fun ofVaultNotFound() { + val vaultNotFound = + BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError.Type + .VAULT_NOT_FOUND_ERROR + ) + .build() + + val betaManagedAgentsDeploymentPausedReasonError = + BetaManagedAgentsDeploymentPausedReasonError.ofVaultNotFound(vaultNotFound) + + assertThat(betaManagedAgentsDeploymentPausedReasonError.environmentArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.agentArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.environmentNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.vaultNotFound()) + .contains(vaultNotFound) + assertThat(betaManagedAgentsDeploymentPausedReasonError.fileNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.sessionResourceNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.workspaceArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.organizationDisabled()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.memoryStoreArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.skillNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.vaultArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.unknown()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.selfHostedResourcesUnsupported()) + .isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.mcpEgressBlocked()).isEmpty + } + + @Test + fun ofVaultNotFoundRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsDeploymentPausedReasonError = + BetaManagedAgentsDeploymentPausedReasonError.ofVaultNotFound( + BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError.Type + .VAULT_NOT_FOUND_ERROR + ) + .build() + ) + + val roundtrippedBetaManagedAgentsDeploymentPausedReasonError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsDeploymentPausedReasonError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsDeploymentPausedReasonError) + .isEqualTo(betaManagedAgentsDeploymentPausedReasonError) + } + + @Test + fun ofFileNotFound() { + val fileNotFound = + BetaManagedAgentsFileNotFoundDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsFileNotFoundDeploymentPausedReasonError.Type + .FILE_NOT_FOUND_ERROR + ) + .build() + + val betaManagedAgentsDeploymentPausedReasonError = + BetaManagedAgentsDeploymentPausedReasonError.ofFileNotFound(fileNotFound) + + assertThat(betaManagedAgentsDeploymentPausedReasonError.environmentArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.agentArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.environmentNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.vaultNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.fileNotFound()) + .contains(fileNotFound) + assertThat(betaManagedAgentsDeploymentPausedReasonError.sessionResourceNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.workspaceArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.organizationDisabled()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.memoryStoreArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.skillNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.vaultArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.unknown()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.selfHostedResourcesUnsupported()) + .isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.mcpEgressBlocked()).isEmpty + } + + @Test + fun ofFileNotFoundRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsDeploymentPausedReasonError = + BetaManagedAgentsDeploymentPausedReasonError.ofFileNotFound( + BetaManagedAgentsFileNotFoundDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsFileNotFoundDeploymentPausedReasonError.Type + .FILE_NOT_FOUND_ERROR + ) + .build() + ) + + val roundtrippedBetaManagedAgentsDeploymentPausedReasonError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsDeploymentPausedReasonError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsDeploymentPausedReasonError) + .isEqualTo(betaManagedAgentsDeploymentPausedReasonError) + } + + @Test + fun ofSessionResourceNotFound() { + val sessionResourceNotFound = + BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError.Type + .SESSION_RESOURCE_NOT_FOUND_ERROR + ) + .build() + + val betaManagedAgentsDeploymentPausedReasonError = + BetaManagedAgentsDeploymentPausedReasonError.ofSessionResourceNotFound( + sessionResourceNotFound + ) + + assertThat(betaManagedAgentsDeploymentPausedReasonError.environmentArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.agentArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.environmentNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.vaultNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.fileNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.sessionResourceNotFound()) + .contains(sessionResourceNotFound) + assertThat(betaManagedAgentsDeploymentPausedReasonError.workspaceArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.organizationDisabled()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.memoryStoreArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.skillNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.vaultArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.unknown()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.selfHostedResourcesUnsupported()) + .isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.mcpEgressBlocked()).isEmpty + } + + @Test + fun ofSessionResourceNotFoundRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsDeploymentPausedReasonError = + BetaManagedAgentsDeploymentPausedReasonError.ofSessionResourceNotFound( + BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError.Type + .SESSION_RESOURCE_NOT_FOUND_ERROR + ) + .build() + ) + + val roundtrippedBetaManagedAgentsDeploymentPausedReasonError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsDeploymentPausedReasonError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsDeploymentPausedReasonError) + .isEqualTo(betaManagedAgentsDeploymentPausedReasonError) + } + + @Test + fun ofWorkspaceArchived() { + val workspaceArchived = + BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError.Type + .WORKSPACE_ARCHIVED_ERROR + ) + .build() + + val betaManagedAgentsDeploymentPausedReasonError = + BetaManagedAgentsDeploymentPausedReasonError.ofWorkspaceArchived(workspaceArchived) + + assertThat(betaManagedAgentsDeploymentPausedReasonError.environmentArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.agentArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.environmentNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.vaultNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.fileNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.sessionResourceNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.workspaceArchived()) + .contains(workspaceArchived) + assertThat(betaManagedAgentsDeploymentPausedReasonError.organizationDisabled()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.memoryStoreArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.skillNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.vaultArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.unknown()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.selfHostedResourcesUnsupported()) + .isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.mcpEgressBlocked()).isEmpty + } + + @Test + fun ofWorkspaceArchivedRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsDeploymentPausedReasonError = + BetaManagedAgentsDeploymentPausedReasonError.ofWorkspaceArchived( + BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError.Type + .WORKSPACE_ARCHIVED_ERROR + ) + .build() + ) + + val roundtrippedBetaManagedAgentsDeploymentPausedReasonError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsDeploymentPausedReasonError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsDeploymentPausedReasonError) + .isEqualTo(betaManagedAgentsDeploymentPausedReasonError) + } + + @Test + fun ofOrganizationDisabled() { + val organizationDisabled = + BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError.Type + .ORGANIZATION_DISABLED_ERROR + ) + .build() + + val betaManagedAgentsDeploymentPausedReasonError = + BetaManagedAgentsDeploymentPausedReasonError.ofOrganizationDisabled( + organizationDisabled + ) + + assertThat(betaManagedAgentsDeploymentPausedReasonError.environmentArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.agentArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.environmentNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.vaultNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.fileNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.sessionResourceNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.workspaceArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.organizationDisabled()) + .contains(organizationDisabled) + assertThat(betaManagedAgentsDeploymentPausedReasonError.memoryStoreArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.skillNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.vaultArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.unknown()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.selfHostedResourcesUnsupported()) + .isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.mcpEgressBlocked()).isEmpty + } + + @Test + fun ofOrganizationDisabledRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsDeploymentPausedReasonError = + BetaManagedAgentsDeploymentPausedReasonError.ofOrganizationDisabled( + BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError.Type + .ORGANIZATION_DISABLED_ERROR + ) + .build() + ) + + val roundtrippedBetaManagedAgentsDeploymentPausedReasonError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsDeploymentPausedReasonError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsDeploymentPausedReasonError) + .isEqualTo(betaManagedAgentsDeploymentPausedReasonError) + } + + @Test + fun ofMemoryStoreArchived() { + val memoryStoreArchived = + BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError.Type + .MEMORY_STORE_ARCHIVED_ERROR + ) + .build() + + val betaManagedAgentsDeploymentPausedReasonError = + BetaManagedAgentsDeploymentPausedReasonError.ofMemoryStoreArchived(memoryStoreArchived) + + assertThat(betaManagedAgentsDeploymentPausedReasonError.environmentArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.agentArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.environmentNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.vaultNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.fileNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.sessionResourceNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.workspaceArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.organizationDisabled()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.memoryStoreArchived()) + .contains(memoryStoreArchived) + assertThat(betaManagedAgentsDeploymentPausedReasonError.skillNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.vaultArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.unknown()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.selfHostedResourcesUnsupported()) + .isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.mcpEgressBlocked()).isEmpty + } + + @Test + fun ofMemoryStoreArchivedRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsDeploymentPausedReasonError = + BetaManagedAgentsDeploymentPausedReasonError.ofMemoryStoreArchived( + BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError.Type + .MEMORY_STORE_ARCHIVED_ERROR + ) + .build() + ) + + val roundtrippedBetaManagedAgentsDeploymentPausedReasonError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsDeploymentPausedReasonError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsDeploymentPausedReasonError) + .isEqualTo(betaManagedAgentsDeploymentPausedReasonError) + } + + @Test + fun ofSkillNotFound() { + val skillNotFound = + BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError.Type + .SKILL_NOT_FOUND_ERROR + ) + .build() + + val betaManagedAgentsDeploymentPausedReasonError = + BetaManagedAgentsDeploymentPausedReasonError.ofSkillNotFound(skillNotFound) + + assertThat(betaManagedAgentsDeploymentPausedReasonError.environmentArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.agentArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.environmentNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.vaultNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.fileNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.sessionResourceNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.workspaceArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.organizationDisabled()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.memoryStoreArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.skillNotFound()) + .contains(skillNotFound) + assertThat(betaManagedAgentsDeploymentPausedReasonError.vaultArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.unknown()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.selfHostedResourcesUnsupported()) + .isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.mcpEgressBlocked()).isEmpty + } + + @Test + fun ofSkillNotFoundRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsDeploymentPausedReasonError = + BetaManagedAgentsDeploymentPausedReasonError.ofSkillNotFound( + BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError.Type + .SKILL_NOT_FOUND_ERROR + ) + .build() + ) + + val roundtrippedBetaManagedAgentsDeploymentPausedReasonError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsDeploymentPausedReasonError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsDeploymentPausedReasonError) + .isEqualTo(betaManagedAgentsDeploymentPausedReasonError) + } + + @Test + fun ofVaultArchived() { + val vaultArchived = + BetaManagedAgentsVaultArchivedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsVaultArchivedDeploymentPausedReasonError.Type + .VAULT_ARCHIVED_ERROR + ) + .build() + + val betaManagedAgentsDeploymentPausedReasonError = + BetaManagedAgentsDeploymentPausedReasonError.ofVaultArchived(vaultArchived) + + assertThat(betaManagedAgentsDeploymentPausedReasonError.environmentArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.agentArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.environmentNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.vaultNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.fileNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.sessionResourceNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.workspaceArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.organizationDisabled()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.memoryStoreArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.skillNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.vaultArchived()) + .contains(vaultArchived) + assertThat(betaManagedAgentsDeploymentPausedReasonError.unknown()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.selfHostedResourcesUnsupported()) + .isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.mcpEgressBlocked()).isEmpty + } + + @Test + fun ofVaultArchivedRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsDeploymentPausedReasonError = + BetaManagedAgentsDeploymentPausedReasonError.ofVaultArchived( + BetaManagedAgentsVaultArchivedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsVaultArchivedDeploymentPausedReasonError.Type + .VAULT_ARCHIVED_ERROR + ) + .build() + ) + + val roundtrippedBetaManagedAgentsDeploymentPausedReasonError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsDeploymentPausedReasonError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsDeploymentPausedReasonError) + .isEqualTo(betaManagedAgentsDeploymentPausedReasonError) + } + + @Test + fun ofUnknown() { + val unknown = + BetaManagedAgentsUnknownDeploymentPausedReasonError.builder() + .type(BetaManagedAgentsUnknownDeploymentPausedReasonError.Type.UNKNOWN_ERROR) + .build() + + val betaManagedAgentsDeploymentPausedReasonError = + BetaManagedAgentsDeploymentPausedReasonError.ofUnknown(unknown) + + assertThat(betaManagedAgentsDeploymentPausedReasonError.environmentArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.agentArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.environmentNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.vaultNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.fileNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.sessionResourceNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.workspaceArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.organizationDisabled()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.memoryStoreArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.skillNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.vaultArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.unknown()).contains(unknown) + assertThat(betaManagedAgentsDeploymentPausedReasonError.selfHostedResourcesUnsupported()) + .isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.mcpEgressBlocked()).isEmpty + } + + @Test + fun ofUnknownRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsDeploymentPausedReasonError = + BetaManagedAgentsDeploymentPausedReasonError.ofUnknown( + BetaManagedAgentsUnknownDeploymentPausedReasonError.builder() + .type(BetaManagedAgentsUnknownDeploymentPausedReasonError.Type.UNKNOWN_ERROR) + .build() + ) + + val roundtrippedBetaManagedAgentsDeploymentPausedReasonError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsDeploymentPausedReasonError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsDeploymentPausedReasonError) + .isEqualTo(betaManagedAgentsDeploymentPausedReasonError) + } + + @Test + fun ofSelfHostedResourcesUnsupported() { + val selfHostedResourcesUnsupported = + BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError.Type + .SELF_HOSTED_RESOURCES_UNSUPPORTED_ERROR + ) + .build() + + val betaManagedAgentsDeploymentPausedReasonError = + BetaManagedAgentsDeploymentPausedReasonError.ofSelfHostedResourcesUnsupported( + selfHostedResourcesUnsupported + ) + + assertThat(betaManagedAgentsDeploymentPausedReasonError.environmentArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.agentArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.environmentNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.vaultNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.fileNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.sessionResourceNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.workspaceArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.organizationDisabled()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.memoryStoreArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.skillNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.vaultArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.unknown()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.selfHostedResourcesUnsupported()) + .contains(selfHostedResourcesUnsupported) + assertThat(betaManagedAgentsDeploymentPausedReasonError.mcpEgressBlocked()).isEmpty + } + + @Test + fun ofSelfHostedResourcesUnsupportedRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsDeploymentPausedReasonError = + BetaManagedAgentsDeploymentPausedReasonError.ofSelfHostedResourcesUnsupported( + BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError + .Type + .SELF_HOSTED_RESOURCES_UNSUPPORTED_ERROR + ) + .build() + ) + + val roundtrippedBetaManagedAgentsDeploymentPausedReasonError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsDeploymentPausedReasonError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsDeploymentPausedReasonError) + .isEqualTo(betaManagedAgentsDeploymentPausedReasonError) + } + + @Test + fun ofMcpEgressBlocked() { + val mcpEgressBlocked = + BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError.Type + .MCP_EGRESS_BLOCKED_ERROR + ) + .build() + + val betaManagedAgentsDeploymentPausedReasonError = + BetaManagedAgentsDeploymentPausedReasonError.ofMcpEgressBlocked(mcpEgressBlocked) + + assertThat(betaManagedAgentsDeploymentPausedReasonError.environmentArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.agentArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.environmentNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.vaultNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.fileNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.sessionResourceNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.workspaceArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.organizationDisabled()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.memoryStoreArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.skillNotFound()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.vaultArchived()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.unknown()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.selfHostedResourcesUnsupported()) + .isEmpty + assertThat(betaManagedAgentsDeploymentPausedReasonError.mcpEgressBlocked()) + .contains(mcpEgressBlocked) + } + + @Test + fun ofMcpEgressBlockedRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsDeploymentPausedReasonError = + BetaManagedAgentsDeploymentPausedReasonError.ofMcpEgressBlocked( + BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError.Type + .MCP_EGRESS_BLOCKED_ERROR + ) + .build() + ) + + val roundtrippedBetaManagedAgentsDeploymentPausedReasonError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsDeploymentPausedReasonError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsDeploymentPausedReasonError) + .isEqualTo(betaManagedAgentsDeploymentPausedReasonError) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val betaManagedAgentsDeploymentPausedReasonError = + jsonMapper() + .convertValue( + testCase.value, + jacksonTypeRef(), + ) + + val e = + assertThrows { + betaManagedAgentsDeploymentPausedReasonError.validate() + } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentPausedReasonTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentPausedReasonTest.kt new file mode 100644 index 000000000..2bd3d4775 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentPausedReasonTest.kt @@ -0,0 +1,125 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.JsonValue +import com.anthropic.core.jsonMapper +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class BetaManagedAgentsDeploymentPausedReasonTest { + + @Test + fun ofManual() { + val manual = + BetaManagedAgentsManualDeploymentPausedReason.builder() + .type(BetaManagedAgentsManualDeploymentPausedReason.Type.MANUAL) + .build() + + val betaManagedAgentsDeploymentPausedReason = + BetaManagedAgentsDeploymentPausedReason.ofManual(manual) + + assertThat(betaManagedAgentsDeploymentPausedReason.manual()).contains(manual) + assertThat(betaManagedAgentsDeploymentPausedReason.error()).isEmpty + } + + @Test + fun ofManualRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsDeploymentPausedReason = + BetaManagedAgentsDeploymentPausedReason.ofManual( + BetaManagedAgentsManualDeploymentPausedReason.builder() + .type(BetaManagedAgentsManualDeploymentPausedReason.Type.MANUAL) + .build() + ) + + val roundtrippedBetaManagedAgentsDeploymentPausedReason = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsDeploymentPausedReason), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsDeploymentPausedReason) + .isEqualTo(betaManagedAgentsDeploymentPausedReason) + } + + @Test + fun ofError() { + val error = + BetaManagedAgentsErrorDeploymentPausedReason.builder() + .error( + BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError.Type + .ENVIRONMENT_ARCHIVED_ERROR + ) + .build() + ) + .type(BetaManagedAgentsErrorDeploymentPausedReason.Type.ERROR) + .build() + + val betaManagedAgentsDeploymentPausedReason = + BetaManagedAgentsDeploymentPausedReason.ofError(error) + + assertThat(betaManagedAgentsDeploymentPausedReason.manual()).isEmpty + assertThat(betaManagedAgentsDeploymentPausedReason.error()).contains(error) + } + + @Test + fun ofErrorRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsDeploymentPausedReason = + BetaManagedAgentsDeploymentPausedReason.ofError( + BetaManagedAgentsErrorDeploymentPausedReason.builder() + .error( + BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError.Type + .ENVIRONMENT_ARCHIVED_ERROR + ) + .build() + ) + .type(BetaManagedAgentsErrorDeploymentPausedReason.Type.ERROR) + .build() + ) + + val roundtrippedBetaManagedAgentsDeploymentPausedReason = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsDeploymentPausedReason), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsDeploymentPausedReason) + .isEqualTo(betaManagedAgentsDeploymentPausedReason) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val betaManagedAgentsDeploymentPausedReason = + jsonMapper() + .convertValue( + testCase.value, + jacksonTypeRef(), + ) + + val e = + assertThrows { + betaManagedAgentsDeploymentPausedReason.validate() + } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentSystemMessageEventTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentSystemMessageEventTest.kt new file mode 100644 index 000000000..c4f917f7f --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentSystemMessageEventTest.kt @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.jsonMapper +import com.anthropic.models.beta.sessions.BetaManagedAgentsSystemContentBlock +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsDeploymentSystemMessageEventTest { + + @Test + fun create() { + val betaManagedAgentsDeploymentSystemMessageEvent = + BetaManagedAgentsDeploymentSystemMessageEvent.builder() + .addTextContent("Where is my order #1234?") + .type(BetaManagedAgentsDeploymentSystemMessageEvent.Type.SYSTEM_MESSAGE) + .build() + + assertThat(betaManagedAgentsDeploymentSystemMessageEvent.content()) + .containsExactly( + BetaManagedAgentsSystemContentBlock.builder() + .text("Where is my order #1234?") + .type(BetaManagedAgentsSystemContentBlock.Type.TEXT) + .build() + ) + assertThat(betaManagedAgentsDeploymentSystemMessageEvent.type()) + .isEqualTo(BetaManagedAgentsDeploymentSystemMessageEvent.Type.SYSTEM_MESSAGE) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsDeploymentSystemMessageEvent = + BetaManagedAgentsDeploymentSystemMessageEvent.builder() + .addTextContent("Where is my order #1234?") + .type(BetaManagedAgentsDeploymentSystemMessageEvent.Type.SYSTEM_MESSAGE) + .build() + + val roundtrippedBetaManagedAgentsDeploymentSystemMessageEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsDeploymentSystemMessageEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsDeploymentSystemMessageEvent) + .isEqualTo(betaManagedAgentsDeploymentSystemMessageEvent) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentTest.kt new file mode 100644 index 000000000..367ee5f6e --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentTest.kt @@ -0,0 +1,220 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.JsonValue +import com.anthropic.core.jsonMapper +import com.anthropic.models.beta.agents.BetaManagedAgentsAgentReference +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsTextBlock +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsDeploymentTest { + + @Test + fun create() { + val betaManagedAgentsDeployment = + BetaManagedAgentsDeployment.builder() + .id("id") + .agent( + BetaManagedAgentsAgentReference.builder() + .id("agent_011CZkYqphY8vELVzwCUpqiQ") + .type(BetaManagedAgentsAgentReference.Type.AGENT) + .version(1) + .build() + ) + .archivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .environmentId("environment_id") + .addUserMessageInitialEvent( + listOf( + BetaManagedAgentsDeploymentUserMessageEvent.Content.ofText( + BetaManagedAgentsTextBlock.builder() + .text("Where is my order #1234?") + .type(BetaManagedAgentsTextBlock.Type.TEXT) + .build() + ) + ) + ) + .metadata( + BetaManagedAgentsDeployment.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .pausedReason( + BetaManagedAgentsManualDeploymentPausedReason.builder() + .type(BetaManagedAgentsManualDeploymentPausedReason.Type.MANUAL) + .build() + ) + .addResource( + BetaManagedAgentsGitHubRepositoryResourceConfig.builder() + .type( + BetaManagedAgentsGitHubRepositoryResourceConfig.Type.GITHUB_REPOSITORY + ) + .url("url") + .branchCheckout("main") + .mountPath("mount_path") + .build() + ) + .schedule( + BetaManagedAgentsSchedule.builder() + .expression("x") + .timezone("x") + .type(BetaManagedAgentsSchedule.Type.CRON) + .lastRunAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUpcomingRunsAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .status(BetaManagedAgentsDeploymentStatus.ACTIVE) + .type(BetaManagedAgentsDeployment.Type.DEPLOYMENT) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addVaultId("string") + .build() + + assertThat(betaManagedAgentsDeployment.id()).isEqualTo("id") + assertThat(betaManagedAgentsDeployment.agent()) + .isEqualTo( + BetaManagedAgentsAgentReference.builder() + .id("agent_011CZkYqphY8vELVzwCUpqiQ") + .type(BetaManagedAgentsAgentReference.Type.AGENT) + .version(1) + .build() + ) + assertThat(betaManagedAgentsDeployment.archivedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(betaManagedAgentsDeployment.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(betaManagedAgentsDeployment.description()).contains("description") + assertThat(betaManagedAgentsDeployment.environmentId()).isEqualTo("environment_id") + assertThat(betaManagedAgentsDeployment.initialEvents()) + .containsExactly( + BetaManagedAgentsDeploymentInitialEvent.ofUserMessage( + BetaManagedAgentsDeploymentUserMessageEvent.builder() + .addTextContent("Where is my order #1234?") + .type(BetaManagedAgentsDeploymentUserMessageEvent.Type.USER_MESSAGE) + .build() + ) + ) + assertThat(betaManagedAgentsDeployment.metadata()) + .isEqualTo( + BetaManagedAgentsDeployment.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(betaManagedAgentsDeployment.name()).isEqualTo("name") + assertThat(betaManagedAgentsDeployment.pausedReason()) + .contains( + BetaManagedAgentsDeploymentPausedReason.ofManual( + BetaManagedAgentsManualDeploymentPausedReason.builder() + .type(BetaManagedAgentsManualDeploymentPausedReason.Type.MANUAL) + .build() + ) + ) + assertThat(betaManagedAgentsDeployment.resources()) + .containsExactly( + BetaManagedAgentsSessionResourceConfig.ofGitHubRepository( + BetaManagedAgentsGitHubRepositoryResourceConfig.builder() + .type( + BetaManagedAgentsGitHubRepositoryResourceConfig.Type.GITHUB_REPOSITORY + ) + .url("url") + .branchCheckout("main") + .mountPath("mount_path") + .build() + ) + ) + assertThat(betaManagedAgentsDeployment.schedule()) + .contains( + BetaManagedAgentsSchedule.builder() + .expression("x") + .timezone("x") + .type(BetaManagedAgentsSchedule.Type.CRON) + .lastRunAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUpcomingRunsAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(betaManagedAgentsDeployment.status()) + .isEqualTo(BetaManagedAgentsDeploymentStatus.ACTIVE) + assertThat(betaManagedAgentsDeployment.type()) + .isEqualTo(BetaManagedAgentsDeployment.Type.DEPLOYMENT) + assertThat(betaManagedAgentsDeployment.updatedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(betaManagedAgentsDeployment.vaultIds()).containsExactly("string") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsDeployment = + BetaManagedAgentsDeployment.builder() + .id("id") + .agent( + BetaManagedAgentsAgentReference.builder() + .id("agent_011CZkYqphY8vELVzwCUpqiQ") + .type(BetaManagedAgentsAgentReference.Type.AGENT) + .version(1) + .build() + ) + .archivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .environmentId("environment_id") + .addUserMessageInitialEvent( + listOf( + BetaManagedAgentsDeploymentUserMessageEvent.Content.ofText( + BetaManagedAgentsTextBlock.builder() + .text("Where is my order #1234?") + .type(BetaManagedAgentsTextBlock.Type.TEXT) + .build() + ) + ) + ) + .metadata( + BetaManagedAgentsDeployment.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .pausedReason( + BetaManagedAgentsManualDeploymentPausedReason.builder() + .type(BetaManagedAgentsManualDeploymentPausedReason.Type.MANUAL) + .build() + ) + .addResource( + BetaManagedAgentsGitHubRepositoryResourceConfig.builder() + .type( + BetaManagedAgentsGitHubRepositoryResourceConfig.Type.GITHUB_REPOSITORY + ) + .url("url") + .branchCheckout("main") + .mountPath("mount_path") + .build() + ) + .schedule( + BetaManagedAgentsSchedule.builder() + .expression("x") + .timezone("x") + .type(BetaManagedAgentsSchedule.Type.CRON) + .lastRunAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUpcomingRunsAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .status(BetaManagedAgentsDeploymentStatus.ACTIVE) + .type(BetaManagedAgentsDeployment.Type.DEPLOYMENT) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addVaultId("string") + .build() + + val roundtrippedBetaManagedAgentsDeployment = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsDeployment), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsDeployment).isEqualTo(betaManagedAgentsDeployment) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentUserDefineOutcomeEventTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentUserDefineOutcomeEventTest.kt new file mode 100644 index 000000000..dcc4f0b31 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentUserDefineOutcomeEventTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.jsonMapper +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsFileRubric +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsDeploymentUserDefineOutcomeEventTest { + + @Test + fun create() { + val betaManagedAgentsDeploymentUserDefineOutcomeEvent = + BetaManagedAgentsDeploymentUserDefineOutcomeEvent.builder() + .description("description") + .fileRubric("file_id") + .type(BetaManagedAgentsDeploymentUserDefineOutcomeEvent.Type.USER_DEFINE_OUTCOME) + .maxIterations(0) + .build() + + assertThat(betaManagedAgentsDeploymentUserDefineOutcomeEvent.description()) + .isEqualTo("description") + assertThat(betaManagedAgentsDeploymentUserDefineOutcomeEvent.rubric()) + .isEqualTo( + BetaManagedAgentsDeploymentUserDefineOutcomeEvent.Rubric.ofFile( + BetaManagedAgentsFileRubric.builder() + .fileId("file_id") + .type(BetaManagedAgentsFileRubric.Type.FILE) + .build() + ) + ) + assertThat(betaManagedAgentsDeploymentUserDefineOutcomeEvent.type()) + .isEqualTo(BetaManagedAgentsDeploymentUserDefineOutcomeEvent.Type.USER_DEFINE_OUTCOME) + assertThat(betaManagedAgentsDeploymentUserDefineOutcomeEvent.maxIterations()).contains(0) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsDeploymentUserDefineOutcomeEvent = + BetaManagedAgentsDeploymentUserDefineOutcomeEvent.builder() + .description("description") + .fileRubric("file_id") + .type(BetaManagedAgentsDeploymentUserDefineOutcomeEvent.Type.USER_DEFINE_OUTCOME) + .maxIterations(0) + .build() + + val roundtrippedBetaManagedAgentsDeploymentUserDefineOutcomeEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsDeploymentUserDefineOutcomeEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsDeploymentUserDefineOutcomeEvent) + .isEqualTo(betaManagedAgentsDeploymentUserDefineOutcomeEvent) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentUserMessageEventTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentUserMessageEventTest.kt new file mode 100644 index 000000000..187d72138 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsDeploymentUserMessageEventTest.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.jsonMapper +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsTextBlock +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsDeploymentUserMessageEventTest { + + @Test + fun create() { + val betaManagedAgentsDeploymentUserMessageEvent = + BetaManagedAgentsDeploymentUserMessageEvent.builder() + .addTextContent("Where is my order #1234?") + .type(BetaManagedAgentsDeploymentUserMessageEvent.Type.USER_MESSAGE) + .build() + + assertThat(betaManagedAgentsDeploymentUserMessageEvent.content()) + .containsExactly( + BetaManagedAgentsDeploymentUserMessageEvent.Content.ofText( + BetaManagedAgentsTextBlock.builder() + .text("Where is my order #1234?") + .type(BetaManagedAgentsTextBlock.Type.TEXT) + .build() + ) + ) + assertThat(betaManagedAgentsDeploymentUserMessageEvent.type()) + .isEqualTo(BetaManagedAgentsDeploymentUserMessageEvent.Type.USER_MESSAGE) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsDeploymentUserMessageEvent = + BetaManagedAgentsDeploymentUserMessageEvent.builder() + .addTextContent("Where is my order #1234?") + .type(BetaManagedAgentsDeploymentUserMessageEvent.Type.USER_MESSAGE) + .build() + + val roundtrippedBetaManagedAgentsDeploymentUserMessageEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsDeploymentUserMessageEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsDeploymentUserMessageEvent) + .isEqualTo(betaManagedAgentsDeploymentUserMessageEvent) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonErrorTest.kt new file mode 100644 index 000000000..56b2995e4 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonErrorTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonErrorTest { + + @Test + fun create() { + val betaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError = + BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError.Type + .ENVIRONMENT_ARCHIVED_ERROR + ) + .build() + + assertThat(betaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError.type()) + .isEqualTo( + BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError.Type + .ENVIRONMENT_ARCHIVED_ERROR + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError = + BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError.Type + .ENVIRONMENT_ARCHIVED_ERROR + ) + .build() + + val roundtrippedBetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError = + jsonMapper.readValue( + jsonMapper.writeValueAsString( + betaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError + ), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError) + .isEqualTo(betaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonErrorTest.kt new file mode 100644 index 000000000..ed47be9ba --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonErrorTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonErrorTest { + + @Test + fun create() { + val betaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError = + BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError.Type + .ENVIRONMENT_NOT_FOUND_ERROR + ) + .build() + + assertThat(betaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError.type()) + .isEqualTo( + BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError.Type + .ENVIRONMENT_NOT_FOUND_ERROR + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError = + BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError.Type + .ENVIRONMENT_NOT_FOUND_ERROR + ) + .build() + + val roundtrippedBetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError = + jsonMapper.readValue( + jsonMapper.writeValueAsString( + betaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError + ), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError) + .isEqualTo(betaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsErrorDeploymentPausedReasonTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsErrorDeploymentPausedReasonTest.kt new file mode 100644 index 000000000..7aff063bb --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsErrorDeploymentPausedReasonTest.kt @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsErrorDeploymentPausedReasonTest { + + @Test + fun create() { + val betaManagedAgentsErrorDeploymentPausedReason = + BetaManagedAgentsErrorDeploymentPausedReason.builder() + .error( + BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError.Type + .ENVIRONMENT_ARCHIVED_ERROR + ) + .build() + ) + .type(BetaManagedAgentsErrorDeploymentPausedReason.Type.ERROR) + .build() + + assertThat(betaManagedAgentsErrorDeploymentPausedReason.error()) + .isEqualTo( + BetaManagedAgentsDeploymentPausedReasonError.ofEnvironmentArchived( + BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError.Type + .ENVIRONMENT_ARCHIVED_ERROR + ) + .build() + ) + ) + assertThat(betaManagedAgentsErrorDeploymentPausedReason.type()) + .isEqualTo(BetaManagedAgentsErrorDeploymentPausedReason.Type.ERROR) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsErrorDeploymentPausedReason = + BetaManagedAgentsErrorDeploymentPausedReason.builder() + .error( + BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError.Type + .ENVIRONMENT_ARCHIVED_ERROR + ) + .build() + ) + .type(BetaManagedAgentsErrorDeploymentPausedReason.Type.ERROR) + .build() + + val roundtrippedBetaManagedAgentsErrorDeploymentPausedReason = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsErrorDeploymentPausedReason), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsErrorDeploymentPausedReason) + .isEqualTo(betaManagedAgentsErrorDeploymentPausedReason) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsFileNotFoundDeploymentPausedReasonErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsFileNotFoundDeploymentPausedReasonErrorTest.kt new file mode 100644 index 000000000..d31e1ead9 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsFileNotFoundDeploymentPausedReasonErrorTest.kt @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsFileNotFoundDeploymentPausedReasonErrorTest { + + @Test + fun create() { + val betaManagedAgentsFileNotFoundDeploymentPausedReasonError = + BetaManagedAgentsFileNotFoundDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsFileNotFoundDeploymentPausedReasonError.Type + .FILE_NOT_FOUND_ERROR + ) + .build() + + assertThat(betaManagedAgentsFileNotFoundDeploymentPausedReasonError.type()) + .isEqualTo( + BetaManagedAgentsFileNotFoundDeploymentPausedReasonError.Type.FILE_NOT_FOUND_ERROR + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsFileNotFoundDeploymentPausedReasonError = + BetaManagedAgentsFileNotFoundDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsFileNotFoundDeploymentPausedReasonError.Type + .FILE_NOT_FOUND_ERROR + ) + .build() + + val roundtrippedBetaManagedAgentsFileNotFoundDeploymentPausedReasonError = + jsonMapper.readValue( + jsonMapper.writeValueAsString( + betaManagedAgentsFileNotFoundDeploymentPausedReasonError + ), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsFileNotFoundDeploymentPausedReasonError) + .isEqualTo(betaManagedAgentsFileNotFoundDeploymentPausedReasonError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsFileResourceConfigTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsFileResourceConfigTest.kt new file mode 100644 index 000000000..73540af5a --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsFileResourceConfigTest.kt @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsFileResourceConfigTest { + + @Test + fun create() { + val betaManagedAgentsFileResourceConfig = + BetaManagedAgentsFileResourceConfig.builder() + .fileId("file_id") + .type(BetaManagedAgentsFileResourceConfig.Type.FILE) + .mountPath("mount_path") + .build() + + assertThat(betaManagedAgentsFileResourceConfig.fileId()).isEqualTo("file_id") + assertThat(betaManagedAgentsFileResourceConfig.type()) + .isEqualTo(BetaManagedAgentsFileResourceConfig.Type.FILE) + assertThat(betaManagedAgentsFileResourceConfig.mountPath()).contains("mount_path") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsFileResourceConfig = + BetaManagedAgentsFileResourceConfig.builder() + .fileId("file_id") + .type(BetaManagedAgentsFileResourceConfig.Type.FILE) + .mountPath("mount_path") + .build() + + val roundtrippedBetaManagedAgentsFileResourceConfig = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsFileResourceConfig), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsFileResourceConfig) + .isEqualTo(betaManagedAgentsFileResourceConfig) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsGitHubRepositoryResourceConfigTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsGitHubRepositoryResourceConfigTest.kt new file mode 100644 index 000000000..86f8009e7 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsGitHubRepositoryResourceConfigTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.jsonMapper +import com.anthropic.models.beta.sessions.BetaManagedAgentsBranchCheckout +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsGitHubRepositoryResourceConfigTest { + + @Test + fun create() { + val betaManagedAgentsGitHubRepositoryResourceConfig = + BetaManagedAgentsGitHubRepositoryResourceConfig.builder() + .type(BetaManagedAgentsGitHubRepositoryResourceConfig.Type.GITHUB_REPOSITORY) + .url("url") + .branchCheckout("main") + .mountPath("mount_path") + .build() + + assertThat(betaManagedAgentsGitHubRepositoryResourceConfig.type()) + .isEqualTo(BetaManagedAgentsGitHubRepositoryResourceConfig.Type.GITHUB_REPOSITORY) + assertThat(betaManagedAgentsGitHubRepositoryResourceConfig.url()).isEqualTo("url") + assertThat(betaManagedAgentsGitHubRepositoryResourceConfig.checkout()) + .contains( + BetaManagedAgentsGitHubRepositoryResourceConfig.Checkout.ofBranch( + BetaManagedAgentsBranchCheckout.builder() + .name("main") + .type(BetaManagedAgentsBranchCheckout.Type.BRANCH) + .build() + ) + ) + assertThat(betaManagedAgentsGitHubRepositoryResourceConfig.mountPath()) + .contains("mount_path") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsGitHubRepositoryResourceConfig = + BetaManagedAgentsGitHubRepositoryResourceConfig.builder() + .type(BetaManagedAgentsGitHubRepositoryResourceConfig.Type.GITHUB_REPOSITORY) + .url("url") + .branchCheckout("main") + .mountPath("mount_path") + .build() + + val roundtrippedBetaManagedAgentsGitHubRepositoryResourceConfig = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsGitHubRepositoryResourceConfig), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsGitHubRepositoryResourceConfig) + .isEqualTo(betaManagedAgentsGitHubRepositoryResourceConfig) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsManualDeploymentPausedReasonTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsManualDeploymentPausedReasonTest.kt new file mode 100644 index 000000000..35981dfaa --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsManualDeploymentPausedReasonTest.kt @@ -0,0 +1,40 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsManualDeploymentPausedReasonTest { + + @Test + fun create() { + val betaManagedAgentsManualDeploymentPausedReason = + BetaManagedAgentsManualDeploymentPausedReason.builder() + .type(BetaManagedAgentsManualDeploymentPausedReason.Type.MANUAL) + .build() + + assertThat(betaManagedAgentsManualDeploymentPausedReason.type()) + .isEqualTo(BetaManagedAgentsManualDeploymentPausedReason.Type.MANUAL) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsManualDeploymentPausedReason = + BetaManagedAgentsManualDeploymentPausedReason.builder() + .type(BetaManagedAgentsManualDeploymentPausedReason.Type.MANUAL) + .build() + + val roundtrippedBetaManagedAgentsManualDeploymentPausedReason = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsManualDeploymentPausedReason), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsManualDeploymentPausedReason) + .isEqualTo(betaManagedAgentsManualDeploymentPausedReason) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonErrorTest.kt new file mode 100644 index 000000000..cb1b2b4eb --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonErrorTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonErrorTest { + + @Test + fun create() { + val betaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError = + BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError.Type + .MCP_EGRESS_BLOCKED_ERROR + ) + .build() + + assertThat(betaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError.type()) + .isEqualTo( + BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError.Type + .MCP_EGRESS_BLOCKED_ERROR + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError = + BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError.Type + .MCP_EGRESS_BLOCKED_ERROR + ) + .build() + + val roundtrippedBetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError = + jsonMapper.readValue( + jsonMapper.writeValueAsString( + betaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError + ), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError) + .isEqualTo(betaManagedAgentsMcpEgressBlockedDeploymentPausedReasonError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonErrorTest.kt new file mode 100644 index 000000000..99ad2b065 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonErrorTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonErrorTest { + + @Test + fun create() { + val betaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError = + BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError.Type + .MEMORY_STORE_ARCHIVED_ERROR + ) + .build() + + assertThat(betaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError.type()) + .isEqualTo( + BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError.Type + .MEMORY_STORE_ARCHIVED_ERROR + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError = + BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError.Type + .MEMORY_STORE_ARCHIVED_ERROR + ) + .build() + + val roundtrippedBetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError = + jsonMapper.readValue( + jsonMapper.writeValueAsString( + betaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError + ), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError) + .isEqualTo(betaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsMemoryStoreResourceConfigTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsMemoryStoreResourceConfigTest.kt new file mode 100644 index 000000000..81ac0a5fb --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsMemoryStoreResourceConfigTest.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsMemoryStoreResourceConfigTest { + + @Test + fun create() { + val betaManagedAgentsMemoryStoreResourceConfig = + BetaManagedAgentsMemoryStoreResourceConfig.builder() + .memoryStoreId("memory_store_id") + .type(BetaManagedAgentsMemoryStoreResourceConfig.Type.MEMORY_STORE) + .access(BetaManagedAgentsMemoryStoreResourceConfig.Access.READ_WRITE) + .instructions("instructions") + .build() + + assertThat(betaManagedAgentsMemoryStoreResourceConfig.memoryStoreId()) + .isEqualTo("memory_store_id") + assertThat(betaManagedAgentsMemoryStoreResourceConfig.type()) + .isEqualTo(BetaManagedAgentsMemoryStoreResourceConfig.Type.MEMORY_STORE) + assertThat(betaManagedAgentsMemoryStoreResourceConfig.access()) + .contains(BetaManagedAgentsMemoryStoreResourceConfig.Access.READ_WRITE) + assertThat(betaManagedAgentsMemoryStoreResourceConfig.instructions()) + .contains("instructions") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsMemoryStoreResourceConfig = + BetaManagedAgentsMemoryStoreResourceConfig.builder() + .memoryStoreId("memory_store_id") + .type(BetaManagedAgentsMemoryStoreResourceConfig.Type.MEMORY_STORE) + .access(BetaManagedAgentsMemoryStoreResourceConfig.Access.READ_WRITE) + .instructions("instructions") + .build() + + val roundtrippedBetaManagedAgentsMemoryStoreResourceConfig = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsMemoryStoreResourceConfig), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsMemoryStoreResourceConfig) + .isEqualTo(betaManagedAgentsMemoryStoreResourceConfig) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonErrorTest.kt new file mode 100644 index 000000000..b81e26ef4 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonErrorTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonErrorTest { + + @Test + fun create() { + val betaManagedAgentsOrganizationDisabledDeploymentPausedReasonError = + BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError.Type + .ORGANIZATION_DISABLED_ERROR + ) + .build() + + assertThat(betaManagedAgentsOrganizationDisabledDeploymentPausedReasonError.type()) + .isEqualTo( + BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError.Type + .ORGANIZATION_DISABLED_ERROR + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsOrganizationDisabledDeploymentPausedReasonError = + BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError.Type + .ORGANIZATION_DISABLED_ERROR + ) + .build() + + val roundtrippedBetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError = + jsonMapper.readValue( + jsonMapper.writeValueAsString( + betaManagedAgentsOrganizationDisabledDeploymentPausedReasonError + ), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError) + .isEqualTo(betaManagedAgentsOrganizationDisabledDeploymentPausedReasonError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsScheduleParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsScheduleParamsTest.kt new file mode 100644 index 000000000..c84baf883 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsScheduleParamsTest.kt @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsScheduleParamsTest { + + @Test + fun create() { + val betaManagedAgentsScheduleParams = + BetaManagedAgentsScheduleParams.builder() + .expression("x") + .timezone("x") + .type(BetaManagedAgentsScheduleParams.Type.CRON) + .build() + + assertThat(betaManagedAgentsScheduleParams.expression()).isEqualTo("x") + assertThat(betaManagedAgentsScheduleParams.timezone()).isEqualTo("x") + assertThat(betaManagedAgentsScheduleParams.type()) + .isEqualTo(BetaManagedAgentsScheduleParams.Type.CRON) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsScheduleParams = + BetaManagedAgentsScheduleParams.builder() + .expression("x") + .timezone("x") + .type(BetaManagedAgentsScheduleParams.Type.CRON) + .build() + + val roundtrippedBetaManagedAgentsScheduleParams = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsScheduleParams), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsScheduleParams) + .isEqualTo(betaManagedAgentsScheduleParams) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsScheduleTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsScheduleTest.kt new file mode 100644 index 000000000..46c02f17c --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsScheduleTest.kt @@ -0,0 +1,73 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsScheduleTest { + + @Test + fun create() { + val betaManagedAgentsSchedule = + BetaManagedAgentsSchedule.builder() + .expression("x") + .timezone("x") + .type(BetaManagedAgentsSchedule.Type.CRON) + .lastRunAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUpcomingRunsAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(betaManagedAgentsSchedule.expression()).isEqualTo("x") + assertThat(betaManagedAgentsSchedule.timezone()).isEqualTo("x") + assertThat(betaManagedAgentsSchedule.type()).isEqualTo(BetaManagedAgentsSchedule.Type.CRON) + assertThat(betaManagedAgentsSchedule.lastRunAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(betaManagedAgentsSchedule.upcomingRunsAt().getOrNull()) + .containsExactly(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun addToUnsetListsOnToBuilder() { + val baseBetaManagedAgentsSchedule = + BetaManagedAgentsSchedule.builder() + .expression("x") + .timezone("x") + .type(BetaManagedAgentsSchedule.Type.CRON) + .build() + + val betaManagedAgentsSchedule = + baseBetaManagedAgentsSchedule + .toBuilder() + .addUpcomingRunsAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(betaManagedAgentsSchedule.upcomingRunsAt().getOrNull()) + .containsExactly(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsSchedule = + BetaManagedAgentsSchedule.builder() + .expression("x") + .timezone("x") + .type(BetaManagedAgentsSchedule.Type.CRON) + .lastRunAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUpcomingRunsAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedBetaManagedAgentsSchedule = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsSchedule), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsSchedule).isEqualTo(betaManagedAgentsSchedule) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonErrorTest.kt new file mode 100644 index 000000000..0b752475f --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonErrorTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonErrorTest { + + @Test + fun create() { + val betaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError = + BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError.Type + .SELF_HOSTED_RESOURCES_UNSUPPORTED_ERROR + ) + .build() + + assertThat( + betaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError.type() + ) + .isEqualTo( + BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError.Type + .SELF_HOSTED_RESOURCES_UNSUPPORTED_ERROR + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError = + BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError.Type + .SELF_HOSTED_RESOURCES_UNSUPPORTED_ERROR + ) + .build() + + val roundtrippedBetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError = + jsonMapper.readValue( + jsonMapper.writeValueAsString( + betaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError + ), + jacksonTypeRef< + BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError + >(), + ) + + assertThat( + roundtrippedBetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError + ) + .isEqualTo(betaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsSessionResourceConfigTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsSessionResourceConfigTest.kt new file mode 100644 index 000000000..1f22c4b0c --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsSessionResourceConfigTest.kt @@ -0,0 +1,163 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.JsonValue +import com.anthropic.core.jsonMapper +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class BetaManagedAgentsSessionResourceConfigTest { + + @Test + fun ofGitHubRepository() { + val githubRepository = + BetaManagedAgentsGitHubRepositoryResourceConfig.builder() + .type(BetaManagedAgentsGitHubRepositoryResourceConfig.Type.GITHUB_REPOSITORY) + .url("url") + .branchCheckout("main") + .mountPath("mount_path") + .build() + + val betaManagedAgentsSessionResourceConfig = + BetaManagedAgentsSessionResourceConfig.ofGitHubRepository(githubRepository) + + assertThat(betaManagedAgentsSessionResourceConfig.githubRepository()) + .contains(githubRepository) + assertThat(betaManagedAgentsSessionResourceConfig.file()).isEmpty + assertThat(betaManagedAgentsSessionResourceConfig.memoryStore()).isEmpty + } + + @Test + fun ofGitHubRepositoryRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsSessionResourceConfig = + BetaManagedAgentsSessionResourceConfig.ofGitHubRepository( + BetaManagedAgentsGitHubRepositoryResourceConfig.builder() + .type(BetaManagedAgentsGitHubRepositoryResourceConfig.Type.GITHUB_REPOSITORY) + .url("url") + .branchCheckout("main") + .mountPath("mount_path") + .build() + ) + + val roundtrippedBetaManagedAgentsSessionResourceConfig = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsSessionResourceConfig), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsSessionResourceConfig) + .isEqualTo(betaManagedAgentsSessionResourceConfig) + } + + @Test + fun ofFile() { + val file = + BetaManagedAgentsFileResourceConfig.builder() + .fileId("file_id") + .type(BetaManagedAgentsFileResourceConfig.Type.FILE) + .mountPath("mount_path") + .build() + + val betaManagedAgentsSessionResourceConfig = + BetaManagedAgentsSessionResourceConfig.ofFile(file) + + assertThat(betaManagedAgentsSessionResourceConfig.githubRepository()).isEmpty + assertThat(betaManagedAgentsSessionResourceConfig.file()).contains(file) + assertThat(betaManagedAgentsSessionResourceConfig.memoryStore()).isEmpty + } + + @Test + fun ofFileRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsSessionResourceConfig = + BetaManagedAgentsSessionResourceConfig.ofFile( + BetaManagedAgentsFileResourceConfig.builder() + .fileId("file_id") + .type(BetaManagedAgentsFileResourceConfig.Type.FILE) + .mountPath("mount_path") + .build() + ) + + val roundtrippedBetaManagedAgentsSessionResourceConfig = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsSessionResourceConfig), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsSessionResourceConfig) + .isEqualTo(betaManagedAgentsSessionResourceConfig) + } + + @Test + fun ofMemoryStore() { + val memoryStore = + BetaManagedAgentsMemoryStoreResourceConfig.builder() + .memoryStoreId("memory_store_id") + .type(BetaManagedAgentsMemoryStoreResourceConfig.Type.MEMORY_STORE) + .access(BetaManagedAgentsMemoryStoreResourceConfig.Access.READ_WRITE) + .instructions("instructions") + .build() + + val betaManagedAgentsSessionResourceConfig = + BetaManagedAgentsSessionResourceConfig.ofMemoryStore(memoryStore) + + assertThat(betaManagedAgentsSessionResourceConfig.githubRepository()).isEmpty + assertThat(betaManagedAgentsSessionResourceConfig.file()).isEmpty + assertThat(betaManagedAgentsSessionResourceConfig.memoryStore()).contains(memoryStore) + } + + @Test + fun ofMemoryStoreRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsSessionResourceConfig = + BetaManagedAgentsSessionResourceConfig.ofMemoryStore( + BetaManagedAgentsMemoryStoreResourceConfig.builder() + .memoryStoreId("memory_store_id") + .type(BetaManagedAgentsMemoryStoreResourceConfig.Type.MEMORY_STORE) + .access(BetaManagedAgentsMemoryStoreResourceConfig.Access.READ_WRITE) + .instructions("instructions") + .build() + ) + + val roundtrippedBetaManagedAgentsSessionResourceConfig = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsSessionResourceConfig), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsSessionResourceConfig) + .isEqualTo(betaManagedAgentsSessionResourceConfig) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val betaManagedAgentsSessionResourceConfig = + jsonMapper() + .convertValue( + testCase.value, + jacksonTypeRef(), + ) + + val e = + assertThrows { + betaManagedAgentsSessionResourceConfig.validate() + } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonErrorTest.kt new file mode 100644 index 000000000..bf28f768c --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonErrorTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonErrorTest { + + @Test + fun create() { + val betaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError = + BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError.Type + .SESSION_RESOURCE_NOT_FOUND_ERROR + ) + .build() + + assertThat(betaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError.type()) + .isEqualTo( + BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError.Type + .SESSION_RESOURCE_NOT_FOUND_ERROR + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError = + BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError.Type + .SESSION_RESOURCE_NOT_FOUND_ERROR + ) + .build() + + val roundtrippedBetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError = + jsonMapper.readValue( + jsonMapper.writeValueAsString( + betaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError + ), + jacksonTypeRef< + BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError + >(), + ) + + assertThat(roundtrippedBetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError) + .isEqualTo(betaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsSkillNotFoundDeploymentPausedReasonErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsSkillNotFoundDeploymentPausedReasonErrorTest.kt new file mode 100644 index 000000000..1161a2b5e --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsSkillNotFoundDeploymentPausedReasonErrorTest.kt @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsSkillNotFoundDeploymentPausedReasonErrorTest { + + @Test + fun create() { + val betaManagedAgentsSkillNotFoundDeploymentPausedReasonError = + BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError.Type + .SKILL_NOT_FOUND_ERROR + ) + .build() + + assertThat(betaManagedAgentsSkillNotFoundDeploymentPausedReasonError.type()) + .isEqualTo( + BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError.Type.SKILL_NOT_FOUND_ERROR + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsSkillNotFoundDeploymentPausedReasonError = + BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError.Type + .SKILL_NOT_FOUND_ERROR + ) + .build() + + val roundtrippedBetaManagedAgentsSkillNotFoundDeploymentPausedReasonError = + jsonMapper.readValue( + jsonMapper.writeValueAsString( + betaManagedAgentsSkillNotFoundDeploymentPausedReasonError + ), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsSkillNotFoundDeploymentPausedReasonError) + .isEqualTo(betaManagedAgentsSkillNotFoundDeploymentPausedReasonError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsUnknownDeploymentPausedReasonErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsUnknownDeploymentPausedReasonErrorTest.kt new file mode 100644 index 000000000..554828f21 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsUnknownDeploymentPausedReasonErrorTest.kt @@ -0,0 +1,40 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsUnknownDeploymentPausedReasonErrorTest { + + @Test + fun create() { + val betaManagedAgentsUnknownDeploymentPausedReasonError = + BetaManagedAgentsUnknownDeploymentPausedReasonError.builder() + .type(BetaManagedAgentsUnknownDeploymentPausedReasonError.Type.UNKNOWN_ERROR) + .build() + + assertThat(betaManagedAgentsUnknownDeploymentPausedReasonError.type()) + .isEqualTo(BetaManagedAgentsUnknownDeploymentPausedReasonError.Type.UNKNOWN_ERROR) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsUnknownDeploymentPausedReasonError = + BetaManagedAgentsUnknownDeploymentPausedReasonError.builder() + .type(BetaManagedAgentsUnknownDeploymentPausedReasonError.Type.UNKNOWN_ERROR) + .build() + + val roundtrippedBetaManagedAgentsUnknownDeploymentPausedReasonError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsUnknownDeploymentPausedReasonError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsUnknownDeploymentPausedReasonError) + .isEqualTo(betaManagedAgentsUnknownDeploymentPausedReasonError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsVaultArchivedDeploymentPausedReasonErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsVaultArchivedDeploymentPausedReasonErrorTest.kt new file mode 100644 index 000000000..2b0f1035e --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsVaultArchivedDeploymentPausedReasonErrorTest.kt @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsVaultArchivedDeploymentPausedReasonErrorTest { + + @Test + fun create() { + val betaManagedAgentsVaultArchivedDeploymentPausedReasonError = + BetaManagedAgentsVaultArchivedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsVaultArchivedDeploymentPausedReasonError.Type + .VAULT_ARCHIVED_ERROR + ) + .build() + + assertThat(betaManagedAgentsVaultArchivedDeploymentPausedReasonError.type()) + .isEqualTo( + BetaManagedAgentsVaultArchivedDeploymentPausedReasonError.Type.VAULT_ARCHIVED_ERROR + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsVaultArchivedDeploymentPausedReasonError = + BetaManagedAgentsVaultArchivedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsVaultArchivedDeploymentPausedReasonError.Type + .VAULT_ARCHIVED_ERROR + ) + .build() + + val roundtrippedBetaManagedAgentsVaultArchivedDeploymentPausedReasonError = + jsonMapper.readValue( + jsonMapper.writeValueAsString( + betaManagedAgentsVaultArchivedDeploymentPausedReasonError + ), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsVaultArchivedDeploymentPausedReasonError) + .isEqualTo(betaManagedAgentsVaultArchivedDeploymentPausedReasonError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsVaultNotFoundDeploymentPausedReasonErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsVaultNotFoundDeploymentPausedReasonErrorTest.kt new file mode 100644 index 000000000..6510ea8c5 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsVaultNotFoundDeploymentPausedReasonErrorTest.kt @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsVaultNotFoundDeploymentPausedReasonErrorTest { + + @Test + fun create() { + val betaManagedAgentsVaultNotFoundDeploymentPausedReasonError = + BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError.Type + .VAULT_NOT_FOUND_ERROR + ) + .build() + + assertThat(betaManagedAgentsVaultNotFoundDeploymentPausedReasonError.type()) + .isEqualTo( + BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError.Type.VAULT_NOT_FOUND_ERROR + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsVaultNotFoundDeploymentPausedReasonError = + BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError.Type + .VAULT_NOT_FOUND_ERROR + ) + .build() + + val roundtrippedBetaManagedAgentsVaultNotFoundDeploymentPausedReasonError = + jsonMapper.readValue( + jsonMapper.writeValueAsString( + betaManagedAgentsVaultNotFoundDeploymentPausedReasonError + ), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsVaultNotFoundDeploymentPausedReasonError) + .isEqualTo(betaManagedAgentsVaultNotFoundDeploymentPausedReasonError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonErrorTest.kt new file mode 100644 index 000000000..79e9a3ab3 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonErrorTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonErrorTest { + + @Test + fun create() { + val betaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError = + BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError.Type + .WORKSPACE_ARCHIVED_ERROR + ) + .build() + + assertThat(betaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError.type()) + .isEqualTo( + BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError.Type + .WORKSPACE_ARCHIVED_ERROR + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError = + BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError.builder() + .type( + BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError.Type + .WORKSPACE_ARCHIVED_ERROR + ) + .build() + + val roundtrippedBetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError = + jsonMapper.readValue( + jsonMapper.writeValueAsString( + betaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError + ), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError) + .isEqualTo(betaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentArchiveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentArchiveParamsTest.kt new file mode 100644 index 000000000..302c9c71d --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentArchiveParamsTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.http.Headers +import com.anthropic.models.beta.AnthropicBeta +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DeploymentArchiveParamsTest { + + @Test + fun create() { + DeploymentArchiveParams.builder() + .deploymentId("deployment_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + } + + @Test + fun pathParams() { + val params = DeploymentArchiveParams.builder().deploymentId("deployment_id").build() + + assertThat(params._pathParam(0)).isEqualTo("deployment_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun headers() { + val params = + DeploymentArchiveParams.builder() + .deploymentId("deployment_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + + val headers = params._headers() + + assertThat(headers) + .isEqualTo( + Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + ) + } + + @Test + fun headersWithoutOptionalFields() { + val params = DeploymentArchiveParams.builder().deploymentId("deployment_id").build() + + val headers = params._headers() + + assertThat(headers).isEqualTo(Headers.builder().build()) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentCreateParamsTest.kt new file mode 100644 index 000000000..a4d17bf79 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentCreateParamsTest.kt @@ -0,0 +1,248 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.JsonValue +import com.anthropic.core.http.Headers +import com.anthropic.models.beta.AnthropicBeta +import com.anthropic.models.beta.sessions.BetaManagedAgentsFileResourceParams +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsTextBlock +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsUserMessageEventParams +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DeploymentCreateParamsTest { + + @Test + fun create() { + DeploymentCreateParams.builder() + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .agent("string") + .environmentId("x") + .addUserMessageInitialEvent( + listOf( + BetaManagedAgentsUserMessageEventParams.Content.ofText( + BetaManagedAgentsTextBlock.builder() + .text("Where is my order #1234?") + .type(BetaManagedAgentsTextBlock.Type.TEXT) + .build() + ) + ) + ) + .name("x") + .description("description") + .metadata( + DeploymentCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addResource( + BetaManagedAgentsFileResourceParams.builder() + .fileId("file_011CNha8iCJcU1wXNR6q4V8w") + .type(BetaManagedAgentsFileResourceParams.Type.FILE) + .mountPath("/uploads/receipt.pdf") + .build() + ) + .schedule( + BetaManagedAgentsScheduleParams.builder() + .expression("x") + .timezone("x") + .type(BetaManagedAgentsScheduleParams.Type.CRON) + .build() + ) + .addVaultId("string") + .build() + } + + @Test + fun headers() { + val params = + DeploymentCreateParams.builder() + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .agent("string") + .environmentId("x") + .addUserMessageInitialEvent( + listOf( + BetaManagedAgentsUserMessageEventParams.Content.ofText( + BetaManagedAgentsTextBlock.builder() + .text("Where is my order #1234?") + .type(BetaManagedAgentsTextBlock.Type.TEXT) + .build() + ) + ) + ) + .name("x") + .description("description") + .metadata( + DeploymentCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addResource( + BetaManagedAgentsFileResourceParams.builder() + .fileId("file_011CNha8iCJcU1wXNR6q4V8w") + .type(BetaManagedAgentsFileResourceParams.Type.FILE) + .mountPath("/uploads/receipt.pdf") + .build() + ) + .schedule( + BetaManagedAgentsScheduleParams.builder() + .expression("x") + .timezone("x") + .type(BetaManagedAgentsScheduleParams.Type.CRON) + .build() + ) + .addVaultId("string") + .build() + + val headers = params._headers() + + assertThat(headers) + .isEqualTo( + Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + ) + } + + @Test + fun headersWithoutOptionalFields() { + val params = + DeploymentCreateParams.builder() + .agent("string") + .environmentId("x") + .addUserMessageInitialEvent( + listOf( + BetaManagedAgentsUserMessageEventParams.Content.ofText( + BetaManagedAgentsTextBlock.builder() + .text("Where is my order #1234?") + .type(BetaManagedAgentsTextBlock.Type.TEXT) + .build() + ) + ) + ) + .name("x") + .build() + + val headers = params._headers() + + assertThat(headers).isEqualTo(Headers.builder().build()) + } + + @Test + fun body() { + val params = + DeploymentCreateParams.builder() + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .agent("string") + .environmentId("x") + .addUserMessageInitialEvent( + listOf( + BetaManagedAgentsUserMessageEventParams.Content.ofText( + BetaManagedAgentsTextBlock.builder() + .text("Where is my order #1234?") + .type(BetaManagedAgentsTextBlock.Type.TEXT) + .build() + ) + ) + ) + .name("x") + .description("description") + .metadata( + DeploymentCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addResource( + BetaManagedAgentsFileResourceParams.builder() + .fileId("file_011CNha8iCJcU1wXNR6q4V8w") + .type(BetaManagedAgentsFileResourceParams.Type.FILE) + .mountPath("/uploads/receipt.pdf") + .build() + ) + .schedule( + BetaManagedAgentsScheduleParams.builder() + .expression("x") + .timezone("x") + .type(BetaManagedAgentsScheduleParams.Type.CRON) + .build() + ) + .addVaultId("string") + .build() + + val body = params._body() + + assertThat(body.agent()).isEqualTo(DeploymentCreateParams.Agent.ofString("string")) + assertThat(body.environmentId()).isEqualTo("x") + assertThat(body.initialEvents()) + .containsExactly( + BetaManagedAgentsDeploymentInitialEventParams.ofUserMessage( + BetaManagedAgentsUserMessageEventParams.builder() + .addTextContent("Where is my order #1234?") + .type(BetaManagedAgentsUserMessageEventParams.Type.USER_MESSAGE) + .build() + ) + ) + assertThat(body.name()).isEqualTo("x") + assertThat(body.description()).contains("description") + assertThat(body.metadata()) + .contains( + DeploymentCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(body.resources().getOrNull()) + .containsExactly( + DeploymentCreateParams.Resource.ofFile( + BetaManagedAgentsFileResourceParams.builder() + .fileId("file_011CNha8iCJcU1wXNR6q4V8w") + .type(BetaManagedAgentsFileResourceParams.Type.FILE) + .mountPath("/uploads/receipt.pdf") + .build() + ) + ) + assertThat(body.schedule()) + .contains( + BetaManagedAgentsScheduleParams.builder() + .expression("x") + .timezone("x") + .type(BetaManagedAgentsScheduleParams.Type.CRON) + .build() + ) + assertThat(body.vaultIds().getOrNull()).containsExactly("string") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + DeploymentCreateParams.builder() + .agent("string") + .environmentId("x") + .addUserMessageInitialEvent( + listOf( + BetaManagedAgentsUserMessageEventParams.Content.ofText( + BetaManagedAgentsTextBlock.builder() + .text("Where is my order #1234?") + .type(BetaManagedAgentsTextBlock.Type.TEXT) + .build() + ) + ) + ) + .name("x") + .build() + + val body = params._body() + + assertThat(body.agent()).isEqualTo(DeploymentCreateParams.Agent.ofString("string")) + assertThat(body.environmentId()).isEqualTo("x") + assertThat(body.initialEvents()) + .containsExactly( + BetaManagedAgentsDeploymentInitialEventParams.ofUserMessage( + BetaManagedAgentsUserMessageEventParams.builder() + .addTextContent("Where is my order #1234?") + .type(BetaManagedAgentsUserMessageEventParams.Type.USER_MESSAGE) + .build() + ) + ) + assertThat(body.name()).isEqualTo("x") + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentListPageResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentListPageResponseTest.kt new file mode 100644 index 000000000..1fd91f59f --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentListPageResponseTest.kt @@ -0,0 +1,226 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.JsonValue +import com.anthropic.core.jsonMapper +import com.anthropic.models.beta.agents.BetaManagedAgentsAgentReference +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsTextBlock +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DeploymentListPageResponseTest { + + @Test + fun create() { + val deploymentListPageResponse = + DeploymentListPageResponse.builder() + .addData( + BetaManagedAgentsDeployment.builder() + .id("id") + .agent( + BetaManagedAgentsAgentReference.builder() + .id("agent_011CZkYqphY8vELVzwCUpqiQ") + .type(BetaManagedAgentsAgentReference.Type.AGENT) + .version(1) + .build() + ) + .archivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .environmentId("environment_id") + .addUserMessageInitialEvent( + listOf( + BetaManagedAgentsDeploymentUserMessageEvent.Content.ofText( + BetaManagedAgentsTextBlock.builder() + .text("Where is my order #1234?") + .type(BetaManagedAgentsTextBlock.Type.TEXT) + .build() + ) + ) + ) + .metadata( + BetaManagedAgentsDeployment.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .pausedReason( + BetaManagedAgentsManualDeploymentPausedReason.builder() + .type(BetaManagedAgentsManualDeploymentPausedReason.Type.MANUAL) + .build() + ) + .addResource( + BetaManagedAgentsGitHubRepositoryResourceConfig.builder() + .type( + BetaManagedAgentsGitHubRepositoryResourceConfig.Type + .GITHUB_REPOSITORY + ) + .url("url") + .branchCheckout("main") + .mountPath("mount_path") + .build() + ) + .schedule( + BetaManagedAgentsSchedule.builder() + .expression("x") + .timezone("x") + .type(BetaManagedAgentsSchedule.Type.CRON) + .lastRunAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUpcomingRunsAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .status(BetaManagedAgentsDeploymentStatus.ACTIVE) + .type(BetaManagedAgentsDeployment.Type.DEPLOYMENT) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addVaultId("string") + .build() + ) + .nextPage("next_page") + .build() + + assertThat(deploymentListPageResponse.data()) + .containsExactly( + BetaManagedAgentsDeployment.builder() + .id("id") + .agent( + BetaManagedAgentsAgentReference.builder() + .id("agent_011CZkYqphY8vELVzwCUpqiQ") + .type(BetaManagedAgentsAgentReference.Type.AGENT) + .version(1) + .build() + ) + .archivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .environmentId("environment_id") + .addUserMessageInitialEvent( + listOf( + BetaManagedAgentsDeploymentUserMessageEvent.Content.ofText( + BetaManagedAgentsTextBlock.builder() + .text("Where is my order #1234?") + .type(BetaManagedAgentsTextBlock.Type.TEXT) + .build() + ) + ) + ) + .metadata( + BetaManagedAgentsDeployment.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .pausedReason( + BetaManagedAgentsManualDeploymentPausedReason.builder() + .type(BetaManagedAgentsManualDeploymentPausedReason.Type.MANUAL) + .build() + ) + .addResource( + BetaManagedAgentsGitHubRepositoryResourceConfig.builder() + .type( + BetaManagedAgentsGitHubRepositoryResourceConfig.Type + .GITHUB_REPOSITORY + ) + .url("url") + .branchCheckout("main") + .mountPath("mount_path") + .build() + ) + .schedule( + BetaManagedAgentsSchedule.builder() + .expression("x") + .timezone("x") + .type(BetaManagedAgentsSchedule.Type.CRON) + .lastRunAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUpcomingRunsAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .status(BetaManagedAgentsDeploymentStatus.ACTIVE) + .type(BetaManagedAgentsDeployment.Type.DEPLOYMENT) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addVaultId("string") + .build() + ) + assertThat(deploymentListPageResponse.nextPage()).contains("next_page") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val deploymentListPageResponse = + DeploymentListPageResponse.builder() + .addData( + BetaManagedAgentsDeployment.builder() + .id("id") + .agent( + BetaManagedAgentsAgentReference.builder() + .id("agent_011CZkYqphY8vELVzwCUpqiQ") + .type(BetaManagedAgentsAgentReference.Type.AGENT) + .version(1) + .build() + ) + .archivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .environmentId("environment_id") + .addUserMessageInitialEvent( + listOf( + BetaManagedAgentsDeploymentUserMessageEvent.Content.ofText( + BetaManagedAgentsTextBlock.builder() + .text("Where is my order #1234?") + .type(BetaManagedAgentsTextBlock.Type.TEXT) + .build() + ) + ) + ) + .metadata( + BetaManagedAgentsDeployment.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .pausedReason( + BetaManagedAgentsManualDeploymentPausedReason.builder() + .type(BetaManagedAgentsManualDeploymentPausedReason.Type.MANUAL) + .build() + ) + .addResource( + BetaManagedAgentsGitHubRepositoryResourceConfig.builder() + .type( + BetaManagedAgentsGitHubRepositoryResourceConfig.Type + .GITHUB_REPOSITORY + ) + .url("url") + .branchCheckout("main") + .mountPath("mount_path") + .build() + ) + .schedule( + BetaManagedAgentsSchedule.builder() + .expression("x") + .timezone("x") + .type(BetaManagedAgentsSchedule.Type.CRON) + .lastRunAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUpcomingRunsAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .status(BetaManagedAgentsDeploymentStatus.ACTIVE) + .type(BetaManagedAgentsDeployment.Type.DEPLOYMENT) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addVaultId("string") + .build() + ) + .nextPage("next_page") + .build() + + val roundtrippedDeploymentListPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(deploymentListPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDeploymentListPageResponse).isEqualTo(deploymentListPageResponse) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentListParamsTest.kt new file mode 100644 index 000000000..10f86410a --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentListParamsTest.kt @@ -0,0 +1,97 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.http.Headers +import com.anthropic.core.http.QueryParams +import com.anthropic.models.beta.AnthropicBeta +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DeploymentListParamsTest { + + @Test + fun create() { + DeploymentListParams.builder() + .agentId("agent_id") + .createdAtGte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAtLte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .includeArchived(true) + .limit(0) + .page("page") + .status(BetaManagedAgentsDeploymentStatus.ACTIVE) + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + } + + @Test + fun headers() { + val params = + DeploymentListParams.builder() + .agentId("agent_id") + .createdAtGte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAtLte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .includeArchived(true) + .limit(0) + .page("page") + .status(BetaManagedAgentsDeploymentStatus.ACTIVE) + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + + val headers = params._headers() + + assertThat(headers) + .isEqualTo( + Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + ) + } + + @Test + fun headersWithoutOptionalFields() { + val params = DeploymentListParams.builder().build() + + val headers = params._headers() + + assertThat(headers).isEqualTo(Headers.builder().build()) + } + + @Test + fun queryParams() { + val params = + DeploymentListParams.builder() + .agentId("agent_id") + .createdAtGte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAtLte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .includeArchived(true) + .limit(0) + .page("page") + .status(BetaManagedAgentsDeploymentStatus.ACTIVE) + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("agent_id", "agent_id") + .put("created_at[gte]", "2019-12-27T18:11:19.117Z") + .put("created_at[lte]", "2019-12-27T18:11:19.117Z") + .put("include_archived", "true") + .put("limit", "0") + .put("page", "page") + .put("status", "active") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = DeploymentListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentPauseParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentPauseParamsTest.kt new file mode 100644 index 000000000..1062b4a48 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentPauseParamsTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.http.Headers +import com.anthropic.models.beta.AnthropicBeta +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DeploymentPauseParamsTest { + + @Test + fun create() { + DeploymentPauseParams.builder() + .deploymentId("deployment_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + } + + @Test + fun pathParams() { + val params = DeploymentPauseParams.builder().deploymentId("deployment_id").build() + + assertThat(params._pathParam(0)).isEqualTo("deployment_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun headers() { + val params = + DeploymentPauseParams.builder() + .deploymentId("deployment_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + + val headers = params._headers() + + assertThat(headers) + .isEqualTo( + Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + ) + } + + @Test + fun headersWithoutOptionalFields() { + val params = DeploymentPauseParams.builder().deploymentId("deployment_id").build() + + val headers = params._headers() + + assertThat(headers).isEqualTo(Headers.builder().build()) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentRetrieveParamsTest.kt new file mode 100644 index 000000000..b2a465ecb --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentRetrieveParamsTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.http.Headers +import com.anthropic.models.beta.AnthropicBeta +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DeploymentRetrieveParamsTest { + + @Test + fun create() { + DeploymentRetrieveParams.builder() + .deploymentId("deployment_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + } + + @Test + fun pathParams() { + val params = DeploymentRetrieveParams.builder().deploymentId("deployment_id").build() + + assertThat(params._pathParam(0)).isEqualTo("deployment_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun headers() { + val params = + DeploymentRetrieveParams.builder() + .deploymentId("deployment_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + + val headers = params._headers() + + assertThat(headers) + .isEqualTo( + Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + ) + } + + @Test + fun headersWithoutOptionalFields() { + val params = DeploymentRetrieveParams.builder().deploymentId("deployment_id").build() + + val headers = params._headers() + + assertThat(headers).isEqualTo(Headers.builder().build()) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentRunParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentRunParamsTest.kt new file mode 100644 index 000000000..0833a3b48 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentRunParamsTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.http.Headers +import com.anthropic.models.beta.AnthropicBeta +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DeploymentRunParamsTest { + + @Test + fun create() { + DeploymentRunParams.builder() + .deploymentId("deployment_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + } + + @Test + fun pathParams() { + val params = DeploymentRunParams.builder().deploymentId("deployment_id").build() + + assertThat(params._pathParam(0)).isEqualTo("deployment_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun headers() { + val params = + DeploymentRunParams.builder() + .deploymentId("deployment_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + + val headers = params._headers() + + assertThat(headers) + .isEqualTo( + Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + ) + } + + @Test + fun headersWithoutOptionalFields() { + val params = DeploymentRunParams.builder().deploymentId("deployment_id").build() + + val headers = params._headers() + + assertThat(headers).isEqualTo(Headers.builder().build()) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentUnpauseParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentUnpauseParamsTest.kt new file mode 100644 index 000000000..b3f954468 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentUnpauseParamsTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.http.Headers +import com.anthropic.models.beta.AnthropicBeta +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DeploymentUnpauseParamsTest { + + @Test + fun create() { + DeploymentUnpauseParams.builder() + .deploymentId("deployment_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + } + + @Test + fun pathParams() { + val params = DeploymentUnpauseParams.builder().deploymentId("deployment_id").build() + + assertThat(params._pathParam(0)).isEqualTo("deployment_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun headers() { + val params = + DeploymentUnpauseParams.builder() + .deploymentId("deployment_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + + val headers = params._headers() + + assertThat(headers) + .isEqualTo( + Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + ) + } + + @Test + fun headersWithoutOptionalFields() { + val params = DeploymentUnpauseParams.builder().deploymentId("deployment_id").build() + + val headers = params._headers() + + assertThat(headers).isEqualTo(Headers.builder().build()) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentUpdateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentUpdateParamsTest.kt new file mode 100644 index 000000000..91175e243 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentUpdateParamsTest.kt @@ -0,0 +1,217 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.deployments + +import com.anthropic.core.JsonValue +import com.anthropic.core.http.Headers +import com.anthropic.models.beta.AnthropicBeta +import com.anthropic.models.beta.sessions.BetaManagedAgentsFileResourceParams +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsTextBlock +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsUserMessageEventParams +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DeploymentUpdateParamsTest { + + @Test + fun create() { + DeploymentUpdateParams.builder() + .deploymentId("deployment_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .agent("string") + .description("description") + .environmentId("environment_id") + .addUserMessageInitialEvent( + listOf( + BetaManagedAgentsUserMessageEventParams.Content.ofText( + BetaManagedAgentsTextBlock.builder() + .text("Where is my order #1234?") + .type(BetaManagedAgentsTextBlock.Type.TEXT) + .build() + ) + ) + ) + .metadata( + DeploymentUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .addResource( + BetaManagedAgentsFileResourceParams.builder() + .fileId("file_011CNha8iCJcU1wXNR6q4V8w") + .type(BetaManagedAgentsFileResourceParams.Type.FILE) + .mountPath("/uploads/receipt.pdf") + .build() + ) + .schedule( + BetaManagedAgentsScheduleParams.builder() + .expression("x") + .timezone("x") + .type(BetaManagedAgentsScheduleParams.Type.CRON) + .build() + ) + .addVaultId("string") + .build() + } + + @Test + fun pathParams() { + val params = DeploymentUpdateParams.builder().deploymentId("deployment_id").build() + + assertThat(params._pathParam(0)).isEqualTo("deployment_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun headers() { + val params = + DeploymentUpdateParams.builder() + .deploymentId("deployment_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .agent("string") + .description("description") + .environmentId("environment_id") + .addUserMessageInitialEvent( + listOf( + BetaManagedAgentsUserMessageEventParams.Content.ofText( + BetaManagedAgentsTextBlock.builder() + .text("Where is my order #1234?") + .type(BetaManagedAgentsTextBlock.Type.TEXT) + .build() + ) + ) + ) + .metadata( + DeploymentUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .addResource( + BetaManagedAgentsFileResourceParams.builder() + .fileId("file_011CNha8iCJcU1wXNR6q4V8w") + .type(BetaManagedAgentsFileResourceParams.Type.FILE) + .mountPath("/uploads/receipt.pdf") + .build() + ) + .schedule( + BetaManagedAgentsScheduleParams.builder() + .expression("x") + .timezone("x") + .type(BetaManagedAgentsScheduleParams.Type.CRON) + .build() + ) + .addVaultId("string") + .build() + + val headers = params._headers() + + assertThat(headers) + .isEqualTo( + Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + ) + } + + @Test + fun headersWithoutOptionalFields() { + val params = DeploymentUpdateParams.builder().deploymentId("deployment_id").build() + + val headers = params._headers() + + assertThat(headers).isEqualTo(Headers.builder().build()) + } + + @Test + fun body() { + val params = + DeploymentUpdateParams.builder() + .deploymentId("deployment_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .agent("string") + .description("description") + .environmentId("environment_id") + .addUserMessageInitialEvent( + listOf( + BetaManagedAgentsUserMessageEventParams.Content.ofText( + BetaManagedAgentsTextBlock.builder() + .text("Where is my order #1234?") + .type(BetaManagedAgentsTextBlock.Type.TEXT) + .build() + ) + ) + ) + .metadata( + DeploymentUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .addResource( + BetaManagedAgentsFileResourceParams.builder() + .fileId("file_011CNha8iCJcU1wXNR6q4V8w") + .type(BetaManagedAgentsFileResourceParams.Type.FILE) + .mountPath("/uploads/receipt.pdf") + .build() + ) + .schedule( + BetaManagedAgentsScheduleParams.builder() + .expression("x") + .timezone("x") + .type(BetaManagedAgentsScheduleParams.Type.CRON) + .build() + ) + .addVaultId("string") + .build() + + val body = params._body() + + assertThat(body.agent()).contains(DeploymentUpdateParams.Agent.ofString("string")) + assertThat(body.description()).contains("description") + assertThat(body.environmentId()).contains("environment_id") + assertThat(body.initialEvents().getOrNull()) + .containsExactly( + BetaManagedAgentsDeploymentInitialEventParams.ofUserMessage( + BetaManagedAgentsUserMessageEventParams.builder() + .addTextContent("Where is my order #1234?") + .type(BetaManagedAgentsUserMessageEventParams.Type.USER_MESSAGE) + .build() + ) + ) + assertThat(body.metadata()) + .contains( + DeploymentUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(body.name()).contains("name") + assertThat(body.resources().getOrNull()) + .containsExactly( + DeploymentUpdateParams.Resource.ofFile( + BetaManagedAgentsFileResourceParams.builder() + .fileId("file_011CNha8iCJcU1wXNR6q4V8w") + .type(BetaManagedAgentsFileResourceParams.Type.FILE) + .mountPath("/uploads/receipt.pdf") + .build() + ) + ) + assertThat(body.schedule()) + .contains( + BetaManagedAgentsScheduleParams.builder() + .expression("x") + .timezone("x") + .type(BetaManagedAgentsScheduleParams.Type.CRON) + .build() + ) + assertThat(body.vaultIds().getOrNull()).containsExactly("string") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = DeploymentUpdateParams.builder().deploymentId("deployment_id").build() + + val body = params._body() + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSessionTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSessionTest.kt index f5f95d395..7d02e7577 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSessionTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSessionTest.kt @@ -250,6 +250,7 @@ internal class BetaManagedAgentsSessionTest { .build() ) .addVaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") + .deploymentId("deployment_id") .build() assertThat(betaManagedAgentsSession.id()).isEqualTo("sesn_011CZkZAtmR3yMPDzynEDxu7") @@ -471,6 +472,7 @@ internal class BetaManagedAgentsSessionTest { ) assertThat(betaManagedAgentsSession.vaultIds()) .containsExactly("vlt_011CZkZDLs7fYzm1hXNPeRjv") + assertThat(betaManagedAgentsSession.deploymentId()).contains("deployment_id") } @Test @@ -700,6 +702,7 @@ internal class BetaManagedAgentsSessionTest { .build() ) .addVaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") + .deploymentId("deployment_id") .build() val roundtrippedBetaManagedAgentsSession = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSystemContentBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSystemContentBlockTest.kt new file mode 100644 index 000000000..861609fe2 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSystemContentBlockTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.sessions + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsSystemContentBlockTest { + + @Test + fun create() { + val betaManagedAgentsSystemContentBlock = + BetaManagedAgentsSystemContentBlock.builder() + .text("Where is my order #1234?") + .type(BetaManagedAgentsSystemContentBlock.Type.TEXT) + .build() + + assertThat(betaManagedAgentsSystemContentBlock.text()).isEqualTo("Where is my order #1234?") + assertThat(betaManagedAgentsSystemContentBlock.type()) + .isEqualTo(BetaManagedAgentsSystemContentBlock.Type.TEXT) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsSystemContentBlock = + BetaManagedAgentsSystemContentBlock.builder() + .text("Where is my order #1234?") + .type(BetaManagedAgentsSystemContentBlock.Type.TEXT) + .build() + + val roundtrippedBetaManagedAgentsSystemContentBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsSystemContentBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsSystemContentBlock) + .isEqualTo(betaManagedAgentsSystemContentBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSystemMessageEventTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSystemMessageEventTest.kt new file mode 100644 index 000000000..49e8878a8 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSystemMessageEventTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.sessions + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsSystemMessageEventTest { + + @Test + fun create() { + val betaManagedAgentsSystemMessageEvent = + BetaManagedAgentsSystemMessageEvent.builder() + .id("id") + .addTextContent("Where is my order #1234?") + .type(BetaManagedAgentsSystemMessageEvent.Type.SYSTEM_MESSAGE) + .processedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(betaManagedAgentsSystemMessageEvent.id()).isEqualTo("id") + assertThat(betaManagedAgentsSystemMessageEvent.content()) + .containsExactly( + BetaManagedAgentsSystemContentBlock.builder() + .text("Where is my order #1234?") + .type(BetaManagedAgentsSystemContentBlock.Type.TEXT) + .build() + ) + assertThat(betaManagedAgentsSystemMessageEvent.type()) + .isEqualTo(BetaManagedAgentsSystemMessageEvent.Type.SYSTEM_MESSAGE) + assertThat(betaManagedAgentsSystemMessageEvent.processedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsSystemMessageEvent = + BetaManagedAgentsSystemMessageEvent.builder() + .id("id") + .addTextContent("Where is my order #1234?") + .type(BetaManagedAgentsSystemMessageEvent.Type.SYSTEM_MESSAGE) + .processedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedBetaManagedAgentsSystemMessageEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsSystemMessageEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsSystemMessageEvent) + .isEqualTo(betaManagedAgentsSystemMessageEvent) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionListPageResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionListPageResponseTest.kt index c38f19a6c..67d900705 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionListPageResponseTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionListPageResponseTest.kt @@ -273,6 +273,7 @@ internal class SessionListPageResponseTest { .build() ) .addVaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") + .deploymentId("deployment_id") .build() ) .nextPage("page_MjAyNS0wNS0xNFQwMDowMDowMFo=") @@ -512,6 +513,7 @@ internal class SessionListPageResponseTest { .build() ) .addVaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") + .deploymentId("deployment_id") .build() ) assertThat(sessionListPageResponse.nextPage()).contains("page_MjAyNS0wNS0xNFQwMDowMDowMFo=") @@ -769,6 +771,7 @@ internal class SessionListPageResponseTest { .build() ) .addVaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") + .deploymentId("deployment_id") .build() ) .build() @@ -1007,6 +1010,7 @@ internal class SessionListPageResponseTest { .build() ) .addVaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") + .deploymentId("deployment_id") .build() ) } @@ -1261,6 +1265,7 @@ internal class SessionListPageResponseTest { .build() ) .addVaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") + .deploymentId("deployment_id") .build() ) .nextPage("page_MjAyNS0wNS0xNFQwMDowMDowMFo=") diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionListParamsTest.kt index 798c178b8..3f22d7dc4 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionListParamsTest.kt @@ -20,6 +20,7 @@ internal class SessionListParamsTest { .createdAtGte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .createdAtLt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .createdAtLte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deploymentId("deployment_id") .includeArchived(true) .limit(0) .memoryStoreId("memory_store_id") @@ -40,6 +41,7 @@ internal class SessionListParamsTest { .createdAtGte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .createdAtLt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .createdAtLte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deploymentId("deployment_id") .includeArchived(true) .limit(0) .memoryStoreId("memory_store_id") @@ -76,6 +78,7 @@ internal class SessionListParamsTest { .createdAtGte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .createdAtLt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .createdAtLte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deploymentId("deployment_id") .includeArchived(true) .limit(0) .memoryStoreId("memory_store_id") @@ -96,6 +99,7 @@ internal class SessionListParamsTest { .put("created_at[gte]", "2019-12-27T18:11:19.117Z") .put("created_at[lt]", "2019-12-27T18:11:19.117Z") .put("created_at[lte]", "2019-12-27T18:11:19.117Z") + .put("deployment_id", "deployment_id") .put("include_archived", "true") .put("limit", "0") .put("memory_store_id", "memory_store_id") diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsCredentialHostUnreachableErrorTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsCredentialHostUnreachableErrorTest.kt new file mode 100644 index 000000000..c5007e0b5 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsCredentialHostUnreachableErrorTest.kt @@ -0,0 +1,77 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.sessions.events + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsCredentialHostUnreachableErrorTest { + + @Test + fun create() { + val betaManagedAgentsCredentialHostUnreachableError = + BetaManagedAgentsCredentialHostUnreachableError.builder() + .credentialId("credential_id") + .message("message") + .retryStatus( + BetaManagedAgentsRetryStatusRetrying.builder() + .type(BetaManagedAgentsRetryStatusRetrying.Type.RETRYING) + .build() + ) + .type( + BetaManagedAgentsCredentialHostUnreachableError.Type + .CREDENTIAL_HOST_UNREACHABLE_ERROR + ) + .vaultId("vault_id") + .build() + + assertThat(betaManagedAgentsCredentialHostUnreachableError.credentialId()) + .isEqualTo("credential_id") + assertThat(betaManagedAgentsCredentialHostUnreachableError.message()).isEqualTo("message") + assertThat(betaManagedAgentsCredentialHostUnreachableError.retryStatus()) + .isEqualTo( + BetaManagedAgentsCredentialHostUnreachableError.RetryStatus.ofRetrying( + BetaManagedAgentsRetryStatusRetrying.builder() + .type(BetaManagedAgentsRetryStatusRetrying.Type.RETRYING) + .build() + ) + ) + assertThat(betaManagedAgentsCredentialHostUnreachableError.type()) + .isEqualTo( + BetaManagedAgentsCredentialHostUnreachableError.Type + .CREDENTIAL_HOST_UNREACHABLE_ERROR + ) + assertThat(betaManagedAgentsCredentialHostUnreachableError.vaultId()).isEqualTo("vault_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsCredentialHostUnreachableError = + BetaManagedAgentsCredentialHostUnreachableError.builder() + .credentialId("credential_id") + .message("message") + .retryStatus( + BetaManagedAgentsRetryStatusRetrying.builder() + .type(BetaManagedAgentsRetryStatusRetrying.Type.RETRYING) + .build() + ) + .type( + BetaManagedAgentsCredentialHostUnreachableError.Type + .CREDENTIAL_HOST_UNREACHABLE_ERROR + ) + .vaultId("vault_id") + .build() + + val roundtrippedBetaManagedAgentsCredentialHostUnreachableError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsCredentialHostUnreachableError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsCredentialHostUnreachableError) + .isEqualTo(betaManagedAgentsCredentialHostUnreachableError) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsEventParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsEventParamsTest.kt index 8eb3fe02d..559176e7a 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsEventParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsEventParamsTest.kt @@ -30,6 +30,7 @@ internal class BetaManagedAgentsEventParamsTest { assertThat(betaManagedAgentsEventParams.userCustomToolResult()).isEmpty assertThat(betaManagedAgentsEventParams.userDefineOutcome()).isEmpty assertThat(betaManagedAgentsEventParams.userToolResult()).isEmpty + assertThat(betaManagedAgentsEventParams.systemMessage()).isEmpty } @Test @@ -69,6 +70,7 @@ internal class BetaManagedAgentsEventParamsTest { assertThat(betaManagedAgentsEventParams.userCustomToolResult()).isEmpty assertThat(betaManagedAgentsEventParams.userDefineOutcome()).isEmpty assertThat(betaManagedAgentsEventParams.userToolResult()).isEmpty + assertThat(betaManagedAgentsEventParams.systemMessage()).isEmpty } @Test @@ -111,6 +113,7 @@ internal class BetaManagedAgentsEventParamsTest { assertThat(betaManagedAgentsEventParams.userCustomToolResult()).isEmpty assertThat(betaManagedAgentsEventParams.userDefineOutcome()).isEmpty assertThat(betaManagedAgentsEventParams.userToolResult()).isEmpty + assertThat(betaManagedAgentsEventParams.systemMessage()).isEmpty } @Test @@ -157,6 +160,7 @@ internal class BetaManagedAgentsEventParamsTest { .contains(userCustomToolResult) assertThat(betaManagedAgentsEventParams.userDefineOutcome()).isEmpty assertThat(betaManagedAgentsEventParams.userToolResult()).isEmpty + assertThat(betaManagedAgentsEventParams.systemMessage()).isEmpty } @Test @@ -203,6 +207,7 @@ internal class BetaManagedAgentsEventParamsTest { assertThat(betaManagedAgentsEventParams.userCustomToolResult()).isEmpty assertThat(betaManagedAgentsEventParams.userDefineOutcome()).contains(userDefineOutcome) assertThat(betaManagedAgentsEventParams.userToolResult()).isEmpty + assertThat(betaManagedAgentsEventParams.systemMessage()).isEmpty } @Test @@ -246,6 +251,7 @@ internal class BetaManagedAgentsEventParamsTest { assertThat(betaManagedAgentsEventParams.userCustomToolResult()).isEmpty assertThat(betaManagedAgentsEventParams.userDefineOutcome()).isEmpty assertThat(betaManagedAgentsEventParams.userToolResult()).contains(userToolResult) + assertThat(betaManagedAgentsEventParams.systemMessage()).isEmpty } @Test @@ -270,6 +276,46 @@ internal class BetaManagedAgentsEventParamsTest { assertThat(roundtrippedBetaManagedAgentsEventParams).isEqualTo(betaManagedAgentsEventParams) } + @Test + fun ofSystemMessage() { + val systemMessage = + BetaManagedAgentsSystemMessageEventParams.builder() + .addTextContent("Where is my order #1234?") + .type(BetaManagedAgentsSystemMessageEventParams.Type.SYSTEM_MESSAGE) + .build() + + val betaManagedAgentsEventParams = + BetaManagedAgentsEventParams.ofSystemMessage(systemMessage) + + assertThat(betaManagedAgentsEventParams.userMessage()).isEmpty + assertThat(betaManagedAgentsEventParams.userInterrupt()).isEmpty + assertThat(betaManagedAgentsEventParams.userToolConfirmation()).isEmpty + assertThat(betaManagedAgentsEventParams.userCustomToolResult()).isEmpty + assertThat(betaManagedAgentsEventParams.userDefineOutcome()).isEmpty + assertThat(betaManagedAgentsEventParams.userToolResult()).isEmpty + assertThat(betaManagedAgentsEventParams.systemMessage()).contains(systemMessage) + } + + @Test + fun ofSystemMessageRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsEventParams = + BetaManagedAgentsEventParams.ofSystemMessage( + BetaManagedAgentsSystemMessageEventParams.builder() + .addTextContent("Where is my order #1234?") + .type(BetaManagedAgentsSystemMessageEventParams.Type.SYSTEM_MESSAGE) + .build() + ) + + val roundtrippedBetaManagedAgentsEventParams = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsEventParams), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsEventParams).isEqualTo(betaManagedAgentsEventParams) + } + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { BOOLEAN(JsonValue.from(false)), STRING(JsonValue.from("invalid")), diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionEventTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionEventTest.kt index 114db55c3..a30fbda53 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionEventTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionEventTest.kt @@ -19,6 +19,7 @@ import com.anthropic.models.beta.agents.BetaManagedAgentsSessionThreadAgent import com.anthropic.models.beta.sessions.BetaManagedAgentsSessionAgent import com.anthropic.models.beta.sessions.BetaManagedAgentsSessionMultiagentCoordinator import com.anthropic.models.beta.sessions.BetaManagedAgentsSessionUpdatedEvent +import com.anthropic.models.beta.sessions.BetaManagedAgentsSystemMessageEvent import com.anthropic.models.beta.sessions.BetaManagedAgentsUserToolResultEvent import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime @@ -75,6 +76,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -146,6 +148,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -221,6 +224,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -299,6 +303,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -379,6 +384,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -461,6 +467,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -536,6 +543,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -616,6 +624,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -699,6 +708,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -779,6 +789,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -861,6 +872,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -940,6 +952,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -1019,6 +1032,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -1097,6 +1111,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -1180,6 +1195,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -1263,6 +1279,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -1336,6 +1353,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -1410,6 +1428,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -1485,6 +1504,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -1559,6 +1579,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -1636,6 +1657,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -1727,6 +1749,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -1814,6 +1837,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -1895,6 +1919,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -1983,6 +2008,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -2061,6 +2087,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -2134,6 +2161,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -2209,6 +2237,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -2291,6 +2320,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -2378,6 +2408,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -2456,6 +2487,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).contains(userToolResult) assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -2537,6 +2569,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()) .contains(sessionThreadStatusRescheduled) assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -2778,6 +2811,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).contains(sessionUpdated) + assertThat(betaManagedAgentsSessionEvent.systemMessage()).isEmpty } @Test @@ -2976,6 +3010,78 @@ internal class BetaManagedAgentsSessionEventTest { .isEqualTo(betaManagedAgentsSessionEvent) } + @Test + fun ofSystemMessage() { + val systemMessage = + BetaManagedAgentsSystemMessageEvent.builder() + .id("id") + .addTextContent("Where is my order #1234?") + .type(BetaManagedAgentsSystemMessageEvent.Type.SYSTEM_MESSAGE) + .processedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val betaManagedAgentsSessionEvent = + BetaManagedAgentsSessionEvent.ofSystemMessage(systemMessage) + + assertThat(betaManagedAgentsSessionEvent.userMessage()).isEmpty + assertThat(betaManagedAgentsSessionEvent.userInterrupt()).isEmpty + assertThat(betaManagedAgentsSessionEvent.userToolConfirmation()).isEmpty + assertThat(betaManagedAgentsSessionEvent.userCustomToolResult()).isEmpty + assertThat(betaManagedAgentsSessionEvent.agentCustomToolUse()).isEmpty + assertThat(betaManagedAgentsSessionEvent.agentMessage()).isEmpty + assertThat(betaManagedAgentsSessionEvent.agentThinking()).isEmpty + assertThat(betaManagedAgentsSessionEvent.agentMcpToolUse()).isEmpty + assertThat(betaManagedAgentsSessionEvent.agentMcpToolResult()).isEmpty + assertThat(betaManagedAgentsSessionEvent.agentToolUse()).isEmpty + assertThat(betaManagedAgentsSessionEvent.agentToolResult()).isEmpty + assertThat(betaManagedAgentsSessionEvent.agentThreadMessageReceived()).isEmpty + assertThat(betaManagedAgentsSessionEvent.agentThreadMessageSent()).isEmpty + assertThat(betaManagedAgentsSessionEvent.agentThreadContextCompacted()).isEmpty + assertThat(betaManagedAgentsSessionEvent.sessionError()).isEmpty + assertThat(betaManagedAgentsSessionEvent.sessionStatusRescheduled()).isEmpty + assertThat(betaManagedAgentsSessionEvent.sessionStatusRunning()).isEmpty + assertThat(betaManagedAgentsSessionEvent.sessionStatusIdle()).isEmpty + assertThat(betaManagedAgentsSessionEvent.sessionStatusTerminated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.sessionThreadCreated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.spanOutcomeEvaluationStart()).isEmpty + assertThat(betaManagedAgentsSessionEvent.spanOutcomeEvaluationEnd()).isEmpty + assertThat(betaManagedAgentsSessionEvent.spanModelRequestStart()).isEmpty + assertThat(betaManagedAgentsSessionEvent.spanModelRequestEnd()).isEmpty + assertThat(betaManagedAgentsSessionEvent.spanOutcomeEvaluationOngoing()).isEmpty + assertThat(betaManagedAgentsSessionEvent.userDefineOutcome()).isEmpty + assertThat(betaManagedAgentsSessionEvent.sessionDeleted()).isEmpty + assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRunning()).isEmpty + assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusIdle()).isEmpty + assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusTerminated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.userToolResult()).isEmpty + assertThat(betaManagedAgentsSessionEvent.sessionThreadStatusRescheduled()).isEmpty + assertThat(betaManagedAgentsSessionEvent.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsSessionEvent.systemMessage()).contains(systemMessage) + } + + @Test + fun ofSystemMessageRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsSessionEvent = + BetaManagedAgentsSessionEvent.ofSystemMessage( + BetaManagedAgentsSystemMessageEvent.builder() + .id("id") + .addTextContent("Where is my order #1234?") + .type(BetaManagedAgentsSystemMessageEvent.Type.SYSTEM_MESSAGE) + .processedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val roundtrippedBetaManagedAgentsSessionEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsSessionEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsSessionEvent) + .isEqualTo(betaManagedAgentsSessionEvent) + } + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { BOOLEAN(JsonValue.from(false)), STRING(JsonValue.from("invalid")), diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsStreamSessionEventsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsStreamSessionEventsTest.kt index 0fa5bd722..0d52e1ab4 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsStreamSessionEventsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsStreamSessionEventsTest.kt @@ -19,6 +19,7 @@ import com.anthropic.models.beta.agents.BetaManagedAgentsSessionThreadAgent import com.anthropic.models.beta.sessions.BetaManagedAgentsSessionAgent import com.anthropic.models.beta.sessions.BetaManagedAgentsSessionMultiagentCoordinator import com.anthropic.models.beta.sessions.BetaManagedAgentsSessionUpdatedEvent +import com.anthropic.models.beta.sessions.BetaManagedAgentsSystemMessageEvent import com.anthropic.models.beta.sessions.BetaManagedAgentsUserToolResultEvent import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime @@ -76,6 +77,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -147,6 +149,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -222,6 +225,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -300,6 +304,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -381,6 +386,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -463,6 +469,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -538,6 +545,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -618,6 +626,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -702,6 +711,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -782,6 +792,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -864,6 +875,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -945,6 +957,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -1024,6 +1037,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -1104,6 +1118,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -1187,6 +1202,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -1272,6 +1288,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -1345,6 +1362,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -1420,6 +1438,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -1495,6 +1514,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -1569,6 +1589,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -1648,6 +1669,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -1741,6 +1763,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -1828,6 +1851,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -1909,6 +1933,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -1997,6 +2022,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -2076,6 +2102,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -2149,6 +2176,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -2226,6 +2254,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -2308,6 +2337,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -2395,6 +2425,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -2473,6 +2504,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).contains(userToolResult) assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -2554,6 +2586,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()) .contains(sessionThreadStatusRescheduled) assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -2795,6 +2828,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).contains(sessionUpdated) + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).isEmpty } @Test @@ -2993,6 +3027,78 @@ internal class BetaManagedAgentsStreamSessionEventsTest { .isEqualTo(betaManagedAgentsStreamSessionEvents) } + @Test + fun ofSystemMessage() { + val systemMessage = + BetaManagedAgentsSystemMessageEvent.builder() + .id("id") + .addTextContent("Where is my order #1234?") + .type(BetaManagedAgentsSystemMessageEvent.Type.SYSTEM_MESSAGE) + .processedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val betaManagedAgentsStreamSessionEvents = + BetaManagedAgentsStreamSessionEvents.ofSystemMessage(systemMessage) + + assertThat(betaManagedAgentsStreamSessionEvents.userMessage()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.userInterrupt()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.userToolConfirmation()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.userCustomToolResult()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.agentCustomToolUse()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.agentMessage()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.agentThinking()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.agentMcpToolUse()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.agentMcpToolResult()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.agentToolUse()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.agentToolResult()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.agentThreadMessageReceived()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.agentThreadMessageSent()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.agentThreadContextCompacted()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.sessionError()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.sessionStatusRescheduled()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.sessionStatusRunning()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.sessionStatusIdle()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.sessionStatusTerminated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadCreated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.spanOutcomeEvaluationStart()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.spanOutcomeEvaluationEnd()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.spanModelRequestStart()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.spanModelRequestEnd()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.spanOutcomeEvaluationOngoing()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.userDefineOutcome()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.sessionDeleted()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRunning()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusIdle()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusTerminated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.userToolResult()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadStatusRescheduled()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionEvents.systemMessage()).contains(systemMessage) + } + + @Test + fun ofSystemMessageRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsStreamSessionEvents = + BetaManagedAgentsStreamSessionEvents.ofSystemMessage( + BetaManagedAgentsSystemMessageEvent.builder() + .id("id") + .addTextContent("Where is my order #1234?") + .type(BetaManagedAgentsSystemMessageEvent.Type.SYSTEM_MESSAGE) + .processedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val roundtrippedBetaManagedAgentsStreamSessionEvents = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsStreamSessionEvents), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsStreamSessionEvents) + .isEqualTo(betaManagedAgentsStreamSessionEvents) + } + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { BOOLEAN(JsonValue.from(false)), STRING(JsonValue.from("invalid")), diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSystemMessageEventParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSystemMessageEventParamsTest.kt new file mode 100644 index 000000000..e9f99193e --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSystemMessageEventParamsTest.kt @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.sessions.events + +import com.anthropic.core.jsonMapper +import com.anthropic.models.beta.sessions.BetaManagedAgentsSystemContentBlock +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsSystemMessageEventParamsTest { + + @Test + fun create() { + val betaManagedAgentsSystemMessageEventParams = + BetaManagedAgentsSystemMessageEventParams.builder() + .addTextContent("Where is my order #1234?") + .type(BetaManagedAgentsSystemMessageEventParams.Type.SYSTEM_MESSAGE) + .build() + + assertThat(betaManagedAgentsSystemMessageEventParams.content()) + .containsExactly( + BetaManagedAgentsSystemContentBlock.builder() + .text("Where is my order #1234?") + .type(BetaManagedAgentsSystemContentBlock.Type.TEXT) + .build() + ) + assertThat(betaManagedAgentsSystemMessageEventParams.type()) + .isEqualTo(BetaManagedAgentsSystemMessageEventParams.Type.SYSTEM_MESSAGE) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsSystemMessageEventParams = + BetaManagedAgentsSystemMessageEventParams.builder() + .addTextContent("Where is my order #1234?") + .type(BetaManagedAgentsSystemMessageEventParams.Type.SYSTEM_MESSAGE) + .build() + + val roundtrippedBetaManagedAgentsSystemMessageEventParams = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsSystemMessageEventParams), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsSystemMessageEventParams) + .isEqualTo(betaManagedAgentsSystemMessageEventParams) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/BetaManagedAgentsStreamSessionThreadEventsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/BetaManagedAgentsStreamSessionThreadEventsTest.kt index be8f8e2b1..2d97c561a 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/BetaManagedAgentsStreamSessionThreadEventsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/BetaManagedAgentsStreamSessionThreadEventsTest.kt @@ -19,6 +19,7 @@ import com.anthropic.models.beta.agents.BetaManagedAgentsSessionThreadAgent import com.anthropic.models.beta.sessions.BetaManagedAgentsSessionAgent import com.anthropic.models.beta.sessions.BetaManagedAgentsSessionMultiagentCoordinator import com.anthropic.models.beta.sessions.BetaManagedAgentsSessionUpdatedEvent +import com.anthropic.models.beta.sessions.BetaManagedAgentsSystemMessageEvent import com.anthropic.models.beta.sessions.BetaManagedAgentsUserToolResultEvent import com.anthropic.models.beta.sessions.events.BetaManagedAgentsAgentCustomToolUseEvent import com.anthropic.models.beta.sessions.events.BetaManagedAgentsAgentMcpToolResultEvent @@ -115,6 +116,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -190,6 +192,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -268,6 +271,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -349,6 +353,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -433,6 +438,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -518,6 +524,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -597,6 +604,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -681,6 +689,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -768,6 +777,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -851,6 +861,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -937,6 +948,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -1021,6 +1033,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -1105,6 +1118,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -1188,6 +1202,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -1274,6 +1289,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -1362,6 +1378,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -1438,6 +1455,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -1516,6 +1534,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -1596,6 +1615,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -1673,6 +1693,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -1755,6 +1776,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -1851,6 +1873,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -1943,6 +1966,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -2027,6 +2051,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -2117,6 +2142,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -2199,6 +2225,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -2276,6 +2303,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -2356,6 +2384,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -2443,6 +2472,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -2532,6 +2562,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -2614,6 +2645,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -2697,6 +2729,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) .contains(sessionThreadStatusRescheduled) assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -2942,6 +2975,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { .isEmpty assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()) .contains(sessionUpdated) + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()).isEmpty } @Test @@ -3140,6 +3174,82 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { .isEqualTo(betaManagedAgentsStreamSessionThreadEvents) } + @Test + fun ofSystemMessage() { + val systemMessage = + BetaManagedAgentsSystemMessageEvent.builder() + .id("id") + .addTextContent("Where is my order #1234?") + .type(BetaManagedAgentsSystemMessageEvent.Type.SYSTEM_MESSAGE) + .processedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val betaManagedAgentsStreamSessionThreadEvents = + BetaManagedAgentsStreamSessionThreadEvents.ofSystemMessage(systemMessage) + + assertThat(betaManagedAgentsStreamSessionThreadEvents.userMessage()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.userInterrupt()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.userToolConfirmation()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.userCustomToolResult()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.agentCustomToolUse()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.agentMessage()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.agentThinking()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.agentMcpToolUse()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.agentMcpToolResult()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.agentToolUse()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.agentToolResult()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.agentThreadMessageReceived()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.agentThreadMessageSent()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.agentThreadContextCompacted()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionError()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionStatusRescheduled()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionStatusRunning()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionStatusIdle()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionStatusTerminated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadCreated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.spanOutcomeEvaluationStart()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.spanOutcomeEvaluationEnd()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.spanModelRequestStart()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.spanModelRequestEnd()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.spanOutcomeEvaluationOngoing()) + .isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.userDefineOutcome()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionDeleted()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRunning()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusIdle()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusTerminated()) + .isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.userToolResult()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadStatusRescheduled()) + .isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionUpdated()).isEmpty + assertThat(betaManagedAgentsStreamSessionThreadEvents.systemMessage()) + .contains(systemMessage) + } + + @Test + fun ofSystemMessageRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsStreamSessionThreadEvents = + BetaManagedAgentsStreamSessionThreadEvents.ofSystemMessage( + BetaManagedAgentsSystemMessageEvent.builder() + .id("id") + .addTextContent("Where is my order #1234?") + .type(BetaManagedAgentsSystemMessageEvent.Type.SYSTEM_MESSAGE) + .processedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val roundtrippedBetaManagedAgentsStreamSessionThreadEvents = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsStreamSessionThreadEvents), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsStreamSessionThreadEvents) + .isEqualTo(betaManagedAgentsStreamSessionThreadEvents) + } + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { BOOLEAN(JsonValue.from(false)), STRING(JsonValue.from("invalid")), diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsCredentialNetworkingParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsCredentialNetworkingParamsTest.kt new file mode 100644 index 000000000..22c4ca339 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsCredentialNetworkingParamsTest.kt @@ -0,0 +1,112 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.vaults.credentials + +import com.anthropic.core.JsonValue +import com.anthropic.core.jsonMapper +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class BetaManagedAgentsCredentialNetworkingParamsTest { + + @Test + fun ofUnrestricted() { + val unrestricted = + BetaManagedAgentsUnrestrictedCredentialNetworkingParams.builder() + .type(BetaManagedAgentsUnrestrictedCredentialNetworkingParams.Type.UNRESTRICTED) + .build() + + val betaManagedAgentsCredentialNetworkingParams = + BetaManagedAgentsCredentialNetworkingParams.ofUnrestricted(unrestricted) + + assertThat(betaManagedAgentsCredentialNetworkingParams.unrestricted()) + .contains(unrestricted) + assertThat(betaManagedAgentsCredentialNetworkingParams.limited()).isEmpty + } + + @Test + fun ofUnrestrictedRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsCredentialNetworkingParams = + BetaManagedAgentsCredentialNetworkingParams.ofUnrestricted( + BetaManagedAgentsUnrestrictedCredentialNetworkingParams.builder() + .type(BetaManagedAgentsUnrestrictedCredentialNetworkingParams.Type.UNRESTRICTED) + .build() + ) + + val roundtrippedBetaManagedAgentsCredentialNetworkingParams = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsCredentialNetworkingParams), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsCredentialNetworkingParams) + .isEqualTo(betaManagedAgentsCredentialNetworkingParams) + } + + @Test + fun ofLimited() { + val limited = + BetaManagedAgentsLimitedCredentialNetworkingParams.builder() + .addAllowedHost("string") + .type(BetaManagedAgentsLimitedCredentialNetworkingParams.Type.LIMITED) + .build() + + val betaManagedAgentsCredentialNetworkingParams = + BetaManagedAgentsCredentialNetworkingParams.ofLimited(limited) + + assertThat(betaManagedAgentsCredentialNetworkingParams.unrestricted()).isEmpty + assertThat(betaManagedAgentsCredentialNetworkingParams.limited()).contains(limited) + } + + @Test + fun ofLimitedRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsCredentialNetworkingParams = + BetaManagedAgentsCredentialNetworkingParams.ofLimited( + BetaManagedAgentsLimitedCredentialNetworkingParams.builder() + .addAllowedHost("string") + .type(BetaManagedAgentsLimitedCredentialNetworkingParams.Type.LIMITED) + .build() + ) + + val roundtrippedBetaManagedAgentsCredentialNetworkingParams = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsCredentialNetworkingParams), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsCredentialNetworkingParams) + .isEqualTo(betaManagedAgentsCredentialNetworkingParams) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val betaManagedAgentsCredentialNetworkingParams = + jsonMapper() + .convertValue( + testCase.value, + jacksonTypeRef(), + ) + + val e = + assertThrows { + betaManagedAgentsCredentialNetworkingParams.validate() + } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsEnvironmentVariableAuthResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsEnvironmentVariableAuthResponseTest.kt new file mode 100644 index 000000000..05670462e --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsEnvironmentVariableAuthResponseTest.kt @@ -0,0 +1,71 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.vaults.credentials + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsEnvironmentVariableAuthResponseTest { + + @Test + fun create() { + val betaManagedAgentsEnvironmentVariableAuthResponse = + BetaManagedAgentsEnvironmentVariableAuthResponse.builder() + .networking( + BetaManagedAgentsUnrestrictedCredentialNetworkingResponse.builder() + .type( + BetaManagedAgentsUnrestrictedCredentialNetworkingResponse.Type + .UNRESTRICTED + ) + .build() + ) + .secretName("secret_name") + .type(BetaManagedAgentsEnvironmentVariableAuthResponse.Type.ENVIRONMENT_VARIABLE) + .build() + + assertThat(betaManagedAgentsEnvironmentVariableAuthResponse.networking()) + .isEqualTo( + BetaManagedAgentsEnvironmentVariableAuthResponse.Networking.ofUnrestricted( + BetaManagedAgentsUnrestrictedCredentialNetworkingResponse.builder() + .type( + BetaManagedAgentsUnrestrictedCredentialNetworkingResponse.Type + .UNRESTRICTED + ) + .build() + ) + ) + assertThat(betaManagedAgentsEnvironmentVariableAuthResponse.secretName()) + .isEqualTo("secret_name") + assertThat(betaManagedAgentsEnvironmentVariableAuthResponse.type()) + .isEqualTo(BetaManagedAgentsEnvironmentVariableAuthResponse.Type.ENVIRONMENT_VARIABLE) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsEnvironmentVariableAuthResponse = + BetaManagedAgentsEnvironmentVariableAuthResponse.builder() + .networking( + BetaManagedAgentsUnrestrictedCredentialNetworkingResponse.builder() + .type( + BetaManagedAgentsUnrestrictedCredentialNetworkingResponse.Type + .UNRESTRICTED + ) + .build() + ) + .secretName("secret_name") + .type(BetaManagedAgentsEnvironmentVariableAuthResponse.Type.ENVIRONMENT_VARIABLE) + .build() + + val roundtrippedBetaManagedAgentsEnvironmentVariableAuthResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsEnvironmentVariableAuthResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsEnvironmentVariableAuthResponse) + .isEqualTo(betaManagedAgentsEnvironmentVariableAuthResponse) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsEnvironmentVariableCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsEnvironmentVariableCreateParamsTest.kt new file mode 100644 index 000000000..cfe5b606d --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsEnvironmentVariableCreateParamsTest.kt @@ -0,0 +1,73 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.vaults.credentials + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsEnvironmentVariableCreateParamsTest { + + @Test + fun create() { + val betaManagedAgentsEnvironmentVariableCreateParams = + BetaManagedAgentsEnvironmentVariableCreateParams.builder() + .networking( + BetaManagedAgentsUnrestrictedCredentialNetworkingParams.builder() + .type( + BetaManagedAgentsUnrestrictedCredentialNetworkingParams.Type + .UNRESTRICTED + ) + .build() + ) + .secretName("x") + .secretValue("x") + .type(BetaManagedAgentsEnvironmentVariableCreateParams.Type.ENVIRONMENT_VARIABLE) + .build() + + assertThat(betaManagedAgentsEnvironmentVariableCreateParams.networking()) + .isEqualTo( + BetaManagedAgentsCredentialNetworkingParams.ofUnrestricted( + BetaManagedAgentsUnrestrictedCredentialNetworkingParams.builder() + .type( + BetaManagedAgentsUnrestrictedCredentialNetworkingParams.Type + .UNRESTRICTED + ) + .build() + ) + ) + assertThat(betaManagedAgentsEnvironmentVariableCreateParams.secretName()).isEqualTo("x") + assertThat(betaManagedAgentsEnvironmentVariableCreateParams.secretValue()).isEqualTo("x") + assertThat(betaManagedAgentsEnvironmentVariableCreateParams.type()) + .isEqualTo(BetaManagedAgentsEnvironmentVariableCreateParams.Type.ENVIRONMENT_VARIABLE) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsEnvironmentVariableCreateParams = + BetaManagedAgentsEnvironmentVariableCreateParams.builder() + .networking( + BetaManagedAgentsUnrestrictedCredentialNetworkingParams.builder() + .type( + BetaManagedAgentsUnrestrictedCredentialNetworkingParams.Type + .UNRESTRICTED + ) + .build() + ) + .secretName("x") + .secretValue("x") + .type(BetaManagedAgentsEnvironmentVariableCreateParams.Type.ENVIRONMENT_VARIABLE) + .build() + + val roundtrippedBetaManagedAgentsEnvironmentVariableCreateParams = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsEnvironmentVariableCreateParams), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsEnvironmentVariableCreateParams) + .isEqualTo(betaManagedAgentsEnvironmentVariableCreateParams) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsEnvironmentVariableUpdateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsEnvironmentVariableUpdateParamsTest.kt new file mode 100644 index 000000000..4a98d6d4e --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsEnvironmentVariableUpdateParamsTest.kt @@ -0,0 +1,70 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.vaults.credentials + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsEnvironmentVariableUpdateParamsTest { + + @Test + fun create() { + val betaManagedAgentsEnvironmentVariableUpdateParams = + BetaManagedAgentsEnvironmentVariableUpdateParams.builder() + .type(BetaManagedAgentsEnvironmentVariableUpdateParams.Type.ENVIRONMENT_VARIABLE) + .networking( + BetaManagedAgentsUnrestrictedCredentialNetworkingParams.builder() + .type( + BetaManagedAgentsUnrestrictedCredentialNetworkingParams.Type + .UNRESTRICTED + ) + .build() + ) + .secretValue("x") + .build() + + assertThat(betaManagedAgentsEnvironmentVariableUpdateParams.type()) + .isEqualTo(BetaManagedAgentsEnvironmentVariableUpdateParams.Type.ENVIRONMENT_VARIABLE) + assertThat(betaManagedAgentsEnvironmentVariableUpdateParams.networking()) + .contains( + BetaManagedAgentsCredentialNetworkingParams.ofUnrestricted( + BetaManagedAgentsUnrestrictedCredentialNetworkingParams.builder() + .type( + BetaManagedAgentsUnrestrictedCredentialNetworkingParams.Type + .UNRESTRICTED + ) + .build() + ) + ) + assertThat(betaManagedAgentsEnvironmentVariableUpdateParams.secretValue()).contains("x") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsEnvironmentVariableUpdateParams = + BetaManagedAgentsEnvironmentVariableUpdateParams.builder() + .type(BetaManagedAgentsEnvironmentVariableUpdateParams.Type.ENVIRONMENT_VARIABLE) + .networking( + BetaManagedAgentsUnrestrictedCredentialNetworkingParams.builder() + .type( + BetaManagedAgentsUnrestrictedCredentialNetworkingParams.Type + .UNRESTRICTED + ) + .build() + ) + .secretValue("x") + .build() + + val roundtrippedBetaManagedAgentsEnvironmentVariableUpdateParams = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsEnvironmentVariableUpdateParams), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsEnvironmentVariableUpdateParams) + .isEqualTo(betaManagedAgentsEnvironmentVariableUpdateParams) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsLimitedCredentialNetworkingParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsLimitedCredentialNetworkingParamsTest.kt new file mode 100644 index 000000000..2739a8d06 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsLimitedCredentialNetworkingParamsTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.vaults.credentials + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsLimitedCredentialNetworkingParamsTest { + + @Test + fun create() { + val betaManagedAgentsLimitedCredentialNetworkingParams = + BetaManagedAgentsLimitedCredentialNetworkingParams.builder() + .addAllowedHost("string") + .type(BetaManagedAgentsLimitedCredentialNetworkingParams.Type.LIMITED) + .build() + + assertThat(betaManagedAgentsLimitedCredentialNetworkingParams.allowedHosts()) + .containsExactly("string") + assertThat(betaManagedAgentsLimitedCredentialNetworkingParams.type()) + .isEqualTo(BetaManagedAgentsLimitedCredentialNetworkingParams.Type.LIMITED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsLimitedCredentialNetworkingParams = + BetaManagedAgentsLimitedCredentialNetworkingParams.builder() + .addAllowedHost("string") + .type(BetaManagedAgentsLimitedCredentialNetworkingParams.Type.LIMITED) + .build() + + val roundtrippedBetaManagedAgentsLimitedCredentialNetworkingParams = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsLimitedCredentialNetworkingParams), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsLimitedCredentialNetworkingParams) + .isEqualTo(betaManagedAgentsLimitedCredentialNetworkingParams) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsLimitedCredentialNetworkingResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsLimitedCredentialNetworkingResponseTest.kt new file mode 100644 index 000000000..718b3f15a --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsLimitedCredentialNetworkingResponseTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.vaults.credentials + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsLimitedCredentialNetworkingResponseTest { + + @Test + fun create() { + val betaManagedAgentsLimitedCredentialNetworkingResponse = + BetaManagedAgentsLimitedCredentialNetworkingResponse.builder() + .addAllowedHost("string") + .type(BetaManagedAgentsLimitedCredentialNetworkingResponse.Type.LIMITED) + .build() + + assertThat(betaManagedAgentsLimitedCredentialNetworkingResponse.allowedHosts()) + .containsExactly("string") + assertThat(betaManagedAgentsLimitedCredentialNetworkingResponse.type()) + .isEqualTo(BetaManagedAgentsLimitedCredentialNetworkingResponse.Type.LIMITED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsLimitedCredentialNetworkingResponse = + BetaManagedAgentsLimitedCredentialNetworkingResponse.builder() + .addAllowedHost("string") + .type(BetaManagedAgentsLimitedCredentialNetworkingResponse.Type.LIMITED) + .build() + + val roundtrippedBetaManagedAgentsLimitedCredentialNetworkingResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsLimitedCredentialNetworkingResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsLimitedCredentialNetworkingResponse) + .isEqualTo(betaManagedAgentsLimitedCredentialNetworkingResponse) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsUnrestrictedCredentialNetworkingParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsUnrestrictedCredentialNetworkingParamsTest.kt new file mode 100644 index 000000000..976317bfb --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsUnrestrictedCredentialNetworkingParamsTest.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.vaults.credentials + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsUnrestrictedCredentialNetworkingParamsTest { + + @Test + fun create() { + val betaManagedAgentsUnrestrictedCredentialNetworkingParams = + BetaManagedAgentsUnrestrictedCredentialNetworkingParams.builder() + .type(BetaManagedAgentsUnrestrictedCredentialNetworkingParams.Type.UNRESTRICTED) + .build() + + assertThat(betaManagedAgentsUnrestrictedCredentialNetworkingParams.type()) + .isEqualTo(BetaManagedAgentsUnrestrictedCredentialNetworkingParams.Type.UNRESTRICTED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsUnrestrictedCredentialNetworkingParams = + BetaManagedAgentsUnrestrictedCredentialNetworkingParams.builder() + .type(BetaManagedAgentsUnrestrictedCredentialNetworkingParams.Type.UNRESTRICTED) + .build() + + val roundtrippedBetaManagedAgentsUnrestrictedCredentialNetworkingParams = + jsonMapper.readValue( + jsonMapper.writeValueAsString( + betaManagedAgentsUnrestrictedCredentialNetworkingParams + ), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsUnrestrictedCredentialNetworkingParams) + .isEqualTo(betaManagedAgentsUnrestrictedCredentialNetworkingParams) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsUnrestrictedCredentialNetworkingResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsUnrestrictedCredentialNetworkingResponseTest.kt new file mode 100644 index 000000000..3f2eaaab0 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsUnrestrictedCredentialNetworkingResponseTest.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.models.beta.vaults.credentials + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsUnrestrictedCredentialNetworkingResponseTest { + + @Test + fun create() { + val betaManagedAgentsUnrestrictedCredentialNetworkingResponse = + BetaManagedAgentsUnrestrictedCredentialNetworkingResponse.builder() + .type(BetaManagedAgentsUnrestrictedCredentialNetworkingResponse.Type.UNRESTRICTED) + .build() + + assertThat(betaManagedAgentsUnrestrictedCredentialNetworkingResponse.type()) + .isEqualTo(BetaManagedAgentsUnrestrictedCredentialNetworkingResponse.Type.UNRESTRICTED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsUnrestrictedCredentialNetworkingResponse = + BetaManagedAgentsUnrestrictedCredentialNetworkingResponse.builder() + .type(BetaManagedAgentsUnrestrictedCredentialNetworkingResponse.Type.UNRESTRICTED) + .build() + + val roundtrippedBetaManagedAgentsUnrestrictedCredentialNetworkingResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString( + betaManagedAgentsUnrestrictedCredentialNetworkingResponse + ), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsUnrestrictedCredentialNetworkingResponse) + .isEqualTo(betaManagedAgentsUnrestrictedCredentialNetworkingResponse) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/webhooks/BetaWebhookEventDataTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/webhooks/BetaWebhookEventDataTest.kt index 5adfec5fd..934c10ab2 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/webhooks/BetaWebhookEventDataTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/webhooks/BetaWebhookEventDataTest.kt @@ -641,6 +641,7 @@ internal class BetaWebhookEventDataTest { BetaWebhookSessionThreadCreatedEventData.builder() .id("id") .organizationId("organization_id") + .sessionThreadId("session_thread_id") .workspaceId("workspace_id") .build() @@ -678,6 +679,7 @@ internal class BetaWebhookEventDataTest { BetaWebhookSessionThreadCreatedEventData.builder() .id("id") .organizationId("organization_id") + .sessionThreadId("session_thread_id") .workspaceId("workspace_id") .build() ) @@ -697,6 +699,7 @@ internal class BetaWebhookEventDataTest { BetaWebhookSessionThreadIdledEventData.builder() .id("id") .organizationId("organization_id") + .sessionThreadId("session_thread_id") .workspaceId("workspace_id") .build() @@ -734,6 +737,7 @@ internal class BetaWebhookEventDataTest { BetaWebhookSessionThreadIdledEventData.builder() .id("id") .organizationId("organization_id") + .sessionThreadId("session_thread_id") .workspaceId("workspace_id") .build() ) @@ -753,6 +757,7 @@ internal class BetaWebhookEventDataTest { BetaWebhookSessionThreadTerminatedEventData.builder() .id("id") .organizationId("organization_id") + .sessionThreadId("session_thread_id") .workspaceId("workspace_id") .build() @@ -791,6 +796,7 @@ internal class BetaWebhookEventDataTest { BetaWebhookSessionThreadTerminatedEventData.builder() .id("id") .organizationId("organization_id") + .sessionThreadId("session_thread_id") .workspaceId("workspace_id") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/webhooks/BetaWebhookSessionThreadCreatedEventDataTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/webhooks/BetaWebhookSessionThreadCreatedEventDataTest.kt index 16f3bfb2a..cf6f74ef2 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/webhooks/BetaWebhookSessionThreadCreatedEventDataTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/webhooks/BetaWebhookSessionThreadCreatedEventDataTest.kt @@ -15,12 +15,15 @@ internal class BetaWebhookSessionThreadCreatedEventDataTest { BetaWebhookSessionThreadCreatedEventData.builder() .id("id") .organizationId("organization_id") + .sessionThreadId("session_thread_id") .workspaceId("workspace_id") .build() assertThat(betaWebhookSessionThreadCreatedEventData.id()).isEqualTo("id") assertThat(betaWebhookSessionThreadCreatedEventData.organizationId()) .isEqualTo("organization_id") + assertThat(betaWebhookSessionThreadCreatedEventData.sessionThreadId()) + .isEqualTo("session_thread_id") assertThat(betaWebhookSessionThreadCreatedEventData.workspaceId()).isEqualTo("workspace_id") } @@ -31,6 +34,7 @@ internal class BetaWebhookSessionThreadCreatedEventDataTest { BetaWebhookSessionThreadCreatedEventData.builder() .id("id") .organizationId("organization_id") + .sessionThreadId("session_thread_id") .workspaceId("workspace_id") .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/webhooks/BetaWebhookSessionThreadIdledEventDataTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/webhooks/BetaWebhookSessionThreadIdledEventDataTest.kt index 8b0932522..4a82d76b2 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/webhooks/BetaWebhookSessionThreadIdledEventDataTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/webhooks/BetaWebhookSessionThreadIdledEventDataTest.kt @@ -15,12 +15,15 @@ internal class BetaWebhookSessionThreadIdledEventDataTest { BetaWebhookSessionThreadIdledEventData.builder() .id("id") .organizationId("organization_id") + .sessionThreadId("session_thread_id") .workspaceId("workspace_id") .build() assertThat(betaWebhookSessionThreadIdledEventData.id()).isEqualTo("id") assertThat(betaWebhookSessionThreadIdledEventData.organizationId()) .isEqualTo("organization_id") + assertThat(betaWebhookSessionThreadIdledEventData.sessionThreadId()) + .isEqualTo("session_thread_id") assertThat(betaWebhookSessionThreadIdledEventData.workspaceId()).isEqualTo("workspace_id") } @@ -31,6 +34,7 @@ internal class BetaWebhookSessionThreadIdledEventDataTest { BetaWebhookSessionThreadIdledEventData.builder() .id("id") .organizationId("organization_id") + .sessionThreadId("session_thread_id") .workspaceId("workspace_id") .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/webhooks/BetaWebhookSessionThreadTerminatedEventDataTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/webhooks/BetaWebhookSessionThreadTerminatedEventDataTest.kt index 6cb89f2fc..71829ab86 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/webhooks/BetaWebhookSessionThreadTerminatedEventDataTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/webhooks/BetaWebhookSessionThreadTerminatedEventDataTest.kt @@ -15,12 +15,15 @@ internal class BetaWebhookSessionThreadTerminatedEventDataTest { BetaWebhookSessionThreadTerminatedEventData.builder() .id("id") .organizationId("organization_id") + .sessionThreadId("session_thread_id") .workspaceId("workspace_id") .build() assertThat(betaWebhookSessionThreadTerminatedEventData.id()).isEqualTo("id") assertThat(betaWebhookSessionThreadTerminatedEventData.organizationId()) .isEqualTo("organization_id") + assertThat(betaWebhookSessionThreadTerminatedEventData.sessionThreadId()) + .isEqualTo("session_thread_id") assertThat(betaWebhookSessionThreadTerminatedEventData.workspaceId()) .isEqualTo("workspace_id") } @@ -32,6 +35,7 @@ internal class BetaWebhookSessionThreadTerminatedEventDataTest { BetaWebhookSessionThreadTerminatedEventData.builder() .id("id") .organizationId("organization_id") + .sessionThreadId("session_thread_id") .workspaceId("workspace_id") .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/DeploymentRunServiceAsyncTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/DeploymentRunServiceAsyncTest.kt new file mode 100644 index 000000000..525d3fa60 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/DeploymentRunServiceAsyncTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.services.async.beta + +import com.anthropic.TestServerExtension +import com.anthropic.client.okhttp.AnthropicOkHttpClientAsync +import com.anthropic.models.beta.AnthropicBeta +import com.anthropic.models.beta.deploymentruns.DeploymentRunRetrieveParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class DeploymentRunServiceAsyncTest { + + @Disabled("buildURL drops path-level query params (SDK-4349)") + @Test + fun retrieve() { + val client = + AnthropicOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("my-anthropic-api-key") + .build() + val deploymentRunServiceAsync = client.beta().deploymentRuns() + + val betaManagedAgentsDeploymentRunFuture = + deploymentRunServiceAsync.retrieve( + DeploymentRunRetrieveParams.builder() + .deploymentRunId("deployment_run_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + ) + + val betaManagedAgentsDeploymentRun = betaManagedAgentsDeploymentRunFuture.get() + betaManagedAgentsDeploymentRun.validate() + } + + @Disabled("buildURL drops path-level query params (SDK-4349)") + @Test + fun list() { + val client = + AnthropicOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("my-anthropic-api-key") + .build() + val deploymentRunServiceAsync = client.beta().deploymentRuns() + + val pageFuture = deploymentRunServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/DeploymentServiceAsyncTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/DeploymentServiceAsyncTest.kt new file mode 100644 index 000000000..451dae09c --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/DeploymentServiceAsyncTest.kt @@ -0,0 +1,257 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.services.async.beta + +import com.anthropic.TestServerExtension +import com.anthropic.client.okhttp.AnthropicOkHttpClientAsync +import com.anthropic.core.JsonValue +import com.anthropic.models.beta.AnthropicBeta +import com.anthropic.models.beta.deployments.BetaManagedAgentsScheduleParams +import com.anthropic.models.beta.deployments.DeploymentArchiveParams +import com.anthropic.models.beta.deployments.DeploymentCreateParams +import com.anthropic.models.beta.deployments.DeploymentPauseParams +import com.anthropic.models.beta.deployments.DeploymentRetrieveParams +import com.anthropic.models.beta.deployments.DeploymentRunParams +import com.anthropic.models.beta.deployments.DeploymentUnpauseParams +import com.anthropic.models.beta.deployments.DeploymentUpdateParams +import com.anthropic.models.beta.sessions.BetaManagedAgentsFileResourceParams +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsTextBlock +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsUserMessageEventParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class DeploymentServiceAsyncTest { + + @Test + fun create() { + val client = + AnthropicOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("my-anthropic-api-key") + .build() + val deploymentServiceAsync = client.beta().deployments() + + val betaManagedAgentsDeploymentFuture = + deploymentServiceAsync.create( + DeploymentCreateParams.builder() + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .agent("string") + .environmentId("x") + .addUserMessageInitialEvent( + listOf( + BetaManagedAgentsUserMessageEventParams.Content.ofText( + BetaManagedAgentsTextBlock.builder() + .text("Where is my order #1234?") + .type(BetaManagedAgentsTextBlock.Type.TEXT) + .build() + ) + ) + ) + .name("x") + .description("description") + .metadata( + DeploymentCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addResource( + BetaManagedAgentsFileResourceParams.builder() + .fileId("file_011CNha8iCJcU1wXNR6q4V8w") + .type(BetaManagedAgentsFileResourceParams.Type.FILE) + .mountPath("/uploads/receipt.pdf") + .build() + ) + .schedule( + BetaManagedAgentsScheduleParams.builder() + .expression("x") + .timezone("x") + .type(BetaManagedAgentsScheduleParams.Type.CRON) + .build() + ) + .addVaultId("string") + .build() + ) + + val betaManagedAgentsDeployment = betaManagedAgentsDeploymentFuture.get() + betaManagedAgentsDeployment.validate() + } + + @Disabled("buildURL drops path-level query params (SDK-4349)") + @Test + fun retrieve() { + val client = + AnthropicOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("my-anthropic-api-key") + .build() + val deploymentServiceAsync = client.beta().deployments() + + val betaManagedAgentsDeploymentFuture = + deploymentServiceAsync.retrieve( + DeploymentRetrieveParams.builder() + .deploymentId("deployment_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + ) + + val betaManagedAgentsDeployment = betaManagedAgentsDeploymentFuture.get() + betaManagedAgentsDeployment.validate() + } + + @Test + fun update() { + val client = + AnthropicOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("my-anthropic-api-key") + .build() + val deploymentServiceAsync = client.beta().deployments() + + val betaManagedAgentsDeploymentFuture = + deploymentServiceAsync.update( + DeploymentUpdateParams.builder() + .deploymentId("deployment_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .agent("string") + .description("description") + .environmentId("environment_id") + .addUserMessageInitialEvent( + listOf( + BetaManagedAgentsUserMessageEventParams.Content.ofText( + BetaManagedAgentsTextBlock.builder() + .text("Where is my order #1234?") + .type(BetaManagedAgentsTextBlock.Type.TEXT) + .build() + ) + ) + ) + .metadata( + DeploymentUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .addResource( + BetaManagedAgentsFileResourceParams.builder() + .fileId("file_011CNha8iCJcU1wXNR6q4V8w") + .type(BetaManagedAgentsFileResourceParams.Type.FILE) + .mountPath("/uploads/receipt.pdf") + .build() + ) + .schedule( + BetaManagedAgentsScheduleParams.builder() + .expression("x") + .timezone("x") + .type(BetaManagedAgentsScheduleParams.Type.CRON) + .build() + ) + .addVaultId("string") + .build() + ) + + val betaManagedAgentsDeployment = betaManagedAgentsDeploymentFuture.get() + betaManagedAgentsDeployment.validate() + } + + @Disabled("buildURL drops path-level query params (SDK-4349)") + @Test + fun list() { + val client = + AnthropicOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("my-anthropic-api-key") + .build() + val deploymentServiceAsync = client.beta().deployments() + + val pageFuture = deploymentServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } + + @Test + fun archive() { + val client = + AnthropicOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("my-anthropic-api-key") + .build() + val deploymentServiceAsync = client.beta().deployments() + + val betaManagedAgentsDeploymentFuture = + deploymentServiceAsync.archive( + DeploymentArchiveParams.builder() + .deploymentId("deployment_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + ) + + val betaManagedAgentsDeployment = betaManagedAgentsDeploymentFuture.get() + betaManagedAgentsDeployment.validate() + } + + @Test + fun pause() { + val client = + AnthropicOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("my-anthropic-api-key") + .build() + val deploymentServiceAsync = client.beta().deployments() + + val betaManagedAgentsDeploymentFuture = + deploymentServiceAsync.pause( + DeploymentPauseParams.builder() + .deploymentId("deployment_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + ) + + val betaManagedAgentsDeployment = betaManagedAgentsDeploymentFuture.get() + betaManagedAgentsDeployment.validate() + } + + @Test + fun run() { + val client = + AnthropicOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("my-anthropic-api-key") + .build() + val deploymentServiceAsync = client.beta().deployments() + + val betaManagedAgentsDeploymentRunFuture = + deploymentServiceAsync.run( + DeploymentRunParams.builder() + .deploymentId("deployment_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + ) + + val betaManagedAgentsDeploymentRun = betaManagedAgentsDeploymentRunFuture.get() + betaManagedAgentsDeploymentRun.validate() + } + + @Test + fun unpause() { + val client = + AnthropicOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("my-anthropic-api-key") + .build() + val deploymentServiceAsync = client.beta().deployments() + + val betaManagedAgentsDeploymentFuture = + deploymentServiceAsync.unpause( + DeploymentUnpauseParams.builder() + .deploymentId("deployment_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + ) + + val betaManagedAgentsDeployment = betaManagedAgentsDeploymentFuture.get() + betaManagedAgentsDeployment.validate() + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/DeploymentRunServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/DeploymentRunServiceTest.kt new file mode 100644 index 000000000..539eca019 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/DeploymentRunServiceTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.services.blocking.beta + +import com.anthropic.TestServerExtension +import com.anthropic.client.okhttp.AnthropicOkHttpClient +import com.anthropic.models.beta.AnthropicBeta +import com.anthropic.models.beta.deploymentruns.DeploymentRunRetrieveParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class DeploymentRunServiceTest { + + @Disabled("buildURL drops path-level query params (SDK-4349)") + @Test + fun retrieve() { + val client = + AnthropicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("my-anthropic-api-key") + .build() + val deploymentRunService = client.beta().deploymentRuns() + + val betaManagedAgentsDeploymentRun = + deploymentRunService.retrieve( + DeploymentRunRetrieveParams.builder() + .deploymentRunId("deployment_run_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + ) + + betaManagedAgentsDeploymentRun.validate() + } + + @Disabled("buildURL drops path-level query params (SDK-4349)") + @Test + fun list() { + val client = + AnthropicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("my-anthropic-api-key") + .build() + val deploymentRunService = client.beta().deploymentRuns() + + val page = deploymentRunService.list() + + page.response().validate() + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/DeploymentServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/DeploymentServiceTest.kt new file mode 100644 index 000000000..494783c8a --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/DeploymentServiceTest.kt @@ -0,0 +1,249 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.anthropic.services.blocking.beta + +import com.anthropic.TestServerExtension +import com.anthropic.client.okhttp.AnthropicOkHttpClient +import com.anthropic.core.JsonValue +import com.anthropic.models.beta.AnthropicBeta +import com.anthropic.models.beta.deployments.BetaManagedAgentsScheduleParams +import com.anthropic.models.beta.deployments.DeploymentArchiveParams +import com.anthropic.models.beta.deployments.DeploymentCreateParams +import com.anthropic.models.beta.deployments.DeploymentPauseParams +import com.anthropic.models.beta.deployments.DeploymentRetrieveParams +import com.anthropic.models.beta.deployments.DeploymentRunParams +import com.anthropic.models.beta.deployments.DeploymentUnpauseParams +import com.anthropic.models.beta.deployments.DeploymentUpdateParams +import com.anthropic.models.beta.sessions.BetaManagedAgentsFileResourceParams +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsTextBlock +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsUserMessageEventParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class DeploymentServiceTest { + + @Test + fun create() { + val client = + AnthropicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("my-anthropic-api-key") + .build() + val deploymentService = client.beta().deployments() + + val betaManagedAgentsDeployment = + deploymentService.create( + DeploymentCreateParams.builder() + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .agent("string") + .environmentId("x") + .addUserMessageInitialEvent( + listOf( + BetaManagedAgentsUserMessageEventParams.Content.ofText( + BetaManagedAgentsTextBlock.builder() + .text("Where is my order #1234?") + .type(BetaManagedAgentsTextBlock.Type.TEXT) + .build() + ) + ) + ) + .name("x") + .description("description") + .metadata( + DeploymentCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addResource( + BetaManagedAgentsFileResourceParams.builder() + .fileId("file_011CNha8iCJcU1wXNR6q4V8w") + .type(BetaManagedAgentsFileResourceParams.Type.FILE) + .mountPath("/uploads/receipt.pdf") + .build() + ) + .schedule( + BetaManagedAgentsScheduleParams.builder() + .expression("x") + .timezone("x") + .type(BetaManagedAgentsScheduleParams.Type.CRON) + .build() + ) + .addVaultId("string") + .build() + ) + + betaManagedAgentsDeployment.validate() + } + + @Disabled("buildURL drops path-level query params (SDK-4349)") + @Test + fun retrieve() { + val client = + AnthropicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("my-anthropic-api-key") + .build() + val deploymentService = client.beta().deployments() + + val betaManagedAgentsDeployment = + deploymentService.retrieve( + DeploymentRetrieveParams.builder() + .deploymentId("deployment_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + ) + + betaManagedAgentsDeployment.validate() + } + + @Test + fun update() { + val client = + AnthropicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("my-anthropic-api-key") + .build() + val deploymentService = client.beta().deployments() + + val betaManagedAgentsDeployment = + deploymentService.update( + DeploymentUpdateParams.builder() + .deploymentId("deployment_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .agent("string") + .description("description") + .environmentId("environment_id") + .addUserMessageInitialEvent( + listOf( + BetaManagedAgentsUserMessageEventParams.Content.ofText( + BetaManagedAgentsTextBlock.builder() + .text("Where is my order #1234?") + .type(BetaManagedAgentsTextBlock.Type.TEXT) + .build() + ) + ) + ) + .metadata( + DeploymentUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .addResource( + BetaManagedAgentsFileResourceParams.builder() + .fileId("file_011CNha8iCJcU1wXNR6q4V8w") + .type(BetaManagedAgentsFileResourceParams.Type.FILE) + .mountPath("/uploads/receipt.pdf") + .build() + ) + .schedule( + BetaManagedAgentsScheduleParams.builder() + .expression("x") + .timezone("x") + .type(BetaManagedAgentsScheduleParams.Type.CRON) + .build() + ) + .addVaultId("string") + .build() + ) + + betaManagedAgentsDeployment.validate() + } + + @Disabled("buildURL drops path-level query params (SDK-4349)") + @Test + fun list() { + val client = + AnthropicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("my-anthropic-api-key") + .build() + val deploymentService = client.beta().deployments() + + val page = deploymentService.list() + + page.response().validate() + } + + @Test + fun archive() { + val client = + AnthropicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("my-anthropic-api-key") + .build() + val deploymentService = client.beta().deployments() + + val betaManagedAgentsDeployment = + deploymentService.archive( + DeploymentArchiveParams.builder() + .deploymentId("deployment_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + ) + + betaManagedAgentsDeployment.validate() + } + + @Test + fun pause() { + val client = + AnthropicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("my-anthropic-api-key") + .build() + val deploymentService = client.beta().deployments() + + val betaManagedAgentsDeployment = + deploymentService.pause( + DeploymentPauseParams.builder() + .deploymentId("deployment_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + ) + + betaManagedAgentsDeployment.validate() + } + + @Test + fun run() { + val client = + AnthropicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("my-anthropic-api-key") + .build() + val deploymentService = client.beta().deployments() + + val betaManagedAgentsDeploymentRun = + deploymentService.run( + DeploymentRunParams.builder() + .deploymentId("deployment_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + ) + + betaManagedAgentsDeploymentRun.validate() + } + + @Test + fun unpause() { + val client = + AnthropicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("my-anthropic-api-key") + .build() + val deploymentService = client.beta().deployments() + + val betaManagedAgentsDeployment = + deploymentService.unpause( + DeploymentUnpauseParams.builder() + .deploymentId("deployment_id") + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + ) + + betaManagedAgentsDeployment.validate() + } +} diff --git a/build.gradle.kts b/build.gradle.kts index f2af6ff51..dc88cd95e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.anthropic" - version = "2.39.0" // x-release-please-version + version = "2.40.0" // x-release-please-version } subprojects {