diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Acl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Acl.kt index f408b1d3..bf184e19 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Acl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Acl.kt @@ -2,7 +2,6 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing @@ -11,7 +10,6 @@ import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -44,7 +42,7 @@ private constructor( private val objectId: JsonField = JsonMissing.of(), @JsonProperty("object_type") @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), + private val objectType: JsonField = JsonMissing.of(), @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), @@ -56,7 +54,7 @@ private constructor( private val permission: JsonField = JsonMissing.of(), @JsonProperty("restrict_object_type") @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), + private val restrictObjectType: JsonField = JsonMissing.of(), @JsonProperty("role_id") @ExcludeMissing private val roleId: JsonField = JsonMissing.of(), @@ -76,7 +74,7 @@ private constructor( fun objectId(): String = objectId.getRequired("object_id") /** The object type that the ACL applies to */ - fun objectType(): ObjectType = objectType.getRequired("object_type") + fun objectType(): AclObjectType = objectType.getRequired("object_type") /** Date of acl creation */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) @@ -94,7 +92,7 @@ private constructor( * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(): Optional = + fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ @@ -119,7 +117,7 @@ private constructor( /** The object type that the ACL applies to */ @JsonProperty("object_type") @ExcludeMissing - fun _objectType(): JsonField = objectType + fun _objectType(): JsonField = objectType /** Date of acl creation */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created @@ -140,7 +138,7 @@ private constructor( */ @JsonProperty("restrict_object_type") @ExcludeMissing - fun _restrictObjectType(): JsonField = restrictObjectType + fun _restrictObjectType(): JsonField = restrictObjectType /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField = roleId @@ -198,11 +196,11 @@ private constructor( private var id: JsonField? = null private var _objectOrgId: JsonField? = null private var objectId: JsonField? = null - private var objectType: JsonField? = null + private var objectType: JsonField? = null private var created: JsonField = JsonMissing.of() private var groupId: JsonField = JsonMissing.of() private var permission: JsonField = JsonMissing.of() - private var restrictObjectType: JsonField = JsonMissing.of() + private var restrictObjectType: JsonField = JsonMissing.of() private var roleId: JsonField = JsonMissing.of() private var userId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -243,10 +241,12 @@ private constructor( fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + fun objectType(objectType: AclObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { this.objectType = objectType } + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } /** Date of acl creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -288,21 +288,21 @@ private constructor( * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + fun restrictObjectType(restrictObjectType: AclObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: Optional) = + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { + fun restrictObjectType(restrictObjectType: JsonField) = apply { this.restrictObjectType = restrictObjectType } @@ -374,465 +374,6 @@ private constructor( ) } - /** The object type that the ACL applies to */ - class ObjectType @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 = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - /** An enum containing [ObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ObjectType] 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, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [ObjectType] 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 -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - 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 BraintrustInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - class Permission @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 CREATE = of("create") - - @JvmField val READ = of("read") - - @JvmField val UPDATE = of("update") - - @JvmField val DELETE = of("delete") - - @JvmField val CREATE_ACLS = of("create_acls") - - @JvmField val READ_ACLS = of("read_acls") - - @JvmField val UPDATE_ACLS = of("update_acls") - - @JvmField val DELETE_ACLS = of("delete_acls") - - @JvmStatic fun of(value: String) = Permission(JsonField.of(value)) - } - - /** An enum containing [Permission]'s known values. */ - enum class Known { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - } - - /** - * An enum containing [Permission]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Permission] 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 { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - /** - * An enum member indicating that [Permission] 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) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - 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 BraintrustInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $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 BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. - */ - class RestrictObjectType - @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 = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = RestrictObjectType(JsonField.of(value)) - } - - /** An enum containing [RestrictObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [RestrictObjectType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [RestrictObjectType] 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, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [RestrictObjectType] 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 -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - 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 BraintrustInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateParams.kt index c7232bb9..c133533b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateParams.kt @@ -2,7 +2,6 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing @@ -15,7 +14,6 @@ import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -630,7 +628,7 @@ private constructor( private val objectId: JsonField = JsonMissing.of(), @JsonProperty("object_type") @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), + private val objectType: JsonField = JsonMissing.of(), @JsonProperty("group_id") @ExcludeMissing private val groupId: JsonField = JsonMissing.of(), @@ -639,7 +637,7 @@ private constructor( private val permission: JsonField = JsonMissing.of(), @JsonProperty("restrict_object_type") @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), + private val restrictObjectType: JsonField = JsonMissing.of(), @JsonProperty("role_id") @ExcludeMissing private val roleId: JsonField = JsonMissing.of(), @@ -654,7 +652,7 @@ private constructor( fun objectId(): String = objectId.getRequired("object_id") /** The object type that the ACL applies to */ - fun objectType(): ObjectType = objectType.getRequired("object_type") + fun objectType(): AclObjectType = objectType.getRequired("object_type") /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be @@ -670,7 +668,7 @@ private constructor( * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(): Optional = + fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** @@ -690,7 +688,7 @@ private constructor( /** The object type that the ACL applies to */ @JsonProperty("object_type") @ExcludeMissing - fun _objectType(): JsonField = objectType + fun _objectType(): JsonField = objectType /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be @@ -709,7 +707,7 @@ private constructor( */ @JsonProperty("restrict_object_type") @ExcludeMissing - fun _restrictObjectType(): JsonField = restrictObjectType + fun _restrictObjectType(): JsonField = restrictObjectType /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided @@ -763,10 +761,10 @@ private constructor( class Builder internal constructor() { private var objectId: JsonField? = null - private var objectType: JsonField? = null + private var objectType: JsonField? = null private var groupId: JsonField = JsonMissing.of() private var permission: JsonField = JsonMissing.of() - private var restrictObjectType: JsonField = JsonMissing.of() + private var restrictObjectType: JsonField = JsonMissing.of() private var roleId: JsonField = JsonMissing.of() private var userId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -790,10 +788,10 @@ private constructor( fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + fun objectType(objectType: AclObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { + fun objectType(objectType: JsonField) = apply { this.objectType = objectType } @@ -836,21 +834,21 @@ private constructor( * When setting a permission directly, optionally restricts the permission grant to just * the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + fun restrictObjectType(restrictObjectType: AclObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** * When setting a permission directly, optionally restricts the permission grant to just * the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: Optional) = + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** * When setting a permission directly, optionally restricts the permission grant to just * the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { + fun restrictObjectType(restrictObjectType: JsonField) = apply { this.restrictObjectType = restrictObjectType } @@ -922,472 +920,6 @@ private constructor( ) } - /** The object type that the ACL applies to */ - class ObjectType @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 = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - /** An enum containing [ObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ObjectType] 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, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [ObjectType] 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 -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - 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 BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - class Permission @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 CREATE = of("create") - - @JvmField val READ = of("read") - - @JvmField val UPDATE = of("update") - - @JvmField val DELETE = of("delete") - - @JvmField val CREATE_ACLS = of("create_acls") - - @JvmField val READ_ACLS = of("read_acls") - - @JvmField val UPDATE_ACLS = of("update_acls") - - @JvmField val DELETE_ACLS = of("delete_acls") - - @JvmStatic fun of(value: String) = Permission(JsonField.of(value)) - } - - /** An enum containing [Permission]'s known values. */ - enum class Known { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - } - - /** - * An enum containing [Permission]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Permission] 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 { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - /** - * An enum member indicating that [Permission] 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) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - 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 BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $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 BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. - */ - class RestrictObjectType - @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 = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = RestrictObjectType(JsonField.of(value)) - } - - /** An enum containing [RestrictObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [RestrictObjectType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [RestrictObjectType] 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, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [RestrictObjectType] 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 -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - 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 BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1425,7 +957,7 @@ private constructor( private val objectId: JsonField = JsonMissing.of(), @JsonProperty("object_type") @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), + private val objectType: JsonField = JsonMissing.of(), @JsonProperty("group_id") @ExcludeMissing private val groupId: JsonField = JsonMissing.of(), @@ -1434,7 +966,7 @@ private constructor( private val permission: JsonField = JsonMissing.of(), @JsonProperty("restrict_object_type") @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), + private val restrictObjectType: JsonField = JsonMissing.of(), @JsonProperty("role_id") @ExcludeMissing private val roleId: JsonField = JsonMissing.of(), @@ -1449,7 +981,7 @@ private constructor( fun objectId(): String = objectId.getRequired("object_id") /** The object type that the ACL applies to */ - fun objectType(): ObjectType = objectType.getRequired("object_type") + fun objectType(): AclObjectType = objectType.getRequired("object_type") /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be @@ -1465,7 +997,7 @@ private constructor( * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(): Optional = + fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** @@ -1485,7 +1017,7 @@ private constructor( /** The object type that the ACL applies to */ @JsonProperty("object_type") @ExcludeMissing - fun _objectType(): JsonField = objectType + fun _objectType(): JsonField = objectType /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be @@ -1504,7 +1036,7 @@ private constructor( */ @JsonProperty("restrict_object_type") @ExcludeMissing - fun _restrictObjectType(): JsonField = restrictObjectType + fun _restrictObjectType(): JsonField = restrictObjectType /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided @@ -1558,10 +1090,10 @@ private constructor( class Builder internal constructor() { private var objectId: JsonField? = null - private var objectType: JsonField? = null + private var objectType: JsonField? = null private var groupId: JsonField = JsonMissing.of() private var permission: JsonField = JsonMissing.of() - private var restrictObjectType: JsonField = JsonMissing.of() + private var restrictObjectType: JsonField = JsonMissing.of() private var roleId: JsonField = JsonMissing.of() private var userId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1585,10 +1117,10 @@ private constructor( fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + fun objectType(objectType: AclObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { + fun objectType(objectType: JsonField) = apply { this.objectType = objectType } @@ -1631,21 +1163,21 @@ private constructor( * When setting a permission directly, optionally restricts the permission grant to just * the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + fun restrictObjectType(restrictObjectType: AclObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** * When setting a permission directly, optionally restricts the permission grant to just * the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: Optional) = + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** * When setting a permission directly, optionally restricts the permission grant to just * the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { + fun restrictObjectType(restrictObjectType: JsonField) = apply { this.restrictObjectType = restrictObjectType } @@ -1717,472 +1249,6 @@ private constructor( ) } - /** The object type that the ACL applies to */ - class ObjectType @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 = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - /** An enum containing [ObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ObjectType] 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, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [ObjectType] 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 -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - 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 BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - class Permission @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 CREATE = of("create") - - @JvmField val READ = of("read") - - @JvmField val UPDATE = of("update") - - @JvmField val DELETE = of("delete") - - @JvmField val CREATE_ACLS = of("create_acls") - - @JvmField val READ_ACLS = of("read_acls") - - @JvmField val UPDATE_ACLS = of("update_acls") - - @JvmField val DELETE_ACLS = of("delete_acls") - - @JvmStatic fun of(value: String) = Permission(JsonField.of(value)) - } - - /** An enum containing [Permission]'s known values. */ - enum class Known { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - } - - /** - * An enum containing [Permission]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Permission] 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 { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - /** - * An enum member indicating that [Permission] 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) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - 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 BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $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 BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. - */ - class RestrictObjectType - @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 = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = RestrictObjectType(JsonField.of(value)) - } - - /** An enum containing [RestrictObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [RestrictObjectType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [RestrictObjectType] 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, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [RestrictObjectType] 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 -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - 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 BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclCreateParams.kt index 58566fc6..c6266e37 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclCreateParams.kt @@ -2,7 +2,6 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing @@ -14,7 +13,6 @@ import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -38,7 +36,7 @@ private constructor( fun objectId(): String = body.objectId() /** The object type that the ACL applies to */ - fun objectType(): ObjectType = body.objectType() + fun objectType(): AclObjectType = body.objectType() /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided @@ -52,7 +50,7 @@ private constructor( * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(): Optional = body.restrictObjectType() + fun restrictObjectType(): Optional = body.restrictObjectType() /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun roleId(): Optional = body.roleId() @@ -66,7 +64,7 @@ private constructor( fun _objectId(): JsonField = body._objectId() /** The object type that the ACL applies to */ - fun _objectType(): JsonField = body._objectType() + fun _objectType(): JsonField = body._objectType() /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided @@ -80,7 +78,7 @@ private constructor( * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. */ - fun _restrictObjectType(): JsonField = body._restrictObjectType() + fun _restrictObjectType(): JsonField = body._restrictObjectType() /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun _roleId(): JsonField = body._roleId() @@ -121,7 +119,7 @@ private constructor( private val objectId: JsonField = JsonMissing.of(), @JsonProperty("object_type") @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), + private val objectType: JsonField = JsonMissing.of(), @JsonProperty("group_id") @ExcludeMissing private val groupId: JsonField = JsonMissing.of(), @@ -130,7 +128,7 @@ private constructor( private val permission: JsonField = JsonMissing.of(), @JsonProperty("restrict_object_type") @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), + private val restrictObjectType: JsonField = JsonMissing.of(), @JsonProperty("role_id") @ExcludeMissing private val roleId: JsonField = JsonMissing.of(), @@ -145,7 +143,7 @@ private constructor( fun objectId(): String = objectId.getRequired("object_id") /** The object type that the ACL applies to */ - fun objectType(): ObjectType = objectType.getRequired("object_type") + fun objectType(): AclObjectType = objectType.getRequired("object_type") /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be @@ -161,7 +159,7 @@ private constructor( * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(): Optional = + fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** @@ -181,7 +179,7 @@ private constructor( /** The object type that the ACL applies to */ @JsonProperty("object_type") @ExcludeMissing - fun _objectType(): JsonField = objectType + fun _objectType(): JsonField = objectType /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be @@ -200,7 +198,7 @@ private constructor( */ @JsonProperty("restrict_object_type") @ExcludeMissing - fun _restrictObjectType(): JsonField = restrictObjectType + fun _restrictObjectType(): JsonField = restrictObjectType /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided @@ -254,10 +252,10 @@ private constructor( class Builder internal constructor() { private var objectId: JsonField? = null - private var objectType: JsonField? = null + private var objectType: JsonField? = null private var groupId: JsonField = JsonMissing.of() private var permission: JsonField = JsonMissing.of() - private var restrictObjectType: JsonField = JsonMissing.of() + private var restrictObjectType: JsonField = JsonMissing.of() private var roleId: JsonField = JsonMissing.of() private var userId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -281,10 +279,10 @@ private constructor( fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + fun objectType(objectType: AclObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { + fun objectType(objectType: JsonField) = apply { this.objectType = objectType } @@ -327,21 +325,21 @@ private constructor( * When setting a permission directly, optionally restricts the permission grant to just * the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + fun restrictObjectType(restrictObjectType: AclObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** * When setting a permission directly, optionally restricts the permission grant to just * the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: Optional) = + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** * When setting a permission directly, optionally restricts the permission grant to just * the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { + fun restrictObjectType(restrictObjectType: JsonField) = apply { this.restrictObjectType = restrictObjectType } @@ -469,10 +467,10 @@ private constructor( fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { body.objectType(objectType) } + fun objectType(objectType: AclObjectType) = apply { body.objectType(objectType) } /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } + fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be @@ -505,7 +503,7 @@ private constructor( * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = apply { + fun restrictObjectType(restrictObjectType: AclObjectType?) = apply { body.restrictObjectType(restrictObjectType) } @@ -513,14 +511,14 @@ private constructor( * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: Optional) = + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { + fun restrictObjectType(restrictObjectType: JsonField) = apply { body.restrictObjectType(restrictObjectType) } @@ -678,465 +676,6 @@ private constructor( AclCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) } - /** The object type that the ACL applies to */ - class ObjectType @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 = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - /** An enum containing [ObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ObjectType] 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, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [ObjectType] 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 -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - 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 BraintrustInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - class Permission @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 CREATE = of("create") - - @JvmField val READ = of("read") - - @JvmField val UPDATE = of("update") - - @JvmField val DELETE = of("delete") - - @JvmField val CREATE_ACLS = of("create_acls") - - @JvmField val READ_ACLS = of("read_acls") - - @JvmField val UPDATE_ACLS = of("update_acls") - - @JvmField val DELETE_ACLS = of("delete_acls") - - @JvmStatic fun of(value: String) = Permission(JsonField.of(value)) - } - - /** An enum containing [Permission]'s known values. */ - enum class Known { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - } - - /** - * An enum containing [Permission]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Permission] 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 { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - /** - * An enum member indicating that [Permission] 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) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - 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 BraintrustInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $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 BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. - */ - class RestrictObjectType - @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 = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = RestrictObjectType(JsonField.of(value)) - } - - /** An enum containing [RestrictObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [RestrictObjectType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [RestrictObjectType] 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, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [RestrictObjectType] 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 -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - 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 BraintrustInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclFindAndDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclFindAndDeleteParams.kt index 43a401e5..237fc6b6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclFindAndDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclFindAndDeleteParams.kt @@ -2,7 +2,6 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing @@ -14,7 +13,6 @@ import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -35,7 +33,7 @@ private constructor( fun objectId(): String = body.objectId() /** The object type that the ACL applies to */ - fun objectType(): ObjectType = body.objectType() + fun objectType(): AclObjectType = body.objectType() /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided @@ -49,7 +47,7 @@ private constructor( * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(): Optional = body.restrictObjectType() + fun restrictObjectType(): Optional = body.restrictObjectType() /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun roleId(): Optional = body.roleId() @@ -63,7 +61,7 @@ private constructor( fun _objectId(): JsonField = body._objectId() /** The object type that the ACL applies to */ - fun _objectType(): JsonField = body._objectType() + fun _objectType(): JsonField = body._objectType() /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided @@ -77,7 +75,7 @@ private constructor( * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. */ - fun _restrictObjectType(): JsonField = body._restrictObjectType() + fun _restrictObjectType(): JsonField = body._restrictObjectType() /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun _roleId(): JsonField = body._roleId() @@ -118,7 +116,7 @@ private constructor( private val objectId: JsonField = JsonMissing.of(), @JsonProperty("object_type") @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), + private val objectType: JsonField = JsonMissing.of(), @JsonProperty("group_id") @ExcludeMissing private val groupId: JsonField = JsonMissing.of(), @@ -127,7 +125,7 @@ private constructor( private val permission: JsonField = JsonMissing.of(), @JsonProperty("restrict_object_type") @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), + private val restrictObjectType: JsonField = JsonMissing.of(), @JsonProperty("role_id") @ExcludeMissing private val roleId: JsonField = JsonMissing.of(), @@ -142,7 +140,7 @@ private constructor( fun objectId(): String = objectId.getRequired("object_id") /** The object type that the ACL applies to */ - fun objectType(): ObjectType = objectType.getRequired("object_type") + fun objectType(): AclObjectType = objectType.getRequired("object_type") /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be @@ -158,7 +156,7 @@ private constructor( * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(): Optional = + fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** @@ -178,7 +176,7 @@ private constructor( /** The object type that the ACL applies to */ @JsonProperty("object_type") @ExcludeMissing - fun _objectType(): JsonField = objectType + fun _objectType(): JsonField = objectType /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be @@ -197,7 +195,7 @@ private constructor( */ @JsonProperty("restrict_object_type") @ExcludeMissing - fun _restrictObjectType(): JsonField = restrictObjectType + fun _restrictObjectType(): JsonField = restrictObjectType /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided @@ -251,10 +249,10 @@ private constructor( class Builder internal constructor() { private var objectId: JsonField? = null - private var objectType: JsonField? = null + private var objectType: JsonField? = null private var groupId: JsonField = JsonMissing.of() private var permission: JsonField = JsonMissing.of() - private var restrictObjectType: JsonField = JsonMissing.of() + private var restrictObjectType: JsonField = JsonMissing.of() private var roleId: JsonField = JsonMissing.of() private var userId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -278,10 +276,10 @@ private constructor( fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + fun objectType(objectType: AclObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { + fun objectType(objectType: JsonField) = apply { this.objectType = objectType } @@ -324,21 +322,21 @@ private constructor( * When setting a permission directly, optionally restricts the permission grant to just * the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + fun restrictObjectType(restrictObjectType: AclObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** * When setting a permission directly, optionally restricts the permission grant to just * the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: Optional) = + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** * When setting a permission directly, optionally restricts the permission grant to just * the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { + fun restrictObjectType(restrictObjectType: JsonField) = apply { this.restrictObjectType = restrictObjectType } @@ -466,10 +464,10 @@ private constructor( fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { body.objectType(objectType) } + fun objectType(objectType: AclObjectType) = apply { body.objectType(objectType) } /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } + fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be @@ -502,7 +500,7 @@ private constructor( * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = apply { + fun restrictObjectType(restrictObjectType: AclObjectType?) = apply { body.restrictObjectType(restrictObjectType) } @@ -510,14 +508,14 @@ private constructor( * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: Optional) = + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { + fun restrictObjectType(restrictObjectType: JsonField) = apply { body.restrictObjectType(restrictObjectType) } @@ -679,465 +677,6 @@ private constructor( ) } - /** The object type that the ACL applies to */ - class ObjectType @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 = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - /** An enum containing [ObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ObjectType] 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, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [ObjectType] 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 -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - 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 BraintrustInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - class Permission @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 CREATE = of("create") - - @JvmField val READ = of("read") - - @JvmField val UPDATE = of("update") - - @JvmField val DELETE = of("delete") - - @JvmField val CREATE_ACLS = of("create_acls") - - @JvmField val READ_ACLS = of("read_acls") - - @JvmField val UPDATE_ACLS = of("update_acls") - - @JvmField val DELETE_ACLS = of("delete_acls") - - @JvmStatic fun of(value: String) = Permission(JsonField.of(value)) - } - - /** An enum containing [Permission]'s known values. */ - enum class Known { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - } - - /** - * An enum containing [Permission]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Permission] 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 { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - /** - * An enum member indicating that [Permission] 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) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - 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 BraintrustInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $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 BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. - */ - class RestrictObjectType - @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 = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = RestrictObjectType(JsonField.of(value)) - } - - /** An enum containing [RestrictObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [RestrictObjectType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [RestrictObjectType] 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, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [RestrictObjectType] 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 -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - 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 BraintrustInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListParams.kt index 46304214..6f389829 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListParams.kt @@ -4,8 +4,6 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.BaseDeserializer import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.Params @@ -14,7 +12,6 @@ import com.braintrustdata.api.core.getOrThrow import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.JsonNode @@ -33,7 +30,7 @@ import kotlin.jvm.optionals.getOrNull class AclListParams private constructor( private val objectId: String, - private val objectType: ObjectType, + private val objectType: AclObjectType, private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -46,7 +43,7 @@ private constructor( fun objectId(): String = objectId /** The object type that the ACL applies to */ - fun objectType(): ObjectType = objectType + fun objectType(): AclObjectType = objectType /** * Pagination cursor id. @@ -114,7 +111,7 @@ private constructor( class Builder internal constructor() { private var objectId: String? = null - private var objectType: ObjectType? = null + private var objectType: AclObjectType? = null private var endingBefore: String? = null private var ids: Ids? = null private var limit: Long? = null @@ -138,7 +135,7 @@ private constructor( fun objectId(objectId: String) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: AclObjectType) = apply { this.objectType = objectType } /** * Pagination cursor id. @@ -321,163 +318,6 @@ private constructor( ) } - /** The object type that the ACL applies to */ - class ObjectType @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 = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - /** An enum containing [ObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ObjectType] 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, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [ObjectType] 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 -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - 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 BraintrustInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - /** * Filter search results to a particular set of object IDs. To specify a list of IDs, include * the query param multiple times diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclObjectType.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclObjectType.kt new file mode 100644 index 00000000..90f9091e --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclObjectType.kt @@ -0,0 +1,162 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator + +/** The object type that the ACL applies to */ +class AclObjectType @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 = of("organization") + + @JvmField val PROJECT = of("project") + + @JvmField val EXPERIMENT = of("experiment") + + @JvmField val DATASET = of("dataset") + + @JvmField val PROMPT = of("prompt") + + @JvmField val PROMPT_SESSION = of("prompt_session") + + @JvmField val GROUP = of("group") + + @JvmField val ROLE = of("role") + + @JvmField val ORG_MEMBER = of("org_member") + + @JvmField val PROJECT_LOG = of("project_log") + + @JvmField val ORG_PROJECT = of("org_project") + + @JvmStatic fun of(value: String) = AclObjectType(JsonField.of(value)) + } + + /** An enum containing [AclObjectType]'s known values. */ + enum class Known { + ORGANIZATION, + PROJECT, + EXPERIMENT, + DATASET, + PROMPT, + PROMPT_SESSION, + GROUP, + ROLE, + ORG_MEMBER, + PROJECT_LOG, + ORG_PROJECT, + } + + /** + * An enum containing [AclObjectType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AclObjectType] 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, + PROJECT, + EXPERIMENT, + DATASET, + PROMPT, + PROMPT_SESSION, + GROUP, + ROLE, + ORG_MEMBER, + PROJECT_LOG, + ORG_PROJECT, + /** + * An enum member indicating that [AclObjectType] 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 -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + 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 BraintrustInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown AclObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AclObjectType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListParams.kt index b0e9f3c4..86d2b48e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListParams.kt @@ -4,8 +4,6 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.BaseDeserializer import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.Params @@ -13,7 +11,6 @@ import com.braintrustdata.api.core.getOrThrow import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.JsonNode @@ -35,7 +32,7 @@ private constructor( private val ids: Ids?, private val limit: Long?, private val objectId: String?, - private val objectType: ObjectType?, + private val objectType: EnvVarObjectType?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -56,7 +53,7 @@ private constructor( fun objectId(): Optional = Optional.ofNullable(objectId) /** The type of the object the environment variable is scoped for */ - fun objectType(): Optional = Optional.ofNullable(objectType) + fun objectType(): Optional = Optional.ofNullable(objectType) fun _additionalHeaders(): Headers = additionalHeaders @@ -93,7 +90,7 @@ private constructor( private var ids: Ids? = null private var limit: Long? = null private var objectId: String? = null - private var objectType: ObjectType? = null + private var objectType: EnvVarObjectType? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -154,10 +151,10 @@ private constructor( fun objectId(objectId: Optional) = objectId(objectId.getOrNull()) /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: ObjectType?) = apply { this.objectType = objectType } + fun objectType(objectType: EnvVarObjectType?) = apply { this.objectType = objectType } /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: Optional) = objectType(objectType.getOrNull()) + fun objectType(objectType: Optional) = objectType(objectType.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -383,115 +380,6 @@ private constructor( } } - /** The type of the object the environment variable is scoped for */ - class ObjectType @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 = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val FUNCTION = of("function") - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - /** An enum containing [ObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - FUNCTION, - } - - /** - * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ObjectType] 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, - PROJECT, - FUNCTION, - /** - * An enum member indicating that [ObjectType] 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 -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - FUNCTION -> Value.FUNCTION - 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 BraintrustInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarObjectType.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarObjectType.kt new file mode 100644 index 00000000..b78e5292 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarObjectType.kt @@ -0,0 +1,115 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator + +/** The type of the object the environment variable is scoped for */ +class EnvVarObjectType @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 = of("organization") + + @JvmField val PROJECT = of("project") + + @JvmField val FUNCTION = of("function") + + @JvmStatic fun of(value: String) = EnvVarObjectType(JsonField.of(value)) + } + + /** An enum containing [EnvVarObjectType]'s known values. */ + enum class Known { + ORGANIZATION, + PROJECT, + FUNCTION, + } + + /** + * An enum containing [EnvVarObjectType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EnvVarObjectType] 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, + PROJECT, + FUNCTION, + /** + * An enum member indicating that [EnvVarObjectType] 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 -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + FUNCTION -> Value.FUNCTION + 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 BraintrustInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + FUNCTION -> Known.FUNCTION + else -> throw BraintrustInvalidDataException("Unknown EnvVarObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EnvVarObjectType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Function.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Function.kt index 57056d70..e4656f96 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Function.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Function.kt @@ -2616,7 +2616,7 @@ private constructor( private val objectId: JsonField = JsonMissing.of(), @JsonProperty("object_type") @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), + private val objectType: JsonField = JsonMissing.of(), @JsonProperty("internal") @ExcludeMissing private val internal_: JsonField = JsonMissing.of(), @@ -2628,7 +2628,7 @@ private constructor( fun objectId(): String = objectId.getRequired("object_id") /** The object type that the ACL applies to */ - fun objectType(): ObjectType = objectType.getRequired("object_type") + fun objectType(): AclObjectType = objectType.getRequired("object_type") /** * The function exists for internal purposes and should not be displayed in the list of @@ -2642,7 +2642,7 @@ private constructor( /** The object type that the ACL applies to */ @JsonProperty("object_type") @ExcludeMissing - fun _objectType(): JsonField = objectType + fun _objectType(): JsonField = objectType /** * The function exists for internal purposes and should not be displayed in the list of @@ -2687,7 +2687,7 @@ private constructor( class Builder internal constructor() { private var objectId: JsonField? = null - private var objectType: JsonField? = null + private var objectType: JsonField? = null private var internal_: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2706,10 +2706,10 @@ private constructor( fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + fun objectType(objectType: AclObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { + fun objectType(objectType: JsonField) = apply { this.objectType = objectType } @@ -2765,165 +2765,6 @@ private constructor( ) } - /** The object type that the ACL applies to */ - class ObjectType @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 = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - /** An enum containing [ObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ObjectType] 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, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [ObjectType] 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 -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - 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 BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionCreateParams.kt index e5ea58a3..13824b46 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionCreateParams.kt @@ -2665,7 +2665,7 @@ private constructor( private val objectId: JsonField = JsonMissing.of(), @JsonProperty("object_type") @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), + private val objectType: JsonField = JsonMissing.of(), @JsonProperty("internal") @ExcludeMissing private val internal_: JsonField = JsonMissing.of(), @@ -2677,7 +2677,7 @@ private constructor( fun objectId(): String = objectId.getRequired("object_id") /** The object type that the ACL applies to */ - fun objectType(): ObjectType = objectType.getRequired("object_type") + fun objectType(): AclObjectType = objectType.getRequired("object_type") /** * The function exists for internal purposes and should not be displayed in the list of @@ -2691,7 +2691,7 @@ private constructor( /** The object type that the ACL applies to */ @JsonProperty("object_type") @ExcludeMissing - fun _objectType(): JsonField = objectType + fun _objectType(): JsonField = objectType /** * The function exists for internal purposes and should not be displayed in the list of @@ -2736,7 +2736,7 @@ private constructor( class Builder internal constructor() { private var objectId: JsonField? = null - private var objectType: JsonField? = null + private var objectType: JsonField? = null private var internal_: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2755,10 +2755,10 @@ private constructor( fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + fun objectType(objectType: AclObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { + fun objectType(objectType: JsonField) = apply { this.objectType = objectType } @@ -2814,165 +2814,6 @@ private constructor( ) } - /** The object type that the ACL applies to */ - class ObjectType @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 = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - /** An enum containing [ObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ObjectType] 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, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [ObjectType] 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 -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - 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 BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionReplaceParams.kt index bf5891ce..65c621fc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionReplaceParams.kt @@ -2665,7 +2665,7 @@ private constructor( private val objectId: JsonField = JsonMissing.of(), @JsonProperty("object_type") @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), + private val objectType: JsonField = JsonMissing.of(), @JsonProperty("internal") @ExcludeMissing private val internal_: JsonField = JsonMissing.of(), @@ -2677,7 +2677,7 @@ private constructor( fun objectId(): String = objectId.getRequired("object_id") /** The object type that the ACL applies to */ - fun objectType(): ObjectType = objectType.getRequired("object_type") + fun objectType(): AclObjectType = objectType.getRequired("object_type") /** * The function exists for internal purposes and should not be displayed in the list of @@ -2691,7 +2691,7 @@ private constructor( /** The object type that the ACL applies to */ @JsonProperty("object_type") @ExcludeMissing - fun _objectType(): JsonField = objectType + fun _objectType(): JsonField = objectType /** * The function exists for internal purposes and should not be displayed in the list of @@ -2736,7 +2736,7 @@ private constructor( class Builder internal constructor() { private var objectId: JsonField? = null - private var objectType: JsonField? = null + private var objectType: JsonField? = null private var internal_: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2755,10 +2755,10 @@ private constructor( fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + fun objectType(objectType: AclObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { + fun objectType(objectType: JsonField) = apply { this.objectType = objectType } @@ -2814,165 +2814,6 @@ private constructor( ) } - /** The object type that the ACL applies to */ - class ObjectType @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 = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - /** An enum containing [ObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ObjectType] 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, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [ObjectType] 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 -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - 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 BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Permission.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Permission.kt new file mode 100644 index 00000000..7b884f8d --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Permission.kt @@ -0,0 +1,146 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator + +/** + * Each permission permits a certain type of operation on an object in the system + * + * Permissions can be assigned to to objects on an individual basis, or grouped into roles + */ +class Permission @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 CREATE = of("create") + + @JvmField val READ = of("read") + + @JvmField val UPDATE = of("update") + + @JvmField val DELETE = of("delete") + + @JvmField val CREATE_ACLS = of("create_acls") + + @JvmField val READ_ACLS = of("read_acls") + + @JvmField val UPDATE_ACLS = of("update_acls") + + @JvmField val DELETE_ACLS = of("delete_acls") + + @JvmStatic fun of(value: String) = Permission(JsonField.of(value)) + } + + /** An enum containing [Permission]'s known values. */ + enum class Known { + CREATE, + READ, + UPDATE, + DELETE, + CREATE_ACLS, + READ_ACLS, + UPDATE_ACLS, + DELETE_ACLS, + } + + /** + * An enum containing [Permission]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Permission] 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 { + CREATE, + READ, + UPDATE, + DELETE, + CREATE_ACLS, + READ_ACLS, + UPDATE_ACLS, + DELETE_ACLS, + /** An enum member indicating that [Permission] 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) { + CREATE -> Value.CREATE + READ -> Value.READ + UPDATE -> Value.UPDATE + DELETE -> Value.DELETE + CREATE_ACLS -> Value.CREATE_ACLS + READ_ACLS -> Value.READ_ACLS + UPDATE_ACLS -> Value.UPDATE_ACLS + DELETE_ACLS -> Value.DELETE_ACLS + 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 BraintrustInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CREATE -> Known.CREATE + READ -> Known.READ + UPDATE -> Known.UPDATE + DELETE -> Known.DELETE + CREATE_ACLS -> Known.CREATE_ACLS + READ_ACLS -> Known.READ_ACLS + UPDATE_ACLS -> Known.UPDATE_ACLS + DELETE_ACLS -> Known.DELETE_ACLS + else -> throw BraintrustInvalidDataException("Unknown Permission: $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 BraintrustInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScore.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScore.kt index fd3e6e1c..21c79f2d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScore.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScore.kt @@ -4,7 +4,6 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.BaseDeserializer import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing @@ -43,7 +42,7 @@ private constructor( private val projectId: JsonField = JsonMissing.of(), @JsonProperty("score_type") @ExcludeMissing - private val scoreType: JsonField = JsonMissing.of(), + private val scoreType: JsonField = JsonMissing.of(), @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), @@ -75,7 +74,7 @@ private constructor( fun projectId(): String = projectId.getRequired("project_id") /** The type of the configured score */ - fun scoreType(): ScoreType = scoreType.getRequired("score_type") + fun scoreType(): ProjectScoreType = scoreType.getRequired("score_type") fun userId(): String = userId.getRequired("user_id") @@ -105,7 +104,9 @@ private constructor( @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** The type of the configured score */ - @JsonProperty("score_type") @ExcludeMissing fun _scoreType(): JsonField = scoreType + @JsonProperty("score_type") + @ExcludeMissing + fun _scoreType(): JsonField = scoreType @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @@ -174,7 +175,7 @@ private constructor( private var id: JsonField? = null private var name: JsonField? = null private var projectId: JsonField? = null - private var scoreType: JsonField? = null + private var scoreType: JsonField? = null private var userId: JsonField? = null private var categories: JsonField = JsonMissing.of() private var config: JsonField = JsonMissing.of() @@ -217,10 +218,10 @@ private constructor( fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** The type of the configured score */ - fun scoreType(scoreType: ScoreType) = scoreType(JsonField.of(scoreType)) + fun scoreType(scoreType: ProjectScoreType) = scoreType(JsonField.of(scoreType)) /** The type of the configured score */ - fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } fun userId(userId: String) = userId(JsonField.of(userId)) @@ -313,139 +314,6 @@ private constructor( ) } - /** The type of the configured score */ - class ScoreType @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 SLIDER = of("slider") - - @JvmField val CATEGORICAL = of("categorical") - - @JvmField val WEIGHTED = of("weighted") - - @JvmField val MINIMUM = of("minimum") - - @JvmField val MAXIMUM = of("maximum") - - @JvmField val ONLINE = of("online") - - @JvmField val FREE_FORM = of("free-form") - - @JvmStatic fun of(value: String) = ScoreType(JsonField.of(value)) - } - - /** An enum containing [ScoreType]'s known values. */ - enum class Known { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - MAXIMUM, - ONLINE, - FREE_FORM, - } - - /** - * An enum containing [ScoreType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ScoreType] 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 { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - MAXIMUM, - ONLINE, - FREE_FORM, - /** - * An enum member indicating that [ScoreType] 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) { - SLIDER -> Value.SLIDER - CATEGORICAL -> Value.CATEGORICAL - WEIGHTED -> Value.WEIGHTED - MINIMUM -> Value.MINIMUM - MAXIMUM -> Value.MAXIMUM - ONLINE -> Value.ONLINE - FREE_FORM -> Value.FREE_FORM - 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 BraintrustInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - SLIDER -> Known.SLIDER - CATEGORICAL -> Known.CATEGORICAL - WEIGHTED -> Known.WEIGHTED - MINIMUM -> Known.MINIMUM - MAXIMUM -> Known.MAXIMUM - ONLINE -> Known.ONLINE - FREE_FORM -> Known.FREE_FORM - else -> throw BraintrustInvalidDataException("Unknown ScoreType: $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 BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - /** For categorical-type project scores, the list of all categories */ @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParams.kt index 51091ebd..3a475043 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParams.kt @@ -4,7 +4,6 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.BaseDeserializer import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing @@ -51,7 +50,7 @@ private constructor( fun projectId(): String = body.projectId() /** The type of the configured score */ - fun scoreType(): ScoreType = body.scoreType() + fun scoreType(): ProjectScoreType = body.scoreType() /** For categorical-type project scores, the list of all categories */ fun categories(): Optional = body.categories() @@ -68,7 +67,7 @@ private constructor( fun _projectId(): JsonField = body._projectId() /** The type of the configured score */ - fun _scoreType(): JsonField = body._scoreType() + fun _scoreType(): JsonField = body._scoreType() /** For categorical-type project scores, the list of all categories */ fun _categories(): JsonField = body._categories() @@ -103,7 +102,7 @@ private constructor( private val projectId: JsonField = JsonMissing.of(), @JsonProperty("score_type") @ExcludeMissing - private val scoreType: JsonField = JsonMissing.of(), + private val scoreType: JsonField = JsonMissing.of(), @JsonProperty("categories") @ExcludeMissing private val categories: JsonField = JsonMissing.of(), @@ -124,7 +123,7 @@ private constructor( fun projectId(): String = projectId.getRequired("project_id") /** The type of the configured score */ - fun scoreType(): ScoreType = scoreType.getRequired("score_type") + fun scoreType(): ProjectScoreType = scoreType.getRequired("score_type") /** For categorical-type project scores, the list of all categories */ fun categories(): Optional = @@ -146,7 +145,7 @@ private constructor( /** The type of the configured score */ @JsonProperty("score_type") @ExcludeMissing - fun _scoreType(): JsonField = scoreType + fun _scoreType(): JsonField = scoreType /** For categorical-type project scores, the list of all categories */ @JsonProperty("categories") @@ -204,7 +203,7 @@ private constructor( private var name: JsonField? = null private var projectId: JsonField? = null - private var scoreType: JsonField? = null + private var scoreType: JsonField? = null private var categories: JsonField = JsonMissing.of() private var config: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() @@ -234,10 +233,12 @@ private constructor( fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** The type of the configured score */ - fun scoreType(scoreType: ScoreType) = scoreType(JsonField.of(scoreType)) + fun scoreType(scoreType: ProjectScoreType) = scoreType(JsonField.of(scoreType)) /** The type of the configured score */ - fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: JsonField) = apply { + this.scoreType = scoreType + } /** For categorical-type project scores, the list of all categories */ fun categories(categories: Categories?) = categories(JsonField.ofNullable(categories)) @@ -373,10 +374,10 @@ private constructor( fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** The type of the configured score */ - fun scoreType(scoreType: ScoreType) = apply { body.scoreType(scoreType) } + fun scoreType(scoreType: ProjectScoreType) = apply { body.scoreType(scoreType) } /** The type of the configured score */ - fun scoreType(scoreType: JsonField) = apply { body.scoreType(scoreType) } + fun scoreType(scoreType: JsonField) = apply { body.scoreType(scoreType) } /** For categorical-type project scores, the list of all categories */ fun categories(categories: Categories?) = apply { body.categories(categories) } @@ -538,139 +539,6 @@ private constructor( ) } - /** The type of the configured score */ - class ScoreType @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 SLIDER = of("slider") - - @JvmField val CATEGORICAL = of("categorical") - - @JvmField val WEIGHTED = of("weighted") - - @JvmField val MINIMUM = of("minimum") - - @JvmField val MAXIMUM = of("maximum") - - @JvmField val ONLINE = of("online") - - @JvmField val FREE_FORM = of("free-form") - - @JvmStatic fun of(value: String) = ScoreType(JsonField.of(value)) - } - - /** An enum containing [ScoreType]'s known values. */ - enum class Known { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - MAXIMUM, - ONLINE, - FREE_FORM, - } - - /** - * An enum containing [ScoreType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ScoreType] 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 { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - MAXIMUM, - ONLINE, - FREE_FORM, - /** - * An enum member indicating that [ScoreType] 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) { - SLIDER -> Value.SLIDER - CATEGORICAL -> Value.CATEGORICAL - WEIGHTED -> Value.WEIGHTED - MINIMUM -> Value.MINIMUM - MAXIMUM -> Value.MAXIMUM - ONLINE -> Value.ONLINE - FREE_FORM -> Value.FREE_FORM - 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 BraintrustInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - SLIDER -> Known.SLIDER - CATEGORICAL -> Known.CATEGORICAL - WEIGHTED -> Known.WEIGHTED - MINIMUM -> Known.MINIMUM - MAXIMUM -> Known.MAXIMUM - ONLINE -> Known.ONLINE - FREE_FORM -> Known.FREE_FORM - else -> throw BraintrustInvalidDataException("Unknown ScoreType: $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 BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - /** For categorical-type project scores, the list of all categories */ @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListParams.kt index 2899a11f..18c456c6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListParams.kt @@ -4,8 +4,6 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.BaseDeserializer import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.Params @@ -13,7 +11,6 @@ import com.braintrustdata.api.core.getOrThrow import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.JsonNode @@ -233,10 +230,10 @@ private constructor( fun scoreType(scoreType: Optional) = scoreType(scoreType.getOrNull()) /** The type of the configured score */ - fun scoreType(project: ScoreType.ProjectScoreType) = scoreType(ScoreType.ofProject(project)) + fun scoreType(project: ProjectScoreType) = scoreType(ScoreType.ofProject(project)) /** The type of the configured score */ - fun scoreTypeOfProjectScoreTypes(projectScoreTypes: List) = + fun scoreTypeOfProjectScoreTypes(projectScoreTypes: List) = scoreType(ScoreType.ofProjectScoreTypes(projectScoreTypes)) /** @@ -611,280 +608,6 @@ private constructor( } } } - - /** The type of the configured score */ - class ProjectScoreType - @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 SLIDER = of("slider") - - @JvmField val CATEGORICAL = of("categorical") - - @JvmField val WEIGHTED = of("weighted") - - @JvmField val MINIMUM = of("minimum") - - @JvmField val MAXIMUM = of("maximum") - - @JvmField val ONLINE = of("online") - - @JvmField val FREE_FORM = of("free-form") - - @JvmStatic fun of(value: String) = ProjectScoreType(JsonField.of(value)) - } - - /** An enum containing [ProjectScoreType]'s known values. */ - enum class Known { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - MAXIMUM, - ONLINE, - FREE_FORM, - } - - /** - * An enum containing [ProjectScoreType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ProjectScoreType] 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 { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - MAXIMUM, - ONLINE, - FREE_FORM, - /** - * An enum member indicating that [ProjectScoreType] 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) { - SLIDER -> Value.SLIDER - CATEGORICAL -> Value.CATEGORICAL - WEIGHTED -> Value.WEIGHTED - MINIMUM -> Value.MINIMUM - MAXIMUM -> Value.MAXIMUM - ONLINE -> Value.ONLINE - FREE_FORM -> Value.FREE_FORM - 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 BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - SLIDER -> Known.SLIDER - CATEGORICAL -> Known.CATEGORICAL - WEIGHTED -> Known.WEIGHTED - MINIMUM -> Known.MINIMUM - MAXIMUM -> Known.MAXIMUM - ONLINE -> Known.ONLINE - FREE_FORM -> Known.FREE_FORM - else -> throw BraintrustInvalidDataException("Unknown ProjectScoreType: $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 BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectScoreType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** The type of the configured score */ - class ProjectScoreType - @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 SLIDER = of("slider") - - @JvmField val CATEGORICAL = of("categorical") - - @JvmField val WEIGHTED = of("weighted") - - @JvmField val MINIMUM = of("minimum") - - @JvmField val MAXIMUM = of("maximum") - - @JvmField val ONLINE = of("online") - - @JvmField val FREE_FORM = of("free-form") - - @JvmStatic fun of(value: String) = ProjectScoreType(JsonField.of(value)) - } - - /** An enum containing [ProjectScoreType]'s known values. */ - enum class Known { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - MAXIMUM, - ONLINE, - FREE_FORM, - } - - /** - * An enum containing [ProjectScoreType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ProjectScoreType] 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 { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - MAXIMUM, - ONLINE, - FREE_FORM, - /** - * An enum member indicating that [ProjectScoreType] 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) { - SLIDER -> Value.SLIDER - CATEGORICAL -> Value.CATEGORICAL - WEIGHTED -> Value.WEIGHTED - MINIMUM -> Value.MINIMUM - MAXIMUM -> Value.MAXIMUM - ONLINE -> Value.ONLINE - FREE_FORM -> Value.FREE_FORM - 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 BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - SLIDER -> Known.SLIDER - CATEGORICAL -> Known.CATEGORICAL - WEIGHTED -> Known.WEIGHTED - MINIMUM -> Known.MINIMUM - MAXIMUM -> Known.MAXIMUM - ONLINE -> Known.ONLINE - FREE_FORM -> Known.FREE_FORM - else -> throw BraintrustInvalidDataException("Unknown ProjectScoreType: $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 BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectScoreType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParams.kt index c4ef2e87..3c35ed4a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParams.kt @@ -4,7 +4,6 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.BaseDeserializer import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing @@ -52,7 +51,7 @@ private constructor( fun projectId(): String = body.projectId() /** The type of the configured score */ - fun scoreType(): ScoreType = body.scoreType() + fun scoreType(): ProjectScoreType = body.scoreType() /** For categorical-type project scores, the list of all categories */ fun categories(): Optional = body.categories() @@ -69,7 +68,7 @@ private constructor( fun _projectId(): JsonField = body._projectId() /** The type of the configured score */ - fun _scoreType(): JsonField = body._scoreType() + fun _scoreType(): JsonField = body._scoreType() /** For categorical-type project scores, the list of all categories */ fun _categories(): JsonField = body._categories() @@ -104,7 +103,7 @@ private constructor( private val projectId: JsonField = JsonMissing.of(), @JsonProperty("score_type") @ExcludeMissing - private val scoreType: JsonField = JsonMissing.of(), + private val scoreType: JsonField = JsonMissing.of(), @JsonProperty("categories") @ExcludeMissing private val categories: JsonField = JsonMissing.of(), @@ -125,7 +124,7 @@ private constructor( fun projectId(): String = projectId.getRequired("project_id") /** The type of the configured score */ - fun scoreType(): ScoreType = scoreType.getRequired("score_type") + fun scoreType(): ProjectScoreType = scoreType.getRequired("score_type") /** For categorical-type project scores, the list of all categories */ fun categories(): Optional = @@ -147,7 +146,7 @@ private constructor( /** The type of the configured score */ @JsonProperty("score_type") @ExcludeMissing - fun _scoreType(): JsonField = scoreType + fun _scoreType(): JsonField = scoreType /** For categorical-type project scores, the list of all categories */ @JsonProperty("categories") @@ -205,7 +204,7 @@ private constructor( private var name: JsonField? = null private var projectId: JsonField? = null - private var scoreType: JsonField? = null + private var scoreType: JsonField? = null private var categories: JsonField = JsonMissing.of() private var config: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() @@ -235,10 +234,12 @@ private constructor( fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** The type of the configured score */ - fun scoreType(scoreType: ScoreType) = scoreType(JsonField.of(scoreType)) + fun scoreType(scoreType: ProjectScoreType) = scoreType(JsonField.of(scoreType)) /** The type of the configured score */ - fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: JsonField) = apply { + this.scoreType = scoreType + } /** For categorical-type project scores, the list of all categories */ fun categories(categories: Categories?) = categories(JsonField.ofNullable(categories)) @@ -374,10 +375,10 @@ private constructor( fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** The type of the configured score */ - fun scoreType(scoreType: ScoreType) = apply { body.scoreType(scoreType) } + fun scoreType(scoreType: ProjectScoreType) = apply { body.scoreType(scoreType) } /** The type of the configured score */ - fun scoreType(scoreType: JsonField) = apply { body.scoreType(scoreType) } + fun scoreType(scoreType: JsonField) = apply { body.scoreType(scoreType) } /** For categorical-type project scores, the list of all categories */ fun categories(categories: Categories?) = apply { body.categories(categories) } @@ -539,139 +540,6 @@ private constructor( ) } - /** The type of the configured score */ - class ScoreType @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 SLIDER = of("slider") - - @JvmField val CATEGORICAL = of("categorical") - - @JvmField val WEIGHTED = of("weighted") - - @JvmField val MINIMUM = of("minimum") - - @JvmField val MAXIMUM = of("maximum") - - @JvmField val ONLINE = of("online") - - @JvmField val FREE_FORM = of("free-form") - - @JvmStatic fun of(value: String) = ScoreType(JsonField.of(value)) - } - - /** An enum containing [ScoreType]'s known values. */ - enum class Known { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - MAXIMUM, - ONLINE, - FREE_FORM, - } - - /** - * An enum containing [ScoreType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ScoreType] 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 { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - MAXIMUM, - ONLINE, - FREE_FORM, - /** - * An enum member indicating that [ScoreType] 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) { - SLIDER -> Value.SLIDER - CATEGORICAL -> Value.CATEGORICAL - WEIGHTED -> Value.WEIGHTED - MINIMUM -> Value.MINIMUM - MAXIMUM -> Value.MAXIMUM - ONLINE -> Value.ONLINE - FREE_FORM -> Value.FREE_FORM - 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 BraintrustInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - SLIDER -> Known.SLIDER - CATEGORICAL -> Known.CATEGORICAL - WEIGHTED -> Known.WEIGHTED - MINIMUM -> Known.MINIMUM - MAXIMUM -> Known.MAXIMUM - ONLINE -> Known.ONLINE - FREE_FORM -> Known.FREE_FORM - else -> throw BraintrustInvalidDataException("Unknown ScoreType: $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 BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - /** For categorical-type project scores, the list of all categories */ @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreType.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreType.kt new file mode 100644 index 00000000..59dff6a1 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreType.kt @@ -0,0 +1,139 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator + +/** The type of the configured score */ +class ProjectScoreType @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 SLIDER = of("slider") + + @JvmField val CATEGORICAL = of("categorical") + + @JvmField val WEIGHTED = of("weighted") + + @JvmField val MINIMUM = of("minimum") + + @JvmField val MAXIMUM = of("maximum") + + @JvmField val ONLINE = of("online") + + @JvmField val FREE_FORM = of("free-form") + + @JvmStatic fun of(value: String) = ProjectScoreType(JsonField.of(value)) + } + + /** An enum containing [ProjectScoreType]'s known values. */ + enum class Known { + SLIDER, + CATEGORICAL, + WEIGHTED, + MINIMUM, + MAXIMUM, + ONLINE, + FREE_FORM, + } + + /** + * An enum containing [ProjectScoreType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ProjectScoreType] 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 { + SLIDER, + CATEGORICAL, + WEIGHTED, + MINIMUM, + MAXIMUM, + ONLINE, + FREE_FORM, + /** + * An enum member indicating that [ProjectScoreType] 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) { + SLIDER -> Value.SLIDER + CATEGORICAL -> Value.CATEGORICAL + WEIGHTED -> Value.WEIGHTED + MINIMUM -> Value.MINIMUM + MAXIMUM -> Value.MAXIMUM + ONLINE -> Value.ONLINE + FREE_FORM -> Value.FREE_FORM + 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 BraintrustInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SLIDER -> Known.SLIDER + CATEGORICAL -> Known.CATEGORICAL + WEIGHTED -> Known.WEIGHTED + MINIMUM -> Known.MINIMUM + MAXIMUM -> Known.MAXIMUM + ONLINE -> Known.ONLINE + FREE_FORM -> Known.FREE_FORM + else -> throw BraintrustInvalidDataException("Unknown ProjectScoreType: $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 BraintrustInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectScoreType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParams.kt index 6813268c..402cb014 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParams.kt @@ -4,7 +4,6 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.BaseDeserializer import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing @@ -61,7 +60,7 @@ private constructor( fun name(): Optional = body.name() /** The type of the configured score */ - fun scoreType(): Optional = body.scoreType() + fun scoreType(): Optional = body.scoreType() /** For categorical-type project scores, the list of all categories */ fun _categories(): JsonField = body._categories() @@ -75,7 +74,7 @@ private constructor( fun _name(): JsonField = body._name() /** The type of the configured score */ - fun _scoreType(): JsonField = body._scoreType() + fun _scoreType(): JsonField = body._scoreType() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -115,7 +114,7 @@ private constructor( private val name: JsonField = JsonMissing.of(), @JsonProperty("score_type") @ExcludeMissing - private val scoreType: JsonField = JsonMissing.of(), + private val scoreType: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -135,7 +134,7 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** The type of the configured score */ - fun scoreType(): Optional = + fun scoreType(): Optional = Optional.ofNullable(scoreType.getNullable("score_type")) /** For categorical-type project scores, the list of all categories */ @@ -158,7 +157,7 @@ private constructor( /** The type of the configured score */ @JsonProperty("score_type") @ExcludeMissing - fun _scoreType(): JsonField = scoreType + fun _scoreType(): JsonField = scoreType @JsonAnyGetter @ExcludeMissing @@ -194,7 +193,7 @@ private constructor( private var config: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var scoreType: JsonField = JsonMissing.of() + private var scoreType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -257,13 +256,15 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** The type of the configured score */ - fun scoreType(scoreType: ScoreType?) = scoreType(JsonField.ofNullable(scoreType)) + fun scoreType(scoreType: ProjectScoreType?) = scoreType(JsonField.ofNullable(scoreType)) /** The type of the configured score */ - fun scoreType(scoreType: Optional) = scoreType(scoreType.getOrNull()) + fun scoreType(scoreType: Optional) = scoreType(scoreType.getOrNull()) /** The type of the configured score */ - fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: JsonField) = apply { + this.scoreType = scoreType + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -393,13 +394,13 @@ private constructor( fun name(name: JsonField) = apply { body.name(name) } /** The type of the configured score */ - fun scoreType(scoreType: ScoreType?) = apply { body.scoreType(scoreType) } + fun scoreType(scoreType: ProjectScoreType?) = apply { body.scoreType(scoreType) } /** The type of the configured score */ - fun scoreType(scoreType: Optional) = scoreType(scoreType.getOrNull()) + fun scoreType(scoreType: Optional) = scoreType(scoreType.getOrNull()) /** The type of the configured score */ - fun scoreType(scoreType: JsonField) = apply { body.scoreType(scoreType) } + fun scoreType(scoreType: JsonField) = apply { body.scoreType(scoreType) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) @@ -782,139 +783,6 @@ private constructor( } } - /** The type of the configured score */ - class ScoreType @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 SLIDER = of("slider") - - @JvmField val CATEGORICAL = of("categorical") - - @JvmField val WEIGHTED = of("weighted") - - @JvmField val MINIMUM = of("minimum") - - @JvmField val MAXIMUM = of("maximum") - - @JvmField val ONLINE = of("online") - - @JvmField val FREE_FORM = of("free-form") - - @JvmStatic fun of(value: String) = ScoreType(JsonField.of(value)) - } - - /** An enum containing [ScoreType]'s known values. */ - enum class Known { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - MAXIMUM, - ONLINE, - FREE_FORM, - } - - /** - * An enum containing [ScoreType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ScoreType] 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 { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - MAXIMUM, - ONLINE, - FREE_FORM, - /** - * An enum member indicating that [ScoreType] 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) { - SLIDER -> Value.SLIDER - CATEGORICAL -> Value.CATEGORICAL - WEIGHTED -> Value.WEIGHTED - MINIMUM -> Value.MINIMUM - MAXIMUM -> Value.MAXIMUM - ONLINE -> Value.ONLINE - FREE_FORM -> Value.FREE_FORM - 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 BraintrustInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - SLIDER -> Known.SLIDER - CATEGORICAL -> Known.CATEGORICAL - WEIGHTED -> Known.WEIGHTED - MINIMUM -> Known.MINIMUM - MAXIMUM -> Known.MAXIMUM - ONLINE -> Known.ONLINE - FREE_FORM -> Known.FREE_FORM - else -> throw BraintrustInvalidDataException("Unknown ScoreType: $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 BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Role.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Role.kt index 3af60e1a..73603212 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Role.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Role.kt @@ -2,7 +2,6 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing @@ -12,7 +11,6 @@ import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -391,7 +389,7 @@ private constructor( private val permission: JsonField = JsonMissing.of(), @JsonProperty("restrict_object_type") @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), + private val restrictObjectType: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -404,7 +402,7 @@ private constructor( fun permission(): Permission = permission.getRequired("permission") /** The object type that the ACL applies to */ - fun restrictObjectType(): Optional = + fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** @@ -419,7 +417,7 @@ private constructor( /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") @ExcludeMissing - fun _restrictObjectType(): JsonField = restrictObjectType + fun _restrictObjectType(): JsonField = restrictObjectType @JsonAnyGetter @ExcludeMissing @@ -456,7 +454,7 @@ private constructor( class Builder internal constructor() { private var permission: JsonField? = null - private var restrictObjectType: JsonField = JsonMissing.of() + private var restrictObjectType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -485,15 +483,15 @@ private constructor( } /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + fun restrictObjectType(restrictObjectType: AclObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: Optional) = + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { + fun restrictObjectType(restrictObjectType: JsonField) = apply { this.restrictObjectType = restrictObjectType } @@ -524,314 +522,6 @@ private constructor( ) } - /** - * Each permission permits a certain type of operation on an object in the system - * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles - */ - class Permission @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 CREATE = of("create") - - @JvmField val READ = of("read") - - @JvmField val UPDATE = of("update") - - @JvmField val DELETE = of("delete") - - @JvmField val CREATE_ACLS = of("create_acls") - - @JvmField val READ_ACLS = of("read_acls") - - @JvmField val UPDATE_ACLS = of("update_acls") - - @JvmField val DELETE_ACLS = of("delete_acls") - - @JvmStatic fun of(value: String) = Permission(JsonField.of(value)) - } - - /** An enum containing [Permission]'s known values. */ - enum class Known { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - } - - /** - * An enum containing [Permission]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Permission] 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 { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - /** - * An enum member indicating that [Permission] 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) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - 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 BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $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 BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** The object type that the ACL applies to */ - class RestrictObjectType - @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 = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = RestrictObjectType(JsonField.of(value)) - } - - /** An enum containing [RestrictObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [RestrictObjectType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [RestrictObjectType] 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, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [RestrictObjectType] 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 -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - 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 BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleCreateParams.kt index 9e08f6e4..28abbef7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleCreateParams.kt @@ -2,7 +2,6 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing @@ -15,7 +14,6 @@ import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -626,7 +624,7 @@ private constructor( private val permission: JsonField = JsonMissing.of(), @JsonProperty("restrict_object_type") @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), + private val restrictObjectType: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -639,7 +637,7 @@ private constructor( fun permission(): Permission = permission.getRequired("permission") /** The object type that the ACL applies to */ - fun restrictObjectType(): Optional = + fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** @@ -654,7 +652,7 @@ private constructor( /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") @ExcludeMissing - fun _restrictObjectType(): JsonField = restrictObjectType + fun _restrictObjectType(): JsonField = restrictObjectType @JsonAnyGetter @ExcludeMissing @@ -691,7 +689,7 @@ private constructor( class Builder internal constructor() { private var permission: JsonField? = null - private var restrictObjectType: JsonField = JsonMissing.of() + private var restrictObjectType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -720,15 +718,15 @@ private constructor( } /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + fun restrictObjectType(restrictObjectType: AclObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: Optional) = + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { + fun restrictObjectType(restrictObjectType: JsonField) = apply { this.restrictObjectType = restrictObjectType } @@ -759,314 +757,6 @@ private constructor( ) } - /** - * Each permission permits a certain type of operation on an object in the system - * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles - */ - class Permission @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 CREATE = of("create") - - @JvmField val READ = of("read") - - @JvmField val UPDATE = of("update") - - @JvmField val DELETE = of("delete") - - @JvmField val CREATE_ACLS = of("create_acls") - - @JvmField val READ_ACLS = of("read_acls") - - @JvmField val UPDATE_ACLS = of("update_acls") - - @JvmField val DELETE_ACLS = of("delete_acls") - - @JvmStatic fun of(value: String) = Permission(JsonField.of(value)) - } - - /** An enum containing [Permission]'s known values. */ - enum class Known { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - } - - /** - * An enum containing [Permission]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Permission] 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 { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - /** - * An enum member indicating that [Permission] 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) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - 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 BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $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 BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** The object type that the ACL applies to */ - class RestrictObjectType - @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 = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = RestrictObjectType(JsonField.of(value)) - } - - /** An enum containing [RestrictObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [RestrictObjectType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [RestrictObjectType] 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, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [RestrictObjectType] 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 -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - 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 BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleReplaceParams.kt index 8b9e78ad..cfb06936 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleReplaceParams.kt @@ -2,7 +2,6 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing @@ -15,7 +14,6 @@ import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -630,7 +628,7 @@ private constructor( private val permission: JsonField = JsonMissing.of(), @JsonProperty("restrict_object_type") @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), + private val restrictObjectType: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -643,7 +641,7 @@ private constructor( fun permission(): Permission = permission.getRequired("permission") /** The object type that the ACL applies to */ - fun restrictObjectType(): Optional = + fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** @@ -658,7 +656,7 @@ private constructor( /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") @ExcludeMissing - fun _restrictObjectType(): JsonField = restrictObjectType + fun _restrictObjectType(): JsonField = restrictObjectType @JsonAnyGetter @ExcludeMissing @@ -695,7 +693,7 @@ private constructor( class Builder internal constructor() { private var permission: JsonField? = null - private var restrictObjectType: JsonField = JsonMissing.of() + private var restrictObjectType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -724,15 +722,15 @@ private constructor( } /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + fun restrictObjectType(restrictObjectType: AclObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: Optional) = + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { + fun restrictObjectType(restrictObjectType: JsonField) = apply { this.restrictObjectType = restrictObjectType } @@ -763,314 +761,6 @@ private constructor( ) } - /** - * Each permission permits a certain type of operation on an object in the system - * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles - */ - class Permission @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 CREATE = of("create") - - @JvmField val READ = of("read") - - @JvmField val UPDATE = of("update") - - @JvmField val DELETE = of("delete") - - @JvmField val CREATE_ACLS = of("create_acls") - - @JvmField val READ_ACLS = of("read_acls") - - @JvmField val UPDATE_ACLS = of("update_acls") - - @JvmField val DELETE_ACLS = of("delete_acls") - - @JvmStatic fun of(value: String) = Permission(JsonField.of(value)) - } - - /** An enum containing [Permission]'s known values. */ - enum class Known { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - } - - /** - * An enum containing [Permission]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Permission] 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 { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - /** - * An enum member indicating that [Permission] 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) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - 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 BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $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 BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** The object type that the ACL applies to */ - class RestrictObjectType - @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 = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = RestrictObjectType(JsonField.of(value)) - } - - /** An enum containing [RestrictObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [RestrictObjectType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [RestrictObjectType] 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, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [RestrictObjectType] 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 -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - 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 BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleUpdateParams.kt index ac99a23e..5c41fd74 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleUpdateParams.kt @@ -2,7 +2,6 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing @@ -15,7 +14,6 @@ import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -649,7 +647,7 @@ private constructor( private val permission: JsonField = JsonMissing.of(), @JsonProperty("restrict_object_type") @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), + private val restrictObjectType: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -662,7 +660,7 @@ private constructor( fun permission(): Permission = permission.getRequired("permission") /** The object type that the ACL applies to */ - fun restrictObjectType(): Optional = + fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** @@ -677,7 +675,7 @@ private constructor( /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") @ExcludeMissing - fun _restrictObjectType(): JsonField = restrictObjectType + fun _restrictObjectType(): JsonField = restrictObjectType @JsonAnyGetter @ExcludeMissing @@ -714,7 +712,7 @@ private constructor( class Builder internal constructor() { private var permission: JsonField? = null - private var restrictObjectType: JsonField = JsonMissing.of() + private var restrictObjectType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -743,15 +741,15 @@ private constructor( } /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + fun restrictObjectType(restrictObjectType: AclObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: Optional) = + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { + fun restrictObjectType(restrictObjectType: JsonField) = apply { this.restrictObjectType = restrictObjectType } @@ -782,314 +780,6 @@ private constructor( ) } - /** - * Each permission permits a certain type of operation on an object in the system - * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles - */ - class Permission @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 CREATE = of("create") - - @JvmField val READ = of("read") - - @JvmField val UPDATE = of("update") - - @JvmField val DELETE = of("delete") - - @JvmField val CREATE_ACLS = of("create_acls") - - @JvmField val READ_ACLS = of("read_acls") - - @JvmField val UPDATE_ACLS = of("update_acls") - - @JvmField val DELETE_ACLS = of("delete_acls") - - @JvmStatic fun of(value: String) = Permission(JsonField.of(value)) - } - - /** An enum containing [Permission]'s known values. */ - enum class Known { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - } - - /** - * An enum containing [Permission]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Permission] 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 { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - /** - * An enum member indicating that [Permission] 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) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - 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 BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $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 BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** The object type that the ACL applies to */ - class RestrictObjectType - @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 = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = RestrictObjectType(JsonField.of(value)) - } - - /** An enum containing [RestrictObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [RestrictObjectType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [RestrictObjectType] 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, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [RestrictObjectType] 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 -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - 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 BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1117,7 +807,7 @@ private constructor( private val permission: JsonField = JsonMissing.of(), @JsonProperty("restrict_object_type") @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), + private val restrictObjectType: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -1130,7 +820,7 @@ private constructor( fun permission(): Permission = permission.getRequired("permission") /** The object type that the ACL applies to */ - fun restrictObjectType(): Optional = + fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** @@ -1145,7 +835,7 @@ private constructor( /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") @ExcludeMissing - fun _restrictObjectType(): JsonField = restrictObjectType + fun _restrictObjectType(): JsonField = restrictObjectType @JsonAnyGetter @ExcludeMissing @@ -1182,7 +872,7 @@ private constructor( class Builder internal constructor() { private var permission: JsonField? = null - private var restrictObjectType: JsonField = JsonMissing.of() + private var restrictObjectType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1211,15 +901,15 @@ private constructor( } /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + fun restrictObjectType(restrictObjectType: AclObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: Optional) = + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { + fun restrictObjectType(restrictObjectType: JsonField) = apply { this.restrictObjectType = restrictObjectType } @@ -1250,314 +940,6 @@ private constructor( ) } - /** - * Each permission permits a certain type of operation on an object in the system - * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles - */ - class Permission @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 CREATE = of("create") - - @JvmField val READ = of("read") - - @JvmField val UPDATE = of("update") - - @JvmField val DELETE = of("delete") - - @JvmField val CREATE_ACLS = of("create_acls") - - @JvmField val READ_ACLS = of("read_acls") - - @JvmField val UPDATE_ACLS = of("update_acls") - - @JvmField val DELETE_ACLS = of("delete_acls") - - @JvmStatic fun of(value: String) = Permission(JsonField.of(value)) - } - - /** An enum containing [Permission]'s known values. */ - enum class Known { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - } - - /** - * An enum containing [Permission]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Permission] 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 { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - /** - * An enum member indicating that [Permission] 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) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - 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 BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $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 BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** The object type that the ACL applies to */ - class RestrictObjectType - @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 = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = RestrictObjectType(JsonField.of(value)) - } - - /** An enum containing [RestrictObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [RestrictObjectType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [RestrictObjectType] 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, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [RestrictObjectType] 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 -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - 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 BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanAttributes.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanAttributes.kt index c7177997..4f5c77c1 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanAttributes.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanAttributes.kt @@ -2,7 +2,6 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing @@ -10,7 +9,6 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -25,7 +23,7 @@ class SpanAttributes @JsonCreator private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -33,13 +31,13 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** Type of the span, for display purposes only */ - fun type(): Optional = Optional.ofNullable(type.getNullable("type")) + fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** Name of the span, for display purposes only */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Type of the span, for display purposes only */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -69,7 +67,7 @@ private constructor( class Builder internal constructor() { private var name: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -89,13 +87,13 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** Type of the span, for display purposes only */ - fun type(type: Type?) = type(JsonField.ofNullable(type)) + fun type(type: SpanType?) = type(JsonField.ofNullable(type)) /** Type of the span, for display purposes only */ - fun type(type: Optional) = type(type.getOrNull()) + fun type(type: Optional) = type(type.getOrNull()) /** Type of the span, for display purposes only */ - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -119,131 +117,6 @@ private constructor( fun build(): SpanAttributes = SpanAttributes(name, type, additionalProperties.toImmutable()) } - /** Type of the span, for display purposes only */ - 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 LLM = of("llm") - - @JvmField val SCORE = of("score") - - @JvmField val FUNCTION = of("function") - - @JvmField val EVAL = of("eval") - - @JvmField val TASK = of("task") - - @JvmField val TOOL = of("tool") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - } - - /** - * 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 { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - /** 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) { - LLM -> Value.LLM - SCORE -> Value.SCORE - FUNCTION -> Value.FUNCTION - EVAL -> Value.EVAL - TASK -> Value.TASK - TOOL -> Value.TOOL - 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 BraintrustInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - LLM -> Known.LLM - SCORE -> Known.SCORE - FUNCTION -> Known.FUNCTION - EVAL -> Known.EVAL - TASK -> Known.TASK - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("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 BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanType.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanType.kt new file mode 100644 index 00000000..2c558123 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanType.kt @@ -0,0 +1,130 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator + +/** Type of the span, for display purposes only */ +class SpanType @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 LLM = of("llm") + + @JvmField val SCORE = of("score") + + @JvmField val FUNCTION = of("function") + + @JvmField val EVAL = of("eval") + + @JvmField val TASK = of("task") + + @JvmField val TOOL = of("tool") + + @JvmStatic fun of(value: String) = SpanType(JsonField.of(value)) + } + + /** An enum containing [SpanType]'s known values. */ + enum class Known { + LLM, + SCORE, + FUNCTION, + EVAL, + TASK, + TOOL, + } + + /** + * An enum containing [SpanType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SpanType] 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 { + LLM, + SCORE, + FUNCTION, + EVAL, + TASK, + TOOL, + /** An enum member indicating that [SpanType] 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) { + LLM -> Value.LLM + SCORE -> Value.SCORE + FUNCTION -> Value.FUNCTION + EVAL -> Value.EVAL + TASK -> Value.TASK + TOOL -> Value.TOOL + 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 BraintrustInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LLM -> Known.LLM + SCORE -> Known.SCORE + FUNCTION -> Known.FUNCTION + EVAL -> Known.EVAL + TASK -> Known.TASK + TOOL -> Known.TOOL + else -> throw BraintrustInvalidDataException("Unknown SpanType: $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 BraintrustInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/View.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/View.kt index 58a05213..031f9f92 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/View.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/View.kt @@ -32,7 +32,7 @@ private constructor( private val objectId: JsonField = JsonMissing.of(), @JsonProperty("object_type") @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), + private val objectType: JsonField = JsonMissing.of(), @JsonProperty("view_type") @ExcludeMissing private val viewType: JsonField = JsonMissing.of(), @@ -64,7 +64,7 @@ private constructor( fun objectId(): String = objectId.getRequired("object_id") /** The object type that the ACL applies to */ - fun objectType(): ObjectType = objectType.getRequired("object_type") + fun objectType(): AclObjectType = objectType.getRequired("object_type") /** Type of table that the view corresponds to. */ fun viewType(): Optional = Optional.ofNullable(viewType.getNullable("view_type")) @@ -97,7 +97,7 @@ private constructor( /** The object type that the ACL applies to */ @JsonProperty("object_type") @ExcludeMissing - fun _objectType(): JsonField = objectType + fun _objectType(): JsonField = objectType /** Type of table that the view corresponds to. */ @JsonProperty("view_type") @ExcludeMissing fun _viewType(): JsonField = viewType @@ -168,7 +168,7 @@ private constructor( private var id: JsonField? = null private var name: JsonField? = null private var objectId: JsonField? = null - private var objectType: JsonField? = null + private var objectType: JsonField? = null private var viewType: JsonField? = null private var created: JsonField = JsonMissing.of() private var deletedAt: JsonField = JsonMissing.of() @@ -211,10 +211,12 @@ private constructor( fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + fun objectType(objectType: AclObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { this.objectType = objectType } + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } /** Type of table that the view corresponds to. */ fun viewType(viewType: ViewType?) = viewType(JsonField.ofNullable(viewType)) @@ -305,163 +307,6 @@ private constructor( ) } - /** The object type that the ACL applies to */ - class ObjectType @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 = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - /** An enum containing [ObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ObjectType] 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, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [ObjectType] 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 -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - 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 BraintrustInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - /** Type of table that the view corresponds to. */ class ViewType @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewCreateParams.kt index 7d07ab02..c9846755 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewCreateParams.kt @@ -42,7 +42,7 @@ private constructor( fun objectId(): String = body.objectId() /** The object type that the ACL applies to */ - fun objectType(): ObjectType = body.objectType() + fun objectType(): AclObjectType = body.objectType() /** Type of table that the view corresponds to. */ fun viewType(): Optional = body.viewType() @@ -66,7 +66,7 @@ private constructor( fun _objectId(): JsonField = body._objectId() /** The object type that the ACL applies to */ - fun _objectType(): JsonField = body._objectType() + fun _objectType(): JsonField = body._objectType() /** Type of table that the view corresponds to. */ fun _viewType(): JsonField = body._viewType() @@ -107,7 +107,7 @@ private constructor( private val objectId: JsonField = JsonMissing.of(), @JsonProperty("object_type") @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), + private val objectType: JsonField = JsonMissing.of(), @JsonProperty("view_type") @ExcludeMissing private val viewType: JsonField = JsonMissing.of(), @@ -134,7 +134,7 @@ private constructor( fun objectId(): String = objectId.getRequired("object_id") /** The object type that the ACL applies to */ - fun objectType(): ObjectType = objectType.getRequired("object_type") + fun objectType(): AclObjectType = objectType.getRequired("object_type") /** Type of table that the view corresponds to. */ fun viewType(): Optional = Optional.ofNullable(viewType.getNullable("view_type")) @@ -161,7 +161,7 @@ private constructor( /** The object type that the ACL applies to */ @JsonProperty("object_type") @ExcludeMissing - fun _objectType(): JsonField = objectType + fun _objectType(): JsonField = objectType /** Type of table that the view corresponds to. */ @JsonProperty("view_type") @ExcludeMissing fun _viewType(): JsonField = viewType @@ -225,7 +225,7 @@ private constructor( private var name: JsonField? = null private var objectId: JsonField? = null - private var objectType: JsonField? = null + private var objectType: JsonField? = null private var viewType: JsonField? = null private var deletedAt: JsonField = JsonMissing.of() private var options: JsonField = JsonMissing.of() @@ -259,10 +259,10 @@ private constructor( fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + fun objectType(objectType: AclObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { + fun objectType(objectType: JsonField) = apply { this.objectType = objectType } @@ -410,10 +410,10 @@ private constructor( fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { body.objectType(objectType) } + fun objectType(objectType: AclObjectType) = apply { body.objectType(objectType) } /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } + fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } /** Type of table that the view corresponds to. */ fun viewType(viewType: ViewType?) = apply { body.viewType(viewType) } @@ -581,163 +581,6 @@ private constructor( ViewCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) } - /** The object type that the ACL applies to */ - class ObjectType @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 = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - /** An enum containing [ObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ObjectType] 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, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [ObjectType] 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 -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - 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 BraintrustInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - /** Type of table that the view corresponds to. */ class ViewType @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDeleteParams.kt index fa0585c3..859f6c54 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDeleteParams.kt @@ -2,7 +2,6 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing @@ -14,7 +13,6 @@ import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -37,13 +35,13 @@ private constructor( fun objectId(): String = body.objectId() /** The object type that the ACL applies to */ - fun objectType(): ObjectType = body.objectType() + fun objectType(): AclObjectType = body.objectType() /** The id of the object the view applies to */ fun _objectId(): JsonField = body._objectId() /** The object type that the ACL applies to */ - fun _objectType(): JsonField = body._objectType() + fun _objectType(): JsonField = body._objectType() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -73,7 +71,7 @@ private constructor( private val objectId: JsonField = JsonMissing.of(), @JsonProperty("object_type") @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), + private val objectType: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -82,7 +80,7 @@ private constructor( fun objectId(): String = objectId.getRequired("object_id") /** The object type that the ACL applies to */ - fun objectType(): ObjectType = objectType.getRequired("object_type") + fun objectType(): AclObjectType = objectType.getRequired("object_type") /** The id of the object the view applies to */ @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId @@ -90,7 +88,7 @@ private constructor( /** The object type that the ACL applies to */ @JsonProperty("object_type") @ExcludeMissing - fun _objectType(): JsonField = objectType + fun _objectType(): JsonField = objectType @JsonAnyGetter @ExcludeMissing @@ -128,7 +126,7 @@ private constructor( class Builder internal constructor() { private var objectId: JsonField? = null - private var objectType: JsonField? = null + private var objectType: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -145,10 +143,10 @@ private constructor( fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + fun objectType(objectType: AclObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { + fun objectType(objectType: JsonField) = apply { this.objectType = objectType } @@ -241,10 +239,10 @@ private constructor( fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { body.objectType(objectType) } + fun objectType(objectType: AclObjectType) = apply { body.objectType(objectType) } /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } + fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) @@ -372,163 +370,6 @@ private constructor( ) } - /** The object type that the ACL applies to */ - class ObjectType @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 = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - /** An enum containing [ObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ObjectType] 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, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [ObjectType] 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 -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - 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 BraintrustInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListParams.kt index dd2f1d06..f7438d8e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListParams.kt @@ -4,8 +4,6 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.BaseDeserializer import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.Params @@ -14,7 +12,6 @@ import com.braintrustdata.api.core.getOrThrow import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.JsonNode @@ -33,7 +30,7 @@ import kotlin.jvm.optionals.getOrNull class ViewListParams private constructor( private val objectId: String, - private val objectType: ObjectType, + private val objectType: AclObjectType, private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -48,7 +45,7 @@ private constructor( fun objectId(): String = objectId /** The object type that the ACL applies to */ - fun objectType(): ObjectType = objectType + fun objectType(): AclObjectType = objectType /** * Pagination cursor id. @@ -124,7 +121,7 @@ private constructor( class Builder internal constructor() { private var objectId: String? = null - private var objectType: ObjectType? = null + private var objectType: AclObjectType? = null private var endingBefore: String? = null private var ids: Ids? = null private var limit: Long? = null @@ -152,7 +149,7 @@ private constructor( fun objectId(objectId: String) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: AclObjectType) = apply { this.objectType = objectType } /** * Pagination cursor id. @@ -349,163 +346,6 @@ private constructor( ) } - /** The object type that the ACL applies to */ - class ObjectType @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 = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - /** An enum containing [ObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ObjectType] 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, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [ObjectType] 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 -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - 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 BraintrustInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - /** * Filter search results to a particular set of object IDs. To specify a list of IDs, include * the query param multiple times @@ -620,161 +460,6 @@ private constructor( } } - /** Type of table that the view corresponds to. */ - class ViewType @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 PROJECTS = of("projects") - - @JvmField val EXPERIMENTS = of("experiments") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val PLAYGROUNDS = of("playgrounds") - - @JvmField val PLAYGROUND = of("playground") - - @JvmField val DATASETS = of("datasets") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPTS = of("prompts") - - @JvmField val TOOLS = of("tools") - - @JvmField val SCORERS = of("scorers") - - @JvmField val LOGS = of("logs") - - @JvmStatic fun of(value: String) = ViewType(JsonField.of(value)) - } - - /** An enum containing [ViewType]'s known values. */ - enum class Known { - PROJECTS, - EXPERIMENTS, - EXPERIMENT, - PLAYGROUNDS, - PLAYGROUND, - DATASETS, - DATASET, - PROMPTS, - TOOLS, - SCORERS, - LOGS, - } - - /** - * An enum containing [ViewType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ViewType] 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 { - PROJECTS, - EXPERIMENTS, - EXPERIMENT, - PLAYGROUNDS, - PLAYGROUND, - DATASETS, - DATASET, - PROMPTS, - TOOLS, - SCORERS, - LOGS, - /** An enum member indicating that [ViewType] 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) { - PROJECTS -> Value.PROJECTS - EXPERIMENTS -> Value.EXPERIMENTS - EXPERIMENT -> Value.EXPERIMENT - PLAYGROUNDS -> Value.PLAYGROUNDS - PLAYGROUND -> Value.PLAYGROUND - DATASETS -> Value.DATASETS - DATASET -> Value.DATASET - PROMPTS -> Value.PROMPTS - TOOLS -> Value.TOOLS - SCORERS -> Value.SCORERS - LOGS -> Value.LOGS - 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 BraintrustInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PROJECTS -> Known.PROJECTS - EXPERIMENTS -> Known.EXPERIMENTS - EXPERIMENT -> Known.EXPERIMENT - PLAYGROUNDS -> Known.PLAYGROUNDS - PLAYGROUND -> Known.PLAYGROUND - DATASETS -> Known.DATASETS - DATASET -> Known.DATASET - PROMPTS -> Known.PROMPTS - TOOLS -> Known.TOOLS - SCORERS -> Known.SCORERS - LOGS -> Known.LOGS - else -> throw BraintrustInvalidDataException("Unknown ViewType: $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 BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewReplaceParams.kt index 3c53c17e..7112d267 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewReplaceParams.kt @@ -42,7 +42,7 @@ private constructor( fun objectId(): String = body.objectId() /** The object type that the ACL applies to */ - fun objectType(): ObjectType = body.objectType() + fun objectType(): AclObjectType = body.objectType() /** Type of table that the view corresponds to. */ fun viewType(): Optional = body.viewType() @@ -66,7 +66,7 @@ private constructor( fun _objectId(): JsonField = body._objectId() /** The object type that the ACL applies to */ - fun _objectType(): JsonField = body._objectType() + fun _objectType(): JsonField = body._objectType() /** Type of table that the view corresponds to. */ fun _viewType(): JsonField = body._viewType() @@ -107,7 +107,7 @@ private constructor( private val objectId: JsonField = JsonMissing.of(), @JsonProperty("object_type") @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), + private val objectType: JsonField = JsonMissing.of(), @JsonProperty("view_type") @ExcludeMissing private val viewType: JsonField = JsonMissing.of(), @@ -134,7 +134,7 @@ private constructor( fun objectId(): String = objectId.getRequired("object_id") /** The object type that the ACL applies to */ - fun objectType(): ObjectType = objectType.getRequired("object_type") + fun objectType(): AclObjectType = objectType.getRequired("object_type") /** Type of table that the view corresponds to. */ fun viewType(): Optional = Optional.ofNullable(viewType.getNullable("view_type")) @@ -161,7 +161,7 @@ private constructor( /** The object type that the ACL applies to */ @JsonProperty("object_type") @ExcludeMissing - fun _objectType(): JsonField = objectType + fun _objectType(): JsonField = objectType /** Type of table that the view corresponds to. */ @JsonProperty("view_type") @ExcludeMissing fun _viewType(): JsonField = viewType @@ -225,7 +225,7 @@ private constructor( private var name: JsonField? = null private var objectId: JsonField? = null - private var objectType: JsonField? = null + private var objectType: JsonField? = null private var viewType: JsonField? = null private var deletedAt: JsonField = JsonMissing.of() private var options: JsonField = JsonMissing.of() @@ -259,10 +259,10 @@ private constructor( fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + fun objectType(objectType: AclObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { + fun objectType(objectType: JsonField) = apply { this.objectType = objectType } @@ -410,10 +410,10 @@ private constructor( fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { body.objectType(objectType) } + fun objectType(objectType: AclObjectType) = apply { body.objectType(objectType) } /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } + fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } /** Type of table that the view corresponds to. */ fun viewType(viewType: ViewType?) = apply { body.viewType(viewType) } @@ -585,163 +585,6 @@ private constructor( ) } - /** The object type that the ACL applies to */ - class ObjectType @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 = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - /** An enum containing [ObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ObjectType] 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, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [ObjectType] 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 -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - 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 BraintrustInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - /** Type of table that the view corresponds to. */ class ViewType @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewRetrieveParams.kt index 84f0af7c..873b0815 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewRetrieveParams.kt @@ -2,15 +2,11 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.Params import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonCreator import java.util.Objects /** Get a view object by its id */ @@ -18,7 +14,7 @@ class ViewRetrieveParams private constructor( private val viewId: String, private val objectId: String, - private val objectType: ObjectType, + private val objectType: AclObjectType, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -30,7 +26,7 @@ private constructor( fun objectId(): String = objectId /** The object type that the ACL applies to */ - fun objectType(): ObjectType = objectType + fun objectType(): AclObjectType = objectType fun _additionalHeaders(): Headers = additionalHeaders @@ -76,7 +72,7 @@ private constructor( private var viewId: String? = null private var objectId: String? = null - private var objectType: ObjectType? = null + private var objectType: AclObjectType? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -96,7 +92,7 @@ private constructor( fun objectId(objectId: String) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: AclObjectType) = apply { this.objectType = objectType } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -206,163 +202,6 @@ private constructor( ) } - /** The object type that the ACL applies to */ - class ObjectType @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 = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - /** An enum containing [ObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ObjectType] 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, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [ObjectType] 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 -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - 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 BraintrustInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewType.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewType.kt new file mode 100644 index 00000000..f09a7f19 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewType.kt @@ -0,0 +1,160 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator + +/** Type of table that the view corresponds to. */ +class ViewType @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 PROJECTS = of("projects") + + @JvmField val EXPERIMENTS = of("experiments") + + @JvmField val EXPERIMENT = of("experiment") + + @JvmField val PLAYGROUNDS = of("playgrounds") + + @JvmField val PLAYGROUND = of("playground") + + @JvmField val DATASETS = of("datasets") + + @JvmField val DATASET = of("dataset") + + @JvmField val PROMPTS = of("prompts") + + @JvmField val TOOLS = of("tools") + + @JvmField val SCORERS = of("scorers") + + @JvmField val LOGS = of("logs") + + @JvmStatic fun of(value: String) = ViewType(JsonField.of(value)) + } + + /** An enum containing [ViewType]'s known values. */ + enum class Known { + PROJECTS, + EXPERIMENTS, + EXPERIMENT, + PLAYGROUNDS, + PLAYGROUND, + DATASETS, + DATASET, + PROMPTS, + TOOLS, + SCORERS, + LOGS, + } + + /** + * An enum containing [ViewType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ViewType] 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 { + PROJECTS, + EXPERIMENTS, + EXPERIMENT, + PLAYGROUNDS, + PLAYGROUND, + DATASETS, + DATASET, + PROMPTS, + TOOLS, + SCORERS, + LOGS, + /** An enum member indicating that [ViewType] 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) { + PROJECTS -> Value.PROJECTS + EXPERIMENTS -> Value.EXPERIMENTS + EXPERIMENT -> Value.EXPERIMENT + PLAYGROUNDS -> Value.PLAYGROUNDS + PLAYGROUND -> Value.PLAYGROUND + DATASETS -> Value.DATASETS + DATASET -> Value.DATASET + PROMPTS -> Value.PROMPTS + TOOLS -> Value.TOOLS + SCORERS -> Value.SCORERS + LOGS -> Value.LOGS + 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 BraintrustInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PROJECTS -> Known.PROJECTS + EXPERIMENTS -> Known.EXPERIMENTS + EXPERIMENT -> Known.EXPERIMENT + PLAYGROUNDS -> Known.PLAYGROUNDS + PLAYGROUND -> Known.PLAYGROUND + DATASETS -> Known.DATASETS + DATASET -> Known.DATASET + PROMPTS -> Known.PROMPTS + TOOLS -> Known.TOOLS + SCORERS -> Known.SCORERS + LOGS -> Known.LOGS + else -> throw BraintrustInvalidDataException("Unknown ViewType: $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 BraintrustInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewUpdateParams.kt index 525a0dbc..6521f2e1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewUpdateParams.kt @@ -43,7 +43,7 @@ private constructor( fun objectId(): String = body.objectId() /** The object type that the ACL applies to */ - fun objectType(): ObjectType = body.objectType() + fun objectType(): AclObjectType = body.objectType() /** Name of the view */ fun name(): Optional = body.name() @@ -64,7 +64,7 @@ private constructor( fun _objectId(): JsonField = body._objectId() /** The object type that the ACL applies to */ - fun _objectType(): JsonField = body._objectType() + fun _objectType(): JsonField = body._objectType() /** Name of the view */ fun _name(): JsonField = body._name() @@ -109,7 +109,7 @@ private constructor( private val objectId: JsonField = JsonMissing.of(), @JsonProperty("object_type") @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), + private val objectType: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -133,7 +133,7 @@ private constructor( fun objectId(): String = objectId.getRequired("object_id") /** The object type that the ACL applies to */ - fun objectType(): ObjectType = objectType.getRequired("object_type") + fun objectType(): AclObjectType = objectType.getRequired("object_type") /** Name of the view */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) @@ -156,7 +156,7 @@ private constructor( /** The object type that the ACL applies to */ @JsonProperty("object_type") @ExcludeMissing - fun _objectType(): JsonField = objectType + fun _objectType(): JsonField = objectType /** Name of the view */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @@ -214,7 +214,7 @@ private constructor( class Builder internal constructor() { private var objectId: JsonField? = null - private var objectType: JsonField? = null + private var objectType: JsonField? = null private var name: JsonField = JsonMissing.of() private var options: JsonField = JsonMissing.of() private var userId: JsonField = JsonMissing.of() @@ -241,10 +241,10 @@ private constructor( fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + fun objectType(objectType: AclObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { + fun objectType(objectType: JsonField) = apply { this.objectType = objectType } @@ -387,10 +387,10 @@ private constructor( fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { body.objectType(objectType) } + fun objectType(objectType: AclObjectType) = apply { body.objectType(objectType) } /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } + fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } /** Name of the view */ fun name(name: String?) = apply { body.name(name) } @@ -563,163 +563,6 @@ private constructor( ) } - /** The object type that the ACL applies to */ - class ObjectType @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 = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - /** An enum containing [ObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ObjectType] 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, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [ObjectType] 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 -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - 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 BraintrustInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $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 BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - /** Type of table that the view corresponds to. */ class ViewType @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclBatchUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclBatchUpdateParamsTest.kt index ce3f43d3..4ad8ce2c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclBatchUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclBatchUpdateParamsTest.kt @@ -14,10 +14,10 @@ class AclBatchUpdateParamsTest { .addAddAcl( AclBatchUpdateParams.AddAcl.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType(AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -25,12 +25,10 @@ class AclBatchUpdateParamsTest { .addRemoveAcl( AclBatchUpdateParams.RemoveAcl.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -45,12 +43,10 @@ class AclBatchUpdateParamsTest { .addAddAcl( AclBatchUpdateParams.AddAcl.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -58,12 +54,10 @@ class AclBatchUpdateParamsTest { .addRemoveAcl( AclBatchUpdateParams.RemoveAcl.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -78,12 +72,10 @@ class AclBatchUpdateParamsTest { listOf( AclBatchUpdateParams.AddAcl.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -94,12 +86,10 @@ class AclBatchUpdateParamsTest { listOf( AclBatchUpdateParams.RemoveAcl.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponseTest.kt index 02a37951..02a05b7e 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponseTest.kt @@ -17,11 +17,11 @@ class AclBatchUpdateResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Acl.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(Acl.Permission.CREATE) - .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -31,11 +31,11 @@ class AclBatchUpdateResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Acl.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(Acl.Permission.CREATE) - .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -48,11 +48,11 @@ class AclBatchUpdateResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Acl.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(Acl.Permission.CREATE) - .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -63,11 +63,11 @@ class AclBatchUpdateResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Acl.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(Acl.Permission.CREATE) - .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclCreateParamsTest.kt index 2f1cbe6c..4e3b9c42 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclCreateParamsTest.kt @@ -12,10 +12,10 @@ class AclCreateParamsTest { fun create() { AclCreateParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclCreateParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclCreateParams.Permission.CREATE) - .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -26,10 +26,10 @@ class AclCreateParamsTest { val params = AclCreateParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclCreateParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclCreateParams.Permission.CREATE) - .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -38,11 +38,10 @@ class AclCreateParamsTest { assertNotNull(body) assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(AclCreateParams.ObjectType.ORGANIZATION) + assertThat(body.objectType()).isEqualTo(AclObjectType.ORGANIZATION) assertThat(body.groupId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.permission()).contains(AclCreateParams.Permission.CREATE) - assertThat(body.restrictObjectType()) - .contains(AclCreateParams.RestrictObjectType.ORGANIZATION) + assertThat(body.permission()).contains(Permission.CREATE) + assertThat(body.restrictObjectType()).contains(AclObjectType.ORGANIZATION) assertThat(body.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } @@ -52,13 +51,13 @@ class AclCreateParamsTest { val params = AclCreateParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclCreateParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .build() val body = params._body() assertNotNull(body) assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(AclCreateParams.ObjectType.ORGANIZATION) + assertThat(body.objectType()).isEqualTo(AclObjectType.ORGANIZATION) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclFindAndDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclFindAndDeleteParamsTest.kt index 8c64fe8b..c965416f 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclFindAndDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclFindAndDeleteParamsTest.kt @@ -12,10 +12,10 @@ class AclFindAndDeleteParamsTest { fun create() { AclFindAndDeleteParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclFindAndDeleteParams.Permission.CREATE) - .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -26,10 +26,10 @@ class AclFindAndDeleteParamsTest { val params = AclFindAndDeleteParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclFindAndDeleteParams.Permission.CREATE) - .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -38,11 +38,10 @@ class AclFindAndDeleteParamsTest { assertNotNull(body) assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(AclFindAndDeleteParams.ObjectType.ORGANIZATION) + assertThat(body.objectType()).isEqualTo(AclObjectType.ORGANIZATION) assertThat(body.groupId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.permission()).contains(AclFindAndDeleteParams.Permission.CREATE) - assertThat(body.restrictObjectType()) - .contains(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) + assertThat(body.permission()).contains(Permission.CREATE) + assertThat(body.restrictObjectType()).contains(AclObjectType.ORGANIZATION) assertThat(body.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } @@ -52,13 +51,13 @@ class AclFindAndDeleteParamsTest { val params = AclFindAndDeleteParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .build() val body = params._body() assertNotNull(body) assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(AclFindAndDeleteParams.ObjectType.ORGANIZATION) + assertThat(body.objectType()).isEqualTo(AclObjectType.ORGANIZATION) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclListParamsTest.kt index 174747e9..f8fb38e1 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclListParamsTest.kt @@ -12,7 +12,7 @@ class AclListParamsTest { fun create() { AclListParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclListParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .limit(0L) @@ -25,7 +25,7 @@ class AclListParamsTest { val params = AclListParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclListParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .limit(0L) @@ -33,7 +33,7 @@ class AclListParamsTest { .build() val expected = QueryParams.builder() expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", AclListParams.ObjectType.ORGANIZATION.toString()) + expected.put("object_type", AclObjectType.ORGANIZATION.toString()) expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put( "ids", @@ -49,11 +49,11 @@ class AclListParamsTest { val params = AclListParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclListParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .build() val expected = QueryParams.builder() expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", AclListParams.ObjectType.ORGANIZATION.toString()) + expected.put("object_type", AclObjectType.ORGANIZATION.toString()) assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclTest.kt index cedb7fe5..61d63fab 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclTest.kt @@ -15,11 +15,11 @@ class AclTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Acl.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(Acl.Permission.CREATE) - .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -27,11 +27,11 @@ class AclTest { assertThat(acl.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(acl._objectOrgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(acl.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(acl.objectType()).isEqualTo(Acl.ObjectType.ORGANIZATION) + assertThat(acl.objectType()).isEqualTo(AclObjectType.ORGANIZATION) assertThat(acl.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(acl.groupId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(acl.permission()).contains(Acl.Permission.CREATE) - assertThat(acl.restrictObjectType()).contains(Acl.RestrictObjectType.ORGANIZATION) + assertThat(acl.permission()).contains(Permission.CREATE) + assertThat(acl.restrictObjectType()).contains(AclObjectType.ORGANIZATION) assertThat(acl.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(acl.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarListParamsTest.kt index 4af4a47a..c946d12b 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarListParamsTest.kt @@ -15,7 +15,7 @@ class EnvVarListParamsTest { .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .limit(0L) .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarListParams.ObjectType.ORGANIZATION) + .objectType(EnvVarObjectType.ORGANIZATION) .build() } @@ -27,7 +27,7 @@ class EnvVarListParamsTest { .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .limit(0L) .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarListParams.ObjectType.ORGANIZATION) + .objectType(EnvVarObjectType.ORGANIZATION) .build() val expected = QueryParams.builder() expected.put("env_var_name", "env_var_name") @@ -37,7 +37,7 @@ class EnvVarListParamsTest { ) expected.put("limit", "0") expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", EnvVarListParams.ObjectType.ORGANIZATION.toString()) + expected.put("object_type", EnvVarObjectType.ORGANIZATION.toString()) assertThat(params._queryParams()).isEqualTo(expected.build()) } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentEventTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentEventTest.kt index f10a67a4..dbcac3f4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentEventTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentEventTest.kt @@ -59,9 +59,7 @@ class ExperimentEventTest { .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) - .spanAttributes( - SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() - ) + .spanAttributes(SpanAttributes.builder().name("name").type(SpanType.LLM).build()) .addSpanParent("string") .addTag("string") .build() @@ -119,7 +117,7 @@ class ExperimentEventTest { .build() ) assertThat(experimentEvent.spanAttributes()) - .contains(SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build()) + .contains(SpanAttributes.builder().name("name").type(SpanType.LLM).build()) assertThat(experimentEvent.spanParents().get()).containsExactly("string") assertThat(experimentEvent.tags().get()).containsExactly("string") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentInsertParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentInsertParamsTest.kt index 8326f83a..6525a6ce 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentInsertParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentInsertParamsTest.kt @@ -62,7 +62,7 @@ class ExperimentInsertParamsTest { .build() ) .spanAttributes( - SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() + SpanAttributes.builder().name("name").type(SpanType.LLM).build() ) .spanId("span_id") .addSpanParent("string") @@ -125,10 +125,7 @@ class ExperimentInsertParamsTest { .build() ) .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() + SpanAttributes.builder().name("name").type(SpanType.LLM).build() ) .spanId("span_id") .addSpanParent("string") @@ -190,10 +187,7 @@ class ExperimentInsertParamsTest { .build() ) .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() + SpanAttributes.builder().name("name").type(SpanType.LLM).build() ) .spanId("span_id") .addSpanParent("string") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponseTest.kt index d8796002..4bd1e40e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponseTest.kt @@ -62,10 +62,7 @@ class FetchExperimentEventsResponseTest { .build() ) .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() + SpanAttributes.builder().name("name").type(SpanType.LLM).build() ) .addSpanParent("string") .addTag("string") @@ -124,7 +121,7 @@ class FetchExperimentEventsResponseTest { .build() ) .spanAttributes( - SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() + SpanAttributes.builder().name("name").type(SpanType.LLM).build() ) .addSpanParent("string") .addTag("string") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponseTest.kt index 480a33d8..9ddf349e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponseTest.kt @@ -63,10 +63,7 @@ class FetchProjectLogsEventsResponseTest { .build() ) .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() + SpanAttributes.builder().name("name").type(SpanType.LLM).build() ) .addSpanParent("string") .addTag("string") @@ -126,7 +123,7 @@ class FetchProjectLogsEventsResponseTest { .build() ) .spanAttributes( - SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() + SpanAttributes.builder().name("name").type(SpanType.LLM).build() ) .addSpanParent("string") .addTag("string") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionCreateParamsTest.kt index 389d6004..b0062e5f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionCreateParamsTest.kt @@ -31,7 +31,7 @@ class FunctionCreateParamsTest { .origin( FunctionCreateParams.Origin.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .internal_(true) .build() ) @@ -141,7 +141,7 @@ class FunctionCreateParamsTest { .origin( FunctionCreateParams.Origin.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .internal_(true) .build() ) @@ -255,7 +255,7 @@ class FunctionCreateParamsTest { .contains( FunctionCreateParams.Origin.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .internal_(true) .build() ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionReplaceParamsTest.kt index 590c73e7..86799252 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionReplaceParamsTest.kt @@ -31,7 +31,7 @@ class FunctionReplaceParamsTest { .origin( FunctionReplaceParams.Origin.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .internal_(true) .build() ) @@ -141,7 +141,7 @@ class FunctionReplaceParamsTest { .origin( FunctionReplaceParams.Origin.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .internal_(true) .build() ) @@ -255,7 +255,7 @@ class FunctionReplaceParamsTest { .contains( FunctionReplaceParams.Origin.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .internal_(true) .build() ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionTest.kt index 2183cad8..69851128 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionTest.kt @@ -42,7 +42,7 @@ class FunctionTest { .origin( Function.Origin.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Function.Origin.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .internal_(true) .build() ) @@ -164,7 +164,7 @@ class FunctionTest { .contains( Function.Origin.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Function.Origin.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .internal_(true) .build() ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventTest.kt index c067cb4b..90c5a67c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventTest.kt @@ -58,9 +58,7 @@ class InsertExperimentEventTest { .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) - .spanAttributes( - SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() - ) + .spanAttributes(SpanAttributes.builder().name("name").type(SpanType.LLM).build()) .spanId("span_id") .addSpanParent("string") .addTag("string") @@ -119,7 +117,7 @@ class InsertExperimentEventTest { .build() ) assertThat(insertExperimentEvent.spanAttributes()) - .contains(SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build()) + .contains(SpanAttributes.builder().name("name").type(SpanType.LLM).build()) assertThat(insertExperimentEvent.spanId()).contains("span_id") assertThat(insertExperimentEvent.spanParents().get()).containsExactly("string") assertThat(insertExperimentEvent.tags().get()).containsExactly("string") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventTest.kt index 20bcc290..3d0fc82f 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventTest.kt @@ -58,9 +58,7 @@ class InsertProjectLogsEventTest { .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) - .spanAttributes( - SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() - ) + .spanAttributes(SpanAttributes.builder().name("name").type(SpanType.LLM).build()) .spanId("span_id") .addSpanParent("string") .addTag("string") @@ -119,7 +117,7 @@ class InsertProjectLogsEventTest { .build() ) assertThat(insertProjectLogsEvent.spanAttributes()) - .contains(SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build()) + .contains(SpanAttributes.builder().name("name").type(SpanType.LLM).build()) assertThat(insertProjectLogsEvent.spanId()).contains("span_id") assertThat(insertProjectLogsEvent.spanParents().get()).containsExactly("string") assertThat(insertProjectLogsEvent.tags().get()).containsExactly("string") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogInsertParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogInsertParamsTest.kt index c5bb43ae..868951f5 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogInsertParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogInsertParamsTest.kt @@ -62,7 +62,7 @@ class ProjectLogInsertParamsTest { .build() ) .spanAttributes( - SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() + SpanAttributes.builder().name("name").type(SpanType.LLM).build() ) .spanId("span_id") .addSpanParent("string") @@ -125,10 +125,7 @@ class ProjectLogInsertParamsTest { .build() ) .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() + SpanAttributes.builder().name("name").type(SpanType.LLM).build() ) .spanId("span_id") .addSpanParent("string") @@ -190,10 +187,7 @@ class ProjectLogInsertParamsTest { .build() ) .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() + SpanAttributes.builder().name("name").type(SpanType.LLM).build() ) .spanId("span_id") .addSpanParent("string") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogsEventTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogsEventTest.kt index e81a0afb..60cbff52 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogsEventTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogsEventTest.kt @@ -60,9 +60,7 @@ class ProjectLogsEventTest { .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) - .spanAttributes( - SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() - ) + .spanAttributes(SpanAttributes.builder().name("name").type(SpanType.LLM).build()) .addSpanParent("string") .addTag("string") .build() @@ -121,7 +119,7 @@ class ProjectLogsEventTest { .build() ) assertThat(projectLogsEvent.spanAttributes()) - .contains(SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build()) + .contains(SpanAttributes.builder().name("name").type(SpanType.LLM).build()) assertThat(projectLogsEvent.spanParents().get()).containsExactly("string") assertThat(projectLogsEvent.tags().get()).containsExactly("string") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParamsTest.kt index ff0c8da7..09035879 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParamsTest.kt @@ -13,7 +13,7 @@ class ProjectScoreCreateParamsTest { ProjectScoreCreateParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .categoriesOfCategorical( listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) ) @@ -46,7 +46,7 @@ class ProjectScoreCreateParamsTest { ProjectScoreCreateParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .categoriesOfCategorical( listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) ) @@ -77,7 +77,7 @@ class ProjectScoreCreateParamsTest { assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.scoreType()).isEqualTo(ProjectScoreCreateParams.ScoreType.SLIDER) + assertThat(body.scoreType()).isEqualTo(ProjectScoreType.SLIDER) assertThat(body.categories()) .contains( ProjectScoreCreateParams.Categories.ofCategorical( @@ -113,7 +113,7 @@ class ProjectScoreCreateParamsTest { ProjectScoreCreateParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .build() val body = params._body() @@ -121,6 +121,6 @@ class ProjectScoreCreateParamsTest { assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.scoreType()).isEqualTo(ProjectScoreCreateParams.ScoreType.SLIDER) + assertThat(body.scoreType()).isEqualTo(ProjectScoreType.SLIDER) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreListParamsTest.kt index 6084f831..1dce4750 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreListParamsTest.kt @@ -18,7 +18,7 @@ class ProjectScoreListParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectName("project_name") .projectScoreName("project_score_name") - .scoreType(ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() } @@ -34,7 +34,7 @@ class ProjectScoreListParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectName("project_name") .projectScoreName("project_score_name") - .scoreType(ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() val expected = QueryParams.builder() @@ -50,9 +50,7 @@ class ProjectScoreListParamsTest { expected.put("project_score_name", "project_score_name") expected.put( "score_type", - ProjectScoreListParams.ScoreType.ofProject( - ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER.toString() - ) + ProjectScoreListParams.ScoreType.ofProject(ProjectScoreType.SLIDER.toString()) .toString(), ) expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParamsTest.kt index 1049822d..fc7147da 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParamsTest.kt @@ -13,7 +13,7 @@ class ProjectScoreReplaceParamsTest { ProjectScoreReplaceParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .categoriesOfCategorical( listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) ) @@ -46,7 +46,7 @@ class ProjectScoreReplaceParamsTest { ProjectScoreReplaceParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .categoriesOfCategorical( listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) ) @@ -77,7 +77,7 @@ class ProjectScoreReplaceParamsTest { assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.scoreType()).isEqualTo(ProjectScoreReplaceParams.ScoreType.SLIDER) + assertThat(body.scoreType()).isEqualTo(ProjectScoreType.SLIDER) assertThat(body.categories()) .contains( ProjectScoreReplaceParams.Categories.ofCategorical( @@ -113,7 +113,7 @@ class ProjectScoreReplaceParamsTest { ProjectScoreReplaceParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .build() val body = params._body() @@ -121,6 +121,6 @@ class ProjectScoreReplaceParamsTest { assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.scoreType()).isEqualTo(ProjectScoreReplaceParams.ScoreType.SLIDER) + assertThat(body.scoreType()).isEqualTo(ProjectScoreType.SLIDER) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreTest.kt index 0e2e0b4b..377bc562 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreTest.kt @@ -15,7 +15,7 @@ class ProjectScoreTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScore.ScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .categoriesOfCategorical( listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) @@ -47,7 +47,7 @@ class ProjectScoreTest { assertThat(projectScore.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(projectScore.name()).isEqualTo("name") assertThat(projectScore.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(projectScore.scoreType()).isEqualTo(ProjectScore.ScoreType.SLIDER) + assertThat(projectScore.scoreType()).isEqualTo(ProjectScoreType.SLIDER) assertThat(projectScore.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(projectScore.categories()) .contains( diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParamsTest.kt index 2407e87f..df455978 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParamsTest.kt @@ -36,7 +36,7 @@ class ProjectScoreUpdateParamsTest { ) .description("description") .name("name") - .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .build() } @@ -69,7 +69,7 @@ class ProjectScoreUpdateParamsTest { ) .description("description") .name("name") - .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .build() val body = params._body() @@ -103,7 +103,7 @@ class ProjectScoreUpdateParamsTest { ) assertThat(body.description()).contains("description") assertThat(body.name()).contains("name") - assertThat(body.scoreType()).contains(ProjectScoreUpdateParams.ScoreType.SLIDER) + assertThat(body.scoreType()).contains(ProjectScoreType.SLIDER) } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleCreateParamsTest.kt index 2a910fde..0f51ab11 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleCreateParamsTest.kt @@ -15,10 +15,8 @@ class RoleCreateParamsTest { .description("description") .addMemberPermission( RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .build() ) .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -34,10 +32,8 @@ class RoleCreateParamsTest { .description("description") .addMemberPermission( RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .build() ) .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -53,10 +49,8 @@ class RoleCreateParamsTest { .contains( listOf( RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .build() ) ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleReplaceParamsTest.kt index 46264e88..bb1f5ff7 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleReplaceParamsTest.kt @@ -15,10 +15,8 @@ class RoleReplaceParamsTest { .description("description") .addMemberPermission( RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .build() ) .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -34,10 +32,8 @@ class RoleReplaceParamsTest { .description("description") .addMemberPermission( RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .build() ) .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -53,10 +49,8 @@ class RoleReplaceParamsTest { .contains( listOf( RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .build() ) ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleTest.kt index 6187d100..d26022f4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleTest.kt @@ -19,8 +19,8 @@ class RoleTest { .description("description") .addMemberPermission( Role.MemberPermission.builder() - .permission(Role.MemberPermission.Permission.CREATE) - .restrictObjectType(Role.MemberPermission.RestrictObjectType.ORGANIZATION) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .build() ) .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -36,8 +36,8 @@ class RoleTest { assertThat(role.memberPermissions().get()) .containsExactly( Role.MemberPermission.builder() - .permission(Role.MemberPermission.Permission.CREATE) - .restrictObjectType(Role.MemberPermission.RestrictObjectType.ORGANIZATION) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .build() ) assertThat(role.memberRoles().get()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleUpdateParamsTest.kt index ee226d14..5fb7036c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleUpdateParamsTest.kt @@ -14,10 +14,8 @@ class RoleUpdateParamsTest { .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addAddMemberPermission( RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .build() ) .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -25,10 +23,8 @@ class RoleUpdateParamsTest { .name("x") .addRemoveMemberPermission( RoleUpdateParams.RemoveMemberPermission.builder() - .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .build() ) .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -42,10 +38,8 @@ class RoleUpdateParamsTest { .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addAddMemberPermission( RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .build() ) .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -53,10 +47,8 @@ class RoleUpdateParamsTest { .name("x") .addRemoveMemberPermission( RoleUpdateParams.RemoveMemberPermission.builder() - .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .build() ) .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -69,10 +61,8 @@ class RoleUpdateParamsTest { .contains( listOf( RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .build() ) ) @@ -83,10 +73,8 @@ class RoleUpdateParamsTest { .contains( listOf( RoleUpdateParams.RemoveMemberPermission.builder() - .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .build() ) ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanAttributesTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanAttributesTest.kt index 562a0b8a..9a2631a4 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanAttributesTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanAttributesTest.kt @@ -9,10 +9,9 @@ class SpanAttributesTest { @Test fun createSpanAttributes() { - val spanAttributes = - SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() + val spanAttributes = SpanAttributes.builder().name("name").type(SpanType.LLM).build() assertThat(spanAttributes).isNotNull assertThat(spanAttributes.name()).contains("name") - assertThat(spanAttributes.type()).contains(SpanAttributes.Type.LLM) + assertThat(spanAttributes.type()).contains(SpanType.LLM) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewCreateParamsTest.kt index 3b7432e8..3d041001 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewCreateParamsTest.kt @@ -15,7 +15,7 @@ class ViewCreateParamsTest { ViewCreateParams.builder() .name("name") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewCreateParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .viewType(ViewCreateParams.ViewType.PROJECTS) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .options( @@ -58,7 +58,7 @@ class ViewCreateParamsTest { ViewCreateParams.builder() .name("name") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewCreateParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .viewType(ViewCreateParams.ViewType.PROJECTS) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .options( @@ -99,7 +99,7 @@ class ViewCreateParamsTest { assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(ViewCreateParams.ObjectType.ORGANIZATION) + assertThat(body.objectType()).isEqualTo(AclObjectType.ORGANIZATION) assertThat(body.viewType()).contains(ViewCreateParams.ViewType.PROJECTS) assertThat(body.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(body.options()) @@ -143,7 +143,7 @@ class ViewCreateParamsTest { ViewCreateParams.builder() .name("name") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewCreateParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .viewType(ViewCreateParams.ViewType.PROJECTS) .build() @@ -152,7 +152,7 @@ class ViewCreateParamsTest { assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(ViewCreateParams.ObjectType.ORGANIZATION) + assertThat(body.objectType()).isEqualTo(AclObjectType.ORGANIZATION) assertThat(body.viewType()).contains(ViewCreateParams.ViewType.PROJECTS) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDeleteParamsTest.kt index 20ab82f1..e13cbc01 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDeleteParamsTest.kt @@ -13,7 +13,7 @@ class ViewDeleteParamsTest { ViewDeleteParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .build() } @@ -23,14 +23,14 @@ class ViewDeleteParamsTest { ViewDeleteParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .build() val body = params._body() assertNotNull(body) assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(ViewDeleteParams.ObjectType.ORGANIZATION) + assertThat(body.objectType()).isEqualTo(AclObjectType.ORGANIZATION) } @Test @@ -39,14 +39,14 @@ class ViewDeleteParamsTest { ViewDeleteParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .build() val body = params._body() assertNotNull(body) assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(ViewDeleteParams.ObjectType.ORGANIZATION) + assertThat(body.objectType()).isEqualTo(AclObjectType.ORGANIZATION) } @Test @@ -55,7 +55,7 @@ class ViewDeleteParamsTest { ViewDeleteParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .build() assertThat(params).isNotNull // path param "viewId" diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewListParamsTest.kt index 35c71549..821a120b 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewListParamsTest.kt @@ -12,13 +12,13 @@ class ViewListParamsTest { fun create() { ViewListParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewListParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .limit(0L) .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .viewName("view_name") - .viewType(ViewListParams.ViewType.PROJECTS) + .viewType(ViewType.PROJECTS) .build() } @@ -27,17 +27,17 @@ class ViewListParamsTest { val params = ViewListParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewListParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .limit(0L) .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .viewName("view_name") - .viewType(ViewListParams.ViewType.PROJECTS) + .viewType(ViewType.PROJECTS) .build() val expected = QueryParams.builder() expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", ViewListParams.ObjectType.ORGANIZATION.toString()) + expected.put("object_type", AclObjectType.ORGANIZATION.toString()) expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put( "ids", @@ -46,7 +46,7 @@ class ViewListParamsTest { expected.put("limit", "0") expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put("view_name", "view_name") - expected.put("view_type", ViewListParams.ViewType.PROJECTS.toString()) + expected.put("view_type", ViewType.PROJECTS.toString()) assertThat(params._queryParams()).isEqualTo(expected.build()) } @@ -55,11 +55,11 @@ class ViewListParamsTest { val params = ViewListParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewListParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .build() val expected = QueryParams.builder() expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", ViewListParams.ObjectType.ORGANIZATION.toString()) + expected.put("object_type", AclObjectType.ORGANIZATION.toString()) assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewReplaceParamsTest.kt index 81ed6e41..47686395 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewReplaceParamsTest.kt @@ -15,7 +15,7 @@ class ViewReplaceParamsTest { ViewReplaceParams.builder() .name("name") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .viewType(ViewReplaceParams.ViewType.PROJECTS) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .options( @@ -58,7 +58,7 @@ class ViewReplaceParamsTest { ViewReplaceParams.builder() .name("name") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .viewType(ViewReplaceParams.ViewType.PROJECTS) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .options( @@ -99,7 +99,7 @@ class ViewReplaceParamsTest { assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(ViewReplaceParams.ObjectType.ORGANIZATION) + assertThat(body.objectType()).isEqualTo(AclObjectType.ORGANIZATION) assertThat(body.viewType()).contains(ViewReplaceParams.ViewType.PROJECTS) assertThat(body.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(body.options()) @@ -143,7 +143,7 @@ class ViewReplaceParamsTest { ViewReplaceParams.builder() .name("name") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .viewType(ViewReplaceParams.ViewType.PROJECTS) .build() @@ -152,7 +152,7 @@ class ViewReplaceParamsTest { assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(ViewReplaceParams.ObjectType.ORGANIZATION) + assertThat(body.objectType()).isEqualTo(AclObjectType.ORGANIZATION) assertThat(body.viewType()).contains(ViewReplaceParams.ViewType.PROJECTS) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewRetrieveParamsTest.kt index 31fdf385..61d70c16 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewRetrieveParamsTest.kt @@ -13,7 +13,7 @@ class ViewRetrieveParamsTest { ViewRetrieveParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .build() } @@ -23,11 +23,11 @@ class ViewRetrieveParamsTest { ViewRetrieveParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .build() val expected = QueryParams.builder() expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", ViewRetrieveParams.ObjectType.ORGANIZATION.toString()) + expected.put("object_type", AclObjectType.ORGANIZATION.toString()) assertThat(params._queryParams()).isEqualTo(expected.build()) } @@ -37,11 +37,11 @@ class ViewRetrieveParamsTest { ViewRetrieveParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .build() val expected = QueryParams.builder() expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", ViewRetrieveParams.ObjectType.ORGANIZATION.toString()) + expected.put("object_type", AclObjectType.ORGANIZATION.toString()) assertThat(params._queryParams()).isEqualTo(expected.build()) } @@ -51,7 +51,7 @@ class ViewRetrieveParamsTest { ViewRetrieveParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .build() assertThat(params).isNotNull // path param "viewId" diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewTest.kt index afd86c23..a9d8e232 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewTest.kt @@ -16,7 +16,7 @@ class ViewTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("name") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(View.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .viewType(View.ViewType.PROJECTS) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -56,7 +56,7 @@ class ViewTest { assertThat(view.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(view.name()).isEqualTo("name") assertThat(view.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(view.objectType()).isEqualTo(View.ObjectType.ORGANIZATION) + assertThat(view.objectType()).isEqualTo(AclObjectType.ORGANIZATION) assertThat(view.viewType()).contains(View.ViewType.PROJECTS) assertThat(view.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(view.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewUpdateParamsTest.kt index f5072c25..fb4c4f8f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewUpdateParamsTest.kt @@ -14,7 +14,7 @@ class ViewUpdateParamsTest { ViewUpdateParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .name("name") .options( ViewOptions.builder() @@ -57,7 +57,7 @@ class ViewUpdateParamsTest { ViewUpdateParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .name("name") .options( ViewOptions.builder() @@ -97,7 +97,7 @@ class ViewUpdateParamsTest { assertNotNull(body) assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(ViewUpdateParams.ObjectType.ORGANIZATION) + assertThat(body.objectType()).isEqualTo(AclObjectType.ORGANIZATION) assertThat(body.name()).contains("name") assertThat(body.options()) .contains( @@ -141,14 +141,14 @@ class ViewUpdateParamsTest { ViewUpdateParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .build() val body = params._body() assertNotNull(body) assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(ViewUpdateParams.ObjectType.ORGANIZATION) + assertThat(body.objectType()).isEqualTo(AclObjectType.ORGANIZATION) } @Test @@ -157,7 +157,7 @@ class ViewUpdateParamsTest { ViewUpdateParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .build() assertThat(params).isNotNull // path param "viewId" diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncTest.kt index 5df9416c..3f295376 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncTest.kt @@ -9,7 +9,9 @@ import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclFindAndDeleteParams import com.braintrustdata.api.models.AclListParams +import com.braintrustdata.api.models.AclObjectType import com.braintrustdata.api.models.AclRetrieveParams +import com.braintrustdata.api.models.Permission import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -29,10 +31,10 @@ class AclServiceAsyncTest { aclServiceAsync.create( AclCreateParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclCreateParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclCreateParams.Permission.CREATE) - .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -73,7 +75,7 @@ class AclServiceAsyncTest { aclServiceAsync.list( AclListParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclListParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .build() ) @@ -114,12 +116,10 @@ class AclServiceAsyncTest { .addAddAcl( AclBatchUpdateParams.AddAcl.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -127,12 +127,10 @@ class AclServiceAsyncTest { .addRemoveAcl( AclBatchUpdateParams.RemoveAcl.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -157,10 +155,10 @@ class AclServiceAsyncTest { aclServiceAsync.findAndDelete( AclFindAndDeleteParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclFindAndDeleteParams.Permission.CREATE) - .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncTest.kt index b64fa2df..cceef9ea 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncTest.kt @@ -7,6 +7,7 @@ import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync import com.braintrustdata.api.models.EnvVarCreateParams import com.braintrustdata.api.models.EnvVarDeleteParams import com.braintrustdata.api.models.EnvVarListParams +import com.braintrustdata.api.models.EnvVarObjectType import com.braintrustdata.api.models.EnvVarReplaceParams import com.braintrustdata.api.models.EnvVarRetrieveParams import com.braintrustdata.api.models.EnvVarUpdateParams @@ -97,7 +98,7 @@ class EnvVarServiceAsyncTest { .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .limit(0L) .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarListParams.ObjectType.ORGANIZATION) + .objectType(EnvVarObjectType.ORGANIZATION) .build() ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncTest.kt index ca4c7bc5..7703f1fc 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncTest.kt @@ -19,6 +19,7 @@ import com.braintrustdata.api.models.InsertExperimentEvent import com.braintrustdata.api.models.ObjectReference import com.braintrustdata.api.models.RepoInfo import com.braintrustdata.api.models.SpanAttributes +import com.braintrustdata.api.models.SpanType import java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -321,10 +322,7 @@ class ExperimentServiceAsyncTest { .build() ) .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() + SpanAttributes.builder().name("name").type(SpanType.LLM).build() ) .spanId("span_id") .addSpanParent("string") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncTest.kt index f1a05501..ea23ac2d 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncTest.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.AclObjectType import com.braintrustdata.api.models.FunctionCreateParams import com.braintrustdata.api.models.FunctionDeleteParams import com.braintrustdata.api.models.FunctionInvokeParams @@ -52,7 +53,7 @@ class FunctionServiceAsyncTest { .origin( FunctionCreateParams.Origin.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .internal_(true) .build() ) @@ -402,7 +403,7 @@ class FunctionServiceAsyncTest { .origin( FunctionReplaceParams.Origin.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .internal_(true) .build() ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncTest.kt index 1aed2310..05701364 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncTest.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.models.ProjectScoreCreateParams import com.braintrustdata.api.models.ProjectScoreDeleteParams import com.braintrustdata.api.models.ProjectScoreReplaceParams import com.braintrustdata.api.models.ProjectScoreRetrieveParams +import com.braintrustdata.api.models.ProjectScoreType import com.braintrustdata.api.models.ProjectScoreUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -32,7 +33,7 @@ class ProjectScoreServiceAsyncTest { ProjectScoreCreateParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .categoriesOfCategorical( listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) ) @@ -120,7 +121,7 @@ class ProjectScoreServiceAsyncTest { ) .description("description") .name("name") - .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .build() ) @@ -177,7 +178,7 @@ class ProjectScoreServiceAsyncTest { ProjectScoreReplaceParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .categoriesOfCategorical( listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncTest.kt index 140fdec7..79732937 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncTest.kt @@ -4,6 +4,8 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync +import com.braintrustdata.api.models.AclObjectType +import com.braintrustdata.api.models.Permission import com.braintrustdata.api.models.RoleCreateParams import com.braintrustdata.api.models.RoleDeleteParams import com.braintrustdata.api.models.RoleReplaceParams @@ -31,10 +33,8 @@ class RoleServiceAsyncTest { .description("description") .addMemberPermission( RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .build() ) .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -79,10 +79,8 @@ class RoleServiceAsyncTest { .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addAddMemberPermission( RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .build() ) .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -90,11 +88,8 @@ class RoleServiceAsyncTest { .name("x") .addRemoveMemberPermission( RoleUpdateParams.RemoveMemberPermission.builder() - .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.RemoveMemberPermission.RestrictObjectType - .ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .build() ) .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -154,10 +149,8 @@ class RoleServiceAsyncTest { .description("description") .addMemberPermission( RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .build() ) .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncTest.kt index 2a7f254c..c45c5a58 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncTest.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.AclObjectType import com.braintrustdata.api.models.ViewCreateParams import com.braintrustdata.api.models.ViewData import com.braintrustdata.api.models.ViewDataSearch @@ -35,7 +36,7 @@ class ViewServiceAsyncTest { ViewCreateParams.builder() .name("name") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewCreateParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .viewType(ViewCreateParams.ViewType.PROJECTS) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .options( @@ -90,7 +91,7 @@ class ViewServiceAsyncTest { ViewRetrieveParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .build() ) @@ -112,7 +113,7 @@ class ViewServiceAsyncTest { ViewUpdateParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .name("name") .options( ViewOptions.builder() @@ -166,7 +167,7 @@ class ViewServiceAsyncTest { viewServiceAsync.list( ViewListParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewListParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .build() ) @@ -188,7 +189,7 @@ class ViewServiceAsyncTest { ViewDeleteParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .build() ) @@ -210,7 +211,7 @@ class ViewServiceAsyncTest { ViewReplaceParams.builder() .name("name") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .viewType(ViewReplaceParams.ViewType.PROJECTS) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .options( diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncTest.kt index 566ece51..a78f59db 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncTest.kt @@ -13,6 +13,7 @@ import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams import com.braintrustdata.api.models.SpanAttributes +import com.braintrustdata.api.models.SpanType import java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -171,10 +172,7 @@ class LogServiceAsyncTest { .build() ) .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() + SpanAttributes.builder().name("name").type(SpanType.LLM).build() ) .spanId("span_id") .addSpanParent("string") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AclServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AclServiceTest.kt index 499ca976..c0c9530f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AclServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AclServiceTest.kt @@ -9,7 +9,9 @@ import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclFindAndDeleteParams import com.braintrustdata.api.models.AclListParams +import com.braintrustdata.api.models.AclObjectType import com.braintrustdata.api.models.AclRetrieveParams +import com.braintrustdata.api.models.Permission import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -29,10 +31,10 @@ class AclServiceTest { aclService.create( AclCreateParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclCreateParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclCreateParams.Permission.CREATE) - .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -71,7 +73,7 @@ class AclServiceTest { aclService.list( AclListParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclListParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .build() ) @@ -110,12 +112,10 @@ class AclServiceTest { .addAddAcl( AclBatchUpdateParams.AddAcl.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -123,12 +123,10 @@ class AclServiceTest { .addRemoveAcl( AclBatchUpdateParams.RemoveAcl.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -152,10 +150,10 @@ class AclServiceTest { aclService.findAndDelete( AclFindAndDeleteParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclFindAndDeleteParams.Permission.CREATE) - .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceTest.kt index 94340681..8a70237d 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceTest.kt @@ -7,6 +7,7 @@ import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.models.EnvVarCreateParams import com.braintrustdata.api.models.EnvVarDeleteParams import com.braintrustdata.api.models.EnvVarListParams +import com.braintrustdata.api.models.EnvVarObjectType import com.braintrustdata.api.models.EnvVarReplaceParams import com.braintrustdata.api.models.EnvVarRetrieveParams import com.braintrustdata.api.models.EnvVarUpdateParams @@ -94,7 +95,7 @@ class EnvVarServiceTest { .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .limit(0L) .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarListParams.ObjectType.ORGANIZATION) + .objectType(EnvVarObjectType.ORGANIZATION) .build() ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceTest.kt index 93c696d6..19639ab4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceTest.kt @@ -19,6 +19,7 @@ import com.braintrustdata.api.models.InsertExperimentEvent import com.braintrustdata.api.models.ObjectReference import com.braintrustdata.api.models.RepoInfo import com.braintrustdata.api.models.SpanAttributes +import com.braintrustdata.api.models.SpanType import java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -313,10 +314,7 @@ class ExperimentServiceTest { .build() ) .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() + SpanAttributes.builder().name("name").type(SpanType.LLM).build() ) .spanId("span_id") .addSpanParent("string") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceTest.kt index 805b0d1d..0dee1b40 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceTest.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.AclObjectType import com.braintrustdata.api.models.FunctionCreateParams import com.braintrustdata.api.models.FunctionDeleteParams import com.braintrustdata.api.models.FunctionInvokeParams @@ -52,7 +53,7 @@ class FunctionServiceTest { .origin( FunctionCreateParams.Origin.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .internal_(true) .build() ) @@ -396,7 +397,7 @@ class FunctionServiceTest { .origin( FunctionReplaceParams.Origin.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .internal_(true) .build() ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceTest.kt index 96b3a100..fef6caa5 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceTest.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.models.ProjectScoreCreateParams import com.braintrustdata.api.models.ProjectScoreDeleteParams import com.braintrustdata.api.models.ProjectScoreReplaceParams import com.braintrustdata.api.models.ProjectScoreRetrieveParams +import com.braintrustdata.api.models.ProjectScoreType import com.braintrustdata.api.models.ProjectScoreUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -32,7 +33,7 @@ class ProjectScoreServiceTest { ProjectScoreCreateParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .categoriesOfCategorical( listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) ) @@ -118,7 +119,7 @@ class ProjectScoreServiceTest { ) .description("description") .name("name") - .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .build() ) @@ -172,7 +173,7 @@ class ProjectScoreServiceTest { ProjectScoreReplaceParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .categoriesOfCategorical( listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/RoleServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/RoleServiceTest.kt index 87471933..b402e232 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/RoleServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/RoleServiceTest.kt @@ -4,6 +4,8 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient +import com.braintrustdata.api.models.AclObjectType +import com.braintrustdata.api.models.Permission import com.braintrustdata.api.models.RoleCreateParams import com.braintrustdata.api.models.RoleDeleteParams import com.braintrustdata.api.models.RoleReplaceParams @@ -31,10 +33,8 @@ class RoleServiceTest { .description("description") .addMemberPermission( RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .build() ) .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -77,10 +77,8 @@ class RoleServiceTest { .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addAddMemberPermission( RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .build() ) .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -88,11 +86,8 @@ class RoleServiceTest { .name("x") .addRemoveMemberPermission( RoleUpdateParams.RemoveMemberPermission.builder() - .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.RemoveMemberPermission.RestrictObjectType - .ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .build() ) .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -149,10 +144,8 @@ class RoleServiceTest { .description("description") .addMemberPermission( RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) + .permission(Permission.CREATE) + .restrictObjectType(AclObjectType.ORGANIZATION) .build() ) .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ViewServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ViewServiceTest.kt index a47e80d3..401da3f7 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ViewServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ViewServiceTest.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.AclObjectType import com.braintrustdata.api.models.ViewCreateParams import com.braintrustdata.api.models.ViewData import com.braintrustdata.api.models.ViewDataSearch @@ -35,7 +36,7 @@ class ViewServiceTest { ViewCreateParams.builder() .name("name") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewCreateParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .viewType(ViewCreateParams.ViewType.PROJECTS) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .options( @@ -89,7 +90,7 @@ class ViewServiceTest { ViewRetrieveParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .build() ) @@ -110,7 +111,7 @@ class ViewServiceTest { ViewUpdateParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .name("name") .options( ViewOptions.builder() @@ -163,7 +164,7 @@ class ViewServiceTest { viewService.list( ViewListParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewListParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .build() ) @@ -184,7 +185,7 @@ class ViewServiceTest { ViewDeleteParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .build() ) @@ -205,7 +206,7 @@ class ViewServiceTest { ViewReplaceParams.builder() .name("name") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .viewType(ViewReplaceParams.ViewType.PROJECTS) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .options( diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceTest.kt index ac3a13bc..01b768a6 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceTest.kt @@ -13,6 +13,7 @@ import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams import com.braintrustdata.api.models.SpanAttributes +import com.braintrustdata.api.models.SpanType import java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -168,10 +169,7 @@ class LogServiceTest { .build() ) .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() + SpanAttributes.builder().name("name").type(SpanType.LLM).build() ) .spanId("span_id") .addSpanParent("string")